Skip to content

Commit dc7247d

Browse files
committed
Learning to use GitHub...
1 parent 3499b60 commit dc7247d

4 files changed

Lines changed: 29 additions & 38 deletions

File tree

js/almcss3/almcss.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ var ALMCSS = function() {
122122
'stylesheet.js',
123123
'css.js',
124124
'parser.js',
125+
'width.js',
125126
'template.js',
126127
'template_dom.js'
127128
], init);

js/almcss3/template.js

Lines changed: 28 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -101,58 +101,48 @@ ALMCSS.template = function() {
101101

102102
Slot.prototype.getIntrinsicMinimumWidth = function() {
103103

104-
var computeIntrinsicMinimumWidth = function() {
105-
106-
if (this.name === Slot.emptySlot) {
107-
return 0;
108-
}
109-
// It is a letter or '@'
110-
if (this.colspan > 1) {
111-
return 0;
112-
}
113-
// Otherwise (it is a letter or '@' slot of a single column) we need
114-
// to do some DOM manipulation to calculate its intrinsic minimumWidth
115-
this.htmlElement.style.float = 'left';
116-
var result = getComputedStyle(this.htmlElement, 'width');
117-
//this.htmlElement.style.float = 'none';
118-
return result;
119-
};
104+
var minimumWidth = ALMCSS.width.computeIntrinsicMinimumWidth;
120105

121106
assert(this.htmlElement, 'For computing the intrinsic minimum width of a slot ' +
122107
'first it is needed to have done the process of moving the elements into it');
123108

124-
if (!this.intrinsicMinimumWidth) {
125-
this.intrinsicMinimumWidth = computeIntrinsicMinimumWidth();
109+
if (this.intrinsicMinimumWidth) {
110+
return this.intrinsicMinimumWidth;
126111
}
112+
113+
if (this.name === Slot.emptySlot) {
114+
return 0;
115+
}
116+
// It is a letter or '@'
117+
if (this.colspan > 1) {
118+
return 0;
119+
}
120+
// Otherwise (it is a letter or '@' slot of a single column) we need
121+
// to do some DOM manipulation to calculate its intrinsic minimum width
122+
this.intrinsicMinimumWidth = minimumWidth(this.htmlElement);
127123
return this.intrinsicMinimumWidth;
128124
};
129125

130126
Slot.prototype.getIntrinsicPreferredWidth = function() {
131127

132-
var computeIntrinsicMinimumWidth = function() {
133-
134-
if (this.name === Slot.emptySlot) {
135-
return 0;
136-
}
137-
// It is a letter or '@'
138-
if (this.colspan > 1) {
139-
return 0;
140-
}
141-
// Otherwise (it is a letter or '@' slot of a single column) we need
142-
// to do some DOM manipulation to calculate its intrinsic minimumWidth
143-
this.htmlElement.style.float = 'left';
144-
var result = getComputedStyle(this.htmlElement, 'width');
145-
//this.htmlElement.style.float = 'none';
146-
return result;
147-
};
128+
var preferredWidth = ALMCSS.width.computeIntrinsicPreferredWidth;
148129

149130
assert(this.htmlElement, 'For computing the intrinsic minimum width of a slot ' +
150131
'first it is needed to have done the process of moving the elements into it');
151132

152-
if (!this.intrinsicMinimumWidth) {
153-
this.intrinsicMinimumWidth = computeIntrinsicMinimumWidth();
133+
if (this.intrinsicPreferredWidth) {
134+
return this.intrinsicPreferredWidth;
154135
}
155-
return this.intrinsicMinimumWidth;
136+
137+
// The intrinsic preferred width of a '.' is 0
138+
if (this.name === Slot.emptySlot) {
139+
return 0;
140+
}
141+
// The intrinsic preferred width of a letter or '@' is the intrinsic
142+
// preferred width as defined by the CSS3 Box Module
143+
// preferred width as defined by the CSS3 Box Module
144+
this.intrinsicPreferredWidth = preferredWidth(this.htmlElement);
145+
return this.intrinsicPreferredWidth;
156146
};
157147

158148
Slot.prototype.valueOf = function() {
@@ -196,7 +186,7 @@ ALMCSS.template = function() {
196186
return slots[i];
197187
}
198188
}
199-
},
189+
},
200190

201191
add: function(slot) {
202192
assert(!this.contains(slot.name),

tests/img/by.png

6.54 KB
Loading

tests/img/niza.jpg

253 KB
Loading

0 commit comments

Comments
 (0)