-
Notifications
You must be signed in to change notification settings - Fork 790
Expand file tree
/
Copy pathOverview.html
More file actions
executable file
·3165 lines (2492 loc) · 135 KB
/
Overview.html
File metadata and controls
executable file
·3165 lines (2492 loc) · 135 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">
<!--
ISSUES
- This list is not complete
- The specification is pretty vague and more importantly inconsistent about
liveness
-->
<html lang=en-US>
<head>
<title>Cascading Style Sheets Object Model (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 }
.proposal { padding:.5em; border:solid blue }
p.note { margin-left:2em; color:green; font-style:italic; font-weight:bold }
p.note::before { content:"Note: " }
.issue { padding:.5em; border:solid red }
.issue::before { content:"Issue: " }
em.ct { text-transform:lowercase; font-variant:small-caps; font-style:normal }
code { color:orangered }
code :link, code :visited { color:inherit }
.members dt { margin:.5em 0 }
.members dd p:first-child { margin-top:0 }
.members dd p:last-child
F888
{ margin-bottom:0 }
</style>
<link href="http://www.w3.org/StyleSheets/TR/base" rel=stylesheet>
<body class=draft>
<div class=head>
<h1 id=cssom>Cascading Style Sheets Object Model (<abbr>CSSOM</abbr>)</h1>
<h2 class="no-num no-toc" id="">Editor's draft <!--W3C Working Draft--> 6
June 2007</h2>
<dl>
<dt>This version:</dt>
<!--
<dd><a href="http://www.w3.org/TR/2007/WD-cssom-20070606/">http://www.w3.org/TR/2007/WD-cssom-20070606/</a></dd>
-->
<dd>...
<dt>Latest version:</dt>
<!--
<dd><a href="http://www.w3.org/TR/cssom/">http://www.w3.org/TR/cssom/</a></dd>
-->
<dd>...
<dt>Previous versions:
<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>The Cascading Style Sheets Object Model defines enables developers to
find style sheets associated with a <code>Document</code>, to query and
modify rules within a CSS style sheet (through an object model) and to
find out layout related information from objects within a
<code>Document</code>.
<h2 class="no-num no-toc" id=sotd>Status of this Document</h2>
<p class=issue>This document is in its very early stages. The intention is
that this specification will in due course supercede DOM Level 2 Style.
<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>
<li><a href="#conformance"><span class=secno>1.2. </span>Conformance
Requirements</a>
<ul class=toc>
<li><a href="#terminology"><span class=secno>1.2.1. </span>Terminology
and Conventions</a>
<li><a href="#dom-feature"><span class=secno>1.2.2. </span>DOM feature
strings</a>
</ul>
</ul>
<li><a href="#accessing"><span class=secno>2. </span>Accessing style
sheets through the DOM</a>
<ul class=toc>
<li><a href="#terminology0"><span class=secno>2.1.
</span>Terminology</a>
<li><a href="#the-linkstyle"><span class=secno>2.2. </span>The
<code>LinkStyle</code> Interface</a>
<ul class=toc>
<li><a href="#requirements"><span class=secno>2.2.1.
</span>Requirements on specifications</a>
<li><a href="#requirements0"><span class=secno>2.2.2.
</span>Requirements on SVG user agents</a>
<li><a href="#ltxml-stylesheet"><span class=secno>2.2.3.
</span><code><?xml-stylesheet?></code> processing instruction</a>
</ul>
<li><a href="#the-documentstyle"><span class=secno>2.3. </span>The
<code>DocumentStyle</code> Interface</a>
<li><a href="#the-stylesheetlist"><span class=secno>2.4. </span>The
<code>StyleSheetList</code> Interface</a>
<li><a href="#dynamically"><span class=secno>2.5. </span>Dynamically
adding new style sheets</a>
<ul class=toc>
<li><a href="#adding"><span class=secno>2.5.1. </span>Adding style
sheets</a>
<li><a href="#changing"><span class=secno>2.5.2. </span>Changing the
preferred style sheet set</a>
<li><a href="#examples"><span class=secno>2.5.3. </span>Examples</a>
</ul>
<li><a href="#interaction"><span class=secno>2.6. </span>Interaction
with the User Interface</a>
<ul class=toc>
<li><a href="#persisting"><span class=secno>2.6.1. </span>Persisting
the selected style sheet set</a>
</ul>
<li><a href="#forward"><span class=secno>2.7. </span>Forward
compatibility</a>
<li><a href="#the-stylesheet"><span class=secno>2.8. </span>The
<code>StyleSheet</code> Interface</a>
<li><a href="#the-medialist"><span class=secno>2.9. </span>The
<code>MediaList</code> Interface</a>
</ul>
<li><a href="#cascading"><span class=secno>3. </span>Cascading Style
Sheets APIs</a>
<ul class=toc>
<li><a href="#processing"><span class=secno>3.1. </span>Processing CSS
Statements</a>
<li><a href="#the-cssstylesheet"><span class=secno>3.2. </span>The
<code>CSSStyleSheet</code> Interface</a>
<li><a href="#the-cssrulelist"><span class=secno>3.3. </span>The
<code>CSSRuleList</code> Interface</a>
<li><a href="#interfaces"><span class=secno>3.4. </span>Interfaces for
CSS Statements</a>
<ul class=toc>
<li><a href="#the-cssrule"><span class=secno>3.4.1. </span>The
<code>CSSRule</code> Interface</a>
<ul class=toc>
<li><a href="#extensibility"><span class=secno>3.4.1.1.
</span>Extensibility</a>
</ul>
<li><a href="#the-cssstylerule"><span class=secno>3.4.2. </span>The
<code>CSSStyleRule</code> Interface</a>
<li><a href="#the-csscharsetrule"><span class=secno>3.4.3. </span>The
<code>CSSCharsetRule</code> Interface</a>
<li><a href="#the-cssimportrule"><span class=secno>3.4.4. </span>The
<code>CSSImportRule</code> Interface</a>
<li><a href="#the-cssmediarule"><span class=secno>3.4.5. </span>The
<code>CSSMediaRule</code> Interface</a>
<li><a href="#the-cssfontfacerule"><span class=secno>3.4.6. </span>The
<code>CSSFontFaceRule</code> Interface</a>
<li><a href="#the-csspagerule"><span class=secno>3.4.7. </span>The
<code>CSSPageRule</code> Interface</a>
<li><a href="#the-cssnamespacerule"><span class=secno>3.4.8.
</span>The <code>CSSNamespaceRule</code> Interface</a>
</ul>
<li><a href="#accessing0"><span class=secno>3.5. </span>Accessing
declaration blocks</a>
<ul class=toc>
<li><a href="#introduction0"><span class=secno>3.5.1.
</span>Introduction</a>
<li><a href="#the-elementcssinlinestyle"><span class=secno>3.5.2.
</span>The <code>ElementCSSInlineStyle</code> Interface</a>
<li><a href="#the-viewcss"><span class=secno>3.5.3. </span>The
<code>ViewCSS</code> Interface</a>
<li><a href="#the-documentcss"><span class=secno>3.5.4. </span>The
<code>DocumentCSS</code> Interface</a>
</ul>
<li><a href="#declaration"><span class=secno>3.6. </span>Declaration
blocks</a>
<ul class=toc>
<li><a href="#parsing"><span class=secno>3.6.1. </span>Parsing
property values</a>
<li><a href="#the-cssstyledeclaration"><span class=secno>3.6.2.
</span>The <code>CSSStyleDeclaration</code> Interface</a>
<li><a href="#css-properties"><span class=secno>3.6.3. </span>CSS
Properties</a>
<ul class=toc>
<li><a href="#the-css2properties"><span class=secno>3.6.3.1.
</span>The <code>CSS2Properties</code> Interface</a>
<li><a href="#the-cssstyledeclarationproperties"><span
class=secno>3.6.3.2. </span>The
<code>CSSStyleDeclarationProperties</code> Interface</a>
</ul>
</ul>
<li><a href="#css-value"><span class=secno>3.7. </span>CSS value related
interfaces</a>
<ul class=toc>
<li><a href="#the-cssbasevalue"><span class=secno>3.7.1. </span>The
<code>CSSBaseValue</code> Interface</a>
<li><a href="#the-csscolorvalue"><span class=secno>3.7.2. </span>The
<code>CSSColorValue</code> Interface</a>
<li><a href="#the-cssurlvalue"><span class=secno>3.7.3. </span>The
<code>CSSUrlValue</code> Interface</a>
<li><a href="#the-csslengthvalue"><span class=secno>3.7.4. </span>The
<code>CSSLengthValue</code> Interface</a>
<li><a href="#the-csspercentagelengthvalue"><span class=secno>3.7.5.
</span>The <code>CSSPercentageLengthValue</code> Interface</a>
</ul>
</ul>
<li><a href="#layout"><span class=secno>4. </span>Layout APIs</a>
<ul class=toc>
<li><a href="#the-windowlayout"><span class=secno>4.1. </span>The
<code>WindowLayout</code> Interface</a>
<ul class=toc>
<li><a href="#the-screen"><span class=secno>4.1.1. </span>The
<code>Screen</code> Interface</a>
</ul>
<li><a href="#the-documentlayout"><span class=secno>4.2. </span>The
<code>DocumentLayout</code> Interface</a>
<li><a href="#the-elementlayout"><span class=secno>4.3. </span>The
<code>ElementLayout</code> Interface</a>
<ul class=toc>
<li><a href="#the-getclientrects"><span class=secno>4.3.1. </span>The
<code>getClientRects()</code> and <code>getBoundingClientRect</code>
methods</a>
<ul class=toc>
<li><a href="#the-textrectanglelist"><span class=secno>4.3.1.1.
</span>The <code>TextRectangleList</code> Interface</a>
<li><a href="#the-textrectangle"><span class=secno>4.3.1.2.
</span>The <code>TextRectangle</code> Interface</a>
</ul>
<li><a href="#the-offset"><span class=secno>4.3.2. </span>The <code
title="">offset<var title="">*</var></code> attributes</a>
<li><a href="#the-scroll"><span class=secno>4.3.3. </span>The
<code>scroll<var>*</var></code> attributes</a>
<li><a href="#the-client"><span class=secno>4.3.4. </span>The
<code>client<var>*</var></code> attributes</a>
</ul>
</ul>
<li><a href="#canon"><span class=secno>5. </span>Canonicalization </a>
<ul class=toc>
<li><a href="#selectors"><span class=secno>5.1. </span>Selectors</a>
<li><a href="#media"><span class=secno>5.2. </span>Media queries</a>
<ul class=toc>
<li><a href="#examples0"><span class=secno>5.2.1. </span>Examples</a>
</ul>
<li><a href="#css-values"><span class=secno>5.3. </span>CSS Values</a>
<ul class=toc>
<li><a href="#examples1"><span class=secno>5.3.1. </span>Examples</a>
</ul>
</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><em>This section is non normative.</em>
<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 akward
for frequent use. This specification no longer contains those features.
<code>DOMImplementationCSS</code> has been removed as well.
<h3 id=conformance><span class=secno>1.2. </span>Conformance Requirements</h3>
<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 [<cite><a
href="#ref-rfc2119">RFC2119</a></cite>].
<p>The following conformance classes are defined (and considered) by this
specification:
<dl>
<dt><dfn id=conforming-implementation>conforming implementation</dfn>
<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 critera in
this specification.
<dt><dfn id="conforming document">conforming document</dfn>
<dd>A document that follows all <em class=ct>must</em>-, <em
class=ct>required</em>- and <em class=ct>shall</em>-level of critera in
this specification that apply to document authors.
<dt><dfn id=conforming-authoring-tool>conforming authoring tool</dfn>
<dd>One that produces conforming documents.
</dl>
<h4 id=terminology><span class=secno>1.2.1. </span>Terminology and
Conventions</h4>
<p>A <dfn id=color>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=color0>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>
<!--
<p>The term <dfn id="whitespace">whitespace</dfn> when used in this
specification refers to the U+0020 SPACE, U+0009 <control>, U+000A
<control>, U+000D <control> and U+000C <control> (if
applicable).</p>
-->
<p>The terms <dfn id=whitespace>whitespace</dfn> and <dfn
id=style-sheet>style sheet</dfn> are used as defined in the <cite>CSS 2.1
Specification</cite> [CSS21].
<p>A <dfn id=css-style-sheet>CSS style sheet</dfn> is a <a
href="#style-sheet">style sheet</a> that conforms to the CSS syntax rules.</p>
<!-- XXX: "Cascading Style Sheet style sheet" is just a joke... -->
<h4 id=dom-feature><span class=secno>1.2.2. </span>DOM feature strings</h4>
<!-- Thanks to Hixie. This is from HTML5. -->
<p>DOM Level 3 Core defines mechanisms for checking for interface support,
and for obtaining implementations of interfaces, using <a
href="http://www.w3.org/TR/DOM-Level-3-Core/core.html#DOMFeatures">feature
strings</a>. <a>[DOM3CORE]</a>
<p>A DOM application can use the <code>hasFeature(<var
title="">feature</var>, <var title="">version</var>)</code> method of the
<code>DOMImplementation</code> interface with parameter values "<code
title="">StyleSheets</code>" and "<code>3.0</code>" (respectively) to
determine whether or not "Accessing style sheets through the DOM" is
supported by the implementation. The feature string "<code
title="">CSS</code>" (with version string "<code>3.0</code>") can be used
to check if the implementation supports "Cascading Style Sheets APIs" and
"<code title="">Layout</code>" (with version string "<code>3.0</code>")
can be used to check if the implementation supports "Layout APIs". User
agents <em class=ct>should</em> respond with a <code>true</code> value
when the <code>hasFeature</code> method is queried with these values.
Authors are cautioned, however, that user agents returning
<code>true</code> might not be perfectly compliant, and that user agents
returning <code>false</code> might well have support for features in this
specification; in general, therefore, use of this method is discouraged.
<p>The values "<code title="">StyleSheets</code>", "<code
title="">CSS</code>" and "<code title="">Layout</code>" (all with version
"<code>3.0</code>") <em class=ct>should</em> also be supported in the
context of the <code>getFeature()</code> and <code>isSupported()</code>
methods, as defined by DOM Level 3 Core.
<p class=note>The interfaces defined in this specification are not always
supersets of the interfaces defined in DOM Level 2 Style; some features
that were formerly deprecated, poorly supported, rarely used or considered
unnecessary have been removed. Therefore it is not guarenteed that an
implementation that supports "<code title="">CSS</code>"
"<code>3.0</code>" also supports "<code title="">CSS</code>"
"<code>2.0</code>".
<h2 id=accessing><span class=secno>2. </span>Accessing style sheets through
the DOM</h2>
<p>Each style sheet is represented by a <code><a
href="#stylesheet">StyleSheet</a></code> object. These objects can be
accessed through the <code><a href="#linkstyle">LinkStyle</a></code>
interface implemented on individual <code>Node</code> objects or through
the <code><a href="#documentstyle">DocumentStyle</a></code> interface
implemented on the <code>Document</code> object. The <code><a
href="#documentstyle">DocumentStyle</a></code> interface also provides an
interface for enabling alternative style sheets and manipulating style
sheet sets.
<h3 id=terminology0><span class=secno>2.1. </span>Terminology</h3>
<p>Each style sheet can have a title. A <a href="#style-sheet">style
sheet</a> is said to <dfn id=style-sheet-title title="have a title">have a
title</dfn> if the <code>title</code> attribute on the <code><a
href="#stylesheet">StyleSheet</a></code> object is neither
<code>null</code> nor the empty string.
<p><dfn id=persistent title="persistent style sheet">Persistent style
sheets</dfn> are style sheets <a href="#style-sheet-title" title="have a
title">without a title</a>.
<p>One or more style sheets <a href="#style-sheet-title" title="have a
title">with the same title</a> (case-sensitive) form a <dfn id=style
title="style sheet set">style sheet set</dfn>.
<h3 id=the-linkstyle><span class=secno>2.2. </span>The <code><a
href="#linkstyle">LinkStyle</a></code> Interface</h3>
<p>Nodes within the DOM causing the association of a style sheet <em
class=ct>must</em> implement the <code><a
href="#linkstyle">LinkStyle</a></code> interface.
<pre class=idl>interface <dfn id=linkstyle>LinkStyle</dfn> {
readonly attribute <a href="#stylesheet">StyleSheet</a> <a href="#linkstyle-sheet" title=linkstyle-sheet>sheet</a>;
};</pre>
<dl class=members>
<dt><dfn id=linkstyle-sheet title=linkstyle-sheet><code>sheet</code></dfn>
of type <code><a href="#stylesheet">StyleSheet</a></code>, readonly
<dd>This attribute <em class=ct>must</em> be the <code><a
href="#stylesheet">StyleSheet</a></code> the node is referring to or
<code>null</code> if the node is not referring to a <code><a
href="#stylesheet">StyleSheet</a></code> (for example, all
<code>link</code> elements in HTML implement this interface, but not all
<code>link</code> elements are used for style sheets).
</dl>
<p class=note>Whether or not the node refers to a style sheet is defined by
the specification that defines the semantics of said node.
<h4 id=requirements><span class=secno>2.2.1. </span>Requirements on
specifications</h4>
<p>Specifications introducing new ways of associating style sheets through
the DOM <em class=ct>should</em> define which objects implement the
<code><a href="#linkstyle">LinkStyle</a></code> interface. In addition,
these specifications <em class=ct>should</em> define how these objects
affect the potentially associated <code><a
href="#stylesheet">StyleSheet</a></code> object (when <code
title=linkstyle-sheet><a href="#linkstyle-sheet">sheet</a></code> is
non-<code>null</code>).
<h4 id=requirements0><span class=secno>2.2.2. </span>Requirements on SVG
user agents</h4>
<!-- Not needed for HTML. -->
<p><em>This section applies to user agents supporting SVG.</em>
<p>SVG user agents <em class=ct>must</em> implement <code><a
href="#linkstyle">LinkStyle</a></code> on objects implementing the
<code>SVGStyleElement</code> interface.
<p class=issue>Should SVG define this instead?
<h4 id=ltxml-stylesheet><span class=secno>2.2.3.
</span><code><?xml-stylesheet?></code> processing instruction</h4>
<p>User agents supporting supporting <code><?xml-stylesheet?></code> <em
class=ct>must</em> implement the <code><a
href="#linkstyle">LinkStyle</a></code> on objects implementing
<code>ProcessingInstruction</code>.
<p>If the <code title="">target</code> DOM attribute of the
<code>ProcessingInstruction</code> is not <code>xml-stylesheet</code> or
if the <code>href</code> pseudo-attribute of the processing instruction
does not point to an external resource or does point to an external
resource that has not yet been downloaded the <code
title=linkstyle-sheet><a href="#linkstyle-sheet">sheet</a></code>
attribute <em class=ct>must</em> be <code>null</code>. Otherwise, if the
<code title="">target</code> DOM attribute is <code>xml-stylesheet</code>,
the resource has been downloaded and the determined type is a supported
style sheet language the <code title=linkstyle-sheet><a
href="#linkstyle-sheet">sheet</a></code> attribute <em class=ct>must</em>
be a <code><a href="#stylesheet">StyleSheet</a></code> object with the
members implemented as follows:
<dl>
<dt><code title=stylesheet-type><a href="#stylesheet-type">type</a></code>
<dd>This <em class=ct>must</em> be the determined type.
<dt><code title=stylesheet-href><a href="#stylesheet-href">href</a></code>
<dd>This <em class=ct>must</em> be the value of the <code>href</code>
pseudo-attribute.
<dt><code title=stylesheet-media><a
href="#stylesheet-media">media</a></code>
<dd>This <em class=ct>must</em> be the value of the <code>media</code>
pseudo-attribute.
<dt><code title=stylesheet-title><a
href="#stylesheet-title">title</a></code>
<dd>This <em class=ct>must</em> be the value of the <code>title</code>
pseudo-attribute.
</dl>
<h3 id=the-documentstyle><span class=secno>2.3. </span>The <code><a
href="#documentstyle">DocumentStyle</a></code> Interface</h3>
<p>Any object implementing the <code>Document</code> interface <em
class=ct>must</em> also implement the <code><a
href="#documentstyle">DocumentStyle</a></code> interface.</p>
<!-- https://bugzilla.mozilla.org/show_bug.cgi?id=200930 (FIXED) -->
<pre class=idl>interface <dfn id=documentstyle>DocumentStyle</dfn> {
readonly attribute <a href="#stylesheetlist">StyleSheetList</a> <a href="#documentstyle-stylesheets">styleSheets</a>;
attribute DOMString <a href="#documentstyle-selectedStyleSheetSet">selectedStyleSheetSet</a>;
readonly attribute DOMString <a href="#documentstyle-lastStyleSheetSet">lastStyleSheetSet</a>;
readonly attribute DOMString <a href="#documentstyle-preferredStyleSheetSet">preferredStyleSheetSet</a>;
readonly attribute DOMStringList <a href="#documentstyle-styleSheetSets">styleSheetSets</a>;
void <a href="#documentstyle-enablestylesheetsforset" title=documentstyle-enablestylesheetsforset>enableStylesheetsForSet</a>(in DOMString <var>name</var>);
};</pre>
<p>For this interface, the <code>DOMString</code> values <code>null</code>
and "the empty string" are distinct and <em class=ct>must</em> not be
considered equivalent.
<p>The members are defined as follows:
<dl class=members>
<dt><dfn id=documentstyle-stylesheets><code>styleSheets</code></dfn> of
type <code><a href="#stylesheetlist">StyleSheetList</a></code>
<dd>
<p>This attribute <em class=ct>must</em> be a <code><a
href="#stylesheetlist">StyleSheetList</a></code> object containing a
collection of all <code><a href="#linkstyle">LinkStyle</a></code>
objects with a non-<code>null</code> preceded by style sheets introduced
through HTTP headers.
</dl>
<p><code title=linkstyle-sheet><a href="#linkstyle-sheet">sheet</a></code>
attribute in document order
<dl>
<dt><dfn
id=documentstyle-selectedStyleSheetSet><code>selectedStyleSheetSet</code></dfn>
of type <code>DOMString</code>
<dd>
<p>This attribute indicates which <a href="#style">style sheet set</a> is
in use. This attribute is <span>live</span>; changing the <code
title=stylesheet-disabled><a
href="#stylesheet-disabled">disabled</a></code> attribute on style
sheets directly will change the value of this attribute.</p>
<p>If all the sheets that are enabled and <a
href="#style-sheet-title">have a title</a> have the <em>same</em> title
(by <span>case-sensitive</span> comparisons) then the value of this
attribute <em class=ct>must</em> be exactly equal to the title of the
first enabled style sheet with a title in the <code><a
href="#documentstyle-stylesheets">styleSheets</a></code> list.
Otherwise, if style sheets from different sets are enabled, then the
return value <em class=ct>must</em> be <code>null</code> (there is no
way to determine what the currently selected style sheet set is in those
conditions). Otherwise, either all style sheets that <a
href="#style-sheet-title">have a title</a> are disabled, or there are no
alternative style sheets, and <code><a
href="#documentstyle-selectedStyleSheetSet">selectedStyleSheetSet</a></code>
<em class=ct>must</em> return the empty string.</p>
<p>Setting this attribute to the <code>null</code> value <em
class=ct>must</em> have no effect.</p>
<p>Setting this attribute to a non-<code>null</code> value <em
class=ct>must</em> call <code
title=documentstyle-enablestylesheetsforset><a
href="#documentstyle-enablestylesheetsforset">enableStylesheetsForSet()</a></code>
with that value as the method's argument, and set <code><a
href="#documentstyle-lastStyleSheetSet">lastStyleSheetSet</a></code> to
that value.</p>
<p>From the DOM's perspective, all views have the same <code><a
href="#documentstyle-selectedStyleSheetSet">selectedStyleSheetSet</a></code>.
If a user agent supports multiple views with different selected
alternative style sheets, then this attribute (and the <code><a
href="#stylesheet">StyleSheet</a></code> interface's
<code>disabled</code> attribute) <em class=ct>must</em> return and set
the value for the default view.</p>
<dt><dfn
id=documentstyle-lastStyleSheetSet><code>lastStyleSheetSet</code></dfn>
of type <code>DOMString</code>, readonly
<dd>
<p>This attribute <em class=ct>must</em> initially have the value
<code>null</code>. Its value changes when the <code><a
href="#documentstyle-selectedStyleSheetSet">selectedStyleSheetSet</a></code>
attribute is set.</p>
<dt><dfn
id=documentstyle-preferredStyleSheetSet><code>preferredStyleSheetSet</code></dfn>
of type <code>DOMString</code>, readonly
<dd>
<p>This attribute <em class=ct>must</em> be the preferred style sheet set
as set by the author. It is determined from the order of style sheet
declarations and the <code>Default-Style</code> HTTP headers. If there
is no preferred style sheet set, this attribute <em class=ct>must</em>
be the empty string. The case of this attribute <em class=ct>must</em>
exactly match the case given by the author where the preferred style
sheet is specified or implied. This attribute <em class=ct>must</em>
never be <code>null</code>.</p>
<dt><dfn id=documentstyle-styleSheetSets><code>styleSheetSets</code></dfn>
of type <code>DOMStringList</code>, readonly
<dd>
<p>This <em class=ct>must</em> be a <span>live</span> list of the
currently available <span>style sheet sets</span>. This list is
constructed by enumerating all the style sheets for this document
available to the implementation, in the order they are listed in the
<code><a href="#documentstyle-stylesheets">styleSheets</a></code>
attribute, adding the title of each style sheet <a
href="#style-sheet-title" title="have a title">with a title</a> to the
list, avoiding duplicates by dropping titles that match
(<span>case-sensitively</span>) titles that have already been added to
the list.</p>
<dt><dfn id=documentstyle-enablestylesheetsforset
title=documentstyle-enablestylesheetsforset><code>enableStylesheetsForSet(<var
title="">name</var>)</code></dfn>, method
<dd>
<p>Invoking this method <em class=ct>must</em> change the <code
title=stylesheet-disabled><a
href="#stylesheet-disabled">disabled</a></code> attribute on each
<code><a href="#stylesheet">StyleSheet</a></code> object <a
href="#style-sheet-title" title="have a title">with a title</a> in the
<code><a href="#documentstyle-stylesheets">styleSheets</a></code>
attribute, so that all those whose title matches the <var
title="">name</var> argument are enabled, and all others are disabled.
Title matches <em class=ct>must</em> be <span>case-sensitive</span>.</p>
<p>Invoking this method with the empty string value <em
class=ct>must</em> disable all alternative and preferred style sheets
(but does not change the state of persistent style sheets).</p>
<p>Invoking this method with the <code>null</code> value <em
class=ct>must</em> have no effect.</p>
<!-- fact: -->
<p>Style sheets that do not <a href="#style-sheet-title">have a title</a>
are never affected by this method. This method does not change the
values of the <code><a
href="#documentstyle-lastStyleSheetSet">lastStyleSheetSet</a></code> or
<code><a
href="#documentstyle-preferredStyleSheetSet">preferredStyleSheetSet</a></code>
attributes.</p>
</dl>
<h3 id=the-stylesheetlist><span class=secno>2.4. </span>The <code><a
href="#stylesheetlist">StyleSheetList</a></code> Interface</h3>
<p>The object implementing this interface represents a live collection of
<code><a href="#stylesheet">StyleSheet</a></code> objects.
<p>In bindings that allow it, enumerating a <code><a
href="#stylesheetlist">StyleSheetList</a></code> object <em
class=ct>must</em> enumerate through the currently stored and accessible
items in the list the object is associated with. This ensures
<code>document.styleSheets[1].<var>x</var></code> is possible from
ECMAScript for example.
<pre class=idl>interface <dfn id=stylesheetlist>StyleSheetList</dfn> {
readonly attribute unsigned long <a href="#stylesheetlist-length" title=stylesheetlist-length>length</a>;
<a href="#stylesheet">StyleSheet</a> <a href="#stylesheetlist-item" title=stylesheetlist-item>item</a>(in unsigned long <var title="">index</var>);
};</pre>
<p>The members of the <code><a
href="#stylesheetlist">StyleSheetList</a></code> object are defined as
follows:
<dl class=members>
<dt><dfn id=stylesheetlist-length
title=stylesheetlist-length><code>length</code></dfn>, of type
<code>unsigned long</code>, readonly
<dd>This attribute <em class=ct>must</em> be the number of <code><a
href="#stylesheet">StyleSheet</a></code> objects currently in the list.
<dt><dfn id=stylesheetlist-item title=stylesheetlist-item><code>item(<var
title="">index</var>)</code></dfn>, method
<dd>When invoked, this method <em class=ct>must</em> return the <code><a
href="#stylesheet">StyleSheet</a></code> in the list given by
<var>index</var>. If <var>index</var> is less than zero then this method
<em class=ct>must</em> raise an <code>INDEX_SIZE_ERR</code> exception. If
<var>index</var> is greater than or equal to the number of style sheets
currently in the list this method <em class=ct>must</em> return
<code>null</code>.</dd>
<!-- Internet Explorer throws an exception for [largevalue] as well. -->
</dl>
<h3 id=dynamically><span class=secno>2.5. </span>Dynamically adding new
style sheets</h3>
<p>If new style sheets <a href="#style-sheet-title" title="have a
title">with titles</a> are added to the document, the user agent <em
class=ct>must</em> decide whether or not the style sheets should be
initially enabled or not. How this happens depends on the exact state of
the document at the time the style sheet is added, as follows.
<h4 id=adding><span class=secno>2.5.1. </span>Adding style sheets</h4>
<p>First, if the style sheet is a preferred style sheet (it <a
href="#style-sheet-title" title="have a title">has a title</a>, but is not
marked as alternative), and there is no current preferred style sheet (the
href="#documentstyle-preferredStyleSheetSet">preferredStyleSheetSet</a></code>
attribute is equal to the empty string) then the <code><a
href="#documentstyle-preferredStyleSheetSet">preferredStyleSheetSet</a></code>
attribute is set to the exact value of this style sheet's title. (This
changes the preferred style sheet set, which causes further changes
— see below.)
<p>Then, for all sheets, if any of the following is true, then the style
sheet <em class=ct>must</em> be enabled:
<ul>
<li>The style sheet has an empty title.
<li>The <code><a
href="#documentstyle-lastStyleSheetSet">lastStyleSheetSet</a></code> is
<code>null</code>, and the style sheet's title matches (by
<span>case-sensitive</span> match) the value of the <code><a
href="#documentstyle-preferredStyleSheetSet">preferredStyleSheetSet</a></code>
attribute.
<li>The style sheet's title matches (by <span>case-sensitive</span> match)
the value of the <code><a
href="#documentstyle-lastStyleSheetSet">lastStyleSheetSet</a></code>
attribute.
</ul>
<p>Otherwise, the style sheet <em class=ct>must</em> be disabled.
<h4 id=changing><span class=secno>2.5.2. </span>Changing the preferred
style sheet set</h4>
<p>The first time the <span>preferred style sheet</span> set is set, which
is either before any alternative style sheets are seen (e.g. using a
<code>Default-Style</code> HTTP header), or is the first time a titled,
non-altenrative style sheet is seen (in the absence of information to the
contrary, the first titled non-alternative sheet sets the name of the
preferred set), the <code><a
href="#documentstyle-preferredStyleSheetSet">preferredStyleSheetSet</a></code>
attribute's value <em class=ct>must</em> be set to the name of that
preferred style sheet set. This does not change the <code><a
href="#documentstyle-lastStyleSheetSet">lastStyleSheetSet</a></code>
attribute.
<p>If the user agent has the preferred style sheet set changed, for example
if it receives a <code>Default-Style</code> HTTP header after it receives
HTTP <code>Link</code> headers implying another preferred style sheet,
then the <code><a
href="#documentstyle-preferredStyleSheetSet">preferredStyleSheetSet</a></code>
attribute's value <em class=ct>must</em> be changed appropriately, and, if
the <code><a
href="#documentstyle-lastStyleSheetSet">lastStyleSheetSet</a></code> is
<code>null</code>, the <code
title=documentstyle-enablestylesheetsforset><a
href="#documentstyle-enablestylesheetsforset">enableStylesheetsForSet()</a></code>
method <em class=ct>must</em> be called with the new <code><a
href="#documentstyle-preferredStyleSheetSet">preferredStyleSheetSet</a></code>
value. (The <code><a
href="#documentstyle-lastStyleSheetSet">lastStyleSheetSet</a></code>
attribute is, again, not changed.)
<h4 id=examples><span class=secno>2.5.3. </span>Examples</h4>
<div class=example>
<p>Thus, in the following HTML snippet:</p>
<pre><link rel="alternate stylesheet" title="foo" href="a">
<link rel="alternate stylesheet" title="bar" href="b">
<script>
document.selectedStyleSheetSet = 'foo';
document.styleSheets[1].disabled = false;
</script>
<link rel="alternate stylesheet" title="foo" href="c">
<link rel="alternate stylesheet" title="bar" href="d"></pre>
<p>...the style sheets that end up enabled are style sheets "a", "b", and
"c", the <code><a
href="#documentstyle-selectedStyleSheetSet">selectedStyleSheetSet</a></code>
attribute would return null, <code><a
href="#documentstyle-lastStyleSheetSet">lastStyleSheetSet</a></code>
would return "foo", and <code><a
href="#documentstyle-preferredStyleSheetSet">preferredStyleSheetSet</a></code>
would return "".</p>
<p>Similarly, in the following HTML snippet:</p>
<pre><link rel="alternate stylesheet" title="foo" href="a">
<link rel="alternate stylesheet" title="bar" href="b">
<script>
var before = document.preferredStyleSheetSet;
document.styleSheets[1].disabled = false;
</script>
<link rel="stylesheet" title="foo" href="c">
<link rel="alternate stylesheet" title="bar" href="d">
<script>
var after = document.preferredStyleSheetSet;
</script></pre>
<p>...the "before" variable will be equal to the empty string, the "after"
variable will be equal to "foo", and style sheets "a" and "c" will be
enabled. This is the case even though the first script block sets style
sheet "b" to be enabled, because upon parsing the following
<code><link></code> element, the <code><a
href="#documentstyle-preferredStyleSheetSet">preferredStyleSheetSet</a></code>
is set and the <code title=documentstyle-enablestylesheetsforset><a
href="#documentstyle-enablestylesheetsforset">enableStylesheetsForSet()</a></code>
method is called (since <code><a
href="#documentstyle-selectedStyleSheetSet">selectedStyleSheetSet</a></code>
was never set explicitly, leaving <code><a
href="#documentstyle-lastStyleSheetSet">lastStyleSheetSet</a></code> at
<code>null</code> throughout), which changes which style sheets are
enabled and which are not.</p>
</div>
<h3 id=interaction><span class=secno>2.6. </span>Interaction with the User
Interface</h3>
<p>The user interface of Web browsers that support style sheets <em
class=ct>should</em> list the style sheet titles given in the <code><a
href="#documentstyle-styleSheetSets">styleSheetSets</a></code> list,
showing the <code><a
href="#documentstyle-selectedStyleSheetSet">selectedStyleSheetSet</a></code>
as the selected style sheet set, leaving none selected if it is
<code>null</code> or the empty string, and selecting an extra option
"Basic Page Style" (or similar) if it is the empty string and the <code><a
href="#documentstyle-preferredStyleSheetSet">preferredStyleSheetSet</a></code>
is the empty string as well.
<p>Selecting a style sheet from this list should set the <code><a
href="#documentstyle-selectedStyleSheetSet">selectedStyleSheetSet</a></code>
attribute. This (by definition) affects the <code><a
href="#documentstyle-lastStyleSheetSet">lastStyleSheetSet</a></code>
attribute.
<h4 id=persisting><span class=secno>2.6.1. </span>Persisting the selected
style sheet set</h4>
<p>If UAs persist the selected style sheet set, they should use the value
of the <code><a
href="#documentstyle-selectedStyleSheetSet">selectedStyleSheetSet</a></code>
attribute, or if that is <code>null</code>, the <code><a
href="#documentstyle-lastStyleSheetSet">lastStyleSheetSet</a></code>
attribute, when leaving the page (or at some other time) to determine the
set name to store. If that is <code>null</code> then the style sheet set
should not be persisted.
<p>When re-setting the style sheet set to the persisted value (which can
happen at any time, typically at the first time the style sheets are
needed for styling the document, after the <code><head></code> of
the document has been parsed, after any scripts that are not dependent on
computed style have executed), the style sheet set should be set by
setting the <code><a
href="#documentstyle-selectedStyleSheetSet">selectedStyleSheetSet</a></code>
attribute as if the user had selected the set manually.
<p class=note>This specification does not give any suggestions on how UAs
should decide to persist the style sheet set or whether or how to persist
the selected set across pages.
<h3 id=forward><span class=secno>2.7. </span>Forward compatibility</h3>
<p>Future versions of CSS may introduce ways of having alternative style
sheets declared at levels lower than the top level, i.e. embedded within
other style sheets. Implementations of this specification that also
support this proposed declaration of alternative style sheets are expected
to perform depth-first traversals of the <code><a
href="#documentstyle-stylesheets">styleSheets</a></code> list, not simply
enumerations of the <code><a
href="#documentstyle-stylesheets">styleSheets</a></code> list that only
contains the top level.
<p class=issue>Would that actually work?!
<h3 id=the-stylesheet><span class=secno>2.8. </span>The <code><a
href="#stylesheet">StyleSheet</a></code> Interface</h3>
<p>Each style sheet is represented by a <code><a
href="#stylesheet">StyleSheet</a></code> object.
<pre class=idl>interface <dfn id=stylesheet>StyleSheet</dfn> {
readonly attribute DOMString <a href="#stylesheet-type" title=stylesheet-type>type</a>;
attribute boolean <a href="#stylesheet-disabled" title=stylesheet-disabled>disabled</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-href" title=stylesheet-href>href</a>;
readonly attribute DOMString <a href="#stylesheet-title" title=stylesheet-title>title</a>;
readonly attribute <a href="#medialist">MediaList</a> <a href="#stylesheet-media" title=stylesheet-media>media</a>;
};</pre>
<dl class=members>
<dt><dfn id=stylesheet-type title=stylesheet-type><code>type</code></dfn>
of type <code>DOMString</code>, readonly
<dd>
<p>This attribute indicates the MIME type of the style sheet. It's set by
objects which cause a <code><a href="#stylesheet">StyleSheet</a></code>
object to be created, such as <code><a
href="#linkstyle">LinkStyle</a></code>.</p>
<dt><dfn id=stylesheet-disabled
title=stylesheet-disabled><code>disabled</code></dfn> of type
<code>boolean</code>
<dd>
<p>On getting, this attribute <em class=ct>must</em> be <code>true</code>
when the style sheet is disabled and <code>false</code> otherwise.</p>
<p>On setting, a value of <code>true</code> <em class=ct>must</em>
disable the style sheet and a value of <code>false</code> enable it.</p>
<dt><dfn id=stylesheet-ownernode
title=stylesheet-ownernode><code>ownerNode</code></dfn> of type
<code>Node</code>, readonly
<dd>This attribute <em class=ct>must</em> be the <code>Node</code> that
associates the style sheet with the document or <code>null</code>
otherwise. This <code>Node</code> has implemented the <code><a
href="#linkstyle">LinkStyle</a></code> interface.
<dt><dfn id=stylesheet-parentstylesheet
title=stylesheet-parentstylesheet><code>parentStyleSheet</code></dfn> of
type <code><a href="#stylesheet">StyleSheet</a></code>, readonly
<dd>This attribute <em class=ct>must</em> be the <code><a
href="#stylesheet">StyleSheet</a></code> object that caused the inclusion
of the current style sheet or <code>null</code> if there is no such
object.
<dt><dfn id=stylesheet-href title=stylesheet-href><code>href</code></dfn>
of type <code>DOMString</code>, readonly
<dd>This attribute <em class=ct>must</em> be an IRI pointing to the
location of the standalone style sheet or <code>null</code> otherwise