Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[cssom] [css-fonts] [css-page] Sort out properties and descriptors. #9686

Merged
merged 1 commit into from Mar 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe the style of keyframe rules should have its own interface to prevent declaring a property defined in CSS Animations?

The <declaration-list> inside of <keyframe-block> accepts any CSS property except those defined in this specification

https://drafts.csswg.org/css-animations-1/#at-ruledef-keyframes

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Possibly...

};
</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;
Copy link
Collaborator

@cdoublev cdoublev Feb 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

font-stretch (descriptor) is now a legacy alias of font-width (b0660ee). I guess fontWidth should also be defined.

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;
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should fonts 5 have the same interface too except adding the size-adjust descriptor and the subscript-* descriptors as well?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes


[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 {
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