-
Notifications
You must be signed in to change notification settings - Fork 790
Expand file tree
/
Copy pathOverview.html
More file actions
executable file
·3558 lines (2713 loc) · 143 KB
/
Overview.html
File metadata and controls
executable file
·3558 lines (2713 loc) · 143 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 href="http://www.w3.org/StyleSheets/TR/W3C-ED" rel=stylesheet>
<body class=draft>
<div class=head>
<h1 id=cssom>CSSOM</h1>
<h2 class="no-num no-toc" id="">Editor's Draft 22 October 2009</h2>
<dl>
<dt>This Version:
<dd><a
href="http://www.w3.org/TR/2009/ED-cssom-20091022/">http://www.w3.org/TR/2009/ED-cssom-20091022/</a>
<dt>Latest Version:
<dd><a href="http://www.w3.org/TR/cssom/">http://www.w3.org/TR/cssom/</a>
<dt>Latest Editor's draft:
<dd><a
href="http://dev.w3.org/csswg/cssom/">http://dev.w3.org/csswg/cssom/</a>
<dt>Previous Version:
<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>
<dt>Editor:
<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>>
</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.
<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>
<!--begin-status-->
<p>This is a public copy of the editors' draft. It is provided for
discussion only and may change at any moment. It probably contains errors.
Its publication here does not imply endorsement of its contents by W3C.
<!--end-status-->
<h2 class="no-num no-toc" id=toc>Table of Contents</h2>
<!--begin-toc-->
<ul class=toc>
<li><a href="#introduction"><span class=secno>1 </span>Introduction</a>
<ul class=toc>
<li><a href="#history"><span class=secno>1.1 </span>History</a>
</ul>
<li><a href="#conformance"><span class=secno>2 </span>Conformance
Requirements</a>
<li><a href="#terminology"><span class=secno>3 </span>Terminology</a>
<li><a href="#media-queries"><span class=secno>4 </span>Media Queries</a>
<ul class=toc>
<li><a href="#parsing-media-queries"><span class=secno>4.1
</span>Parsing Media Queries</a>
<li><a href="#serializing-media-queries"><span class=secno>4.2
</span>Serializing Media Queries</a>
<ul class=toc>
<li><a href="#serializing-media-feature-values"><span
class=secno>4.2.1 </span>Serializing Media Feature Values</a>
</ul>
<li><a href="#comparing-media-queries"><span class=secno>4.3
</span>Comparing Media Queries</a>
<li><a href="#the-medialist-interface"><span class=secno>4.4 </span>The
<code title="">MediaList</code> Interface</a>
<li><a href="#creating-a-medialist-object"><span class=secno>4.5
</span>Creating a <code title="">MediaList</code> Object</a>
</ul>
<li><a href="#selectors"><span class=secno>5 </span>Selectors</a>
<li><a href="#style-sheets"><span class=secno>6 </span>Style Sheets</a>
<ul class=toc>
<li><a href="#style-sheet0"><span class=secno>6.1 </span>Style Sheet</a>
<ul class=toc>
<li><a href="#the-stylesheet-interface"><span class=secno>6.1.1
</span>The <code title="">StyleSheet</code> Interface</a>
</ul>
<li><a href="#style-sheet-collections"><span class=secno>6.2
</span>Style Sheet Collections</a>
<ul class=toc>
<li><a href="#the-http-default-style-header"><span class=secno>6.2.1
</span>The HTTP <code title="">Default-Style</code> Header</a>
<li><a href="#the-stylesheetlist-sequence"><span class=secno>6.2.2
</span>The <code title="">StyleSheetList</code> Sequence</a>
<li><a href="#the-documentstyle-interface"><span class=secno>6.2.3
</span>The <code title="">DocumentStyle</code> Interface</a>
<li><a href="#interaction-with-the-user-interface"><span
class=secno>6.2.4 </span>Interaction with the User Interface</a>
<ul class=toc>
<li><a href="#persisting-the-selected-style-sheet-set"><span
class=secno>6.2.4.1. </span>Persisting the selected style sheet
set</a>
</ul>
<li><a href="#examples"><span class=secno>6.2.5 </span>Examples</a>
</ul>
<li><a href="#style-sheet-association"><span class=secno>6.3
</span>Style Sheet Association</a>
<ul class=toc>
<li><a href="#the-linkstyle-interface"><span class=secno>6.3.1
</span>The <code title="">LinkStyle</code> Interface</a>
<li><a href="#requirements-on-specifications"><span class=secno>6.3.2
</span>Requirements on specifications</a>
<li><a href="#requirements-on-user-agents-implementing"><span
class=secno>6.3.3 </span>Requirements on User Agents Implementing the
<span title=""><code>xml-stylesheet</code> processing
instruction</span></a>
<li><a href="#requirements-on-user-agents-implementing0"><span
class=secno>6.3.4 </span>Requirements on User Agents Implementing the
HTTP <code title="">Link</code> Header</a>
</ul>
</ul>
<li><a href="#css-style-sheets"><span class=secno>7 </span>CSS Style
Sheets</a>
<ul class=toc>
<li><a href="#css-style-sheet"><span class=secno>7.1 </span>CSS Style
Sheet</a>
<ul class=toc>
<li><a href="#the-cssstylesheet-interface"><span class=secno>7.1.1
</span>The <code title="">CSSStyleSheet</code> Interface</a>
</ul>
<li><a href="#css-statements"><span class=secno>7.2 </span>CSS
Statements</a>
<ul class=toc>
<li><a href="#the-cssrulelist-interface"><span class=secno>7.2.1
</span>The <code title="">CSSRuleList</code> Interface</a>
<li><a href="#the-cssrule-interface"><span class=secno>7.2.2
</span>The <code title="">CSSRule</code> Interface</a>
<ul class=toc>
<li><a href="#extensibility"><span class=secno>7.2.2.1.
</span>Extensibility</a>
</ul>
<li><a href="#the-cssstylerule-interface"><span class=secno>7.2.3
</span>The <code title="">CSSStyleRule</code> Interface</a>
<li><a href="#the-cssimportrule-interface"><span class=secno>7.2.4
</span>The <code title="">CSSImportRule</code> Interface</a>
<li><a href="#the-cssmediarule-interface"><span class=secno>7.2.5
</span>The <code title="">CSSMediaRule</code> Interface</a>
<li><a href="#the-cssfontfacerule-interface"><span class=secno>7.2.6
</span>The <code title="">CSSFontFaceRule</code> Interface</a>
<li><a href="#the-csspagerule-interface"><span class=secno>7.2.7
</span>The <code title="">CSSPageRule</code> Interface</a>
<li><a href="#the-cssnamespacerule-interface"><span class=secno>7.2.8
</span>The <code title="">CSSNamespaceRule</code> Interface</a>
</ul>
<li><a href="#css-declaration-blocks"><span class=secno>7.3 </span>CSS
Declaration Blocks</a>
<ul class=toc>
<li><a href="#examples0"><span class=secno>7.3.1 </span>Examples</a>
<li><a href="#the-cssstyledeclaration-interface"><span
class=secno>7.3.2 </span>The <code
title="">CSSStyleDeclaration</code> Interface</a>
</ul>
</ul>
<li><a href="#css-property-value-apis"><span class=secno>8 </span>CSS
Property Value APIs</a>
<ul class=toc>
<li><a href="#the-elementcssinlinestyle-interface"><span class=secno>8.1
</span>The <code>ElementCSSInlineStyle</code> Interface</a>
<li><a href="#the-viewcss-interface"><span class=secno>8.2 </span>The
<code title="">ViewCSS</code> Interface</a>
</ul>
<li class=no-num><a href="#iana-considerations">IANA Considerations</a>
<ul class=toc>
<li class=no-num><a href="#default-style-"><code>Default-Style</code>
</a>
</ul>
<li class=no-num><a href="#references">References</a>
<li class=no-num><a href="#acknowledgements">Acknowledgements</a>
</ul>
<!--end-toc-->
<h2 id=introduction><span class=secno>1 </span>Introduction</h2>
<p class=issue>...
<h3 id=history><span class=secno>1.1 </span>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.
<h2 id=conformance><span class=secno>2 </span>Conformance Requirements</h2>
<p>Everything in this specification is normative except for diagrams,
examples, notes and sections marked non-normative.
<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><span class=secno>3 </span>Terminology</h2>
<p class=XXX> <dfn id=resolve-a-url>resolve a URL</dfn>, <dfn
id=case-sensitive>case-sensitive</dfn>, <dfn
id=ascii-case-insensitive>ASCII case-insensitive</dfn>, <dfn
id=url>URL</dfn>, <dfn id=content-type-metadata>Content-Type
metadata</dfn>, <dfn id=supported-styling-language>supported styling
language</dfn>, <dfn
id=xml-stylesheet-processing-instruction><code>xml-stylesheet</code>
processing instruction</dfn>, <dfn id=fetch>fetch</dfn>, ...
<p>A <dfn id=color-component-integer>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>A <dfn id=color-component-separator>color component separator</dfn> is a
literal U+002C COMMA followed by a U+0020 SPACE.
<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>The term <dfn id=whitespace>whitespace</dfn> is used as defined in CSS.
<!--XXX <a href="#ref-css">[CSS]</a>-->
<h2 id=media-queries><span class=secno>4 </span>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 id=parsing-media-queries><span class=secno>4.1 </span>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 <a
href="#parse-a-list-of-media-queries">parse a list of media queries</a>
steps and return null if more than one media query is returned or a media
query if a single media query is returned.
<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>".
<h3 id=serializing-media-queries><span class=secno>4.2 </span>Serializing
Media Queries</h3>
<p>To <dfn id=serialize-a-media-query>serialize a media query</dfn> run
these steps:
<ol>
<li>
<p>Let <var title="">s</var> be the empty string.
<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>.
<li>
<p>Let <var title="">type</var> be the media query, <span>converted to
ASCII lowercase</span>.
<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.
<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>.
<li>
<p>Sort the media features in lexicographical order.
<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>.
<li>
<p>If a value is given append a U+003A COLON (:) character, followed by
a U+0020 SPACE character, followed by the <a
href="#serialize-a-media-feature-value
5E37
" title="serialize a media
feature value">serialized media feature value</a>, to <var>s</var>.</p>
<li>
<p>Append a U+0029 RIGHT PARENTHESIS character to <var>s</var>.
<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>
<p>Return <var>s</var>.
</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:
<ol>
<li>
<p>Let <var>s</var> be the empty string.
<li>
<p>If the list is empty return <var>s</var> and terminate this algorithm.
<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>.
<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>.
</ol>
<li>
<p>Return <var>s</var>.
</ol>
<h4 id=serializing-media-feature-values><span class=secno>4.2.1
</span>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>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:
<table>
<tbody>
<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.
<h3 id=comparing-media-queries><span class=secno>4.3 </span>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 <a
href="#case-sensitive">case-sensitive</a> match and false if they are not.
<h3 id=the-medialist-interface><span class=secno>4.4 </span>The <code
title="">MediaList</code> Interface</h3>
<p>An object that implements the <code><a
href="#medialist">MediaList</a></code> interface has an associated <dfn
id=list-of-media-queries>list of media queries</dfn>.</p>
<!-- http://dev.w3.org/2006/webapi/WebIDL/#idl-indexed-properties -->
<pre class=idl>interface <dfn id=medialist>MediaList</dfn> {
stringifier attribute DOMString <a href="#medialist-mediatext" title=medialist-mediatext>mediaText</a>;
readonly attribute unsigned long <a href="#medialist-length" title=medialist-length>length</a>;
getter DOMString <a href="#medialist-item" title=medialist-item>item</a>(unsigned long <var title="">index</var>);
void <a href="#medialist-appendmedium" title=medialist-appendmedium>appendMedium</a>(DOMString <var title="">medium</var>)
void <a href="#medialist-deletemedium" title=medialist-deletemedium>deleteMedium</a>(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 <a
href="#serialize-a-list-of-media-queries" title="serialize a list of media
queries">serialization</a> of the <span>list of media qeuries</span>.
<p>On setting the <code title=medialist-mediatext><a
href="#medialist-mediatext">mediaText</a></code> attribute these steps <em
class=ct>must</em> be run:
<ol>
<li>
<p>Empty the <a href="#list-of-media-queries">list of media queries</a>.
<li>
<p>If the given value is the empty string terminate these steps.
<li>
<p>Append all the media queries as a result of <a
href="#parse-a-list-of-media-queries" title="parse a list of media
queries">parsing</a> the given value to the <a
href="#list-of-media-queries">list of media queries</a>.
</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 <a
href="#list-of-media-queries">list of media queries</a>.
<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:
<ol>
<li>
<p>Let <var title="">m</var> be the result of <a
href="#parse-a-media-query" title="parse a media query">parsing</a> the
given value.
<li>
<p>If <var title="">m</var> is null terminate these steps.
<li>
<p>If <a href="#compare-media-queries" title="compare media
queries">comparing</a> <var title="">m</var> with any of the media
queries in the <a href="#list-of-media-queries">list of media
queries</a> returns true terminate these steps.
<li>
<p>Append <var title="">m</var> to the <a
href="#list-of-media-queries">list of media queries</a>.
</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:
<ol>
<li>
<p>Let <var title="">m</var> be the result of <a
href="#parse-a-media-query" title="parse a media query">parsing</a> the
given value.
<li>
<p>If <var title="">m</var> is null terminate these steps.
<li>
<p>Remove any media query from the <a href="#list-of-media-queries">list
of media queries</a> for which <a href="#compare-media-queries"
title="compare media queries">comparing</a> the media query with <var
title="">m</var> returns true.
</ol>
<h3 id=creating-a-medialist-object><span class=secno>4.5 </span>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:
<ol>
<li>
<p>Create a new <code><a href="#medialist">MediaList</a></code> object.
<li>
<p>Set its <a href="#medialist-mediatext"
title=medialist-mediatext>mediaText</a> attribute to <var
title="">s</var>.
<li>
<p>Return the newly created <code><a
href="#medialist">MediaList</a></code> object.
</ol>
<h2 id=selectors><span class=secno>5 </span>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 <a href="#whitespace">whitespace</a>.
<li>
<p>Replace one or more consecutive <a href="#whitespace">whitespace</a>
characters with a single U+0020 SPACE character.
<li>
<p>Make sure combinators other than the descendant combinator are
preceded and followed by a single U+0020 SPACE character (and not more).
<li>
<p>Make sure each U+002C COMMA (,) character is followed by a single
U+0020 SPACE character (and not more).
<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>.
</li>
<!-- XXX namespace refs? -->
<li>
<p>Remove any <span title="universal selector">universal selectors</span>
that can be omitted.
<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.
</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.
2258
</li>
<!-- XXX or does this happen during parsing -->
</ul>
<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>.</p>
<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 <a href="#whitespace">whitespace</a> around the
argument, and serialize the value as follows:</p>
<dl>
<dt>If the pseudo-class is <code title="">:lang()</code>
<dd>
<p>The literal value.
<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>
<dd>
<ol>
<li>
<p>If the value is odd let the value be "<code title="">2n+1</code>".
<li>
<p>If the value is even let the value be "<code title="">2n</code>".
<li>
<p>If <var title="">a</var> is zero let the value be <var
title="">b</var> serialized as string.
</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>".
<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.
</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>".
</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.
</li>
<!-- XXX serialize integer -->
</ol>
<dt>If the pseudo-class is <code title="">:not()</code>
<dd>
<p>The result of serializing the value using the rules for <a
href="#serialize-a-group-of-selectors" title="serialize a group of
selectors">serializing a group of selectors</a>.
<dt>Any other pseudo-class
<dd>
<p class=XXX>Hopefully Selectors Level 4 defines serialization itself.
</dl>
</ol>
<h2 id=style-sheets><span class=secno>6 </span>Style Sheets</h2>
<h3 id=style-sheet0><span class=secno>6.1 </span>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 <a
href="#style-sheet">style sheet</a> is a <code><a
href="#stylesheet">StyleSheet</a></code> object. A <a
href="#style-sheet">style sheet</a> has a number of associated properties:
<dl>
<dt><dfn id=style-sheet-type>style sheet type</dfn>
<dd>
<p>The <a href="#content-type-metadata">Content-Type metadata</a> of the
<a href="#style-sheet">style sheet</a>.
<dt><dfn id=style-sheet-location>style sheet location</dfn>
<dd>
<p>The <a href="#url">URL</a> of the <a href="#style-sheet">style
sheet</a> or null if the <a href="#style-sheet">style sheet</a> was
embedded.
<dt><dfn id=style-sheet-node>style sheet node</dfn>
<dd>
<p>The DOM node associated with the <a href="#style-sheet">style
sheet</a> or null if there is no associated DOM node.
<dt><dfn id=style-sheet-parent>style sheet parent</dfn>
<dd>
<p>The <a href="#style-sheet">style sheet</a> that is the parent of the
<a href="#style-sheet">style sheet</a>.
<dt><dfn id=style-sheet-media>style sheet media</dfn>
<dd>
<p>The <code><a href="#medialist">MediaList</a></code> object associated
with the <a href="#style-sheet">style sheet</a>.</p>
<p>If this property is set to a string run the <a
href="#create-a-medialist-object">create a <code>MediaList</code>
object</a> steps for that string and associate the returned object with
the <a href="#style-sheet">style sheet</a>.</p>
<dt><dfn id=style-sheet-title>style sheet title</dfn>
<dd>
<p>The title of the <a href="#style-sheet">style sheet</a>. It is said to
be empty if the title is the empty string.</p>
<div class=example>
<p>In these examples the <a href="#style-sheet-title">style sheet
title</a> ends up being empty:</p>
<pre><style title=""> body { background:papayawhip } </style></pre>
<pre><style> body { background:orange } </style></pre>
</div>
<dt><dfn id=style-sheet-alternate-flag>style sheet alternate flag</dfn>
<dd>
<p>Either true or false. False by default.</p>
<div class=example>
<p>The following <a href="#style-sheet" title="style sheet">style
sheets</a> have their <a href="#style-sheet-alternate-flag">style sheet
alternate flag</a> 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>
<dt><dfn id=style-sheet-disabled-flag>style sheet disabled flag</dfn>
<dd>
<p>Either true or false. False by default.</p>
<p class=note>Even when false it does not necessarily mean that the <a
href="#style-sheet">style sheet</a> is actually rendered.</p>
</dl>
<p>When you are to <a href="#create-a-style-sheet">create a style sheet</a>
the above properties are to be set to their proper values.</p>
<!-- same-origin restrictions -->
<h4 id=the-stylesheet-interface><span class=secno>6.1.1 </span>The <code
title="">StyleSheet</code> Interface</h4>
<p>In the DOM a <a href="#style-sheet">style sheet</a> is represented by an
object that implements the <code><a
href="#stylesheet">StyleSheet</a></code> interface.
<pre class=idl>interface <dfn id=stylesheet>StyleSheet</dfn> {
readonly attribute DOMString <a href="#stylesheet-type" title=stylesheet-type>type</a>;
readonly attribute DOMString <a href="#stylesheet-href" title=stylesheet-href>href</a>;
readonly attribute Node <a href="#stylesheet-ownernode" title=stylesheet-ownernode>ownerNode</a>;
readonly attribute <a href="#stylesheet">StyleSheet</a> <a href="#stylesheet-parentstylesheet" title=stylesheet-parentstylesheet>parentStyleSheet</a>;
readonly attribute DOMString <a href="#stylesheet-title" title=stylesheet-title>title</a>;
[PutForwards=mediaText] readonly attribute <a href="#medialist">MediaList</a> <a href="#stylesheet-media" title=stylesheet-media>media</a>;
attribute boolean <a href="#stylesheet-disabled" title=stylesheet-disabled>disabled</a>;
};</pre>
<p>The <dfn id=stylesheet-type
title=stylesheet-type><code>type</code></dfn> attribute <em
class=ct>must</em> return the <a href="#style-sheet-type">style sheet
type</a>.
<p>The <dfn id=stylesheet-href
title=stylesheet-href><code>href</code></dfn> attribute <em
class=ct>must</em> return the <a href="#style-sheet-location">style sheet
location</a>.
<p>The <dfn id=stylesheet-ownernode
title=stylesheet-ownernode><code>ownerNode</code></dfn> attribute <em
class=ct>must</em> return the <a href="#style-sheet-node">style sheet
node</a>.
<p>The <dfn id=stylesheet-parentstylesheet
title=stylesheet-parentstylesheet><code>parentStyleSheet</code></dfn>
attribute <em class=ct>must</em> return the <a
href="#style-sheet-parent">style sheet parent</a>.
<p>The <dfn id=stylesheet-title
title=stylesheet-title><code>title</code></dfn> attribute <em
class=ct>must</em> return the <a href="#style-sheet-title">style sheet
title</a>.
<p>The <dfn id=stylesheet-media
title=stylesheet-media><code>media</code></dfn> attribute <em
class=ct>must</em> return the <a href="#style-sheet-media">style sheet
media</a>.
<p>The <dfn id=stylesheet-disabled
title=stylesheet-disabled><code>disabled</code></dfn> attribute <em
class=ct>must</em>, on getting, return the <a
href="#style-sheet-disabled-flag">style sheet disabled flag</a>. On
setting, it <em class=ct>must</em> set the <a
href="#style-sheet-disabled-flag">style sheet disabled flag</a> to the
given value.
<h3 id=style-sheet-collections><span class=secno>6.2 </span>Style Sheet
Collections</h3>
<p>Below various new concepts are defined that are associated with each
<code>Document</code> object.
<p>Each <code>Document</code> has an associated list of zero or more <a
href="#style-sheet" title="style sheet">style sheets</a>, named the <dfn
id=document-style-sheets>document style sheets</dfn>. This is an ordered
list that contains all <a href="#style-sheet" title="style sheet">style
sheets</a> associated with the <code>Document</code>, in <span>tree
order</span>, with <a href="#style-sheet" title="style sheet">style
sheets</a> created from HTTP <code title=http-link>Link</code> headers
first, if any, in header order.
<p>To <dfn id=create-a-style-sheet>create a style sheet</dfn>, run these
steps:
<ol>
<li>
<p>Create a new <a href="#style-sheet">style sheet</a> object and set its
properties as specified.
<li>
<p>Then run the <a href="#add-a-style-sheet">add a style sheet</a> steps
for the newly created <a href="#style-sheet">style sheet</a>.
</ol>
<p>To <dfn id=add-a-style-sheet>add a style sheet</dfn>, run these steps:
<ol>
<li>
<p>Add the <a href="#style-sheet">style sheet</a> to the list of <a
href="#document-style-sheets">document style sheets</a> at the