Skip to content

Commit

Permalink
[css-conditional-3][css-conditional-4] Create a css-conditional-4 dra…
Browse files Browse the repository at this point in the history
…ft, and dispose of the features in css-conditional-3 marked for moving to level 4. (#3777)

There were two commented-out features in css-conditional-3 marked as
being deferred to level 4.  These are removed from the draft, but NOT
added in css-conditional-4, because:

- the `@import` `supports()` syntax is already in
  https://drafts.csswg.org/css-cascade-4/#at-ruledef-import

- the addition of an `@document` rule is probably no longer desirable
  given the discussion and removal in
  https://bugzilla.mozilla.org/show_bug.cgi?id=1035091 which was the
  only implementation.

Also correct a few bits of metadata in css-conditional-3.

This is being done as part of the resolution in
#3207 (comment)
  • Loading branch information
dbaron committed Mar 29, 2019
1 parent 550369f commit 3fc9245
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 218 deletions.
220 changes: 2 additions & 218 deletions css-conditional-3/Overview.bs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ Shortname: css-conditional
Level: 3
Status: ED
Work Status: Testing
ED: https://drafts.csswg.org/css3-conditional/
ED: https://drafts.csswg.org/css-conditional-3/
TR: https://www.w3.org/TR/css3-conditional/
Previous Version: https://www.w3.org/TR/2013/CR-css3-conditional-20130404/
Test Suite: http://test.csswg.org/suites/css3-conditional/nightly-unstable/
Test Suite: http://test.csswg.org/suites/css-conditional-3_dev/nightly-unstable/
Editor: L. David Baron, Mozilla https://www.mozilla.org/, https://dbaron.org/, w3cid 15393
Abstract: This module contains the features of CSS for conditional processing of parts of
style sheets, conditioned on capabilities of the processor or the
Expand All @@ -27,12 +27,6 @@ spec:css-color-4; type:property; text:color
spec:html; type:element; text:link
</pre>

<!--
Things to go in level 4:
* Create some way to put these new conditional things on an @import.
* The @document rule (commented out, down below). -->

<h2 id="introduction">Introduction</h2>

<h3 id="context">Background</h3>
Expand Down Expand Up @@ -478,216 +472,6 @@ compound values; implementations must implement all parts of the value
in order to consider the declaration supported, either inside a style rule
or in the declaration condition of an ''@supports'' rule.

<!--
<h2 id="at-document">Document queries: the ''@document'' rule</h2>
The <dfn>@document</dfn> rule is a conditional group
rule whose condition depends on the
<a href="#url-of-doc">URL of the document being styled</a>.
This allows style sheets, particularly user style sheets, to have styles
that only apply to a set of pages rather than to all pages using the
style sheet.
Issue: Given that this @-rule is intended primarily for user
style sheets, what should this specification say about its use in author
style sheets? Should it be forbidden? Should use instead be
discouraged? Or should this specification remain neutral on the
topic, since there are valid uses in author style sheets?
<p id="url-of-doc">The <dfn>URL of the document being styled</dfn> is
the URI at which the document is located, excluding any fragment
identifiers. (This means, for example, that HTTP redirects have been
followed.) If the styles are being applied inside a complete document
embedded into the presentation of another (e.g., [[HTML5]]&#39;s <code
class="html">iframe</code>, <code class="html">object</code>, or <code
class="html">img</code> elements), the relevant URI is that of the
frame, not of its container. However, if content from other documents
is mixed in via mechanisms that mix content from one document into
another (e.g., [[SVG11]]&#39;s <code>use</code> element), then the
address of the container document is used.
Note: In [[HTML5]], this is the
<a href="http://dev.w3.org/html5/spec/dom.html#documents">document's address</a>
of a document in a
<a href="http://dev.w3.org/html5/spec/browsers.html#browsing-context">browsing context</a>.
<div class="issue">What form of normalization is done on URLs and domains
before matching? In particular, this specification needs to describe:
<ul>
<li>what form is used for the <a href="#url-of-doc">URL of the document
being styled</a> (and what has been normalized in that form)
<li>what normalization (if any) happens to the argument of each of the match
functions before the comparison that they describe and
<li>whether the
comparison algorithm used is string comparison or some other URL
comparison algorithm.</ul></div>
The ''@document'' rule's condition is written as a
comma-separated list of <dfn>URL matching functions</dfn>, and the
condition evaluates to true whenever any one of those functions
evaluates to true. The following URL matching functions are
permitted:
<dl>
<dt><dfn id="url-exact" title="url()|URL matching functions::exact">&lt;url&gt;</dfn>
<dd>
The 'url()' function is the <dfn>exact url matching
function</dfn>. It evaluates to true whenever the <a
href="#url-of-doc">URL of the document being styled</a> is exactly
the URL given.
Note: The 'url()' function, since it is a core syntax
element in CSS, is allowed (subject to different character
limitations and thus escaping requirements) to contain an unquoted
value (in addition to the string values that are allowed as
arguments for all four functions).
<div class="example">
For example, this rule:
<pre>
@document url("http://www.w3.org/Style/CSS/") {
#summary { background: yellow; color: black}
}
</pre>
styles the <code class="html">summary</code> element on the page
<code>http://www.w3.org/Style/CSS/</code>, but not on any other
pages.
</div>
<dt><dfn id="url-prefix" title="url-prefix()|URL matching functions::prefix">url-prefix(&lt;string&gt;)</dfn>
<dd>
The 'url-prefix()' function is the <dfn>url prefix
matching function</dfn>. It evaluates to true whenever the
<a href="#url-of-doc">URL of the document being styled</a>
has the argument to the function as an
initial substring (which is true when the two strings are equal).
When the argument is the empty string, it evaluates to true for all
documents.
<div class="example">
For example, this rule:
<pre>
@document url-prefix("http://www.w3.org/Style/CSS/") {
#summary { background: yellow; color: black}
}
</pre>
styles the <code class="html">summary</code> element on the page
<code>http://www.w3.org/Style/CSS/</code> and on the page
<code>http://www.w3.org/Style/CSS/Test</code>, but it does not
affect the page <code>http://www.w3.org/</code> or the page
<code>http://www.example.com/Style/CSS/</code>.
</div>
<dt><dfn id="url-domain" title="domain()|URL matching functions::domain">domain(&lt;string&gt;)</dfn>
<dd>
The 'domain()' function is the <dfn>domain
matching function</dfn>. It evaluates to true whenever
the <a href="#url-of-doc">URL of the document being styled</a>
has a host subcomponent (as defined in [[!URI]])
and that host subcomponent is exactly the argument to the
'domain()' function or a final substring of the host
component is a period (U+002E) immediately followed by the argument
to the 'domain()' function.
<div class="example">
For example, this rule:
<pre>
@document domain("w3.org") {
body { font-size: 16px ! important }
}
</pre>
changes the font size of the body element for pages such as
<code>http://www.w3.org/Style/CSS/</code> and
<code>http://w3.org/Style/CSS/</code> and
<code>http://lists.w3.org/Archives/Public/www-style/</code>
but it does not affect the page
<code>http://www.example.com/Style/CSS/</code>.
</div>
<dt><dfn id="url-regexp" title="regexp()|URL matching functions::regular expression">regexp(&lt;string&gt;)</dfn>
<dd>
The contents of the &lt;string&gt; argument <strong>must</strong>
match the JavaScript <code>Pattern</code> production
([[!ECMA-262-5.1]], section 15.10.1). However,
failing to do so is not a CSS syntax error and does not trigger any
error handling for CSS syntax errors.
The ''regexp()'' function evaluates to true whenever the string
argument compiled as a JavaScript regular expression with the
<code>global</code>, <code>ignoreCase</code> and
<code>multiline</code> flags <em>disabled</em>
(see [[!ECMA-262-5.1]], sections 15.10.7.2 through 15.10.7.4)
compiles successfully and the resulting regular expression matches
the entirety of the
<a href="#url-of-doc">URL of the document being styled</a>.
Note: Note that regular expression must match the entire
URL, not just a part of it.
Note: Note that this definition intentionally matches the
behavior of the <a
href="http://dev.w3.org/html5/spec/common-input-element-attributes.html#attr-input-pattern"><code class="html">pattern</code>
attribute</a> on the <code class="html">input</code> element
in [[HTML5]].
<div class="example">
For example, this rule:
<pre>
@document regexp("https://www.w3.org/TR/\\d{4}/[^/]*-CSS2-\\d{8}/") {
body { font-size: 20px ! important }
}
</pre>
changes the font size of the body element for pages such as
<code>https://www.w3.org/TR/2011/PR-CSS2-20110412/</code>.
Note: Note that the backslashes in the regular
expression require CSS escaping as ''\\''.
</div>
</dl>
Implementations <strong>must</strong> treat any unknown URL matching
functions as a syntax error, and thus ignore the ''@document'' rule.
<span class="issue">Should we instead have more complicated error
handling rules to make forward-compatibility work differently, or is
this rule the best solution for such future expansion anyway?</span>
<div class="issue">This syntax doesn't offer any ability to do negations,
which has been requested in <a
href="https://bugzilla.mozilla.org/show_bug.cgi?id=349813">Mozilla bug
349813</a>. Use cases that people have wanted negations for
include:
<ul>
<li>User style sheets that want a particular rule in general, but know
that that rule does more harm than good on specific sites.
<li>Authors who have a rule that they want to apply to most of their
pages, but wish to make a few exceptions for.
</ul>
</div>
This extends the lexical scanner in the
<a href="https://www.w3.org/TR/CSS21/grammar.html">Grammar of CSS 2.1</a>
([[!CSS21]], Appendix G) by adding:
<pre>@{D}{O}{C}{U}{M}{E}{N}{T} {return DOCUMENT_SYM;}</pre>
and the grammar by adding
<pre>
<dfn>document_rule</dfn>
: DOCUMENT_SYM S+ <a>url_match_fn</a> ( "," S* <a>url_match_fn</a> )* <a>group_rule_body</a>
;
<dfn>url_match_fn</dfn>
: (URI | FUNCTION S* STRING S* ')' ) S*
;
</pre>
-->


<h2 id="apis">APIs</h2>

<h3 id='extentions-to-cssrule-interface'>
Expand Down
32 changes: 32 additions & 0 deletions css-conditional-4/Overview.bs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<pre class="metadata">
Title: CSS Conditional Rules Module Level 4
Group: csswg
Shortname: css-conditional
Level: 4
Status: ED
Work Status: Exploring
ED: https://drafts.csswg.org/css-conditional-4/
TR: https://www.w3.org/TR/css-conditional-4/
Test Suite: http://test.csswg.org/suites/css-conditional-4_dev/nightly-unstable/
Editor: L. David Baron, Mozilla https://www.mozilla.org/, https://dbaron.org/, w3cid 15393
Abstract: This module contains the features of CSS for conditional processing of parts of
style sheets, conditioned on capabilities of the processor or the
document the style sheet is being applied to. It includes and extends the
functionality of CSS level&nbsp;2 [[!CSS21]], which builds on CSS level&nbsp;1
[[CSS1]]. The main extensions compared to level&nbsp;2 are allowing nesting of
certain at-rules inside ''@media'', and the addition of the ''@supports'' rule for
conditional processing.
Default Highlight: css
</pre>

<h2 id="introduction">Introduction</h2>

This is currently an early draft of the things that are <em>new</em> in level 4.
The features in level 3 are still defined in [[css3-conditional]]
and have not yet been copied here.

Issue: In the future, copy the contents of [[css3-conditional]] into this document.


<h2 class=no-num id="acknowledgments">Acknowledgments</h2>

0 comments on commit 3fc9245

Please sign in to comment.