Skip to content

Commit f12290d

Browse files
committed
Add the new CSSRule constants, the CSSSupportsRule interface, and the supportsProperty() function.
1 parent 541f1bb commit f12290d

2 files changed

Lines changed: 224 additions & 49 deletions

File tree

css3-conditional/Overview.html

Lines changed: 149 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@
1717

1818
<h1>CSS Conditional Rules Module Level 3</h1>
1919

20-
<h2 class="no-num no-toc" id=longstatus-date>Editor's Draft 17 July 2012</h2>
20+
<h2 class="no-num no-toc" id=longstatus-date>Editor's Draft 31 July 2012</h2>
2121

2222
<dl>
2323
<dt>This version:
2424

25-
<dd><a href="http://www.w3.org/TR/2012/ED-css3-conditional-20120717/">
26-
http://www.w3.org/TR/2012/ED-css3-conditional-20120717/</a>
25+
<dd><a href="http://www.w3.org/TR/2012/ED-css3-conditional-20120731/">
26+
http://www.w3.org/TR/2012/ED-css3-conditional-20120731/</a>
2727

2828
<dt>Latest version:
2929

@@ -201,6 +201,16 @@ <h2 class="no-num no-toc" id=contents>Table of contents</h2>
201201
the ‘<code class=css>@document</code>’ rule</a>
202202

203203
<li><a href="#apis"><span class=secno>8. </span>APIs</a>
204+
<ul class=toc>
205+
<li><a href="#extentions-to-cssrule-interface"><span class=secno>8.1.
206+
</span> Extensions to the <code>CSSRule</code> interface</a>
207+
208+
<li><a href="#the-csssupportsrule-interface"><span class=secno>8.2.
209+
</span> The <code>CSSSupportsRule</code> interface</a>
210+
211+
<li><a href="#supports-property-api"><span class=secno>8.3.
212+
</span>supportsProperty() function</a>
213+
</ul>
204214

205215
<li><a href="#conformance"><span class=secno>9. </span>Conformance</a>
206216
<ul class=toc>
@@ -428,8 +438,8 @@ <h2 id=contents-of><span class=secno>3. </span>Contents of conditional
428438
rel=biblioentry>[CSS3-FONTS]<!--{{!CSS3-FONTS}}--></a>,
429439
<code>keyframes_rule</code> defined in <a href="#CSS3-ANIMATIONS"
430440
rel=biblioentry>[CSS3-ANIMATIONS]<!--{{!CSS3-ANIMATIONS}}--></a>, and
431-
<code>media</code>, <code>supports_rule</code> and
432-
<code>document_rule</code> defined in this specification.
441+
<code>media</code>, <a href="#supportsrule"><code>supports_rule</code></a>
442+
and <code>document_rule</code> defined in this specification.
433443

434444
<p>In general, future CSS specifications that add new @-rules that are not
435445
forbidden to occur after some other types of rules should modify this
@@ -549,32 +559,38 @@ <h2 id=at-supports><span class=secno>6. </span>Feature queries: the ‘<a
549559

550560
<p>and the grammar by adding
551561

552-
<pre>supports_rule
562+
<pre><dfn id=supportsrule>supports_rule</dfn>
553563
: SUPPORTS_SYM S+ supports_condition group_rule_body
554564
;
555565

556-
supports_condition
566+
<dfn
567+
id=supportscondition>supports_condition</dfn>
557568
: supports_negation | supports_conjunction | supports_disjunction |
558569
supports_condition_in_parens
559570
;
560571

561-
supports_condition_in_parens
572+
<dfn
573+
id=supportsconditioninparens>supports_condition_in_parens</dfn>
562574
: ( '(' S* supports_condition ')' S* ) | supports_declaration_condition
563575
;
564576

565-
supports_negation
577+
<dfn
578+
id=supportsnegation>supports_negation</dfn>
566579
: 'not' S* supports_condition_in_parens
567580
;
568581

569-
supports_conjunction
582+
<dfn
583+
id=supportsconjunction>supports_conjunction</dfn>
570584
: supports_condition_in_parens ( 'and' S* supports_condition_in_parens )+
571585
;
572586

573-
supports_disjunction
587+
<dfn
588+
id=supportsdisjunction>supports_disjunction</dfn>
574589
: supports_condition_in_parens ( 'or' S* supports_condition_in_parens )+
575590
;
576591

577-
supports_declaration_condition
592+
<dfn
593+
id=supportsdeclarationcondition>supports_declaration_condition</dfn>
578594
: '(' S* core_declaration ')' S*
579595
;</pre>
580596

@@ -613,26 +629,28 @@ <h2 id=at-supports><span class=secno>6. </span>Feature queries: the ‘<a
613629

614630
<dt>supports_condition_in_parens
615631

616-
<dd> The result is the result of the single
617-
<code>supports_condition</code> or
618-
<code>supports_declaration_condition</code> child term.
632+
<dd> The result is the result of the single <a
633+
href="#supportscondition"><code>supports_condition</code></a> or <a
634+
href="#supportsdeclarationcondition"><code>supports_declaration_condition</code></a>
635+
child term.
619636

620637
<dt>supports_negation
621638

622-
<dd> The result is the <em>negation</em> of the result of the
623-
<code>supports_condition_in_parens</code> child term.
639+
<dd> The result is the <em>negation</em> of the result of the <a
640+
href="#supportsconditioninparens"><code>supports_condition_in_parens</code></a>
641+
child term.
624642

625643
<dt>supports_conjunction
626644

627-
<dd> The result is true if the result of <em>all</em> of the
628-
<code>supports_condition_in_parens</code> child terms is true; otherwise
629-
it is false.
645+
<dd> The result is true if the result of <em>all</em> of the <a
646+
href="#supportsconditioninparens"><code>supports_condition_in_parens</code></a>
647+
child terms is true; otherwise it is false.
630648

631649
<dt>supports_disjunction
632650

633-
<dd> The result is true if the result of <em>any</em> of the
634-
<code>supports_condition_in_parens</code> child terms is true; otherwise
635-
it is false.
651+
<dd> The result is true if the result of <em>any</em> of the <a
652+
href="#supportsconditioninparens"><code>supports_condition_in_parens</code></a>
653+
child terms is true; otherwise it is false.
636654

637655
<dt>supports_declaration_condition
638656

@@ -641,9 +659,10 @@ <h2 id=at-supports><span class=secno>6. </span>Feature queries: the ‘<a
641659
</dl>
642660

643661
<p>The condition of the ‘<a href="#dfn-support"><code
644-
class=css>@supports</code></a>’ rule is the result of the
645-
<code>supports_condition</code> term that is a child of the
646-
<code>supports_rule</code> term.
662+
class=css>@supports</code></a>’ rule is the result of the <a
663+
href="#supportscondition"><code>supports_condition</code></a> term that is
664+
a child of the <a href="#supportsrule"><code>supports_rule</code></a>
665+
term.
647666

648667
<div class=example>
649668
<p>For example, the following rule</p>
@@ -1025,15 +1044,89 @@ <h2 id=at-document><span class=secno>7. </span>Document queries: the
10251044

10261045
<h2 id=apis><span class=secno>8. </span>APIs</h2>
10271046

1028-
<p class=issue>This specification needs to define the CSSOM interfaces for
1029-
the new rule types. I've reserved new CSSRule constants on <a
1030-
href="http://wiki.csswg.org/spec/cssom-constants">the wiki</a>:
1031-
SUPPORTS_RULE as 12 and DOCUMENT_RULE as 13.
1047+
<h3 id=extentions-to-cssrule-interface><span class=secno>8.1. </span>
1048+
Extensions to the <code>CSSRule</code> interface</h3>
1049+
1050+
<p>The <code>CSSRule</code> interface is extended as follows:
1051+
1052+
<pre class=idl>partial interface CSSRule {
1053+
const unsigned short SUPPORTS_RULE = 12;
1054+
const unsigned short DOCUMENT_RULE = 13;
1055+
}</pre>
1056+
1057+
<h3 id=the-csssupportsrule-interface><span class=secno>8.2. </span> The
1058+
<code>CSSSupportsRule</code> interface</h3>
1059+
1060+
<p>The <code>CSSSupportsRule</code> interface represents a ‘<code
1061+
class=css>@media</code>’ rule.
1062+
1063+
<pre class=idl>interface CSSSupportsRule : CSSRule {
1064+
attribute DOMString supportsCondition;
1065+
readonly attribute CSSRuleList cssRules;
1066+
unsigned long insertRule (DOMString rule, unsigned long index);
1067+
void deleteRule (unsigned long index);
1068+
}</pre>
1069+
1070+
<dl class=idl-attributes>
1071+
<dt><a href="#supportscondition"><code>supportsCondition</code></a> of
1072+
type <code>DOMString</code>, readonly
1073+
1074+
<dd>The <ocde>supportsCondition attribute, on getting, must return the
1075+
result of serializing the associated support condition.
1076+
<p>On setting the <a
1077+
href="#supportscondition"><code>supportsCondition</code></a> attribute
1078+
these steps must be run:
1079+
1080+
<ol>
1081+
<li>Trim the given value of white space.
1082+
1083+
<li>If the given value matches the grammar of the <a
1084+
href="#supportscondition"><code>supports_condition</code></a>
1085+
production, replace the associated CSS support condition with the given
1086+
value.
1087+
1088+
<li>Otherwise, do nothing.
1089+
</ol>
1090+
1091+
<p class=issue>This name sucks. Suggestions?
10321092

1033-
<p class=issue>Should this specification also define APIs for querying
1034-
@supports, like <code>matchMedium</code> allows querying of media? See <a
1035-
href="http://lists.w3.org/Archives/Public/www-style/2011Oct/0323.html">proposal
1036-
on list</a>, agreed in WG telecon 2011-10-12.
1093+
<dt><code>cssRules</code> of type <code>CSSRuleList</code>, readonly
1094+
1095+
<dd>The <code>cssRules</code> attribute must return a
1096+
<code>CSSRuleList</code> object for the list of CSS rules specified with
1097+
the ‘<a href="#dfn-support"><code class=css>@supports</code></a>
1098+
rule.
1099+
</ocde>
1100+
</dl>
1101+
1102+
<dl class=idl-methods>
1103+
<dt><code>insertRule(DOMString rule, unsigned long index)</code>, returns
1104+
<code>unsigned long</code>
1105+
1106+
<dd>The <code>insertRule</code> operation must insert a CSS rule
1107+
<var>rule</var> into the CSS rule list returned by <code>cssRules</code>
1108+
at <var>index</var>.
1109+
1110+
<dt><code>deleteRule (unsigned long index)</code>, return
1111+
<code>void</code>
1112+
1113+
<dd>The <code>deleteRule</code> operation must remove a CSS rule from the
1114+
CSS rule list returned by <code>cssRules</code> at <var>index</var>.
1115+
</dl>
1116+
1117+
<p class=issue>Define the CSSDocumentRule interface.
1118+
1119+
<h3 id=supports-property-api><span class=secno>8.3.
1120+
</span>supportsProperty() function</h3>
1121+
1122+
<pre class=idl>partial interface Window {
1123+
boolean supportsProperty (DOMString property, DOMString value);
1124+
};</pre>
1125+
1126+
<p>The <code>supportsProperty</code> function must return <code>true</code>
1127+
if the implementation <a href="#dfn-support"><i>supports</i></a> the value
1128+
given by <var>value</var> for the property given by <var>property</var>,
1129+
and <code>false</code> otherwise.
10371130

10381131
<h2 id=conformance><span class=secno>9. </span>Conformance</h2>
10391132

@@ -1385,10 +1478,32 @@ <h2 class=no-num id=index>Index</h2>
13851478
<li>support, <a href="#dfn-support"
13861479
title=support><strong>6.1.</strong></a>
13871480

1481+
<li>supports_condition, <a href="#supportscondition"
1482+
title="supports_condition"><strong>6.</strong></a>
1483+
1484+
<li>supports_condition_in_parens, <a href="#supportsconditioninparens"
1485+
title="supports_condition_in_parens"><strong>6.</strong></a>
1486+
1487+
<li>supports_conjunction, <a href="#supportsconjunction"
1488+
title="supports_conjunction"><strong>6.</strong></a>
1489+
1490+
<li>supports_declaration_condition, <a
1491+
href="#supportsdeclarationcondition"
1492+
title="supports_declaration_condition"><strong>6.</strong></a>
1493+
1494+
<li>supports_disjunction, <a href="#supportsdisjunction"
1495+
title="supports_disjunction"><strong>6.</strong></a>
1496+
1497+
<li>supports_negation, <a href="#supportsnegation"
1498+
title="supports_negation"><strong>6.</strong></a>
1499+
13881500
<li><a href="#dfn-support"><code class=css>@supports</code></a>
13891501
rule, <a href="#supports-rule"
13901502
title="'@supports' rule"><strong>6.</strong></a>
13911503

1504+
<li>supports_rule, <a href="#supportsrule"
1505+
title="supports_rule"><strong>6.</strong></a>
1506+
13921507
<li>url(), <a href="#url-exact" title="url()"><strong>7.</strong></a>
13931508

13941509
<li>URL matching functions, <a href="#url-matching-functions"

css3-conditional/Overview.src.html

Lines changed: 75 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -367,32 +367,32 @@ <h2 id="at-supports">Feature queries: the '@supports' rule</h2>
367367
([[!CSS21]], Appendix G) by adding:
368368
<pre>@{S}{U}{P}{P}{O}{R}{T}{S} {return SUPPORTS_SYM;}</pre>
369369
<p>and the grammar by adding</p>
370-
<pre>supports_rule
370+
<pre><dfn>supports_rule</dfn>
371371
: SUPPORTS_SYM S+ supports_condition group_rule_body
372372
;
373373

374-
supports_condition
374+
<dfn>supports_condition</dfn>
375375
: supports_negation | supports_conjunction | supports_disjunction |
376376
supports_condition_in_parens
377377
;
378378

379-
supports_condition_in_parens
379+
<dfn>supports_condition_in_parens</dfn>
380380
: ( '(' S* supports_condition ')' S* ) | supports_declaration_condition
381381
;
382382

383-
supports_negation
383+
<dfn>supports_negation</dfn>
384384
: 'not' S* supports_condition_in_parens
385385
;
386386

387-
supports_conjunction
387+
<dfn>supports_conjunction</dfn>
388388
: supports_condition_in_parens ( 'and' S* supports_condition_in_parens )+
389389
;
390390

391-
supports_disjunction
391+
<dfn>supports_disjunction</dfn>
392392
: supports_condition_in_parens ( 'or' S* supports_condition_in_parens )+
393393
;
394394

395-
supports_declaration_condition
395+
<dfn>supports_declaration_condition</dfn>
396396
: '(' S* core_declaration ')' S*
397397
;</pre>
398398
<p>in which <code>core_declaration</code> is the production
@@ -785,15 +785,75 @@ <h2 id="at-document">Document queries: the '@document' rule</h2>
785785

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

788-
<p class="issue">This specification needs to define the CSSOM interfaces
789-
for the new rule types. I've reserved new CSSRule constants on <a
790-
href="http://wiki.csswg.org/spec/cssom-constants">the wiki</a>:
791-
SUPPORTS_RULE as 12 and DOCUMENT_RULE as 13.</p>
788+
<h3 id='extentions-to-cssrule-interface'>
789+
Extensions to the <code>CSSRule</code> interface</h3>
792790

793-
<p class="issue">Should this specification also define APIs for querying
794-
@supports, like <code>matchMedium</code> allows querying of media?
795-
See <a href="http://lists.w3.org/Archives/Public/www-style/2011Oct/0323.html">proposal
796-
on list</a>, agreed in WG telecon 2011-10-12.</p>
791+
<p>The <code>CSSRule</code> interface is extended as follows:
792+
793+
<pre class='idl'>partial interface CSSRule {
794+
const unsigned short SUPPORTS_RULE = 12;
795+
const unsigned short DOCUMENT_RULE = 13;
796+
}</pre>
797+
798+
799+
<h3 id="the-csssupportsrule-interface">
800+
The <code>CSSSupportsRule</code> interface</h3>
801+
802+
<p>The <code>CSSSupportsRule</code> interface represents a ''@media'' rule.</p>
803+
804+
<pre class='idl'>interface CSSSupportsRule : CSSRule {
805+
attribute DOMString supportsCondition;
806+
readonly attribute CSSRuleList cssRules;
807+
unsigned long insertRule (DOMString rule, unsigned long index);
808+
void deleteRule (unsigned long index);
809+
}</pre>
810+
811+
<dl class='idl-attributes'>
812+
<dt><code>supportsCondition</code> of type <code>DOMString</code>, readonly
813+
<dd>The <ocde>supportsCondition</code> attribute, on getting, must return
814+
the result of serializing the associated support condition.
815+
816+
<p>On setting the <code>supportsCondition</code> attribute these steps
817+
must be run:
818+
819+
<ol>
820+
<li>Trim the given value of white space.
821+
<li>If the given value matches the grammar of the
822+
<code>supports_condition</code> production, replace the associated
823+
CSS support condition with the given value.
824+
<li>Otherwise, do nothing.
825+
</ol>
826+
827+
<p class='issue'>This name sucks. Suggestions?
828+
829+
<dt><code>cssRules</code> of type <code>CSSRuleList</code>, readonly
830+
<dd>The <code>cssRules</code> attribute must return a <code>CSSRuleList</code>
831+
object for the list of CSS rules specified with the ''@supports'' rule.
832+
</dl>
833+
834+
<dl class='idl-methods'>
835+
<dt><code>insertRule(DOMString rule, unsigned long index)</code>, returns
836+
<code>unsigned long</code>
837+
<dd>The <code>insertRule</code> operation must insert a CSS rule <var>rule</var>
838+
into the CSS rule list returned by <code>cssRules</code> at <var>index</var>.
839+
840+
<dt><code>deleteRule (unsigned long index)</code>, return <code>void</code>
841+
<dd>The <code>deleteRule</code> operation must remove a CSS rule from the
842+
CSS rule list returned by <code>cssRules</code> at <var>index</var>.
843+
</dl>
844+
845+
<p class='issue'>Define the CSSDocumentRule interface.
846+
847+
848+
<h3 id="supports-property-api">supportsProperty() function</h3>
849+
850+
<pre class='idl'>partial interface Window {
851+
boolean supportsProperty (DOMString property, DOMString value);
852+
};</pre>
853+
854+
<p>The <code>supportsProperty</code> function must return <code>true</code>
855+
if the implementation <i>supports</i> the value given by <var>value</var> for
856+
the property given by <var>property</var>, and <code>false</code> otherwise.
797857

798858
<h2 id="conformance">Conformance</h2>
799859

0 commit comments

Comments
 (0)