Skip to content

Commit d2e8771

Browse files
committed
[css-images-4][css-images-5] Punt the non-color uses of image() to level 5, per WG resolution.
1 parent a9f3a6f commit d2e8771

2 files changed

Lines changed: 229 additions & 171 deletions

File tree

css-images-4/Overview.bs

Lines changed: 8 additions & 171 deletions
Original file line numberDiff line numberDiff line change
@@ -379,140 +379,16 @@ Resolution/Type Negotiation: the ''image-set()'' notation {#image-set-notation}
379379
Image Fallbacks and Annotations: the ''image()'' notation {#image-notation}
380380
---------------------------------------------------------------------------
381381

382-
The ''image()'' function allows an author to:
383-
384-
* use <a href="https://www.w3.org/TR/media-frags/">media fragments</a> to clip out a portion of an image
385-
* use a solid color as an image
386-
* fallback to a solid-color image, when the image at the specified url can't be downloaded or decoded
387-
* automatically respect the image orientation specified in the image's metadata
388-
389-
The ''image()'' notation is defined as:
382+
The ''image()'' function allows an author
383+
to easily generate a solid-color image from any color.
384+
Its syntax is:
390385

391386
<pre class='prod'>
392-
<dfn>image()</dfn> = image( <<image-tags>>? [ <<image-src>>? , <<color>>? ]! )
393-
<dfn>&lt;image-tags></dfn> = [ ltr | rtl ]
394-
<dfn>&lt;image-src></dfn> = [ <<url>> | <<string>> ]
387+
<dfn>image()</dfn> = image( <<color>> )
395388
</pre>
396389

397-
A <<string>> used in ''image()'' represents a <<url>>.
398-
As usual for URLs in CSS,
399-
relative URLs are resolved to an absolute URL
400-
(as described in Values &amp; Units [[!CSS-VALUES-3]])
401-
when a specified ''image()'' value is computed.
402-
403-
If the image has an orientation specified in its metadata,
404-
such as EXIF,
405-
the UA must rotate or flip the image to correctly orient it
406-
as the metadata specifies.
407-
408-
### Image Fallbacks ### {#image-fallbacks}
409-
410-
If both a URL and a <<color>> are specified in ''image()'',
411-
then whenever the URL represents an [=invalid image=] or [=loading image=],
412-
the ''image()'' function renders as if the URL were not specified at all;
413-
it generates a solid-color image as specified in [[#color-images]].
414-
415-
If just a URL is specified (no <<color>>)
416-
and it represents an [=invalid image=] or [=loading image=],
417-
the ''image()'' function represents the same.
418-
419-
<wpt>
420-
css-image-fallbacks-and-annotations.html
421-
css-image-fallbacks-and-annotations002.html
422-
css-image-fallbacks-and-annotations003.html
423-
css-image-fallbacks-and-annotations004.html
424-
css-image-fallbacks-and-annotations005.html
425-
</wpt>
426-
427-
<div class='example' id='ex-fallback'>
428-
The fallback color can be used to ensure that text is still readable
429-
even when the image fails to load.
430-
For example, the following legacy code works fine if the image is rectangular and has no transparency:
431-
432-
<pre class="lang-css">
433-
body { color: black; background: white; }
434-
p.special { color: white; background: url("dark.png") black; }
435-
</pre>
436-
437-
When the image doesn't load,
438-
the background color is still there to ensure that the white text is readable.
439-
However, if the image has some transparency,
440-
the black will be visible behind it,
441-
which is probably not desired.
442-
The ''image()'' function addresses this:
443-
444-
<pre class="lang-css">
445-
body { color: black; background: white; }
446-
p.special { color: white; background: image("dark.png", black); }
447-
</pre>
448-
449-
Now, the black won't show at all if the image loads,
450-
but if for whatever reason the image fails,
451-
it'll pop in and prevent the white text from being set against a white background.
452-
</div>
453-
454-
<!-- Good example for the fallback() function
455-
<div class='example' id='ex-fallback-2'>
456-
For example, if a future specification defined a way to refer to a specific frame of an animated GIF with a fragment identifier,
457-
an author could write the following to get newer browsers to use the GIF's frame,
458-
and older browsers to instead download the fallback image:
459-
460-
<pre class="lang-css">background-image: image("cat_meme.gif#frame=5", "lolcat.png");</pre>
461-
</div>
462-
-->
463-
464-
### Image Fragments ### {#image-fragments}
465-
466-
When a URL specified in ''image()'' represents a portion of a resource
467-
(e.g. by the use of <a href="https://www.w3.org/TR/media-frags/#naming-space">media fragment identifiers</a>)
468-
that portion is clipped out of its context and used as a standalone image.
469-
470-
<div class="example" id='ex-image-fragment'>
471-
For example, given the following image and CSS:
472-
473-
<a href="images/sprites.svg">
474-
<img src="images/sprites.svg" height="20" width="180" alt="[9 circles, with 0 to 8 eighths filled in]">
475-
</a>
476-
477-
<pre class="lang-css">background-image: image('sprites.svg#xywh=40,0,20,20')</pre>
478-
479-
...the background of the element will be the portion of the image that starts at (40px,0px) and is 20px wide and tall,
480-
which is just the circle with a quarter filled in.
481-
</div>
482-
483-
So that authors can take advantage of CSS's forwards-compatible parsing rules to provide a fallback for image slices,
484-
implementations that support the ''image()'' notation
485-
<em>must</em> support the <code>xywh=#,#,#,#</code> form of media fragment identifiers
486-
for images specified via ''image()''. [[!MEDIA-FRAGS]]
487-
488-
<div class='example' id='ex-image-fragment-fallback'>
489-
Note that image fragments can also be used with the ''url()'' notation.
490-
However, a legacy UA that doesn't understand the media fragments notation
491-
will ignore the fragment and simply display the entirety of the image.
492-
493-
Since the ''image()'' notation requires UAs to support media fragments,
494-
authors can take advantage of CSS's forward-compatible parsing rules
495-
to provide a fallback when using an image fragment URL:
496-
497-
<pre class="lang-css">
498-
background-image: url('swirl.png'); /* old UAs */
499-
background-image: image('sprites.png#xywh=10,30,60,20'); /* new UAs */
500-
</pre>
501-
</div>
502-
503-
If a URL uses a fragment identifier syntax that the implementation does not understand,
504-
or does not consider valid for that type of image,
505-
the URL must be treated as representing an <a>invalid image</a>.
506-
507-
Note: This error-handling is limited to ''image()'',
508-
and not in the definition of URL,
509-
for legacy compat reasons.
510-
511-
512-
### Solid-color Images ### {#color-images}
513-
514-
If the ''image()'' function is specified with only a <<color>> argument (no URL),
515-
it represents a solid-color image of the specified color with no [=natural dimensions=].
390+
The ''image()'' function represents a solid-color image of the specified color
391+
with no [=natural dimensions=].
516392

517393
<div class='example' id='ex-solid-color'>
518394
For example,
@@ -525,47 +401,8 @@ Image Fallbacks and Annotations: the ''image()'' notation {#image-notation}
525401
as the solid color it generates always lies <em>beneath</em> all the background images.
526402
</div>
527403

528-
529-
### Bidi-sensitive Images ### {#bidi-images}
530-
531-
Before listing any <code>&lt;image-src>s</code>,
532-
the author may specify a directionality for the image,
533-
similar to adding a <code>dir</code> attribute to an element in HTML.
534-
If a directional image is used on or in an element with opposite <a href="https://www.w3.org/TR/CSS21/visuren.html#propdef-direction">direction</a>,
535-
the image must be flipped in the inline direction
536-
(as if it was transformed by, e.g., <code>scaleX(-1)</code>, if the inline direction is the X axis).
537-
538-
Note: Absent this declaration,
539-
images default to no directionality at all,
540-
and thus don't care about the directionality of the surrounding element.
541-
542-
<div class='example' id='ex-image-directionality'>
543-
A list may use an arrow for a bullet that points into the content.
544-
If the list can contain both LTR and RTL text,
545-
though, the bullet may be on the left or the right,
546-
and an image designed to point into the text on one side will point out of the text on the other side.
547-
This can be fixed with code like:
548-
549-
<pre class="lang-html">
550-
&lt;ul style="list-style-image: image(ltr 'arrow.png');">
551-
&lt;li dir='ltr'>My bullet is on the left!&lt;/li>
552-
&lt;li dir='rtl'>MY BULLET IS ON THE RIGHT!&lt;/li>
553-
&lt;/ul>
554-
</pre>
555-
556-
This should render something like:
557-
558-
<pre class="lang-html">
559-
&#8658; My bullet is on the left!
560-
!THGIR EHT NO SI TELLUB YM &#8656;
561-
</pre>
562-
563-
In LTR list items, the image will be used as-is.
564-
In the RTL list items, however,
565-
it will be flipped in the inline direction,
566-
so it still points into the content.
567-
</div>
568-
404+
Note: This function previously defined a number of additional behaviors,
405+
but those have been shifted to [[css-images-5]].
569406

570407
<!-- Big Text: cross-fade
571408

0 commit comments

Comments
 (0)