@@ -5,10 +5,10 @@ Shortname: css-conditional
5
5
Level : 3
6
6
Status : ED
7
7
Work Status : Testing
8
- ED : https://drafts.csswg.org/css3 -conditional/
8
+ ED : https://drafts.csswg.org/css -conditional-3 /
9
9
TR : https://www.w3.org/TR/css3-conditional/
10
10
Previous Version : https://www.w3.org/TR/2013/CR-css3-conditional-20130404/
11
- Test Suite : http://test.csswg.org/suites/css3 -conditional/nightly-unstable/
11
+ Test Suite : http://test.csswg.org/suites/css -conditional-3_dev /nightly-unstable/
12
12
Editor : L. David Baron, Mozilla https://www.mozilla.org/, https://dbaron.org/, w3cid 15393
13
13
Abstract : This module contains the features of CSS for conditional processing of parts of
14
14
style sheets, conditioned on capabilities of the processor or the
@@ -19,7 +19,6 @@ Abstract: This module contains the features of CSS for conditional processing of
19
19
conditional processing.
20
20
At Risk : The inclusion of @font-face rules and @keyframes rules as allowed within all of the @-rules in this specification is at risk, though only because of the relative rates of advancement of specifications. If this specification is able to advance faster than one or both of the specifications defining those rules, then the inclusion of those rules will move from this specification to the specification defining those rules.
21
21
At Risk : The addition of support for @-rules inside of conditional grouping rules is at risk; if interoperable implementations are not found, it may be removed to advance the other features in this specification to Proposed Recommendation.
22
- At Risk : The @supports rule is at risk; if interoperable implementations are not found, it may be removed to advance the other features in this specification to Proposed Recommendation.
23
22
Default Highlight : css
24
23
</pre>
25
24
@@ -28,12 +27,6 @@ spec:css-color-4; type:property; text:color
28
27
spec:html; type:element; text:link
29
28
</pre>
30
29
31
- <!--
32
- Things to go in level 4:
33
-
34
- * Create some way to put these new conditional things on an @import.
35
- * The @document rule (commented out, down below). -->
36
-
37
30
<h2 id="introduction">Introduction</h2>
38
31
39
32
<h3 id="context">Background</h3>
@@ -479,216 +472,6 @@ compound values; implementations must implement all parts of the value
479
472
in order to consider the declaration supported, either inside a style rule
480
473
or in the declaration condition of an ''@supports'' rule.
481
474
482
- <!--
483
- <h2 id="at-document">Document queries: the ''@document'' rule</h2>
484
-
485
- The <dfn>@document</dfn> rule is a conditional group
486
- rule whose condition depends on the
487
- <a href="#url-of-doc">URL of the document being styled</a> .
488
- This allows style sheets, particularly user style sheets, to have styles
489
- that only apply to a set of pages rather than to all pages using the
490
- style sheet.
491
-
492
- Issue: Given that this @-rule is intended primarily for user
493
- style sheets, what should this specification say about its use in author
494
- style sheets? Should it be forbidden? Should use instead be
495
- discouraged? Or should this specification remain neutral on the
496
- topic, since there are valid uses in author style sheets?
497
-
498
- <p id="url-of-doc"> The <dfn>URL of the document being styled</dfn> is
499
- the URI at which the document is located, excluding any fragment
500
- identifiers. (This means, for example, that HTTP redirects have been
501
- followed.) If the styles are being applied inside a complete document
502
- embedded into the presentation of another (e.g., [[HTML5]] 's <code
503
- class="html"> iframe</code> , <code class="html"> object</code> , or <code
504
- class="html"> img</code> elements), the relevant URI is that of the
505
- frame, not of its container. However, if content from other documents
506
- is mixed in via mechanisms that mix content from one document into
507
- another (e.g., [[SVG11]] 's <code> use</code> element), then the
508
- address of the container document is used.
509
-
510
- Note: In [[HTML5]] , this is the
511
- <a href="http://dev.w3.org/html5/spec/dom.html#documents">document's address</a>
512
- of a document in a
513
- <a href="http://dev.w3.org/html5/spec/browsers.html#browsing-context">browsing context</a> .
514
-
515
- <div class="issue"> What form of normalization is done on URLs and domains
516
- before matching? In particular, this specification needs to describe:
517
- <ul>
518
- <li> what form is used for the <a href="#url-of-doc">URL of the document
519
- being styled</a> (and what has been normalized in that form)
520
- <li> what normalization (if any) happens to the argument of each of the match
521
- functions before the comparison that they describe and
522
- <li> whether the
523
- comparison algorithm used is string comparison or some other URL
524
- comparison algorithm.</ul></div>
525
-
526
- The ''@document'' rule's condition is written as a
527
- comma-separated list of <dfn>URL matching functions</dfn> , and the
528
- condition evaluates to true whenever any one of those functions
529
- evaluates to true. The following URL matching functions are
530
- permitted:
531
-
532
- <dl>
533
- <dt> <dfn id="url-exact" title="url()|URL matching functions::exact"><url></dfn>
534
-
535
- <dd>
536
- The 'url()' function is the <dfn>exact url matching
537
- function</dfn> . It evaluates to true whenever the <a
538
- href="#url-of-doc"> URL of the document being styled</a> is exactly
539
- the URL given.
540
-
541
- Note: The 'url()' function, since it is a core syntax
542
- element in CSS, is allowed (subject to different character
543
- limitations and thus escaping requirements) to contain an unquoted
544
- value (in addition to the string values that are allowed as
545
- arguments for all four functions).
546
-
547
- <div class="example">
548
- For example, this rule:
549
- <pre>
550
- @document url("http://www.w3.org/Style/CSS/") {
551
- #summary { background: yellow; color: black}
552
- }
553
- </pre>
554
- styles the <code class="html"> summary</code> element on the page
555
- <code> http://www.w3.org/Style/CSS/</code> , but not on any other
556
- pages.
557
- </div>
558
-
559
-
560
- <dt> <dfn id="url-prefix" title="url-prefix()|URL matching functions::prefix">url-prefix(<string>)</dfn>
561
-
562
- <dd>
563
- The 'url-prefix()' function is the <dfn>url prefix
564
- matching function</dfn> . It evaluates to true whenever the
565
- <a href="#url-of-doc">URL of the document being styled</a>
566
- has the argument to the function as an
567
- initial substring (which is true when the two strings are equal).
568
- When the argument is the empty string, it evaluates to true for all
569
- documents.
570
- <div class="example">
571
- For example, this rule:
572
- <pre>
573
- @document url-prefix("http://www.w3.org/Style/CSS/") {
574
- #summary { background: yellow; color: black}
575
- }
576
- </pre>
577
- styles the <code class="html"> summary</code> element on the page
578
- <code> http://www.w3.org/Style/CSS/</code> and on the page
579
- <code> http://www.w3.org/Style/CSS/Test</code> , but it does not
580
- affect the page <code> http://www.w3.org/</code> or the page
581
- <code> http://www.example.com/Style/CSS/</code> .
582
- </div>
583
-
584
-
585
- <dt> <dfn id="url-domain" title="domain()|URL matching functions::domain">domain(<string>)</dfn>
586
-
587
- <dd>
588
- The 'domain()' function is the <dfn>domain
589
- matching function</dfn> . It evaluates to true whenever
590
- the <a href="#url-of-doc">URL of the document being styled</a>
591
- has a host subcomponent (as defined in [[!URI]] )
592
- and that host subcomponent is exactly the argument to the
593
- 'domain()' function or a final substring of the host
594
- component is a period (U+002E) immediately followed by the argument
595
- to the 'domain()' function.
596
- <div class="example">
597
- For example, this rule:
598
- <pre>
599
- @document domain("w3.org") {
600
- body { font-size: 16px ! important }
601
- }
602
- </pre>
603
- changes the font size of the body element for pages such as
604
- <code> http://www.w3.org/Style/CSS/</code> and
605
- <code> http://w3.org/Style/CSS/</code> and
606
- <code> http://lists.w3.org/Archives/Public/www-style/</code>
607
- but it does not affect the page
608
- <code> http://www.example.com/Style/CSS/</code> .
609
- </div>
610
-
611
-
612
- <dt> <dfn id="url-regexp" title="regexp()|URL matching functions::regular expression">regexp(<string>)</dfn>
613
-
614
- <dd>
615
- The contents of the <string> argument <strong> must</strong>
616
- match the JavaScript <code> Pattern</code> production
617
- ([[!ECMA-262-5.1]] , section 15.10.1). However,
618
- failing to do so is not a CSS syntax error and does not trigger any
619
- error handling for CSS syntax errors.
620
-
621
- The ''regexp()'' function evaluates to true whenever the string
622
- argument compiled as a JavaScript regular expression with the
623
- <code> global</code> , <code> ignoreCase</code> and
624
- <code> multiline</code> flags <em> disabled</em>
625
- (see [[!ECMA-262-5.1]] , sections 15.10.7.2 through 15.10.7.4)
626
- compiles successfully and the resulting regular expression matches
627
- the entirety of the
628
- <a href="#url-of-doc">URL of the document being styled</a> .
629
-
630
- Note: Note that regular expression must match the entire
631
- URL, not just a part of it.
632
-
633
- Note: Note that this definition intentionally matches the
634
- behavior of the <a
635
- href="http://dev.w3.org/html5/spec/common-input-element-attributes.html#attr-input-pattern"><code class="html"> pattern</code>
636
- attribute</a> on the <code class="html"> input</code> element
637
- in [[HTML5]] .
638
-
639
- <div class="example">
640
- For example, this rule:
641
- <pre>
642
- @document regexp("https://www.w3.org/TR/\\d{4}/[^/] *-CSS2-\\d{8}/") {
643
- body { font-size: 20px ! important }
644
- }
645
- </pre>
646
- changes the font size of the body element for pages such as
647
- <code> https://www.w3.org/TR/2011/PR-CSS2-20110412/</code> .
648
-
649
- Note: Note that the backslashes in the regular
650
- expression require CSS escaping as ''\\'' .
651
- </div>
652
-
653
-
654
- </dl>
655
-
656
- Implementations <strong> must</strong> treat any unknown URL matching
657
- functions as a syntax error, and thus ignore the ''@document'' rule.
658
- <span class="issue"> Should we instead have more complicated error
659
- handling rules to make forward-compatibility work differently, or is
660
- this rule the best solution for such future expansion anyway?</span>
661
-
662
- <div class="issue"> This syntax doesn't offer any ability to do negations,
663
- which has been requested in <a
664
- href="https://bugzilla.mozilla.org/show_bug.cgi?id=349813"> Mozilla bug
665
- 349813</a> . Use cases that people have wanted negations for
666
- include:
667
- <ul>
668
- <li> User style sheets that want a particular rule in general, but know
669
- that that rule does more harm than good on specific sites.
670
- <li> Authors who have a rule that they want to apply to most of their
671
- pages, but wish to make a few exceptions for.
672
- </ul>
673
- </div>
674
-
675
- This extends the lexical scanner in the
676
- <a href="https://www.w3.org/TR/CSS21/grammar.html">Grammar of CSS 2.1</a>
677
- ([[!CSS21]] , Appendix G) by adding:
678
- <pre> @{D}{O}{C}{U}{M}{E}{N}{T} {return DOCUMENT_SYM;}</pre>
679
- and the grammar by adding
680
- <pre>
681
- <dfn>document_rule</dfn>
682
- : DOCUMENT_SYM S+ <a>url_match_fn</a> ( "," S* <a>url_match_fn</a> )* <a>group_rule_body</a>
683
- ;
684
-
685
- <dfn>url_match_fn</dfn>
686
- : (URI | FUNCTION S* STRING S* ')' ) S*
687
- ;
688
- </pre>
689
- -->
690
-
691
-
692
475
<h2 id="apis">APIs</h2>
693
476
694
477
<h3 id='extentions-to-cssrule-interface'>
0 commit comments