From 581417f657693dc7c301bcf51aa3776db337fa46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Fri, 8 Dec 2023 13:31:36 +0100 Subject: [PATCH] [cssom] [css-fonts] [css-page] Sort out properties and descriptors. This is intended to address #5649. --- css-animations-1/Overview.bs | 4 +- css-fonts-4/Overview.bs | 32 ++++++++++++++- cssom-1/Overview.bs | 76 +++++++++++++++++++++++++----------- 3 files changed, 86 insertions(+), 26 deletions(-) diff --git a/css-animations-1/Overview.bs b/css-animations-1/Overview.bs index 7fb241b9188..dc0c56902ec 100644 --- a/css-animations-1/Overview.bs +++ b/css-animations-1/Overview.bs @@ -1052,7 +1052,7 @@ IDL Definition [Exposed=Window] interface CSSKeyframeRule : CSSRule { attribute CSSOMString keyText; - [SameObject, PutForwards=cssText] readonly attribute CSSStyleDeclaration style; + [SameObject, PutForwards=cssText] readonly attribute CSSStyleProperties style; }; @@ -1074,7 +1074,7 @@ Attributes
style
- Must return a {{CSSStyleDeclaration}} object for the + Must return a {{CSSStyleProperties}} object for the keyframe rule, with the following properties:
diff --git a/css-fonts-4/Overview.bs b/css-fonts-4/Overview.bs index 95bcbad87f6..7f34853d5aa 100644 --- a/css-fonts-4/Overview.bs +++ b/css-fonts-4/Overview.bs @@ -8224,9 +8224,39 @@ The CSSFontFaceRule interface The CSSFontFaceRule interface represents a <<@font-face>> rule.
+[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;
 };
 
diff --git a/cssom-1/Overview.bs b/cssom-1/Overview.bs index de209b309f8..0a5bb80a0b1 100644 --- a/cssom-1/Overview.bs +++ b/cssom-1/Overview.bs @@ -2000,7 +2000,7 @@ The CSSStyleRule 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; }; @@ -2013,11 +2013,13 @@ On setting the {{CSSStyleRule/selectorText}} attribute these steps must be run:
  • Otherwise, if the algorithm returns a null value, do nothing. -The style attribute must return a CSSStyleDeclaration object for the style rule, with the +The style attribute must return a CSSStyleProperties object for the style rule, with the following properties:
    computed flag
    Unset. +
    readonly flag +
    Unset.
    declarations
    The declared declarations in the rule, in specified order.
    parent CSS rule @@ -2106,14 +2108,30 @@ Issue: Need to define the rules for serialize a list of CSS page selectors.
    +[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;
     };
     
    -The selectorText attribute, on getting, must return the result of +The selectorText attribute, on getting, must return the result of serializing the associated list of CSS page selectors. On setting the {{CSSPageRule/selectorText}} attribute these steps must be run:
      @@ -2122,13 +2140,15 @@ On setting the {{CSSPageRule/selectorText}} attribute these steps must be run:
    1. Otherwise, if the algorithm returns a null value, do nothing.
    -The style attribute must return a CSSStyleDeclaration object for the +The style attribute must return a CSSPageDescriptors object for the @page at-rule, with the following properties:
    computed flag
    Unset. +
    readonly flag +
    Unset.
    declarations -
    The declared declarations in the rule, in specified order. +
    The declared descriptors in the rule, in specified order.
    parent CSS rule
    The context object.
    owner node @@ -2145,18 +2165,20 @@ The CSSMarginRule interface represents a margin at-rule (e.g. The name attribute must return the name of the margin at-rule. The @ character is not included in the name. [[!CSS3SYN]] -The style attribute must return a CSSStyleDeclaration object for the +The style attribute must return a CSSMarginDescriptors object for the margin at-rule, with the following properties:
    computed flag
    Unset. +
    readonly flag +
    Unset.
    declarations
    The declared declarations in the rule, in specified order.
    parent CSS rule @@ -2217,6 +2239,9 @@ the DOM a CSS declaration block is a
    Set if the object is a computed style declaration, rather than a specified style. Unless otherwise stated it is unset. +
    readonly flag +
    Set if the object is not modifiable.
    +
    declarations
    The CSS declarations associated with the object. @@ -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; }; @@ -2388,7 +2417,7 @@ Getting the cssText attribute mus Setting the {{CSSStyleDeclaration/cssText}} attribute must run these steps:
      -
    1. If the computed flag is set, +
    2. If the readonly flag is set, then throw a {{NoModificationAllowedError}} exception.
    3. Empty the declarations.
    4. Parse the given value and, if the return value is not the empty list, insert the items in the list @@ -2454,7 +2483,7 @@ value would be "important". The setProperty(property, value, priority) method must run these steps:
        -
      1. If the computed flag is set, +
      2. If the readonly flag is set, then throw a {{NoModificationAllowedError}} exception.
      3. If property is not a custom property, follow these substeps:
          @@ -2569,7 +2598,7 @@ use different algorithms as long as the constraints above hold. The removeProperty(property) method must run these steps:
            -
          1. If the computed flag is set, +
          2. If the readonly flag is set, then throw a {{NoModificationAllowedError}} exception.
          3. If property is not a custom property, let property be property converted to ASCII lowercase. @@ -2592,7 +2621,7 @@ The removeProperty(property)parentRule attribute must return the parent CSS rule. -The cssFloat +The cssFloat attribute, on getting, must return the result of invoking {{CSSStyleDeclaration/getPropertyValue()}} with float as argument. On setting, the attribute must invoke @@ -2606,17 +2635,17 @@ is obtained by running the CSS property to IDL attribute algorithm for property.
            -partial interface CSSStyleDeclaration {
            +partial interface CSSStyleProperties {
               [CEReactions] attribute [LegacyNullToEmptyString] CSSOMString _camel_cased_attribute;
             };
             
            -The camel-cased attribute attribute, on getting, must return the +The camel-cased attribute attribute, on getting, must return the result of invoking {{CSSStyleDeclaration/getPropertyValue()}} with the argument being the result of running the IDL attribute to CSS property algorithm for camel-cased attribute. -Setting the camel-cased attribute attribute must invoke +Setting the camel-cased attribute attribute must invoke {{CSSStyleDeclaration/setProperty()}} with the first argument being the result of running the IDL attribute to CSS property algorithm for camel-cased attribute, as second argument the given value, and no third argument. Any @@ -2630,12 +2659,12 @@ with the string -webkit-, the following partial interface applies w algorithm for property, with the lowercase first flag set.
            -partial interface CSSStyleDeclaration {
            +partial interface CSSStyleProperties {
               [CEReactions] attribute [LegacyNullToEmptyString] CSSOMString _webkit_cased_attribute;
             };
             
            -The webkit-cased attribute attribute, on +The webkit-cased attribute attribute, on getting, must return the result of invoking {{CSSStyleDeclaration/getPropertyValue()}} with the argument being the result of running the IDL attribute to CSS property algorithm for webkit-cased attribute, with the dash prefix flag set. @@ -2655,16 +2684,16 @@ except for properties that have no "-" (U+002D) in the property nam the following partial interface applies where dashed attribute is property.
            -partial interface CSSStyleDeclaration {
            +partial interface CSSStyleProperties {
               [CEReactions] attribute [LegacyNullToEmptyString] CSSOMString _dashed_attribute;
             };
             
            -The dashed attribute attribute, on getting, must return the +The dashed attribute attribute, on getting, must return the result of invoking {{CSSStyleDeclaration/getPropertyValue()}} with the argument being dashed attribute. -Setting the dashed attribute attribute must invoke +Setting the dashed attribute attribute must invoke {{CSSStyleDeclaration/setProperty()}} with the first argument being dashed attribute, as second argument the given value, and no third argument. Any exceptions thrown must be re-thrown. @@ -2976,7 +3005,7 @@ interface mixin ElementCSSInlineStyle { The style attribute must return a CSS declaration block object whose -computed flag is unset, whose parent CSS rule is null, and +readonly flag is unset, whose parent CSS rule is null, and whose owner node is the context object. If the user agent supports HTML, the following IDL applies: [[HTML]] @@ -3043,10 +3072,12 @@ steps: #4947.
          4. - Return a live CSS declaration block with the following properties: + Return a live CSSStyleProperties object with the following properties:
            computed flag
            Set. +
            readonly flag +
            Set.
            declarations
            decls.
            parent CSS rule @@ -3054,7 +3085,6 @@ steps:
            owner node
            obj.
            -

          The {{Window/getComputedStyle()}} method exposes information from CSS style