-
Notifications
You must be signed in to change notification settings - Fork 790
Expand file tree
/
Copy pathOverview.src.html
More file actions
936 lines (703 loc) · 37.4 KB
/
Overview.src.html
File metadata and controls
936 lines (703 loc) · 37.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
81
8000
1
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
<!DOCTYPE html>
<html lang="en">
<head profile="http://www.w3.org/2006/03/hcard">
<meta charset="utf-8">
<title>CSS TEMPLATE Module Level N</title>
<link rel="stylesheet" type="text/css" href="../default.css">
<link rel="stylesheet" type="text/css" href="http://www.w3.org/StyleSheets/TR/W3C-[STATUS].css">
<style type="text/css">
/* delete this block when you've cleared out all the .replaceme elements */
.replaceme {
border: solid red;
padding: 0 0.5em;
margin: 0 0.1em;
background: yellow;
color: green;
}
.replaceme:before {
content: "FIXME(";
color: black;
}
.replaceme:after {
content: ")";
color: black;
}
</style>
</head>
<div class="head">
<!--logo-->
<h1>CSS Image Values and Replaced Content Module Level 4</h1>
<h2 class="no-num no-toc">[LONGSTATUS] [DATE]</h2>
<dl>
<dt>This version:
<dd><a href="[VERSION]">
http://www.w3.org/TR/[YEAR]/[STATUS]-[SHORTNAME]-[CDATE]</a>
<dt>Latest version:
<dd><a href="http://www.w3.org/TR/css4-color">
http://www.w3.org/TR/css4-images</a>
<dt>Editor's draft:
<dd><a href="http://dev.w3.org/csswg/css4-images">http://dev.w3.org/csswg/css4-images</a>
<dt>Previous version:
<dd><a href="http://www.w3.org/PreviousVersionURI">
http://www.w3.org/PreviousVersionURI</a>
<dt>Editors:
<dd class=vcard><span class=fn>Tab Atkins Jr.</span>,
<span class=org>Google, Inc.</span>,
<a class=url href="http://xanthir.com/contact">http://xanthir.com/contact</a>
<dd class=vcard><span class=fn>Elika J. Etemad (fantasai)</span>,
<span class=org>W3C Invited Expert</span>,
<a class=url href="http://fantasai.inkedblade.net/contact">http://fantasai.inkedblade.net/contact</a>
</dl>
<!--copyright-->
<hr title="Separator for header">
</div>
<h2 class="no-num no-toc" id="abstract">Abstract</h2>
<p>CSS is a language for describing the rendering of structured documents
(such as HTML and XML) on screen, on paper, in speech, etc. This module
contains the features of CSS level 4 relating to specifying and rendering external and generated images and, in some cases, general replaced content.
It includes and extends the functionality of CSS level 3 Image Values [[css3-images]] and CSS level 2 [[CSS21]],
which builds on CSS level 1 [[CSS1]].
The main extensions compared to level 3 are <var class="replaceme">SUMMARIZE HERE</var>.
<h2 class="no-num no-toc" id="status">Status of this document</h2>
<!--status-->
<h2 class="no-num no-toc" id="contents">Table of contents</h2>
<!--toc-->
<h2 id="intro">
Introduction</h2>
<p><em>This section is not normative.</em>
<p><var class="replaceme">Provide background, motivation, etc.</var></p>
<h3 id="placement">
Module Interactions</h3>
<p class="replaceme">Explain, normatively, how this module affects the definition of CSS.</p>
<p>This module replaces and extends the <var class="replaceme">SUMMARIZE HERE</var>
features defined in [[!CSS21]] sections <var class="replaceme">W.X and Y.Z</var>.
<h3 id="values">
Values</h3>
<p>This specification follows the
<a href="http://www.w3.org/TR/CSS21/about.html#property-defs">CSS property
definition conventions</a> from [[!CSS21]]. Value types not defined in
this specification are defined in CSS Level 2 Revision 1 [[!CSS21]].
Other CSS modules may expand the definitions of these value types: for
example [[CSS3COLOR]], when combined with this module, expands the
definition of the <color> value type as used in this specification.</p>
<p>In addition to the property-specific values listed in their definitions,
all properties defined in this specification also accept the
<a href="http://www.w3.org/TR/CSS21/cascade.html#value-def-inherit">inherit</a>
keyword as their property value. For readability it has not been repeated
explicitly.</p>
<h2>Planned Features</h2>
<ol>
<li>Logical keywords for specifying linear gradient direction.</li>
<li>Conical gradients</li>
</ol>
<h2>Stuff I'm Pulling From Images 3</h2>
<!-- ====================================================================== -->
<h3 id="image-notation">
Image Annotations and Fallbacks: the ''image()'' notation</h3>
<p class=issue>I've put the bare image() function with fallback functionality only back into Images 3. The resolution and direction keywords are still intended to show up here in Images 4.</p>
<p>The ''image()'' notation allows an author to tag an image with a few types
of useful processing instructions which can affect the rendering of the image
and to declare fallback images to be used if the original image can't be
decoded or is a type that the browser doesn't recognize.
The author can specify the desired resolution the image should be rendered at,
declare the directionality of an image so that it can be automatically be
reversed if used in text with a different directionality.</p>
<p>So that authors can take advantage of CSS's forwards-compatible parsing
rules to provide a fallback for image slices, implementations that support
the ''image()'' notation <em>must</em> support the <code>xywh=#,#,#,#</code>
form of media fragment identifiers for images. [[!MEDIA-FRAGS]]
<p>The ''image()'' notation is defined as:
<pre class='prod'><dfn><image-list></dfn> =
image( [ <image-decl> , ]* [ <image-decl> | <color> ] )</pre>
<p>where <image-decl> is given by:</p>
<pre class='prod'><dfn><image-decl></dfn> =
<string> [ [ snap? && <resolution> ] || [ ltr | rtl ] ]</pre>
<p>Each <i><image-decl></i> represents the external image referenced
by the URI given as the <string> argument.</p>
<p>If the image is a raster image and a <resolution> is given, the image
must be rendered at that resolution. This must override the default resolution
given by the 'image-resolution' property.
<span class='note'>Recall that the default resolution of raster images is ''1dppx'',
so that one image pixel corresponds to one CSS ''px'' unit.</span> If the
''snap'' keyword is also specified, and the specified resolution would make
one image pixel larger than one device pixel, the image must be rendered at
the specified resolution, rounded to the nearest value that would map one image
pixel to an integer number of device pixels; if the specified resolution would
make one image pixel smaller than one device pixel, the image must be rendered
at the specified resolution, rounded to the nearest value that would map an
integer number of image pixels to one device pixel. If the image is a vector
image, specifying a resolution has no effect.</p>
<p>If a directional keyword (''ltr'' or ''rtl'') is given, the image itself
gains that directionality. If the image is used in a property on an element
with opposite directionality, is must be mirrored in the inline dimension
when rendered.</p>
<p>Multiple arguments can be given separated by commas, in which case the
function represents the first <image-decl> representing an image that
the browser can successfully load and display. The final argument can specify
a <color> to serve as an ultimate fallback; this can be used, e.g. for
'background-image', to ensure adequate contrast if none of the preceding
<image-decl>s can be used. If the final argument is a <color>, it
represents a solid-color image of the given color with no <i>intrinsic
dimensions</i>.
<div class="example">
<p>The rule below would tell the UA to load ''wavy.svg'' if
it can; failing that to load ''wavy.png'' and display it at 150dpi;
failing that to display ''wavy.gif''; and finally, if none of the images
can be loaded and displayed, to use the color ''rgba(0,0,255,0.5)'' to create a
dimensionless background image. For example, the browser might not understand
how to render SVG images, the PNG may be malformed, and the GIF might not
exist on the server and return 404 error instead of an image.</p>
<pre>background-image: image(url(wavy.svg), 'wavy.png' 150dpi, "wavy.gif", rgba(0,0,255,0.5));</pre>
<p>The 'background-size' property specifies that dimensionless images
by default stretch to cover the entire background positioning area
[[CSS3BG]], so if none of the specified images can be displayed
the background will be painted semi-transparent blue. As with any image,
this fallback will be painted over the 'background-color' (if any).</p>
</div>
<!-- ====================================================================== -->
<h3 id='cross-fade-function'>
Combining images: the ''cross-fade()'' notation</h3>
<p>When transitioning between images, CSS requires a way to explicitly refer
to the intermediate image that is a combination of the start and end images.
This is accomplished with the ''cross-fade()'' function, which indicates
the two images to be combined and how far along in the transition the
combination is.
<p class="note">Authors can also use the ''cross-fade()'' function for many
simple image manipulations, such as tinting an image with a solid color or
highlighting a particular area of the page by combining an image with a
radial gradient.
<p>The syntax for ''cross-fade()'' is defined as:</p>
<pre class=prod><dfn><image-combination></dfn> = cross-fade( <image>, <image>, <percentage> )</pre>
<p>The function represents an image generated by combining the first and
second image (referred to in this section as the "start" and "end" images,
respectively). The percentage represents how far along the transformation
is, with 0% representing the start image, 100% representing the end image,
and percentages between that representing corresponding combinations of the
two images. The <code><percentage></code> must be between 0% and 100% inclusive;
any other value is invalid.</p>
<p>More precisely, given ''cross-fade(A,B,p)'', where <var>A</var> and <var>B</var>
are images and <var>p</var> is a percentage between 0% and 100%, the function represents
an image with width equal to
<code>width<sub>A</sub> × (1-<var>p</var>) + width<sub>B</sub> × p</code>
and height equal to
<code>height<sub>A</sub> × (1-<var>p</var>) + height<sub>B</sub> × p</code>.
The contents of the image must be constructed by first scaling <var>A</var> and <var>B</var> to the size of the
generated image, then applying
<code>dissolve(<var>A</var>,1-<var>p</var>) plus dissolve(<var>B</var>,<var>p</var>)</code>.
<span class='note'>The "dissolve()" function and "plus" compositing operator are defined
in the literature by Porter-Duff.</span></p>
<!-- ====================================================================== -->
<!-- ====================================================================== -->
<!-- ====================================================================== -->
<h3 id='image-rendering'>
Determining How to Scale an Image: the 'image-rendering' property</h3>
<table class=propdef>
<tr>
<th>Name:
<td><dfn>image-rendering</dfn>
<tr>
<th>Value:
<td>auto | crisp-edges<!-- | pixelated -->
<tr>
<th>Initial:
<td>auto
<tr>
<th>Applies to:
<td>all elements
<tr>
<th>Inherited:
<td>yes
<tr>
<th>Media:
<td>visual
<tr>
<th>Computed Value:
<td>specified value
</table>
<p>The 'image-rendering' property provides a hint to the user-agent about what aspects of an image are most important to preserve when the image is scaled, to aid the user-agent in the choice of an appropriate scaling algorithm. When specified on an element, it applies to all images given in properties for the element, such as background images, list-style images, or the content of replaced elements when they represent an image that must be scaled. The values of the 'image-rendering' property are interpreted as follows:</p>
<dl>
<dt><dfn title="image-rendering-auto">auto</dfn></dt>
<dd>
<p>The image should be scaled with an algorithm that maximizes the appearance of the image, possibly smoothing colors or introducing minor blur. This value is intended for use with photos and similar "real-life" images.</p>
<p>For example, algorithms such as bilinear interpolation or lancosz interpolation are acceptable. Lesser or greater algorithms may be used as well; in high-load situations, user agents may choose to use a very cheap algorithm such as nearest-neighbor, while in low-load situations they may choose to use a very expensive and high-quality scaling algorithm.</p>
</dd>
<dt><dfn>crisp-edges</dfn></dt>
<dd>
<p>The image should be scaled with an algorithm that preserves contrast and edges in the image, and which does not smooth colors or introduce blur to the image in the process. This is intended for images such as pixel art, or diagrams with sharp, straight lines. When downscaling an image, some color-smoothing is acceptable, but should not introduce blurriness.</p>
<p>For example, when upscaling an image, algorithms such as nearest-neighbor are acceptable, as are specialized pixel-art scaling algorithms like EPX or <a href="http://research.microsoft.com/en-us/um/people/kopf/pixelart/">the algorithm described in this SIGGRAPH paper</a>. When downscaling an image, algorithms such as nearest-neighbor or bilinear interpolation are acceptable.</p>
</dd>
<!--<dt><dfn>pixelated</dfn></dt>
<dd>
<p>The image should be scaled with an algorithm that preserves a "pixelated" look. This is intended for images such as pixel art.</p>
<p>If the image is upscaled an integer multiple of its original size, it must be scaled with the nearest-neighbor algorithm. When upscaled by any other factor, nearest-neighbor is acceptable, as are other algorithms that preserve a pixelated look. When downscaling an image, any algorithm that preserves a pixelated look are acceptable, such as nearest-neighbor or bilinear interpolation.</p>
</dd>-->
</dl>
<p>This property does <em>not</em> dictate any particular scaling algorithm to be used. For example, with ''image-rendering:auto'', a user agent might scale images with bilinear interpolation by default, switch to nearest-neighbor interpolation in high-load situations, and switch to a high-quality scaling algorithm like Lanczos interpolation for static images that aren't moving or changing. Similarly, with ''image-rendering:crisp-edges'', a user agent might scale images with nearest-neighbor interpolation by default, and switch to EPX interpolation in low-load situations.</p>
<p>This property must only have an effect on raster images. Vector images can be upscaled or downscaled infinitely without losing detail, and thus do not require any hints as to what details are important to preserve.</p>
<p>This property previously accepted the values ''optimizeSpeed'' and ''optimizeQuality''. These are now deprecated; a user agent may accept them as valid values, but must treat them as aliases for the ''auto'' value.</p>
<p class=issue>dbaron suggests that optimizeSpeed should instead alias to crisp-edges.</p>
<!-- ====================================================================== -->
<h2 id='serialization'>
Serialization</h2>
<p>This section describes the serialization of all new properties and value
types introduced in this specification, for the purpose of interfacing with
the CSS Object Model [[CSSOM]].</p>
<p>All of these algorithms refer to a variable "s". For each, let s initially
be the empty string, run the steps described, and then return s.</p>
<!-- ====================================================================== -->
<h3 id='serializing-resolution'>
Serializing a <resolution></h3>
<p>The serialization of the <i><resolution></i> value type is defined in
the CSSOM spec.</p>
<p class=note>This spec defines several new units for resolutions. These
can all be converted to the canonical "dpcm" unit that CSSOM defines the
serialization in terms of.</p>
<!-- ====================================================================== -->
<h3 id='serializing-url-notation'>
Serializing the ''url()'' notation</h3>
<p>The serialization of the url() function is defined in the CSSOM spec.</p>
<!-- ====================================================================== -->
<h3 id='serializing-image-notation'>
Serializing the ''image()'' / <i><image-list></i> notation</h3>
<p>To serialize an <i><image-list></i>:</p>
<ol>
<li>Append "image(" to s.</li>
<li>For each argument, serialize the argument as an <image-decl> or
<color> as appropriate, and append it to s. Then, if it is not the final
argument, append a comma and a space ", " to s.</li>
<li>Append a close parenthesis ")" to s.</li>
</ol>
<p>To serialize an <i><image-decl></i>:</p>
<ol>
<li>Serialize the first part of the value (the <string>) as a string.</li>
<li>If a <resolution> was provided, append a space " " to s. Then
serialize the <resolution> and append it to s.</li>
<li>If the 'snap' keyword was provided, append a space " " and the literal
string "snap" to s.</li>
<li>If a directional keyword was provided, append a space " " to s, then
append the keyword to s.</li>
</ol>
<!-- ====================================================================== -->
<h3 id='serializing-element-notation'>
Serializing the ''element()'' / <i><element-reference></i> notation</h3>
<p>To serialize an <i><element-reference></i>:</p>
<ol>
<li>Append "element(" to s.</li>
<li>Serialize the argument as a selector or identifier, as appropriate,
and append it to s.</li>
<li>Append a close parenthesis ")" to s.</li>
</ol>
<!-- ====================================================================== -->
<h3 id='serializing-cross-fade'>
Serializing the ''cross-fade()'' / <i><image-combination></i> notation</h3>
<p>To serialize an <i><image-combination></i>:</p>
<ol>
<li>Append "cross-fade(" to s.</li>
<li>Serialize the first argument to the function as an <i><image></i>,
and append it to s.</li>
<li>Append a comma and a space ", " to s.</li>
<li>Serialize the second argument to the function as an <i><image></i>,
and append it to s.</li>
<li>Append a comma and a space ", " to s.</li>
<li>Serialize the third argument to the function as a <percentage>,
and append it to s.</li>
<li>Append a close parenthesis ")" to s.</li>
</ol>
<!-- ====================================================================== -->
<h3 id="serializing-gradients">
Serializing Gradients</h3>
<p>To serialize a <i><linear-gradient></i>:</p>
<ol>
<li>Append "linear-gradient(" to s.</li>
<li>
<ul>
<li>If the first argument to the gradient function was a single
keyword, serialize the keyword and append it
8096
to s.</li>
<li>Otherwise, if the first argument to the gradient function was
two keywords, serialize the vertical keyword (''top'' or ''bottom'')
and append it to s, then append a space " " to s, then serialize
the horizontal keyword (''left'' or ''right'') and append it to s.</li>
<li>Otherwise, if the first argument to the gradient function was
an <angle>, serialize the <angle> and append it to s.</li>
<li>Otherwise, append "top" to s.</li>
</ul>
</li>
<li>Append a comma and a space ", " to s.</li>
<li>For each color-stop in the gradient, serialize the color-stop, and
append it to s. Then, if it is not the final color-stop, append a comma
and a space ", " to s.</li>
<li>Append a close parenthesis ")" to s.</li>
</ol>
<p>To serialize a <i><radial-gradient></i>:</p>
<ol>
<li>Append "radial-gradient(" to s.</li>
<li>If a <bg-position> was specified in the first argument to the
gradient function, serialize it and append it to s. Otherwise, append
"center" to s.</li>
<li>Append a comma and a space ", " to s.</li>
<li>
<ul>
<li>If a <shape> and/or <size> was specified in the second
argument to the gradient function:
<ol>
<li>If a <shape> was specified, serialize it as a keyword
and append it to s. Otherwise, append "ellipse" to s.</li>
<li>Append a space " " to s.</li>
<li>If a <size> was specified, serialize it as a keyword
and append it to s. Otherwise, append "cover" to s.</li>
</ol>
</li>
<li>Otherwise, if two <length>s or <percentage>s were specified
in the second argument to the gradient function:
<ol>
<li>Serialize the first <length> or <percentage> and
append it to s.</li>
<li>Append a space " " to s.</li>
<li>Serialize the second <length> or <percentage> and
append it to s.</li>
</ol>
</li>
<li>Otherwise, append "ellipse cover" to s.</li>
</ul>
</li>
<li>Append a comma and a space ", " to s.</li>
<li>For each color-stop in the gradient, serialize the color-stop, and
append it to s. Then, if it is not the final color-stop, append a comma
and a space ", " to s.</li>
<li>Append a close parenthesis ")" to s.</li>
</ol>
<p>To serialize a <i><repeating-linear-gradient></i>:</p>
<ol>
<li>Append "repeating-linear-gradient(" to s.</li>
<li>Follow the steps for serializing a <i><linear-gradient></i>, except
skip step 1.</li>
</ol>
<p>To serialize a <i><repeating-radial-gradient></i>:</p>
<ol>
<li>Append "repeating-radial-gradient(" to s.</li>
<li>Follow the steps for serializing a <i><radial-gradient></i>, except
skip step 1.</li>
</ol>
<p>To serialize a <i><color-stop></i>:</p>
<ol>
<li>Serialize the <color>, and append it to s.</li>
<li>If a <length> or <percentage> was specified, append a space
" " to s, then serialize the <length> or <percentage> and append
it to s.</li>
</ol>
<!-- ====================================================================== -->
<h3 id='serializing-properties'>
Serializing new properties</h3>
<p>To serialize the 'image-resolution' property:
<ol>
<li>If the ''from-image'' keyword is specified in the property value,
append "from-image" to s.</li>
<li>If both the ''from-image'' keyword and a <resolution> are specified,
append a space " " to s.</li>
<li>If a <resolution> is specified, serialize it and append it to s.</li>
</ol>
<p>To serialize the 'image-orientation' property:</p>
<ol>
<li>Serialize the <angle> and append it to s.</li>
</ol>
<p>To serialize the 'image-rendering' property:</p>
<ol>
<li>Serialize the keyword and append it to s.</li>
</ol>
<p>To serialize the 'object-fit' property:</p>
<ol>
<li>Serialize the keyword and append it to s.</li>
</ol>
<p>To serialize the 'object-position' property:</p>
<ol>
<li>Serialize the value as a <bg-position> and append it to s.</li>
</ol>
<!-- ====================================================================== -->
<h2 id='interpolation'>
Interpolation</h2>
<p>This section describes how to interpolate between new value types defined
in this specification, for use with modules such as CSS Transitions and CSS
Animations.</p>
<p>If an algorithm below simply states that two values should be "interpolated"
or "transitioned" without further details, then the value should be interpolated
as described by the Transitions spec. Otherwise, the algorithm may reference
a variable "t" in its detailed description of the interpolation. This is a
number which starts at 0% and goes to 100%, and is set to a value that represents
the progress through the transition, based on the duration of the transition,
the elapsed time, and the timing function in use. For example, with a linear
timing function and a 1s duration, after .3s t is equal to 30%.</p>
<!-- ====================================================================== -->
<h3 id='interpolating-images'>
Interpolating <i><image></i></h3>
<p>All images can be interpolated, though some special types of images (like
some gradients) have their own special interpolation rules. In general terms,
images are interpolated by scaling them to the size of the start image and
cross-fading the two while they transition to the size of the end image.</p>
<p>In specific terms, at each point in the interpolation the image is equal
to <code>cross-fade(<start image>, <end image>, t)</code>.</p>
<!-- ======================================================================= -->
<h3 id='interpolating-image-combinations'>
Interpolating <i><image-combination></i></h3>
<p>Combinations of the same images at different progress points can be
smoothly animated by simply animating the progress. Theoretically, this
produces the same visual effect as the generic <image> interpolation
would; in practice, implementations may have slight differences due to
how they scale or rasterize images. Additionally, the generic <image>
interpolation produces nested cross-fade() functions, which is undesirable
if it can be avoided.</p>
<p>If both the starting and ending images are <image-combination>s with the
same image arguments, they must be interpolated by interpolating their third
argument, the percentage. Otherwise, they must be interpolated as generic
<image>s.</p>
<!-- ======================================================================= -->
<h3 id='interpolating-gradients'>
Interpolating <i><gradient></i></h3>
<p>Gradient images can be interpolated directly in CSS transitions and
animations, smoothly animating from one gradient to another. There are only
a few restrictions on what gradients are allowed to be interpolated:</p>
<ol>
<li>Both the starting and ending gradient must be expressed with the same
function. (For example, you can transition from a linear-gradient() to
a linear-gradient(), but not from a linear-gradient() to a radial-gradient()
or a repeating-linear-gradient().)</li>
<li>Both the starting and ending gradient must have the same number of
color-stops. For this purpose, a repeating gradient is considered to
have infinite color-stops, and thus all repeating gradients have the same
number of color-stops. (Note that one may pad a gradient with additional
color-stops placed atop each other, if necessary to make two gradients
have the same number of color-stops.)</li>
</ol>
<p>If the two gradients satisfy both of those constraints, they must be
interpolated as described below. If not, they must be interpolated as a
generic image.</p>
<ol>
<li>Convert both the start and end gradients to their explicit forms:
<dl>
<dt>For linear gradients:</dt>
<dd>
<ul>
<li>If the direction is specified as an <angle>, it
is already in its explicit form.</li>
<li>Otherwise, if the direction is specified as a single
keyword, change 'bottom' to '0deg', 'left' to '90deg',
'top' to '180deg', or 'right' to '270deg'.</li>
<li>Otherwise, if the direction is specified as two
keywords, change the direction to an <angle> in the
following ranges that would produce an equivalent
gradient: for 'bottom left' or 'left bottom', the angle must
be between 0deg and 90deg; for 'top left' or
'left top', the angle must be between 90deg and
180deg; for 'top right' or 'right top', the angle
must be between 180deg and 270deg; for 'bottom right' or
'right bottom', the angle must be between 270deg and 360deg.</li>
<li>If both the start and end gradients had their direction
specified with keywords, and the absolute difference
between the angles their directions mapped to is greater
than 180deg, add 360deg to the direction of the gradient
with the smaller angle. <span class='note'>This ensures
that a transition from, for example, "right" (270deg) to
"bottom" (0deg) rotates the gradient a quarter-turn
clockwise, as expected, rather than rotating
three-quarters of a turn counter-clockwise.</span></li>
</ul>
</dd>
<dt>For radial gradients:</dt>
<dd>
<ul>
<li>If the size is specified as two <length>s or
<percentage>s, it is already in its explicit form.</li>
<li>Otherwise, the size must be changed to a pair of
<length>s that would produce an equivalent
ending-shape.</li>
</ul>
</dd>
</dl>
</li>
<li>Interpolate each component and color-stop of the gradients independently.
For linear gradients, the only component is the angle. For radial gradients,
the components are the horizontal and vertical position of the center
and the horizontal and vertical axis lengths.</li>
<li>To interpolate a color-stop, first match each color-stop in the start
gradient to the corresponding color-stop at the same index in the end
gradient. For repeating gradients, the first specified color-stop in
the start and end gradients are considered to be at the same index, and
all other color-stops following and preceding are indexed appropriately.
Then, for each pair of color-stops, interpolate the position and color
independently.</li>
</ol>
<!-- ====================================================================== -->
<h2 id="conformance">
Conformance</h2>
<h3 id="conventions">
Document Conventions</h3>
<p>Conformance requirements are expressed with a combination of
descriptive assertions and RFC 2119 terminology. The key words “MUST”,
“MUST NOT”, “REQUIRED”, “SHALL”, “SHALL NOT”, “SHOULD”, “SHOULD NOT”,
“RECOMMENDED”, “MAY”, and “OPTIONAL” in the normative parts of this
document are to be interpreted as described in RFC 2119.
However, for readability, these words do not appear in all uppercase
letters in this specification.
<p>All of the text of this specification is normative except sections
explicitly marked as non-normative, examples, and notes. [[!RFC2119]]</p>
<p>Examples in this specification are introduced with the words “for example”
or are set apart from the normative text with <code>class="example"</code>,
like this:
<div class="example">
<p>This is an example of an informative example.</p>
</div>
<p>Informative notes begin with the word “Note” and are set apart from the
normative text with <code>class="note"</code>, like this:
<p class="note">Note, this is an informative note.</p>
<h3 id="conformance-classes">
Conformance Classes</h3>
<p>Conformance to <var class="replaceme">CSS TEMPLATE Module</var>
is defined for three conformance classes:
<dl>
<dt><dfn title="style sheet!!as conformance class">style sheet</dfn>
<dd>A <a href="http://www.w3.org/TR/CSS21/conform.html#style-sheet">CSS
style sheet</a>.
<dt><dfn>renderer</dfn></dt>
<dd>A <a href="http://www.w3.org/TR/CSS21/conform.html#user-agent">UA</a>
that interprets the semantics of a style sheet and renders
documents that use them.
<dt><dfn id="authoring-tool">authoring tool</dfn></dt>
<dd>A <a href="http://www.w3.org/TR/CSS21/conform.html#user-agent">UA</a>
that writes a style sheet.
</dl>
<p>A style sheet is conformant to <var class="replaceme">CSS TEMPLATE Module</var>
if all of its declarations that use properties defined in this module
have values that are valid according to the generic CSS grammar and the
individual grammars of each property as given in this module.
<p>A renderer is conformant to <var class="replaceme">CSS TEMPLATE Module</var>
if, in addition to interpreting the style sheet as defined by the
appropriate specifications, it supports all the features defined
by <var class="replaceme">CSS TEMPLATE Module</var> by parsing them correctly
and rendering the document accordingly. However, the inability of a
UA to correctly render a document due to limitations of the device
does not make the UA non-conformant. (For example, a UA is not
required to render color on a monochrome monitor.)
<p>An authoring tool is conformant to <var class="replaceme">CSS TEMPLATE Module</var>
if it writes style sheets that are syntactically correct according to the
generic CSS grammar and the individual grammars of each feature in
this module, and meet all other conformance requirements of style sheets
as described in this module.
<h3 id="partial">
Partial Implementations</h3>
<p>So that authors can exploit the forward-compatible parsing rules to
assign fallback values, CSS renderers <strong>must</strong>
treat as invalid (and <a href="http://www.w3.org/TR/CSS21/conform.html#ignore">ignore
as appropriate</a>) any at-rules, properties, property values, keywords,
and other syntactic constructs for which they have no usable level of
support. In particular, user agents <strong>must not</strong> selectively
ignore unsupported component values and honor supported values in a single
multi-value property declaration: if any value is considered invalid
(as unsupported values must be), CSS requires that the entire declaration
be ignored.</p>
<h3 id="experimental">
Experimental Implementations</h3>
<p>To avoid clashes with future CSS features, the CSS2.1 specification
reserves a <a href="http://www.w3.org/TR/CSS21/syndata.html#vendor-keywords">prefixed
syntax</a> for proprietary and experimental extensions to CSS.
&
133E
lt;p>Prior to a specification reaching the Candidate Recommendation stage
in the W3C process, all implementations of a CSS feature are considered
experimental. The CSS Working Group recommends that implementations
use a vendor-prefixed syntax for such features, including those in
W3C Working Drafts. This avoids incompatibilities with future changes
in the draft.
</p>
<h3 id="testing">Non-Experimental Implementations</h3>
<p>Once a specification reaches the Candidate Recommendation stage,
non-experimental implementations are possible, and implementors should
release an unprefixed implementation of any CR-level feature they
can demonstrate to be correctly implemented according to spec.
<p>To establish and maintain the interoperability of CSS across
implementations, the CSS Working Group requests that non-experimental
CSS renderers submit an implementation report (and, if necessary, the
testcases used for that implementation report) to the W3C before
releasing an unprefixed implementation of any CSS features. Testcases
submitted to W3C are subject to review and correction by the CSS
Working Group.
<p>Further information on submitting testcases and implementation reports
can be found from on the CSS Working Group's website at
<a href="http://www.w3.org/Style/CSS/Test/">http://www.w3.org/Style/CSS/Test/</a>.
Questions should be directed to the
<a href="http://lists.w3.org/Archives/Public/public-css-testsuite">public-css-testsuite@w3.org</a>
mailing list.
<h3 id="cr-exit-criteria">
CR Exit Criteria</h3>
<p class=issue>[Change or remove the following CR exit criteria if
the spec is not a module, but, e.g., a Note or a profile. This text was <a
href="http://www.w3.org/Style/CSS/Tracker/actions/44"> decided on 2008-06-04.</a>]</p>
<p id='cr-exit-criteria'>
For this specification to be advanced to Proposed Recommendation,
there must be at least two independent, interoperable implementations
of each feature. Each feature may be implemented by a different set of
products, there is no requirement that all features be implemented by
a single product. For the purposes of this criterion, we define the
following terms:
<dl>
<dt>independent <dd>each implementation must be developed by a
different party and cannot share, reuse, or derive from code
used by another qualifying implementation. Sections of code that
have no bearing on the implementation of this specification are
exempt from this requirement.
<dt>interoperable <dd>passing the respective test case(s) in the
official CSS test suite, or, if the implementation is not a Web
browser, an equivalent test. Every relevant test in the test
suite should have an equivalent test created if such a user
agent (UA) is to be used to claim interoperability. In addition
if such a UA is to be used to claim interoperability, then there
must one or more additional UAs which can also pass those
equivalent tests in the same way for the purpose of
interoperability. The equivalent tests must be made publicly
available for the purposes of peer review.
<dt>implementation <dd>a user agent which:
<ol class=inline>
<li>implements the specification.
<li>is available to the general public. The implementation may
be a shipping product or other publicly available version
(i.e., beta version, preview release, or “nightly build”).
Non-shipping product releases must have implemented the
feature(s) for a period of at least one month in order to
demonstrate stability.
<li>is not experimental (i.e., a version specifically designed
to pass the test suite and is not intended for normal usage
going forward).
</ol>
</dl>
<p>The specification will remain Candidate Recommendation for at least
six months.
<h2 class=no-num id="acknowledgments">Acknowledgments</h2>
<p><var class="replaceme">[acknowledgments]</var></p>
<h2 class=no-num id="references">References</h2>
<h3 class="no-num" id="normative-references">Normative references</h3>
<!--normative-->
<h3 class="no-num" id="other-references">Other references</h3>
<!--informative-->
<h2 class="no-num" id="index">Index</h2>
<!--index-->
<h2 class="no-num" id="property-index">Property index</h2>
<!-- properties -->
</body>
</html>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-declaration:"~/SGML/HTML4.decl"
sgml-default-doctype-name:"html"
sgml-minimize-attributes:t
sgml-nofill-elements:("pre" "style" "br")
sgml-live-element-indicator:t
sgml-omittag:nil
sgml-shorttag:nil
sgml-namecase-general:t
sgml-general-insert-case:lower
sgml-always-quote-attributes:t
sgml-indent-step:nil
sgml-indent-data:t
sgml-parent-document:nil
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
-->