-
Notifications
You must be signed in to change notification settings - Fork 790
Expand file tree
/
Copy pathOverview.src.html
More file actions
executable file
·2762 lines (2185 loc) · 122 KB
/
Overview.src.html
File metadata and controls
executable file
·2762 lines (2185 loc) · 122 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
811
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
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html lang="en-US">
<head>
<title>CSSOM</title>
<style type="text/css">
pre.idl { border:solid thin; background:#eee; color:#000; padding:0.5em }
pre.idl :link, pre.idl :visited { color:inherit; background:transparent }
dfn { font-weight:bold; font-style:normal }
div.example { margin-left:1em; padding-left:1em; border-left:double; color:#222; background:#fcfcfc }
div.example table code { color:inherit }
td, th { padding:.1em }
.note { margin-left:2em; color:green; font-style:italic; font-weight:bold }
p.note::before { content:"Note: " }
.XXX { padding:.5em; border:solid red }
p.XXX::before { content:"Issue: " }
em.ct { text-transform:lowercase; font-variant:small-caps; font-style:normal }
code { color:orangered }
code :link, code :visited { color:inherit }
</style>
<link rel="stylesheet" href="http://www.w3.org/StyleSheets/TR/W3C-[STATUS]">
</head>
<body class="draft">
<div class="head">
<h1 id="cssom">CSSOM</h1>
<h2 class="no-num no-toc" id="">[LONGSTATUS] [DATE: 3 August 2002]</h2>
<dl>
<dt>This Version:</dt>
<dd><a href="[VERSION]/">http://www.w3.org/TR/[YEAR]/ED-cssom-[CDATE]/</a></dd>
<dt>Latest Version:</dt>
<dd><a href="http://www.w3.org/TR/cssom/">http://www.w3.org/TR/cssom/</a></dd>
<dt>Latest Editor's draft:</dt>
<dd><a href="http://dev.w3.org/csswg/cssom/">http://dev.w3.org/csswg/cssom/</a></dd>
<dt>Previous Version:</dt>
<dd><a href="http://www.w3.org/TR/2000/REC-DOM-Level-2-Style-20001113/">http://www.w3.org/TR/2000/REC-DOM-Level-2-Style-20001113/</a></dd>
<dt>Editor:</dt>
<dd><a href="http://annevankesteren.nl/">Anne van Kesteren</a>
(<a href="http://www.opera.com/">Opera Software ASA</a>)
<<a href="mailto:annevk@opera.com">annevk@opera.com</a>></dd>
</dl>
</div>
<h2 class="no-num no-toc" id="abstract">Abstract</h2>
<p>CSSOM defines how style sheets interact with the DOM and defines an
API for CSS style sheets.</p>
<h2 class="no-num no-toc" id="sotd">Status of this Document</h2>
<p class="XXX">The plan is that this document provides the successor to
DOM Level 2 Style.</p>
<!--status-->
<h2 class="no-num no-toc" id="toc">Table of Contents</h2>
7FBB
<!--toc-->
<h2 id="introduction">Introduction</h2>
<p class="issue">...</p>
<h3 id="history">History</h3>
<p>Several interfaces from DOM Level 2 Style
<a href="http://www.w3.org/mid/Pine.LNX.4.05.10310302134070.1173-100000@lanalana.inria.fr" title="[CSSOM] CSSValue and related interfaces (message from the CSS WG)">have
been obsoleted</a> because they where thought to be too awkward for
frequent use. This specification no longer contains those features.
<code>DOMImplementationCSS</code> and <code>CSSCharsetRule</code> have
been removed as well as they were not deemed necessary.</p>
<h2 id="conformance">Conformance Requirements</h2>
<p>Everything in this specification is normative except for diagrams,
examples, notes and sections marked non-normative.</p>
<p>The key words <em class="ct">must</em>, <em class="ct">must not</em>,
<em class="ct">required</em>, <em class="ct">shall</em>, <em class="ct">shall
not</em>, <em class="ct">should</em>, <em class="ct">should not</em>,
<em class="ct">recommended</em>, <em class="ct">may</em>, and
<em class="ct">optional</em> in the normative parts of this document are to be
interpreted as described in RFC 2119
<a href="#ref-rfc2119">[RFC2119]</a>.</p>
<!-- XXX
<p>The following conformance classes are defined (and considered) by this
specification:</p>
<dl>
<dt><dfn id="conforming-implementation">conforming implementation</dfn></dt>
<dd>A user agent that implements all interfaces described in this
specification and follows all <em class="ct">must</em>-,
<em class="ct">required</em>- and <em class="ct">shall</em>-level of criteria
in this specification.</dd>
<dt><dfn id="conforming-document">conforming document</dfn></dt>
<dd>A document that follows all <em class="ct">must</em>-,
<em class="ct">required</em>- and <em class="ct">shall</em>-level of criteria
in this specification that apply to document authors.</dd>
<dt><dfn id="conforming-authoring-tool">conforming authoring tool</dfn></dt>
<dd>One that produces conforming documents.</dd>
</dl>
-->
<h2 id="terminology">Terminology</h2>
<p class="XXX">
<dfn>resolve a URL</dfn>,
<dfn>case-sensitive</dfn>,
<dfn>ASCII case-insensitive</dfn>,
<dfn>URL</dfn>,
<dfn>Content-Type metadata</dfn>,
<dfn>supported styling language</dfn>,
<dfn><code>xml-stylesheet</code> processing instruction</dfn>,
<dfn>fetch</dfn>, ...
</p>
<p>A <dfn>color component integer</dfn> is a base-ten integer in the range
0-255 using digits 0-9, U+0030 to U+0039, in the shortest form possible.</p>
<p>A <dfn>color component separator</dfn> is a literal U+002C COMMA followed
by a U+0020 SPACE.</p>
<p>When this specification talks about object <code><var>A</var></code>
where <code><var>A</var></code> is actually an interface, it generally means
an object implementing interface <code><var>A</var></code>.</p>
<p>The term <dfn id="whitespace">whitespace</dfn> is used as defined in
CSS. <!--XXX <a href="#ref-css">[CSS]</a>--></p>
<h2>Media Queries</h2>
<p>Media queries are defined by the Media Queries specification. This
section defines various concepts around media queries, including their API
and serialization form.</p> <!-- XXX ref -->
<h3>Parsing Media Queries</h3>
<p>To
<dfn id="parse-a-media-query">parse a media query</dfn> for a given string
<var title="">s</var> means to follow the
<span>parse a list of media queries</span> steps and return null if more
than one media query is returned or a media query if a
single media query is returned.</p>
<p>To
<dfn id="parse-a-list-of-media-queries">parse a list of media queries</dfn>
for a given string <var>s</var> into a list of media queries is defined in
the Media Queries specification. Return the list of one or more media
queries that the algorithm defined there gives.</p> <!-- XXX ref -->
<p class="note">If everything ends up being ignored the list will contain
the media query "<code title="">not all</code>".</p>
<h3>Serializing Media Queries</h3>
<p>To
<dfn id="serialize-a-media-query">serialize a media query</dfn> run these
steps:</p>
<ol>
<li><p>Let <var title="">s</var> be the empty string.</p></li>
<li><p>If the media query is negated append the literal string
"<code>not</code>", followed by a U+0020 SPACE character, to
<var title="">s</var>.</p></li>
<li><p>Let <var title="">type</var> be the media query,
<span>converted to ASCII lowercase</span>.</p></li>
<li><p>If the media query does not contain media features append
<var title="">type</var>, to <var>s</var>,
then return <var>s</var> and terminate this algorithm.</p></li>
<li><p>If <var title="">type</var> is not "<code>all</code>" or if the
media query is negated append <var title="">type</var>, followed by
a U+0020 SPACE character, followed by "<code>and</code>", followed by a
U+0020 SPACE character, to <var title="">s</var>.</p></li>
<li><p>Sort the media features in lexicographical order.</p></li>
<li>
<p>Then, for each media feature:</p>
<ol>
<li>Append a U+0028 LEFT PARENTHESIS character, followed by the media
feature name, <span>converted to ASCII lowercase</span>, to
<var>s</var>.</p></li>
<li><p>If a value is given append a U+003A COLON (:)
character, followed by a U+0020 SPACE character, followed by the
<span title="serialize a media feature value">serialized media feature value</span>,
to <var>s</var>.</p>
<li><p>Append a U+0029 RIGHT PARENTHESIS character to
<var>s</var>.</p></li>
<li><p>If this is not the last media feature append a U+0020 SPACE
character, followed by the literal string "<code>and</code>", followed
by a U+0020 SPACE character, to <var>s</var>.</p>
</ol>
</li>
<li><p>Return <var>s</var>.</p></li>
</ol>
<div class="example">
<p>Here are some examples of input (first column) and output (second
column):</p>
<table>
<thead>
<tr><th>Input<th>Output
<tbody>
<tr>
<td><code>not screen and (min-WIDTH:5px) AND (max-width:40px )</code>
<td><code>not screen and (max-width: 40px) and (min-width: 5px)</code>
<tr>
<td><code>all and (color) and (color)</code>
<td><code>(color)</code>
</table>
</div>
<p>To
<dfn id="serialize-a-list-of-media-queries">serialize a list of media queries</dfn>
run these steps:</p>
<ol>
<li><p>Let <var>s</var> be the empty string.</p></li>
<li><p>If the list is empty return <var>s</var> and terminate this
algorithm.</p></li>
<li>
<p>For each media query in the list:</p>
<ol>
<li><p>Append the result of
<span title="serializing-media-query">serializing the media
query</span> to <var>s</var>.</p></li>
<li><p>If this is not the last media query append a U+002C COMMA
(,) character, followed by a U+0020 SPACE character to
<var>s</var>.</p></li>
</ol>
</li>
<li><p>Return <var>s</var>.</p></li>
</ol>
<h4>Serializing Media Feature Values</h4>
<p class="XXX">This should probably be done in terms of mapping it to
serializing CSS values as media features are defined in terms of CSS
values after all.</p>
<p>To <dfn id="serialize-a-media-feature-value">serialize a media feature value</dfn>
named <var title="">v</var> locate <var title="">v</var> in the first
column of the table below and use the serialization format described in
the second column:</p>
<table>
<tr>
<th>Media Feature
<th>Serialization
<tr>
<td><code title="">width</code>
<td>...
<tr>
<td><code title="">height</code>
<td>...
<tr>
<td><code title="">device-width</code>
<td>...
<tr>
<td><code title="">device-height</code>
<td>...
<tr>
<td><code title="">orientation</code>
<td>
<p>If the value is `<code title="">portrait</code>`: "<code title="">portrait</code>".</p>
<p>If the value is `<code title="">landscape</code>`: "<code title="">landscape</code>".</p>
<tr>
<td><code title="">aspect-ratio</code>
<td>...
<tr>
<td><code title="">device-aspect-ratio</code>
<td>...
<tr>
<td><code title="">color</code>
<td>...
<tr>
<td><code title="">color-index</code>
<td>...
<tr>
<td><code title="">monochrome</code>
<td>...
<tr>
<td><code title="">resolution</code>
<td>...
<tr>
<td><code title="">scan</code>
<td>
<p>If the value is `<code title="">progressive</code>`: "<code title="">progressive</code>".</p>
<p>If the value is `<code title="">interlace</code>`: "<code title="">interlace</code>".</p>
<tr>
<td><code title="">grid</code>
<td>...
</table>
<p>Other specifications can extend this table and vendor-prefixed media
features can have custom serialization formats as well.</p>
<h3>Comparing Media Queries</h3>
<p>To
<dfn id="compare-media-queries">compare media queries</dfn>
<var>m1</var> and <var>m2</var> means to
<span title="serializing media query">serialize</span> them both and
return true if they are a <span>case-sensitive</span> match and false if
they are not.</p>
<h3>The <code title="">MediaList</code> Interface</h3>
<p>An object that implements the <code>MediaList</code> interface has an
associated <dfn>list of media queries</dfn>.</p>
<!-- http://dev.w3.org/2006/webapi/WebIDL/#idl-indexed-properties -->
<pre class="idl">interface <dfn>MediaList</dfn> {
stringifier attribute DOMString <span title="medialist-mediatext">mediaText</span>;
readonly attribute unsigned long <span title="medialist-length">length</span>;
getter DOMString <span title="medialist-item">item</span>(unsigned long <var title="">index</var>);
void <span title="medialist-appendmedium">appendMedium</span>(DOMString <var title="">medium</var>)
void <span title="medialist-deletemedium">deleteMedium</span>(DOMString <var title="">medium</var>)
};</pre>
<p>The
<dfn id="medialist-mediatext" title="medialist-mediatext"><code>mediaText</code></dfn>
attribute <em class="ct">must</em>, on getting, return a
<span title="serialize a list of media queries">serialization</span> of
the <span>list of media qeuries</span>.</p>
<p>On setting the <code title="medialist-mediatext">mediaText</code>
attribute these steps <em class="ct">must</em> be run:</p>
<ol>
<li><p>Empty the <span>list of media queries</span>.</p></li>
<li><p>If the given value is the empty string terminate these
steps.</p></li>
<li><p>Append all the media queries as a result of
<span title="parse a list of media queries">parsing</span> the given
value to the <span>list of media queries</span>.</p></li>
</ol>
<p>The
<dfn id="medialist-length" title="medialist-length"><code>length</code></dfn>
attribute, on getting, <em class="ct">must</em> return the number of media
queries in the <span>list of media queries</span>.</p>
<p>The
<dfn id="medialist-item" title="medialist-item"><code>item(<var title="">index</var>)</code></dfn>
method, when invoked, <em class="ct">must</em> return the item in the list
given by <var>index</var>, or <code>null</code>, if <var>index</var> is
greater than or equal to the number of items in the list.</p>
<!-- XXX need consistency here WebIDL? list of media queries? -->
<p>The
<dfn id="medialist-appendmedium" title="medialist-appendmedium"><code>appendMedium(<var title="">medium</var>)</code></dfn>
method <em class="ct">must</em>, when invoked, run these steps:</p>
<ol>
<li><p>Let <var title="">m</var> be the result of
<span title="parse a media query">parsing</span> the given
value.</p></li>
<li><p>If <var title="">m</var> is null terminate these steps.</p></li>
<li><p>If <span title="compare media queries">comparing</span>
<var title="">m</var> with any of the media queries in the
<span>list of media queries</span> returns true terminate these
steps.</p></li>
<li><p>Append <var title="">m</var> to the
<span>list of media queries</span>.</p></li>
</ol>
<p>The
<dfn id="medialist-deletemedium" title="medialist-deletemedium"><code>deleteMedium(<var title="">medium</var>)</code></dfn>
method <em class="ct">must</em>, when invoked, run these steps:</p>
<ol>
<li><p>Let <var title="">m</var> be the result of
<span title="parse a media query">parsing</span> the given
value.</p></li>
<li><p>If <var title="">m</var> is null terminate these steps.</p></li>
<li><p>Remove any media query from the <span>list of media queries</span>
for which <span title="compare media queries">comparing</span> the media
query with <var title="">m</var> returns true.</p></li>
</ol>
<h3>Creating a <code title="">MediaList</code> Object</h3>
<p>To
<dfn id="create-a-medialist-object">create a <code>MediaList</code> object</dfn>
from <var title="">s</var> run these steps:</p>
<ol>
<li><p>Create a new <code>MediaList</code> object.</p></li>
<li><p>Set its <span title="medialist-mediatext">mediaText</span>
attribute to <var title="">s</var>.</p></li>
<li><p>Return the newly created <code>MediaList</code> object.</p></li>
</ol>
<h2>Selectors</h2>
<p>Selectors are defined in the Selectors specification. This section
defines how to serialize them.</p> <!-- XXX ref -->
<p>To
<dfn id="parse-a-group-of-selectors">parse a group of selectors</dfn>
means to parse the value using the <code title="">selectors_group</code>
production defined in the Selectors specification and return either a
group of selectors if parsing did not fail or null if parsing did
fail.</p> <!-- XXX ref -->
<p>To
<dfn id="serialize-a-group-of-selectors">serialize a group of selectors</dfn>
run these steps:</p>
<!-- http://dump.testsuite.org/2009/cssom/serializing-selectors.htm -->
<ol>
<!-- XXX say something about CSS character escapes? -->
<li><p>Remove leading and trailing <span>whitespace</span>.</p></li>
<li><p>Replace one or more consecutive <span>whitespace</span> characters
with a single U+0020 SPACE character.</p></li>
<li><p>Make sure combinators other than the descendant combinator are
preceded and followed by a single U+0020 SPACE character (and not
more).</p></li>
<li><p>Make sure each U+002C COMMA (,) character is followed by a
single U+0020 SPACE character (and not more).</p></li>
<li><p>If there is no default namespace and the namespace prefix of a
<span>type selector</span> or <span>universal selector</span> is set to a
U+002A ASTERISK (*) character remove the namespace component of that
<span>type selector</span> or <span>universal selector</span>.</p></li>
<!-- XXX namespace refs? -->
<li><p>Remove any
<span title="universal selector">universal selectors</span> that can be
omitted.</p></li>
<li>
<p>Follow these rules for serializing attribute selectors:</p>
<ul>
<li><p>If there is no namespace prefix (which includes the asterisk)
remove the U+007C VERTICAL LINE (|) before the attribute name if it is
present.</p></li>
<!-- XXX ref namespace prefix? -->
<li><p>If an identifier was given as value insert a leading and
trailing U+0022 QUOTATION MARK (") character around the identifier and
escape any U+0022 QUOTATION MARK (") characters in the value by
inserting a U+005C REVERSE SOLIDUS (\) character in front of
them.</p></li>
<!-- XXX or does this happen during parsing -->
</ul>
</li>
<li>
<p>Pseudo-classes without arguments and pseudo-elements are serialized
to their canonical form as given in the specification.</p>
<p class="note">E.g. <code>:HOver</code> becomes <code>:hover</code> and
<code>:befoRe</code> becomes <code>::before</code>.</span></p>
</li>
<li>
<p>The rules for pseudo-classes with arguments are to serialize their
name to their canonical name as given in the specification, remove any
leading and trailing <span>whitespace</span> around the argument, and
serialize the value as follows:</p>
<dl>
<dt>If the pseudo-class is <code title="">:lang()</code></dt>
<dd><p>The literal value.</p></dd>
<dt>If the pseudo-class is <code title="">:nth-child()</code>,
<code title="">:nth-last-child()</code>,
<code title="">:nth-of-type()</code>, or
<code title="">:nth-last-of-type()</code></dt>
<dd>
<ol>
<li><p>If the value is odd let the value be
"<code title="">2n+1</code>".</p></li>
<li><p>If the value is even let the value be
"<code title="">2n</code>".</p></li>
<li><p>If <var title="">a</var> is zero let the value be
<var title="">b</var> serialized as string.</p></li>
<!-- XXX serialize integer -->
<li><p>If <var title="">a</var> is one or minus one and
<var title="">b</var> is zero let the value be
"<code title="">n</code>".</p></li>
<li><p>If <var title="">a</var> is one or minus one let the value be
"<code title="">n</code>" followed by a U+002B PLUS SIGN (+)
character if <var title="">b</var> is positive, followed by
<var title="">b</var> serialized as string.</p></li>
<!-- XXX serialize integer -->
<li><p>If <var title="">b</var> is zero let the value be
<var title="">a</var> serialized as string followed by
"<code title="">n</code>".</p></li>
<!-- XXX serialize integer -->
<li><p>Otherwise let the value be
<var title="">a</var> serialized as string followed by
"<code title="">n</code>" followed by a U+002B PLUS SIGN (+)
character if <var title="">b</var> is positive, followed by
<var title="">b</var> serialized as string.</p></li>
<!-- XXX serialize integer -->
</ol>
</dd>
<dt>If the pseudo-class is <code title="">:not()</code></dt>
<dd><p>The result of serializing the value using the rules for
<span title="serialize a group of selectors">serializing a group of selectors</span>.</p></dd>
<dt>Any other pseudo-class</dt>
<dd><p class="XXX">Hopefully Selectors Level 4 defines serialization itself.</p></dd>
</dl>
</li>
</ol>
<h2>Style Sheets</h2>
<h3>Style Sheet</h3>
<!-- XXX
element inserted into the DOM, style sheet created, element removed from
the DOM, what happens to StyleSheet?
-->
<p>A <dfn id="style-sheet">style sheet</dfn> is an abstract concept that
represents any kind of style sheet. In the DOM a <span>style sheet</span>
is a <code>StyleSheet</code> object. A <span>style sheet</span> has a
number of associated properties:</p>
<dl>
<dt><dfn id="style-sheet-type">style sheet type</dfn></dt>
<dd><p>The <span>Content-Type metadata</span> of the
<span>style sheet</span>.</p></dd>
<dt><dfn id="style-sheet-location">style sheet location</dfn></dt>
<dd><p>The <span>URL</span> of the <span>style sheet</span> or null if
the <span>style sheet</span> was embedded.</p></dd>
<dt><dfn id="style-sheet-node">style sheet node</dfn></dt>
<dd><p>The DOM node associated with the <span>style sheet</span> or
null if there is no associated DOM node.</p></dd>
<dt><dfn id="style-sheet-parent">style sheet parent</dfn></dt>
<dd><p>The <span>style sheet</span> that is the parent of the
<span>style sheet</span>.</p></dd>
<dt><dfn id="style-sheet-media">style sheet media</dfn></dt>
<dd>
<p>The <code>MediaList</code> object associated with the
<span>style sheet</span>.</p>
<p>If this property is set to a string run the
<span>create a <code>MediaList</code> object</span> steps for that
string and associate the returned object with the
<span>style sheet</span>.</p>
</dd>
<dt><dfn id="style-sheet-title">style sheet title</dfn></dt>
<dd>
<p>The title of the <span>style sheet</span>. It is said to be empty
if the title is the empty string.</p>
<div class="example">
<p>In these examples the <span>style sheet title</span> ends up being
empty:</p>
<pre><style title=""> body { background:papayawhip } </style></pre>
<pre><style> body { background:orange } </style></pre>
</div>
</dd>
<dt><dfn id="style-sheet-alternate-flag">style sheet alternate flag</dfn></dt>
<dd>
<p>Either true or false. False by default.</p>
<div class="example">
<p>The following <span title="style sheet">style sheets</span> have
their <span>style sheet alternate flag</span> set:</p>
<pre><code><?xml-stylesheet alternate="yes" title="x" href="data:text/css,…"?></code></pre>
<pre><code><link rel="alternate stylesheet" title="x" href="data:text/css,…"></code></pre>
</div>
</dd>
<dt><dfn>style sheet disabled flag</dfn></dt>
<dd>
<p>Either true or false. False by default.</p>
<p class="note">Even when false it does not necessarily mean that the
<span>style sheet</span> is actually rendered.</p>
</dd>
</dl>
<p>When you are to <span>create a style sheet</span> the above properties
are to be set to their proper values.</p>
<!-- same-origin restrictions -->
<h4>The <code title="">StyleSheet</code> Interface</h4>
<p>In the DOM a <span>style sheet</span> is represented by an object that
implements the <code>StyleSheet</code> interface.</p>
<pre class="idl">interface <dfn id="stylesheet">StyleSheet</dfn> {
readonly attribute DOMString <span title="stylesheet-type">type</span>;
readonly attribute DOMString <span title="stylesheet-href">href</span>;
readonly attribute Node <span title="stylesheet-ownernode">ownerNode</span>;
readonly attribute <span>StyleSheet</span> <span title="stylesheet-parentstylesheet">parentStyleSheet</span>;
readonly attribute DOMString <span title="stylesheet-title">title</span>;
[PutForwards=mediaText] readonly attribute <span>MediaList</span> <span title="stylesheet-media">media</span>;
attribute boolean <span title="stylesheet-disabled">disabled</span>;
};</pre>
<p>The
<dfn id="stylesheet-type" title="stylesheet-type"><code>type</code></dfn>
attribute <em class="ct">must</em> return the
<span>style sheet type</span>.</p>
<dfn id="stylesheet-href" title="stylesheet-href"><code>href</code></dfn>
attribute <em class="ct">must</em> return the
<span>style sheet location</span>.</p>
<p>The
<dfn id="stylesheet-ownernode" title="stylesheet-ownernode"><code>ownerNode</code></dfn>
attribute <em class="ct">must</em> return the
<span>style sheet node</span>.</p>
<p>The
<dfn id="stylesheet-parentstylesheet" title="stylesheet-parentstylesheet"><code>parentStyleSheet</code></dfn>
attribute <em class="ct">must</em> return the
<span>style sheet parent</span>.</p>
<p>The
<dfn id="stylesheet-title" title="stylesheet-title"><code>title</code></dfn>
attribute <em class="ct">must</em> return the
<span>style sheet title</span>.</p>
<p>The
<dfn id="stylesheet-media" title="stylesheet-media"><code>media</code></dfn>
attribute <em class="ct">must</em> return the
<span>style sheet media</span>.</p>
<p>The
<dfn id="stylesheet-disabled" title="stylesheet-disabled"><code>disabled</code></dfn>
attribute <em class="ct">must</em>, on getting, return the
<span>style sheet disabled flag</span>. On setting, it
<em class="ct">must</em> set the <span>style sheet disabled flag</span> to
the given value.</p>
<h3>Style Sheet Collections</h3>
<p>Below various new concepts are defined that are associated with each
<code>Document</code> object.</p>
<p>Each <code>Document</code> has an associated list of zero or more
<span title="style sheet">style sheets</span>, named the
<dfn id="document-style-sheets">document style sheets</dfn>. This is
an ordered list that contains all
<span title="style sheet">style sheets</span> associated with the
<code>Document</code>, in <span>tree order</span>, with
<span title="style sheet">style sheets</span> created from HTTP
<code title="http-link">Link</code> headers first, if any, in header
order.</p>
<p>To <dfn id="create-a-style-sheet">create a style sheet</dfn>, run these
steps:</p>
<ol>
<li><p>Create a new <span>style sheet</span> object and set its
properties as specified.</p></li>
<li><p>Then run the <span>add a style sheet</span> steps for the newly
created <span>style sheet</span>.</p></li>
</ol>
<p>To <dfn id="add-a-style-sheet">add a style sheet</dfn>, run these
steps:</p>
<ol>
<li><p>Add the <span>style sheet</span> to the list of
<span>document style sheets</span> at the appropriate location. The
remainder of these steps deal with the
<span>style sheet disabled flag</span>.</p></li>
<li><p>If the <span>style sheet disabled flag</span> is true terminate
these steps.</p></li>
<li><p>If the <span>style sheet title</span> is non-empty, the
<span>style sheet alternate flag</span> is false, and
<span>preferred style sheet set name</span> is the empty string
<span>change the preferred style sheet set name</span> to the
<span>style sheet title</span>.</p></li>
<li>
<p>If any of the following is true set the
<span>style sheet disabled flag</span> to false and terminate these
steps:</p>
<ul>
<li><p>The <span>style sheet title</span> is empty.</p></li>
<li><p>The <span>last style sheet set name</span> is null and the
<span>style sheet title</span> is a <span>case-sensitive</span> match
for the <span>preferred style sheet set name</span>.</p></li>
<li><p>The <span>style sheet title</span> is a
<span>case-sensitive</span> match for the
<span>last style sheet set name</span>.</p></li>
</ul>
</li>
<li><p>Set the <span>style sheet disabled flag</span> to true.</p></li>
</ol>
<p>A <dfn id="persistent-style-sheet">persistent style sheet</dfn> is a
<span>style sheet</span> from the <span>document style sheets</span>
whose <span>style sheet title</span> is the empty string and whose
<span>style sheet alternate flag</span> is false.</p>
<p>A <dfn id="style-sheet-set">style sheet set</dfn> is an ordered
collection of one or more <span title="style sheet">style sheets</span>
from the <span>document style sheets</span> which have an identical
<span>style sheet title</span> that is not the empty string.</p>
<p>A <dfn id="style-sheet-set-name">style sheet set name</dfn> is the
<span>style sheet title</span> the <span>style sheet set</span> has in
common.</p>
<p>An <dfn id="enabled-style-sheet-set">enabled style sheet set</dfn> is a
<span>style sheet set</span> of which each <span>style sheet</span> has
its <span>style sheet disabled flag</span> set to false.</p>
<p>To <dfn id="enable-a-style-sheet-set">enable a style sheet set</dfn>
with name <var title="">name</var>, run these steps:</p>
<ol>
<li><p>If <var title="">name</var> is the empty string set the
<span>style sheet disabled flag</span> for each <span>style sheet</span>
that is in a <span>style sheet set</span> to true and terminate these
steps.</p></li>
<li><p>Set the <span>style sheet disabled flag</span> for each
<span>style sheet</span> in a <span>style sheet set</span> whose
<span>style sheet set name</span> is a case-sensitive match for
<var title="">name</var> to false and set it to false for all other
<span title="style sheet">style sheets</span> in a
<span>style sheet set</span>.</p></li>
</ol>
<p>To <dfn id="select-a-style-sheet-set">select a style sheet set</dfn>
with name <var title="">name</var>, run these steps:</p>
<ol>
<li><p><span>Enable a style sheet set</span> with name
<var title="">name</var>.</p></li>
<li><p>Set <span>last style sheet set name</span> to
<var title="">name</var>.</p></li>
</ol>
<p>A <dfn id="last-style-sheet-set-name">last style sheet set name</dfn>
is a concept to determine what <span>style sheet set</span> was last
<span title="select a style sheet set">selected</span>. Initially its
value is null.</p>
<p>A
<dfn id="preferred-style-sheet-set-name">preferred style sheet set name</dfn>
is a concept to determine which
<span style="style sheet">style sheets</span> need to have their
<span>style sheet disabled flag</span> set to false. Initially its value
is the empty string.
<p>To
<dfn id="change-the-preferred-style-sheet-set-name">change the preferred style sheet set name</dfn>
with name <var title="">name</var>, run these steps:</p>
<ol>
<li><p>Let the <span>preferred style sheet set name</span> be
<var title="">current</var>.</p></li>
<li><p>Set <span>preferred style sheet set name</span> to
<var title="">name</var>.</p></li>
<li><p>If <var title="">name</var> is not a <span>case-sensitive</span>
match for <var title="">current</var> and
<span>last style sheet set name</span> is null
<span>enable a style sheet set</span> with name
<var title="">new</var>.</p></li>
</ol>
<!-- XXX ought to define "applied"
thoughts:
depends on disabled flag, alternate flag, media queries, sheesh
-->
<h4>The HTTP <code title="">Default-Style</code> Header</h4>
<p>The HTTP <code title="http-default-style">Default-Style</code> header
can be used to set the <span>preferred style sheet set name</span>
influencing which <span>style sheet set</span> is (initially) the
<span>enabled style sheet set</span>.</p>
<p>For each HTTP <code title="http-default-style">Default-Style</code>
header, in header order, the user agent <em class="ct">must</em>
<span>change the preferred style sheet set name</span> with name being the
value of the header.</p>
<h4>The <code title="">StyleSheetList</code> Sequence</h4>
<p>The sequence parameterized type represents an ordered collection of
<span title="style sheet">style sheets</span>.</p>
<pre class="idl">typedef sequence<<span>StyleSheet</span>> <dfn>StyleSheetList</dfn>;</pre>
<!--
<pre class="idl">interface <dfn>StyleSheetList</dfn> {
readonly attribute unsigned long <span title="stylesheetlist-length">length</span>;
getter <span>StyleSheet</span> <span title="stylesheetlist-item">item</span>(unsigned long <var title="">index</var>);
};</pre>
<p>The
<dfn id="stylesheetlist-length" title="stylesheetlist-length"><code>length</code></dfn>
attribute, on getting, <em class="ct">must</em> return the number of
objects currently in the list.</p>
<p>The
<dfn id="stylesheetlist-item" title="stylesheetlist-item"><code>item(<var title="">index</var>)</code></dfn>
method, when invoked, <em class="ct">must</em> return the
<code>StyleSheet</code> object in the list given by <var>index</var>, or
<code>null</code>, if <var>index</var> is greater than or equal to the
number of items in the list.</p>
-->
<h4>The <code title="">DocumentStyle</code> Interface</h4>
<!-- https://bugzilla.mozilla.org/show_bug.cgi?id=200930 (FIXED) -->
<pre class="idl">interface <dfn>DocumentStyle</dfn> {
readonly attribute <span>StyleSheetList</span> <span>styleSheets</span>;
attribute DOMString? <span>selectedStyleSheetSet</span>;
readonly attribute DOMString? <span>lastStyleSheetSet</span>;
readonly attribute DOMString? <span>preferredStyleSheetSet</span>;
readonly attribute DOMStringList <span>styleSheetSets</span>;
void <span title="documentstyle-enablestylesheetsforset">enableStylesheetsForSet</span>(DOMString? <var>name</var>);
};
<span>Document</span> implements <span>DocumentStyle</span>;</pre>
<!-- XXX use Supplemental instead? -->
<p>The
<dfn id="documentstyle-stylesheets"><code>styleSheets</code></dfn>
attribute <em class="ct">must</em> return a <code>StyleSheetList</code>
sequence representing the <span>document style sheets</span>.</p
<p>The
<dfn id="documentstyle-selectedStyleSheetSet"><code>selectedStyleSheetSet</code></dfn>
<em class="ct">must</em>, on getting, run these steps:</p>
<ol
6916
>
<li><p>If there is a single <span>enabled style sheet set</span> and no
other <span>document style sheets</span> with a non-empty
<span>style sheet title</span> have the
<span>style sheet disabled flag</span> set to false return the
<span>style sheet set name</span> of the
<span>enabled style sheet set</span> and terminate this set of
steps.</p></li>
<li><p>Otherwise, if <span title="style sheet">style sheets</span> from
different <span title="style sheet set">style sheet sets</span> have
their <span>style sheet disabled flag</span> set to false return
null and terminate this set of steps.</p></li>
<li>
<p>Otherwise, return the empty string.</p>
<p class="note">At this point either all
<span title="style sheet">style sheets</span> with a non-empty
<span>style sheet title</span> have the
<span>style sheet disabled flag</span> set to true or there are no such
<span title="style sheet">style sheets</span>.</p>
</li>
</ol>
<p>On setting the <code>selectedStyleSheetSet</code> attribute these steps
<em class="ct">must</em> be run:</p>
<ol>
<li><p>If the value is null terminate this set of steps.</p></li>
<li><p>Otherwise, <span>select a style sheet set</span> with as name the
value passed.</p></li>
</ol>
<p>From the DOM's perspective, all views have the same
<code>selectedStyleSheetSet</code>. If a user agent supports multiple
views with different selected alternative style sheets, then this
attribute (and the <code>StyleSheet</code> interface's
<code>disabled</code> attribute) <em class="ct">must</em> return and set
the value for the default view.</p>
<!-- XXX clean up once we get rid of views -->
<p>The
<dfn id="documentstyle-lastStyleSheetSet"><code>lastStyleSheetSet</code></dfn>
attribute <em class="ct">must</em> return the
<span>last style sheet set name</span>.</p>
<p class="note">This attribute is initially null.</p>
<p>The
<dfn id="documentstyle-preferredStyleSheetSet"><code>preferredStyleSheetSet</code></dfn>
attribute <em class="ct">must</em> return the
<span>preferred style sheet set name</span>.</p>