8000 csswg-drafts/cssom/Overview.src.html at 9153134829ee254dde04bf520017ed2087e04e1b · w3c/csswg-drafts · GitHub
Skip to content

Latest commit

 

History

History
3282 lines (2609 loc) · 167 KB

File metadata and controls

3282 lines (2609 loc) · 167 KB
<dt><dfn title=concept-css-style-sheet-css-rules>CSS rules</dfn></dt>
<dd><p>The <span title="CSS rule">CSS rules</span> associated with the
<span>CSS style sheet</span>.</p></dd>
<dt><dfn title=concept-css-style-sheet-origin-clean-flag>origin-clean flag</dfn>
<dd><p>Specified when created. Either set or unset. If it is set, the API allows reading and modifying of the <span title=concept-css-style-sheet-css-rules>CSS
rules</span>.
</dl>
<h4>The <code title>StyleSheet</code> Interface</h4>
<!--
//
// All members defined since DOM-2 Style. Only difference
// is addition of [PutForwards=mediaText], which is presently
// not defined in CSSOM draft.
//
-->
<p>The <code>StyleSheet</code> interface represents an abstract, base style sheet.</p>
<pre class=idl>interface <dfn>StyleSheet</dfn> {
readonly attribute DOMString <span title=dom-StyleSheet-type>type</span>;
readonly attribute DOMString? <span title=dom-StyleSheet-href>href</span>;
readonly attribute (<span data-anolis-spec=dom>Element</span> or <span data-anolis-spec=dom>ProcessingInstruction</span>)? <!--
--><span title=dom-StyleSheet-ownerNode>ownerNode</span>;
readonly attribute <span>StyleSheet</span>? <span title=dom-StyleSheet-parentStyleSheet>parentStyleSheet</span>;
readonly attribute DOMString? <span title=dom-StyleSheet-title>title</span>;
[SameObject, PutForwards=<span title=dom-MediaList-mediaText>mediaText</span>] readonly attribute <span>MediaList</span> <!--
--><span title=dom-StyleSheet-media>media</span>;
attribute boolean <span title=dom-StyleSheet-disabled>disabled</span>;
};</pre>
<p>The <dfn title=dom-StyleSheet-type><code>type</code></dfn> attribute must return the <span title=concept-css-style-sheet-type>type</span>.</p>
<p>The <dfn title=dom-StyleSheet-href><code>href</code></dfn> attribute must return the <span title=concept-css-style-sheet-location>location</span>.</p>
<p>The <dfn title=dom-StyleSheet-ownerNode><code>ownerNode</code></dfn> attribute must return the <span title=concept-css-style-sheet-owner-node>owner
node</span>.</p>
<p>The <dfn title=dom-StyleSheet-parentStyleSheet><code>parentStyleSheet</code></dfn> attribute must return the
<span title=concept-css-style-sheet-parent-css-style-sheet>parent CSS style sheet</span>.</p>
<p>The <dfn title=dom-StyleSheet-title><code>title</code></dfn> attribute must return the <span title=concept-css-style-sheet-title>title</span> or null if
<span title=concept-css-style-sheet-title>title</span> is the empty string.</p>
<p>The <dfn title=dom-StyleSheet-media><code>media</code></dfn> attribute must return the <span title=concept-css-style-sheet-media>media</span>.</p>
<p>The <dfn title=dom-StyleSheet-disabled><code>disabled</code></dfn> attribute, on getting, must return true if the
<span title=concept-css-style-sheet-disabled-flag>disabled flag</span>
is set, or false otherwise. On setting, the <code title=dom-StyleSheet-disabled>disabled</code> attribute must set the
<span title=concept-css-style-sheet-disabled-flag>disabled flag</span> if the new value is true, or unset the
<span title=concept-css-style-sheet-disabled-flag>disabled flag</span> otherwise.</p>
<h4>The <code title>CSSStyleSheet</code> Interface</h4>
<!--
//
// All members defined since DOM-2 Style. The only differences are:
//
// 1. removal of raises(DOMException) on {insert,delete}Rule operations.
//
-->
<p>The <code>CSSStyleSheet</code> interface represents a <span>CSS style sheet</span>.</p>
<pre class=idl>interface <dfn>CSSStyleSheet</dfn> : <span>StyleSheet</span> {
readonly attribute <span>CSSRule</span>? <span title=dom-CSSStyleSheet-ownerRule>ownerRule</span>;
[SameObject] readonly attribute <span>CSSRuleList</span> <span title=dom-CSSStyleSheet-cssRules>cssRules</span>;
unsigned long <span title=dom-CSSStyleSheet-insertRule>insertRule</span>(DOMString rule, unsigned long index);
void <span title=dom-CSSStyleSheet-deleteRule>deleteRule</span>(unsigned long index);
};</pre>
<p>The <dfn title=dom-CSSStyleSheet-ownerRule><code>ownerRule</code></dfn> attribute must return the <span title=concept-css-style-sheet-owner-css-rule>owner
CSS rule</span>. If a value other than null is ever returned, then that same value must always be returned on each get access.</p>
<p>The <dfn title=dom-CSSStyleSheet-cssRules><code>cssRules</code></dfn> attribute must follow these steps:
<ol>
<li><p>If the <span title=concept-css-style-sheet-origin-clean-flag>origin-clean flag</span> is unset,
<span title=concept-throw data-anolis-spec=dom>throw</span> a <code data-anolis-spec=dom>SecurityError</code> exception.
<li><p>Return a read-only, live <code>CSSRuleList</code> object representing
the <span title=concept-css-style-sheet-css-rules>CSS rules</span>.</p>
<p class='note'>Even though the returned <code>CSSRuleList</code> object is read-only (from the perspective of
client-authored script), it can nevertheless change over time due to its liveness status. For example, invoking
the <code title=dom-CSSStyleSheet-insertRule>insertRule()</code> or <code title=dom-CSSStyleSheet-deleteRule>deleteRule()</code> methods can result in
mutations reflected in the returned object.</p>
</ol>
<p>The <dfn title=dom-CSSStyleSheet-insertRule><code>insertRule(<var>rule</var>, <var>index</var>)</code></dfn> method must run the following steps:
<ol>
<li><p>If the <span title=concept-css-style-sheet-origin-clean-flag>origin-clean flag</span> is unset,
<span title=concept-throw data-anolis-spec=dom>throw</span> a <code data-anolis-spec=dom>SecurityError</code> exception.
<li><p>Return the result of invoking <span>insert a CSS rule</span> <var>rule</var> in the <span title=concept-css-style-sheet-css-rules>CSS rules</span>
at <var>index</var>.
</ol>
<p>The <dfn title=dom-CSSStyleSheet-deleteRule><code>deleteRule(<var>index</var>)</code></dfn> method must run the following steps:
<ol>
<li><p>If the <span title=concept-css-style-sheet-origin-clean-flag>origin-clean flag</span> is unset,
<span title=concept-throw data-anolis-spec=dom>throw</span> a <code data-anolis-spec=dom>SecurityError</code> exception.
<li><p><span>Remove a CSS rule</span> in the <span title=concept-css-style-sheet-css-rules>CSS rules</span> at <var>index</var>.
</ol>
<h3>CSS Style Sheet Collections</h3>
<p>Below various new concepts are defined that are associated with each
<code data-anolis-spec=dom>Document</code> object.</p>
<p>Each <code data-anolis-spec=dom>Document</code> has an associated list of zero or more
<span title="CSS style sheet">CSS style sheets</span>, named the
<dfn>document CSS style sheets</dfn>. This is
an ordered list that contains all
<span title="CSS style sheet">CSS style sheets</span> associated with the
<code data-anolis-spec=dom>Document</code>, in
<span data-anolis-spec=dom title=concept-tree-order>tree order</span>, with
<span title="CSS style sheet">CSS style sheets</span> created from HTTP
<code title>Link</code> headers first, if any, in header
order.</p>
<p>To <dfn>create a CSS style sheet</dfn>, run these
steps:</p>
<ol>
<li><p>Create a new <span>CSS style sheet</span> object and set its
properties as specified.</p></li>
<li>
<p>Then run the <span>add a CSS style sheet</span> steps for the newly created <span>CSS style sheet</span>.
<p class=warning>If the <span title=concept-css-style-sheet-origin-clean-flag>origin-clean flag</span> is unset, this can expose information from the user's
intranet.
</ol>
<p>To <dfn>add a CSS style sheet</dfn>, run these
steps:</p>
<ol>
<li><p>Add the <span>CSS style sheet</span> to the list of
<span>document CSS style sheets</span> at the appropriate location. The
remainder of these steps deal with the
<span title=concept-css-style-sheet-disabled-flag>disabled flag</span>.</p></li>
<li><p>If the <span title=concept-css-style-sheet-disabled-flag>disabled flag</span> is set, terminate
these steps.</p></li>
<li><p>If the <span title=concept-css-style-sheet-title>title</span> is not the empty string, the
<span title=concept-css-style-sheet-alternate-flag>alternate flag</span> is unset, and
<span>preferred CSS style sheet set name</span> is the empty string
<span>change the preferred CSS style sheet set name</span> to the
<span title=concept-css-style-sheet-title>title</span>.</p></li>
<li>
<p>If any of the following is true unset the
<span title=concept-css-style-sheet-disabled-flag>disabled flag</span> and terminate these steps:
<ul>
<li><p>The <span title=concept-css-style-sheet-title>title</span> is the empty string.</p></li>
<li><p>The <span>last CSS style sheet set name</span> is null and the
<span title=concept-css-style-sheet-title>title</span> is a
<span data-anolis-spec=dom>case-sensitive</span> match
for the <span>preferred CSS style sheet set name</span>.</p></li>
<li><p>The <span title=concept-css-style-sheet-title>title</span> is a
<span data-anolis-spec=dom>case-sensitive</span> match for the
<span>last CSS style sheet set name</span>.</p></li>
</ul>
</li>
<li><p>Set the <span title=concept-css-style-sheet-disabled-flag>disabled flag</span>.</li>
</ol>
<p>To <dfn>remove a CSS style sheet</dfn>, run these steps:</p>
<ol>
<li><p>Remove the <span>CSS style sheet</span> from the list of <span>document CSS style sheets</span>.