You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
1. Restore default sizing algorithm to its previous scope.
2. Add contain/cover sizing as a separate algorithm, using same wording
as object-fit's contain/cover values
3. Better explanations of how these algorithms relate to the rest of CSS.
Copy file name to clipboardExpand all lines: css3-images/Overview.src.html
+45-16Lines changed: 45 additions & 16 deletions
Original file line number
Diff line number
Diff line change
@@ -1062,7 +1062,7 @@ <h3 id="sizing-terms">
1062
1062
</dd>
1063
1063
1064
1064
<dt><dfn>specified size</dfn></dt>
1065
-
<dd>The specified size of an object is a set of constraints given by CSS, such as through the 'width' and 'height' or 'background-size' properties. The specified size may be a width and/or a height, or alternately a "cover" or "contain" constraint. Additionally, the specified size may have a horizontal or vertical "rounding" constraint.</dd>
1065
+
<dd>The specified size of an object is given by CSS, such as through the 'width' and 'height' or 'background-size' properties. The specified size can be a definite width andheight, a set of constraints, or a combination thereof.</dd>
1066
1066
1067
1067
<dt><dfn>concrete object size</dfn></dt>
1068
1068
<dd>The <i>concrete object size</i> is the result of combining an object's <i>intrinsic dimensions</i> and <i>specified size</i> with the <i>default object size</i> of the context it's used in, producing a rectangle with a definite width and height.</dd>
<p>In the absence of more specific rules, an object's <i>intrinsic dimensions</i> are resolved to a <i>concrete object size</i> with the <dfn>default sizing algorithm</dfn>, as follows:</p>
1113
+
<p>Currently the rules for sizing objects are described in each context that
1114
+
such objects are used. This section defines some common sizing constraints
1115
+
and how to resolve them so that future specs can refer to them instead of
1116
+
redefining size resolution in each instance.
1117
+
1118
+
<h4id="default-sizing">
1119
+
Default Sizing Algorithm</h4>
1120
+
1121
+
<p>The <dfn>default sizing algorithm</dfn> is a set of rules commonly used
1122
+
to find an object's <i>concrete object size</i>. It resolves the simultaneous
1123
+
constraints presented by the object's <i>intrinsic dimensions</i> and either an
1124
+
unconstrained <i>specified size</i> or one consisting of only a definite width
1125
+
and/or height.
1126
+
1127
+
<p>Some object sizing rules (such as those for 'list-style-image') correspond
1128
+
exactly to the <i>default sizing algorithm</i>. Others (such as those for
1129
+
'border-image') invoke the default sizing algorithm but also apply additional
1130
+
sizing rules before arriving at a final <i>concrete object size</i>.
1131
+
1132
+
<p>The <i>default sizing algorithm</i> is defined as follows:
1114
1133
1115
1134
<ul>
1116
1135
<li>If the <i>specified size</i> is a definite width and height, the <i>concrete object size</i> is given that width and height.</li>
1117
1136
1118
-
<li>If the <i>specified size</i>has only a width or height, but not both, then the <i>concrete object size</i> is given that specified width or height. The other dimension is calculated as follows:
1137
+
<li>If the <i>specified size</i>is only a width or height (but not both) then the <i>concrete object size</i> is given that specified width or height. The other dimension is calculated as follows:
1119
1138
1120
1139
<ol>
1121
-
<li>If the object has an <i>intrinsic aspect ratio</i>, the missing dimension of the <i>concrete object size</i> is calculated using the <i>intrinsic aspect-ratio</i> and the present dimension.</li>
1140
+
<li>If the object has an <i>intrinsic aspect ratio</i>, the missing dimension of the <i>concrete object size</i> is calculated using the <i>intrinsic aspectratio</i> and the present dimension.</li>
1122
1141
1123
1142
<li>Otherwise, if the missing dimension is present in the object's <i>intrinsic dimensions</i>, the missing dimension is taken from the object's <i>intrinsic dimensions</i>.</li>
1124
1143
1125
1144
<li>Otherwise, the missing dimension of the <i>concrete object size</i> is taken from the <i>default object size</i>.</li>
1126
1145
</ol>
1127
1146
</li>
1128
1147
1129
-
<li>If the <i>specified size</i> is a "contain" constraint and the object has an intrinsic aspect ratio, the <i>concrete object size</i> is the largest rectangle with that aspect ratio that completely fits within the <i>default object size</i>. If the object doesnt' have an intrinsic aspec tratio, the <i>concrete object size</i> is the <i>default object size</i>.</li>
1130
-
1131
-
<li>If the <i>specified size</i> is a "cover" constraint and the object has an intrinsic aspect ratio, the <i>concrete object size</i> is the smallest rectangle with that aspect ratio that can completely cover within the <i>default object size</i>. If the object doesnt' have an intrinsic aspec tratio, the <i>concrete object size</i> is the <i>default object size</i>.</li>
1132
-
1133
-
<li>Otherwise:
1148
+
<li>If the <i>specified size</i> has no constraints:
1134
1149
1135
1150
<ol>
1136
1151
<li>If the object has only an <i>intrinsic aspect ratio</i>, the <i>concrete object size</i> must have that aspect ratio, and additionally be as large as possible without either its height or width exceeding the height or width of the <i>default object size</i>. Otherwise, the width and height of the <i>concrete object size</i> is the same as the object's <i>intrinsic width</i> and <i>intrinsic height</i>, if they exist.</li>
@@ -1140,13 +1155,27 @@ <h3 id="default-sizing">
1140
1155
</li>
1141
1156
</ul>
1142
1157
1143
-
<p>If the <i>specified size</i> has a horizontal or vertical rounding constraint and the <i>concrete object size</i> in that dimension is non-zero, the <i>concrete object size</i> is then adjusted in that dimension so that it fits a whole number of times into the <i>default object size</i>, as follows:</p>
1158
+
<h4id="cover-contain">
1159
+
Cover and Contain Constraint Sizing</h4>
1160
+
1161
+
<p>Two other common specified sizes are the <i>contain constraint</i> and
1162
+
the <i>cover constraint</i>, both of which are resolved against a specified
1163
+
<dfn>constraint rectangle</dfn> using the object's <i>intrinsic aspect ratio</i>:
1144
1164
1145
-
<blockquote>
1146
-
<p>If <var>X</var> is the size of the <i>concrete object size</i> in the given dimension and <var>W</var> is the size of the <i>default object size</i> in the same dimension, the <i>concrete object size</i> in that dimension is changed to <var>X'</var> = <var>W</var> / round(<var>W</var> / <var>X</var>), where round() is a function that returns the nearest natural number.</p>
1147
-
</blockquote>
1165
+
<ul>
1166
+
<li>A <dfn>contain constraint</dfn> is resolved by setting the
1167
+
<i>concrete object size</i> to the largest rectangle that has the object's
1168
+
<i>intrinsic aspect ratio</i> and additionally has neither width nor height
1169
+
larger than the constraint rectangle's width and height, respectively.</li>
1170
+
1171
+
<li>A <dfn>cover constraint</dfn> is resolved by setting the
1172
+
<i>concrete object size</i> to the smallest rectangle that has the object's
1173
+
<i>intrinsic aspect ratio</i> and additionally has neither width nor height
1174
+
smaller than the constraint rectangle's width and height, respectively.</li>
1175
+
</ul>
1148
1176
1149
-
<p>Then, if the object has an intrinsic aspect ratio and the <i>specified size</i> had a horizontal rounding constraint but no height, the height of the <i>concrete object size</i> is adjust so that the <i>concrete object size</i> has the same aspect ratio as the object's intrinsic aspect ratio (and analogously for a <i>specified size</i> with a vertical rounding constraint but no width).</p>
1177
+
<p>In both cases, if the object doesn't have an intrinsic aspect ratio,
1178
+
the <i>concrete object size</i> is the specified constraint rectangle.
0 commit comments