8000 Revised view boxes section based on feedback from fantasai. · w3c/csswg-drafts@326be6d · GitHub
Skip to content

Commit 326be6d

Browse files
committed
Revised view boxes section based on feedback from fantasai.
1 parent 9aa2018 commit 326be6d

2 files changed

Lines changed: 166 additions & 123 deletions

File tree

css3-images/Overview.html

Lines changed: 132 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@
1616

1717
<h1>CSS Image Values Module Level 3</h1>
1818

19-
<h2 class="no-num no-toc" id=longstatus-date>Editor's Draft 8 April 2010</h2>
19+
<h2 class="no-num no-toc" id=longstatus-date>Editor's Draft 1 May 2010</h2>
2020

2121
<dl>
2222
<dt>This version:</dt>
2323

24-
<!-- <dd><a href="http://www.w3.org/TR/2010/CR-css3-images-20100408/">http://www.w3.org/TR/2010/CR-css3-images-20100408/</a></dd> -->
24+
<!-- <dd><a href="http://www.w3.org/TR/2010/CR-css3-images-20100501/">http://www.w3.org/TR/2010/CR-css3-images-20100501/</a></dd> -->
2525

2626
<dd><a
2727
href="http://dev.w3.org/csswg/css3-images/">http://dev.w3.org/csswg/css3-images/</a>
@@ -138,15 +138,17 @@ <h2 class="no-num no-toc" id=contents>Table of contents</h2>
138138

139139
</ul>
140140

141-
<li><a href="#view-boxes-or-sizing-images-in-css"><span class=secno>8.
142-
</span>View Boxes, or Sizing Images in CSS</a>
141+
<li><a href="#view-boxes-or-sizing-images-and-objects-"><span
142+
class=secno>8. </span>View Boxes, or Sizing Images and Objects in CSS</a>
143+
143144

144145
<li><a href="#resolution-units"><span class=secno>9. </span>Resolution
145146
Units</a>
146147

147148
<li class=no-num><a href="#acknowledgments">Acknowledgments</a>
148149

149150
<li class=no-num><a href="#references">References</a>
151+
150152
<ul class=toc>
151153
<li class=no-num><a href="#normative-references">Normative
152154
references</a>
@@ -158,6 +160,7 @@ <h2 class="no-num no-toc" id=contents>Table of contents</h2>
158160
<!--end-toc-->
159161

160162
<div>
163+
161164
<h2 id=intro><span class=secno>1. </span>Introduction</h2>
162165

163166
<p><em>This section is non-normative.</em></p>
@@ -168,7 +171,6 @@ <h2 id=intro><span class=secno>1. </span>Introduction</h2>
168171
additional notations that allow a 2D image to be given as a list of URIs
169172
denoting fallbacks, as a slice of a larger image (sprite), and as a
170173
gradient.</p>
171-
172174
</div>
173175

174176
<div>
@@ -183,7 +185,6 @@ <h2 id=conformance><span class=secno>2. </span>Conformance</h2>
183185
<p>Conformance to CSS Namespaces is defined for two classes:
184186

185187
<dl>
186-
187188
<dt><dfn id=style-sheet>style sheet</dfn>
188189

189190
<dd>A <a href="http://www.w3.org/TR/CSS21/conform.html#style-sheet">CSS
@@ -219,6 +220,7 @@ <h2 id=conformance><span class=secno>2. </span>Conformance</h2>
219220
normative text with <code>class="note"</code>, like this:
220221

221222
<p class=note>Note, this is an informative note.</p>
223+
222224
</div>
223225

224226
<div>
@@ -406,14 +408,14 @@ <h2 id=gradients-><span class=secno>7. </span>Gradients</h2>
406408

407409
<p>In many places this specification references a box, such as "the box's
408410
top-left corner" or "the box's right side". In all of these
409-
circumstances, the "box" refers to the &lsquo;<code class=css><a
410-
href="#css-view-box">CSS View Box</a></code>&rsquo; (see the "View Boxes"
411-
section of this spec for clarification). A gradient's &lsquo;<code
412-
class=css><a href="#image-view-box">Image View Box</a></code>&rsquo; has
413-
no intrinsic dimensions. This means that, for example, if you use a
414-
gradient in a background-image, the "box" will simply be the size of the
415-
background area. If you use a gradient in a list-style-image, the "box"
416-
will be a 1em square.</p>
411+
circumstances, the "box" refers to the &lsquo;<a
412+
href="#css-view-box"><code class=css>CSS View Box</code></a>&rsquo; (see
413+
the "View Boxes" section of this spec for clarification). A gradient's
414+
&lsquo;<code class=css>Image View Box</code>&rsquo; has no intrinsic
415+
dimensions. This means that, for example, if you use a gradient in a
416+
background-image, the "box" will simply be the size of the background
417+
area. If you use a gradient in a list-style-image, the "box" will be a
418+
1em square.</p>
417419

418420
<div class=example>
419421
<p>As with the other &lt;image&gt; types defined in this specification,
@@ -464,8 +466,6 @@ <h4 class=no-toc id=linear-gradient-syntax><span class=secno>7.1.1.
464466
the starting-point of the gradient-line. The ending-point is obtained by
465467
rotating the starting-point 180 degrees around the center of the box.</p>
466468

467-
<div class=example></div>
468-
469469
<p>If only a <code>&lt;angle&gt;</code> is specified, it specifies the
470470
direction of the gradient-line, and the starting-point and ending-point
471471
of the gradient-line are implied by the value of the
@@ -746,7 +746,7 @@ <h4 class=no-toc id=radial-gradient-syntax><span class=secno>7.2.1.
746746
<code>&lt;angle&gt;</code> in the first argument. The ending-point is
< 24BA /code>
747747
where this line intersects the gradient-shape.</p>
748748

749-
<p><code><a href="#ltcolor-stopgt">&lt;color-stop&gt;</a></code> is
749+
<p><a href="#ltcolor-stopgt"><code>&lt;color-stop&gt;</code></a> is
750750
defined identically to its treatment in <code>linear-gradient()</code>.
751751
As E706 in linear gradients, 0% is at the starting-point of the
752752
gradient-line, and 100% is at the ending-point. Distances past 100% can
@@ -845,104 +845,133 @@ <h3>Repeating Gradients</h3>
845845
</div>
846846

847847
<div>
848-
<h2 id=view-boxes-or-sizing-images-in-css><span class=secno>8. </span>View
849-
Boxes, or Sizing Images in CSS</h2>
848+
<h2 id=view-boxes-or-sizing-images-and-objects-><span class=secno>8.
849+
</span>View Boxes, or Sizing Images and Objects in CSS</h2>
850850

851851
<p>Images used in CSS may come from a number of sources, from defined
852852
image formats (such as gif, jpeg, etc), dedicated markup formats (such as
853853
SVG), and CSS-specific formats (such as the linear-gradient() value type
854-
defined in this specification). These images may offer many types of
855-
sizing information to CSS, or none at all. The concepts &lsquo;<code
856-
class=css><a href="#image-view-box">Image View Box</a></code>&rsquo; and
857-
&lsquo;<code class=css><a href="#css-view-box">CSS View
858-
Box</a></code>&rsquo; are specified here to define exactly how such
859-
images are treated within CSS.</p>
854+
defined in this specification). As well, a document may conain many other
855+
types of objects, such as video, plugins, or nested documents. These
856+
images and objects (just "objects" hereafter) may offer many types of
857+
sizing information to CSS, or none at all. This section defines
858+
generically the size negotiation model between the image or replaced
859+
content object and the CSS layout algorithms.</p>
860860

861-
<p>In order to define this handling, we must define a few new terms, to
862-
make it easier to refer to various concepts:</p>
861+
<p>In order to define this handling, we must define a few terms, to make
862+
it easier to refer to various concepts:</p>
863863

864864
<dl>
865-
<dt><dfn id=default-image-sizing-area>default image sizing area</dfn>
866-
867-
<dd>The default image sizing area is a rectangle with a definite height
868-
and width used to resolve the sizing information present in the Image
869-
View Box into a CSS View Box. For example, the default image sizing area
870-
for a background-image is defined by the background-origin and
871-
background-size properties, while the default image sizing area for a
872-
list-style-image is a 1em square. The image may end up being drawn
873-
larger or smaller than the default image sizing area.
874-
875-
<dt><dfn id=image-view-box>Image View Box</dfn>
876-
877-
<dd>The Image View Box is a box defined by an image which represents the
878-
image's preferred, natural size. This may have an intrinsic height and
879-
intrinsic width, defining a definite box. It may be missing an intrinsic
880-
height or an intrinsic width, implying that it may scale along its
881-
height or width. It may have an intrinsic size ratio, defining the ratio
882-
of its width and height, which may or may not be accompanied by an
883-
intrinsic width and/or height. Finally, it may have no intrinsic
884-
dimensions at all, implying that the element has no preferred size.
865+
<dt><dfn id=intrinsic-dimensions>intrinsic dimensions</dfn>
866+
867+
<dd>The intrinsic dimensions are defined are the object's preferred,
868+
natural size or aspect ratio, if any. There can be an <dfn
869+
id=intrinsic-height>intrinsic height</dfn> and <dfn
870+
id=intrinsic-width>intrinsic width</dfn>, defining a definite rectangle.
871+
(Most bitmap images fall into this category.) There can be an <dfn
872+
id=intrinsic-aspect-ratio>intrinsic aspect ratio</dfn> defining the
873+
relation of the width to the height, but no definite size. (SVG images
874+
designed to scale may fall into this category.) There can be just an
875+
intrinsic height or width. Or there can be no intrinsic dimensions at
876+
all, implying that the object has no preferred size or aspect ratio.
877+
(Embedded documents are often assumed to have no intrinsic size, as are
878+
CSS gradients, defined in this specification.)
879+
<p>If an object (such as an icon) has multiple sizes, then the largest
880+
size is used. If it has multiple aspect ratios of that size (or of no
881+
size), then the aspect ratio closest to the aspect ratio of the default
882+
image sizing area is use <span class=issue>This is pretty
883+
arbitrary</span>.
884+
885+
<dt><dfn id=specified-size>specified size</dfn>
886+
887+
<dd>The specified size of an object is given by CSS, such as through the
888+
`object-fit` or `background-size` properties. The specified size can be
889+
a definite width and height, a set of constraints, or a combination
890+
thereof.
885891

886892
<dt><dfn id=css-view-box>CSS View Box</dfn>
887893

888-
<dd>The CSS View Box is the result of transforming the Image View Box
889-
into a concrete size, based on the size of the default image sizing
890-
area. A CSS View Box always has a definite height and width.
894+
<dd>The CSS View Box is the result of transforming the intrinsic
895+
dimensions into a concrete size, based on the specified size and the
896+
default image sizing area. A CSS View Box always has a definite height
897+
and width.
898+
899+
<dt><dfn id=default-image-sizing-area>default image sizing area</dfn>
900+
901+
<dd>The default image sizing area is a rectangle with a definite height
902+
and width used to determine the size of the CSS View Box when both the
903+
intrinsic dimensions and specified size are missing dimensions.
891904
</dl>
892905

893-
<p>The general treatment of images in CSS is as follows:</p>
906+
<p>Images and objects in CSS are sized as follows:</p>
894907

895908
<ol>
896-
<li>When an image is specified in CSS, such as through a url() value in
897-
the background-image property, CSS requests an &lsquo;<code class=css><a
898-
href="#image-view-box">Image View Box</a></code>&rsquo; from the image.
899-
The Image View Box may have an intrinsic width, an intrinsic height,
900-
neither, both, or any combination of those with an intrinsic size ratio.
901-
902-
<li>The Image View Box is then then transformed into a &lsquo;<code
903-
class=css><a href="#css-view-box">CSS View Box</a></code>&rsquo; that
904-
defines the actual size that the image will display in as follows:
905-
<ol>
909+
<li>When an image or object is specified in a document, such as through
910+
url() value in a background-image property or a @src attribute on an
911+
&lt;img> element, CSS queries the object for its intrinsic size.
906912

907-
<li>If the Image View Box has an intrinsic width and an intrinsic
908-
height, the CSS View Box is that height and width.
909-
910-
<li>If the Image View Box has only an intrinsic width or only an
911-
intrinsic height, and no intrinsic size ratio, the CSS View Box has
912-
that intrinsic height or width, and the other dimension is equal to
913-
the corresponding dimension of the &lsquo;<code class=css><a
914-
href="#default-image-sizing-area">default image sizing
915-
area</a></code>&rsquo;.
916-
917-
<li>If the Image View Box has an intrinsic width or an intrinsic width
918-
but not both, and an intrinsic size ratio, the CSS View Box has the
919-
same width or height (as appropriate), with the other dimension
920-
determined so as to have the same size ratio as the Image View Box.
921-
922-
<li>If the Image View Box has only an intrinsic size ratio, the CSS
923-
View Box has a the largest height and width such that it has the same
924-
size ratio as the Image View Box's intrinsic size ratio, and neither
925-
its width nor its height are larger than the height or width of the
926-
default image sizing area.
927-
928-
<li>If the Image View Box has neither an intrinsic height, nor an
929-
intrinsic width, nor an intrinsic size ratio, then the CSS View Box
930-
has a size equal to the default image sizing area.
913+
<li>Using the intrinsic dimensions and the specified size, CSS then
914+
computes a CSS View Box that defines the size of the region the object
915+
will render in, as follows:
916+
<ol>
917+
<li>If the specified size is just a definite width and height, the CSS
918+
View Box must be that width and height.
919+
920+
<li>If the specified size is just a definite width or just a definite
921+
height, then the CSS View Box must have the same width or height, as
922+
appropriate. The other dimension is calculated as follows:
923+
<ol>
924+
<li>If the object has an intrinsic aspect ratio, the CSS View Box
925+
must have the same aspect ratio..
926+
927+
<li>Otherwise, if the object has an an intrinsic height or intrinsic
928+
width (whichever is missing from the specified size), then the CSS
929+
View Box must have that height or width.
930+
931+
<li>Otherwise, the CSS View Box must have the same width or height
932+
(whichever is missing from the specified size) as the default image
933+
sizing area.
934+
</ol>
935+
936+
<li>If the specified size is neither a definite width nor height, and
937+
has no additional contraints, the dimensions of the CSS View Box must
938+
be computed as follows:
939+
<ol>
940+
<li>If the object has an intrinsic width and an intrinsic height, the
941+
CSS View Box must have that same height and width.
942+
943+
<li>If the object has only an intrinsic width or intrinsic height,
944+
and no intrinsic aspect ratio, the CSS View Box must have that
945+
height or width, and the width or height (whichever is missing from
946+
the intrinsic dimensions) of the default image sizing area.
947+
948+
<li>If the object has only an intrinsic aspect ratio, the CSS View
949+
Box must have that aspect ratio, and additionally be as large as
950+
possible without either its height or width exceeding the height or
951+
width of the default image sizing area.
952+
953+
<li>Otherwise, the CSS View Box must be the size of the default image
954+
sizing area.
955+
</ol>
956+
957+
<li>If the specified size has additional constraints, the CSS View Box
958+
must be sized to satisfy those constraints. (For example,
959+
object-fit:contain specifies slightly more complex handling for sizing
960+
replaced elements, and background-repeat:round can adjust the size
961+
specified in background-size so that the image fits an even number of
962+
times into the background positioning area.)
931963
</ol>
932-
933-
<li>The image is then given the dimensions of the CSS View Box and asked
934-
to render itself according to these dimensions. CSS does not define how
935-
image formats may react to a CSS View Box that is a different size than
936-
the Image View Box, but commonly the image will scale itself to fit the
937-
new dimensions, perhaps scaling both dimensions independently, scaling
938-
both dimensions together so that it exactly touches the sides of the
939-
view box without going outside of them, seam carving to remove content
940-
that does not fit within the dimensions, or any other method.
941-
942-
<li>After the image is rendered according to the CSS View Box, CSS may
943-
clip or otherwise transform the image before displaying it in the
944-
document.
945964
</ol>
965+
966+
<p>After determining the size of the CSS View Box, CSS positions it within
967+
the appropriate area according to any relevant properties, such as
968+
object-position or background-position, and asks the object to render
969+
itself using the dimensions of the CSS View Box. CSS does not define how
970+
objects when the dimensions of the CSS View Box are different than the
971+
object's intrinsic dimensions. The object may adjust itself to match the
972+
dimensions of the CSS View Box in some way, or even render itself larger
973+
or smaller than the CSS View Box to satisfy sizing constraints of its
974+
own.</p>
946975
</div>
947976

948977
<div>
@@ -952,6 +981,7 @@ <h2 id=resolution-units><span class=secno>9. </span>Resolution Units</h2>
952981
id=ltresolutiongt>&lt;resolution&gt;</dfn> value type:
953982

954983
<dl>
984+
955985
<dt>dpi
956986

957987
<dd>dots per inch
@@ -967,6 +997,7 @@ <h2 id=resolution-units><span class=secno>9. </span>Resolution Units</h2>
967997

968998
<p class=note>The default resolution of raster images in CSS is
969999
&lsquo;<code class=css>1dppx</code>&rsquo;.</p>
1000+
9701001
</div>
971< 4FE8 /td>1002

9721003
<h2 class=no-num id=acknowledgments>Acknowledgments</h2>
@@ -988,8 +1019,8 @@ <h3 class=no-num id=normative-references>Normative references</h3>
9881019
Sheets Level 2 Revision 1 (CSS 2.1) Specification.</cite></a> 8 September
9891020
2009. W3C Candidate Recommendation. (Work in progress.) URL: <a
9901021
href="http://www.w3.org/TR/2009/CR-CSS2-20090908">http://www.w3.org/TR/2009/CR-CSS2-20090908</a>
991-
9921022
</dd>
1023+
9931024
<!---->
9941025

9951026
<dt id=RFC2119>[RFC2119]
@@ -1000,8 +1031,8 @@ <h3 class=no-num id=normative-references>Normative references</h3>
10001031
href="http://www.ietf.org/rfc/rfc2119.txt">http://www.ietf.org/rfc/rfc2119.txt</a>
10011032
</dd>
10021033
<!---->
1003-
10041034
</dl>
1035+
10051036
<!--end-normative-->
10061037

10071038
<h3 class=no-num id=informative-references>Informative references</h3>
@@ -1010,7 +1041,6 @@ <h3 class=no-num id=informative-references>Informative references</h3>
10101041

10111042
<dl class=bibliography>
10121043
<dt style="display: none"><!-- keeps the doc valid if the DL is empty -->
1013-
10141044
<!---->
10151045

10161046
<dt id=CSS3BG>[CSS3BG]
@@ -1023,8 +1053,8 @@ <h3 class=no-num id=informative-references>Informative references</h3>
10231053
</dd>
10241054
<!---->
10251055
</dl>
1026-
10271056
<!--end-informative-->
1057+
10281058
</html>
10291059
<!-- Keep this comment at the end of the file
10301060
Local variables:

0 commit comments

Comments
 (0)