Skip to content

Commit

Permalink
[cssom] [css-fonts] [css-page] Sort out properties and descriptors.
Browse files Browse the repository at this point in the history
This is intended to address #5649.
  • Loading branch information
emilio authored and svgeesus committed Mar 20, 2024
1 parent 33402a8 commit 2e8c502
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 26 deletions.
4 changes: 2 additions & 2 deletions css-animations-1/Overview.bs
Expand Up @@ -1052,7 +1052,7 @@ IDL Definition</h4>
[Exposed=Window]
interface CSSKeyframeRule : CSSRule {
attribute CSSOMString keyText;
[SameObject, PutForwards=cssText] readonly attribute CSSStyleDeclaration style;
[SameObject, PutForwards=cssText] readonly attribute CSSStyleProperties style;
};
</pre>

Expand All @@ -1074,7 +1074,7 @@ Attributes</h4>

<dt><dfn>style</dfn>
<dd>
Must return a {{CSSStyleDeclaration}} object for the
Must return a {{CSSStyleProperties}} object for the
keyframe rule, with the following properties:

<dl>
Expand Down
32 changes: 31 additions & 1 deletion css-fonts-4/Overview.bs
Expand Up @@ -8224,9 +8224,39 @@ The <code id="cssfontfacerule2">CSSFontFaceRule</code> interface</h3>
The <dfn id="cssfontfacerule-interface">CSSFontFaceRule</dfn> interface represents a <<@font-face>> rule.

<pre class="idl">
[Exposed=Window]
interface CSSFontFaceDescriptors : CSSStyleDeclaration {
attribute [LegacyNullToEmptyString] CSSOMString src;
attribute [LegacyNullToEmptyString] CSSOMString fontFamily;
attribute [LegacyNullToEmptyString] CSSOMString font-family;
attribute [LegacyNullToEmptyString] CSSOMString fontStyle;
attribute [LegacyNullToEmptyString] CSSOMString font-style;
attribute [LegacyNullToEmptyString] CSSOMString fontWeight;
attribute [LegacyNullToEmptyString] CSSOMString fontStretch;
attribute [LegacyNullToEmptyString] CSSOMString font-stretch;
attribute [LegacyNullToEmptyString] CSSOMString unicodeRange;
attribute [LegacyNullToEmptyString] CSSOMString unicode-range;
attribute [LegacyNullToEmptyString] CSSOMString fontFeatureSettings;
attribute [LegacyNullToEmptyString] CSSOMString font-feature-settings;
attribute [LegacyNullToEmptyString] CSSOMString fontVariationSettings;
attribute [LegacyNullToEmptyString] CSSOMString font-variation-settings;
attribute [LegacyNullToEmptyString] CSSOMString fontNamedInstance;
attribute [LegacyNullToEmptyString] CSSOMString font-named-instance;
attribute [LegacyNullToEmptyString] CSSOMString fontDisplay;
attribute [LegacyNullToEmptyString] CSSOMString font-display;
attribute [LegacyNullToEmptyString] CSSOMString fontLanguageOverride;
attribute [LegacyNullToEmptyString] CSSOMString font-language-override;
attribute [LegacyNullToEmptyString] CSSOMString ascentOverride;
attribute [LegacyNullToEmptyString] CSSOMString ascent-override;
attribute [LegacyNullToEmptyString] CSSOMString descentOverride;
attribute [LegacyNullToEmptyString] CSSOMString descent-override;
attribute [LegacyNullToEmptyString] CSSOMString lineGapOverride;
attribute [LegacyNullToEmptyString] CSSOMString line-gap-override;
};

[Exposed=Window]
interface CSSFontFaceRule : CSSRule {
readonly attribute CSSStyleDeclaration style;
readonly attribute CSSFontFaceDescriptors style;
};
</pre>

Expand Down
76 changes: 53 additions & 23 deletions cssom-1/Overview.bs
Expand Up @@ -2000,7 +2000,7 @@ The <code>CSSStyleRule</code> interface represents a style rule.
[Exposed=Window]
interface CSSStyleRule : CSSGroupingRule {
attribute CSSOMString selectorText;
[SameObject, PutForwards=cssText] readonly attribute CSSStyleDeclaration style;
[SameObject, PutForwards=cssText] readonly attribute CSSStyleProperties style;
};
</pre>

Expand All @@ -2013,11 +2013,13 @@ On setting the {{CSSStyleRule/selectorText}} attribute these steps must be run:
<li>Otherwise, if the algorithm returns a null value, do nothing.
</ol>

The <dfn attribute for=CSSStyleRule>style</dfn> attribute must return a <code>CSSStyleDeclaration</code> object for the style rule, with the
The <dfn attribute for=CSSStyleRule>style</dfn> attribute must return a <code>CSSStyleProperties</code> object for the style rule, with the
following properties:
<dl>
<dt><a for="CSSStyleDeclaration">computed flag</a>
<dd>Unset.
<dt><a for="CSSStyleDeclaration">readonly flag</a>
<dd>Unset.
<dt><a for="CSSStyleDeclaration">declarations</a>
<dd>The declared declarations in the rule, in <a>specified order</a>.
<dt><a for="CSSStyleDeclaration">parent CSS rule</a>
Expand Down Expand Up @@ -2106,14 +2108,30 @@ Issue: Need to define the rules for
<dfn export>serialize a list of CSS page selectors</dfn>.

<pre class=idl>
[Exposed=Window]
interface CSSPageDescriptors : CSSStyleDeclaration {

This comment has been minimized.

Copy link
@mstensho

mstensho Apr 15, 2024

Are they descriptors or properties, or don't we care?

Also, this list is incomplete. What about things like margin-block-start? Furthermore, we need to include all the properties from https://drafts.csswg.org/css-page-3/#page-property-list , and really also https://drafts.csswg.org/css-page-3/#margin-property-list , since anything that applies in a margin context can be inherited from a page context, even if the property doesn't apply in a page context. For example: direction.

Also, page-orientation, needs to be included.

attribute [LegacyNullToEmptyString] CSSOMString margin;
attribute [LegacyNullToEmptyString] CSSOMString marginTop;
attribute [LegacyNullToEmptyString] CSSOMString marginRight;
attribute [LegacyNullToEmptyString] CSSOMString marginBottom;
attribute [LegacyNullToEmptyString] CSSOMString marginLeft;
attribute [LegacyNullToEmptyString] CSSOMString margin-top;
attribute [LegacyNullToEmptyString] CSSOMString margin-right;
attribute [LegacyNullToEmptyString] CSSOMString margin-bottom;
attribute [LegacyNullToEmptyString] CSSOMString margin-left;
attribute [LegacyNullToEmptyString] CSSOMString size;
attribute [LegacyNullToEmptyString] CSSOMString marks;
attribute [LegacyNullToEmptyString] CSSOMString bleed;
};

[Exposed=Window]
interface CSSPageRule : CSSGroupingRule {
attribute CSSOMString selectorText;
[SameObject, PutForwards=cssText] readonly attribute CSSStyleDeclaration style;
[SameObject, PutForwards=cssText] readonly attribute CSSPageDescriptors style;
};
</pre>

The <dfn attribute for=CSSGroupingRule>selectorText</dfn> attribute, on getting, must return the result of
The <dfn attribute for=CSSPageRule>selectorText</dfn> attribute, on getting, must return the result of
<a lt="serialize a list of CSS page selectors">serializing</a> the associated <a>list of CSS page selectors</a>.
On setting the {{CSSPageRule/selectorText}} attribute these steps must be run:
<ol>
Expand All @@ -2122,13 +2140,15 @@ On setting the {{CSSPageRule/selectorText}} attribute these steps must be run:
<li>Otherwise, if the algorithm returns a null value, do nothing.
</ol>

The <dfn attribute for=CSSGroupingRule>style</dfn> attribute must return a <code>CSSStyleDeclaration</code> object for the
The <dfn attribute for=CSSPageRule>style</dfn> attribute must return a <code>CSSPageDescriptors</code> object for the
<code>@page</code> at-rule, with the following properties:
<dl>
<dt><a for="CSSStyleDeclaration">computed flag</a>
<dd>Unset.
<dt><a for="CSSStyleDeclaration">readonly flag</a>
<dd>Unset.
<dt><a for="CSSStyleDeclaration">declarations</a>
<dd>The declared declarations in the rule, in <a>specified order</a>.
<dd>The declared descriptors in the rule, in <a>specified order</a>.
<dt><a for="CSSStyleDeclaration">parent CSS rule</a>
<dd>The <a>context object</a>.
<dt><a for="CSSStyleDeclaration">owner node</a>
Expand All @@ -2145,18 +2165,20 @@ The <code>CSSMarginRule</code> interface represents a margin at-rule (e.g. <code
[Exposed=Window]
interface CSSMarginRule : CSSRule {
readonly attribute CSSOMString name;
[SameObject, PutForwards=cssText] readonly attribute CSSStyleDeclaration style;
[SameObject, PutForwards=cssText] readonly attribute CSSMarginDescriptors style;
};
</pre>

The <dfn attribute for=CSSMarginRule>name</dfn> attribute must return the name of the margin at-rule. The <code>@</code> character is not
included in the name. [[!CSS3SYN]]

The <dfn attribute for=CSSMarginRule>style</dfn> attribute must return a <code>CSSStyleDeclaration</code> object for the
The <dfn attribute for=CSSMarginRule>style</dfn> attribute must return a <code>CSSMarginDescriptors</code> object for the
margin at-rule, with the following properties:
<dl>
<dt><a for="CSSStyleDeclaration">computed flag</a>
<dd>Unset.
<dt><a for="CSSStyleDeclaration">readonly flag</a>
<dd>Unset.
<dt><a for="CSSStyleDeclaration">declarations</a>
<dd>The declared declarations in the rule, in <a>specified order</a>.
<dt><a for="CSSStyleDeclaration">parent CSS rule</a>
Expand Down Expand Up @@ -2217,6 +2239,9 @@ the DOM a <a>CSS declaration block</a> is a
<dd>Set if the object is a computed style declaration, rather than a specified
style. Unless otherwise stated it is unset.

<dt><dfn>readonly flag</dfn>
<dd>Set if the object is not modifiable.</dd>

<dt><dfn>declarations</dfn>
<dd>The <a>CSS declarations</a> associated with the object.

Expand Down Expand Up @@ -2373,6 +2398,10 @@ interface CSSStyleDeclaration {
[CEReactions] undefined setProperty(CSSOMString property, [LegacyNullToEmptyString] CSSOMString value, optional [LegacyNullToEmptyString] CSSOMString priority = "");
[CEReactions] CSSOMString removeProperty(CSSOMString property);
readonly attribute CSSRule? parentRule;
};

[Exposed=Window]
interface CSSStyleProperties : CSSStyleDeclaration {
[CEReactions] attribute [LegacyNullToEmptyString] CSSOMString cssFloat;
};
</pre>
Expand All @@ -2388,7 +2417,7 @@ Getting the <dfn attribute for="CSSStyleDeclaration">cssText</dfn> attribute mus

Setting the {{CSSStyleDeclaration/cssText}} attribute must run these steps:
<ol>
<li>If the <a for="CSSStyleDeclaration">computed flag</a> is set,
<li>If the <a for="CSSStyleDeclaration">readonly flag</a> is set,
then <a>throw</a> a {{NoModificationAllowedError}} exception.
<li>Empty the <a for="CSSStyleDeclaration">declarations</a>.
<li><a lt="Parse a CSS declaration block">Parse</a> the given value and, if the return value is not the empty list, insert the items in the list
Expand Down Expand Up @@ -2454,7 +2483,7 @@ value would be "<code>important</code>".</div>

The <dfn method for=CSSStyleDeclaration>setProperty(<var>property</var>, <var>value</var>, <var>priority</var>)</dfn> method must run these steps:
<ol>
<li>If the <a for="CSSStyleDeclaration">computed flag</a> is set,
<li>If the <a for="CSSStyleDeclaration">readonly flag</a> is set,
then <a>throw</a> a {{NoModificationAllowedError}} exception.
<li>If <var>property</var> is not a <a>custom property</a>, follow these substeps:
<ol>
Expand Down Expand Up @@ -2569,7 +2598,7 @@ use different algorithms as long as the constraints above hold.

The <dfn method for=CSSStyleDeclaration>removeProperty(<var>property</var>)</dfn> method must run these steps:
<ol>
<li>If the <a for="CSSStyleDeclaration">computed flag</a> is set,
<li>If the <a for="CSSStyleDeclaration">readonly flag</a> is set,
then <a>throw</a> a {{NoModificationAllowedError}} exception.
<li>If <var>property</var> is not a <a>custom property</a>,
let <var>property</var> be <var>property</var> <a lt="ASCII lowercase">converted to ASCII lowercase</a>.
Expand All @@ -2592,7 +2621,7 @@ The <dfn method for=CSSStyleDeclaration>removeProperty(<var>property</var>)</dfn
The <dfn attribute for=CSSStyleDeclaration>parentRule</dfn> attribute must return the
<a for="CSSStyleDeclaration">parent CSS rule</a>.

The <dfn attribute for=CSSStyleDeclaration>cssFloat</dfn>
The <dfn attribute for=CSSStyleProperties>cssFloat</dfn>
attribute, on getting, must return the result of invoking
{{CSSStyleDeclaration/getPropertyValue()}} with
<code>float</code> as argument. On setting, the attribute must invoke
Expand All @@ -2606,17 +2635,17 @@ is obtained by running the <a>CSS property to IDL attribute</a> algorithm for
<var>property</var>.

<pre class="idl extract">
partial interface CSSStyleDeclaration {
partial interface CSSStyleProperties {
[CEReactions] attribute [LegacyNullToEmptyString] CSSOMString _<var>camel_cased_attribute</var>;
};
</pre>

The <a attribute for=CSSStyleDeclaration><var>camel-cased attribute</var></a> attribute, on getting, must return the
The <a attribute for=CSSStyleProperties><var>camel-cased attribute</var></a> attribute, on getting, must return the
result of invoking {{CSSStyleDeclaration/getPropertyValue()}} with the
argument being the result of running the <a>IDL attribute to CSS property</a>
algorithm for <var>camel-cased attribute</var>.

Setting the <a attribute for=CSSStyleDeclaration><var>camel-cased attribute</var></a> attribute must invoke
Setting the <a attribute for=CSSStyleProperties><var>camel-cased attribute</var></a> attribute must invoke
{{CSSStyleDeclaration/setProperty()}} with the
first argument being the result of running the <a>IDL attribute to CSS property</a>
algorithm for <var>camel-cased attribute</var>, as second argument the given value, and no third argument. Any
Expand All @@ -2630,12 +2659,12 @@ with the string <code>-webkit-</code>, the following partial interface applies w
algorithm for <var>property</var>, with the <i>lowercase first</i> flag set.

<pre class="idl extract">
partial interface CSSStyleDeclaration {
partial interface CSSStyleProperties {
[CEReactions] attribute [LegacyNullToEmptyString] CSSOMString _<var>webkit_cased_attribute</var>;
};
</pre>

The <dfn attribute for=CSSStyleDeclaration><var>webkit-cased attribute</var></dfn> attribute, on
The <dfn attribute for=CSSStyleProperties><var>webkit-cased attribute</var></dfn> attribute, on
getting, must return the result of invoking {{CSSStyleDeclaration/getPropertyValue()}} with the
argument being the result of running the <a>IDL attribute to CSS property</a> algorithm for
<var>webkit-cased attribute</var>, with the <i>dash prefix</i> flag set.
Expand All @@ -2655,16 +2684,16 @@ except for properties that have no "<code>-</code>" (U+002D) in the property nam
the following partial interface applies where <var>dashed attribute</var> is <var>property</var>.

<pre class="idl extract">
partial interface CSSStyleDeclaration {
partial interface CSSStyleProperties {
[CEReactions] attribute [LegacyNullToEmptyString] CSSOMString _<var>dashed_attribute</var>;
};
</pre>

The <dfn attribute for=CSSStyleDeclaration><var>dashed attribute</var></dfn> attribute, on getting, must return the
The <dfn attribute for=CSSStyleProperties><var>dashed attribute</var></dfn> attribute, on getting, must return the
result of invoking {{CSSStyleDeclaration/getPropertyValue()}} with the
argument being <var>dashed attribute</var>.

Setting the <a attribute for=CSSStyleDeclaration><var>dashed attribute</var></a> attribute must invoke
Setting the <a attribute for=CSSStyleProperties><var>dashed attribute</var></a> attribute must invoke
{{CSSStyleDeclaration/setProperty()}} with the
first argument being <var>dashed attribute</var>, as second argument the given value, and no third argument. Any
exceptions thrown must be re-thrown.
Expand Down Expand Up @@ -2976,7 +3005,7 @@ interface mixin ElementCSSInlineStyle {
</pre>

The <dfn attribute for=ElementCSSInlineStyle>style</dfn> attribute must return a <a>CSS declaration block</a> object whose
<a for="CSSStyleDeclaration">computed flag</a> is unset, whose <a for="CSSStyleDeclaration">parent CSS rule</a> is null, and
<a for="CSSStyleDeclaration">readonly flag</a> is unset, whose <a for="CSSStyleDeclaration">parent CSS rule</a> is null, and
whose <a for="CSSStyleDeclaration">owner node</a> is the <a>context object</a>.

If the user agent supports HTML, the following IDL applies: [[HTML]]
Expand Down Expand Up @@ -3043,18 +3072,19 @@ steps:
<a href="https://github.com/w3c/csswg-drafts/issues/4947">#4947</a>.

<li>
Return a live <a>CSS declaration block</a> with the following properties:
Return a live <a>CSSStyleProperties</a> object with the following properties:
<dl>
<dt><a for="CSSStyleDeclaration">computed flag</a>
<dd>Set.
<dt><a for="CSSStyleDeclaration">readonly flag</a>
<dd>Set.
<dt><a for="CSSStyleDeclaration">declarations</a>
<dd><var>decls</var>.
<dt><a for="CSSStyleDeclaration">parent CSS rule</a>
<dd>Null.
<dt><a for="CSSStyleDeclaration">owner node</a>
<dd><var>obj</var>.
</dl>

</ol>

<p class=warning>The {{Window/getComputedStyle()}} method exposes information from <a lt="CSS style sheet">CSS style
Expand Down

0 comments on commit 2e8c502

Please sign in to comment.