Title: [268564] trunk
Revision
268564
Author
[email protected]
Date
2020-10-15 17:28:16 -0700 (Thu, 15 Oct 2020)

Log Message

CSSStyleDeclaration breaks JS spec (properties not showing up in Object.getOwnPropertyNames)
https://bugs.webkit.org/show_bug.cgi?id=217623

Reviewed by Darin Adler.

LayoutTests/imported/w3c:

* web-platform-tests/css/cssom/cssstyledeclaration-properties-expected.txt:
Update test result now that it is passing.

Source/WebCore:

Replace named getter/setter based implementation of access to CSSStyleDeclaration property values
with a generated partial interface that lists all the properties exactly.

To keep things consistent with existing behavior, in addition to the spec'd properties, we also
maintain additional properties such as Epub* (in addition to the epub* properties the spec says
we should), and Css, css, Pos, pos, Pixel, and Pixel prefixed properties. As a follow up, we should
consider removing these as they are not supported by the standard or other browsers.

* CMakeLists.txt:
* DerivedSources-output.xcfilelist:
* DerivedSources.make:
Generate CSSStyleDeclaration+PropertyNames.idl and ensure it is compile together with the other
bindings.

* css/makeprop.pl:
Add generation of CSSStyleDeclaration+PropertyNames.idl from CSSProperties.json.

* bindings/scripts/IDLAttributes.json:
Remove CallNamedSetterOnlyForSupportedProperties and DefaultDefineOwnProperty extended attributes,
which now have no users, and add the CSSProperty extended attribute, used to avoid unnecessary
implementation overhead for each property. Rather, in an analogous way to EventHandlers, the bindings
now directly pass in the associate CSSPropertyID to an appropriate CSSStyleDeclaration function.

* bindings/scripts/CodeGeneratorJS.pm:
(GenerateInvokeNamedPropertySetter):
(GeneratePut):
(GeneratePutByIndex):
(GenerateDefineOwnProperty):
Remove all use of CallNamedSetterOnlyForSupportedProperties.

(InstanceOverridesDefineOwnProperty):
Remove support for DefaultDefineOwnProperty, which is now unused.

(ToMethodName):
Match the actual setting name, and don't transform names that start with CSSOM.

(GenerateAttributeGetterBodyDefinition):
(GenerateAttributeSetterBodyDefinition):
Add support for the new CSSProperty extended attribute which uses the passsed
value to to directly call CSSStyleDeclaration functions with a CSSPropertyID.

* css/CSSStyleDeclaration.cpp:
(WebCore::CSSStyleDeclaration::setPropertyValueInternal):
(WebCore::CSSStyleDeclaration::getPropertyValueInternalForPosOrPixelPrefixed):
(WebCore::CSSStyleDeclaration::setPropertyValueInternalForPosOrPixelPrefixed):
(WebCore::CSSStyleDeclaration::getCSSPropertyIDFromJavaScriptPropertyName):
(WebCore::CSSStyleDeclaration::namedItem): Deleted.
(WebCore::CSSStyleDeclaration::setNamedItem): Deleted.
(WebCore::CSSStyleDeclaration::supportedPropertyNames const): Deleted.
* css/CSSStyleDeclaration.h:
Replace old named getter/setter support code with new helpers which operate directly
on CSSPropertyIDs.

* css/CSSStyleDeclaration.idl:
Update to match the current spec (almost, still need to getPropertyPriority to not return
null) and remove custom named getter/setter operations.

LayoutTests:

* fast/css/style-enumerate-properties-expected.txt:
* fast/css/style-enumerate-properties.html:
* fast/dom/domListEnumeration-expected.txt:
* fast/dom/domListEnumeration.html:
Remove tests for iteration order, which is not standardized, and not consistent among
browsers.

* fast/dom/CSSStyleDeclaration/cssstyledeclaration-properties-descriptor-expected.txt:
* fast/dom/CSSStyleDeclaration/cssstyledeclaration-properties-descriptor.html:
Update now that the properties are proper attributes on the prototype.

* js/dom/put-override-should-not-use-ic.html:
Switch to using a DOMStringList as the object that overrides put, since CSSStyleDeclaration no longer does.

* transitions/transitions-parsing-expected.txt:
* transitions/transitions-parsing.html:
Remove Object.keys() aspect of the test, which is no longer meaningful since the
properties should no longer exist in the result set.

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (268563 => 268564)


--- trunk/LayoutTests/ChangeLog	2020-10-16 00:09:37 UTC (rev 268563)
+++ trunk/LayoutTests/ChangeLog	2020-10-16 00:28:16 UTC (rev 268564)
@@ -1,3 +1,29 @@
+2020-10-15  Sam Weinig  <[email protected]>
+
+        CSSStyleDeclaration breaks JS spec (properties not showing up in Object.getOwnPropertyNames)
+        https://bugs.webkit.org/show_bug.cgi?id=217623
+
+        Reviewed by Darin Adler.
+
+        * fast/css/style-enumerate-properties-expected.txt:
+        * fast/css/style-enumerate-properties.html:
+        * fast/dom/domListEnumeration-expected.txt:
+        * fast/dom/domListEnumeration.html:
+        Remove tests for iteration order, which is not standardized, and not consistent among
+        browsers.
+
+        * fast/dom/CSSStyleDeclaration/cssstyledeclaration-properties-descriptor-expected.txt:
+        * fast/dom/CSSStyleDeclaration/cssstyledeclaration-properties-descriptor.html:
+        Update now that the properties are proper attributes on the prototype.
+
+        * js/dom/put-override-should-not-use-ic.html:
+        Switch to using a DOMStringList as the object that overrides put, since CSSStyleDeclaration no longer does.
+
+        * transitions/transitions-parsing-expected.txt:
+        * transitions/transitions-parsing.html:
+        Remove Object.keys() aspect of the test, which is no longer meaningful since the
+        properties should no longer exist in the result set.
+
 2020-10-15  Truitt Savell  <[email protected]>
 
         Rebaseline tests for Catalina and iOS after the changes in r268520

Modified: trunk/LayoutTests/fast/css/style-enumerate-properties-expected.txt (268563 => 268564)


--- trunk/LayoutTests/fast/css/style-enumerate-properties-expected.txt	2020-10-16 00:09:37 UTC (rev 268563)
+++ trunk/LayoutTests/fast/css/style-enumerate-properties-expected.txt	2020-10-16 00:28:16 UTC (rev 268564)
@@ -11,7 +11,6 @@
 PASS 'bogus-random-String' in document.body.style is false
 PASS 'cssText' in document.body.style is true
 PASS 'getPropertyCSSValue' in document.body.style is true
-PASS The CSS property order is correct
 PASS successfullyParsed is true
 
 TEST COMPLETE

Modified: trunk/LayoutTests/fast/css/style-enumerate-properties.html (268563 => 268564)


--- trunk/LayoutTests/fast/css/style-enumerate-properties.html	2020-10-16 00:09:37 UTC (rev 268563)
+++ trunk/LayoutTests/fast/css/style-enumerate-properties.html	2020-10-16 00:28:16 UTC (rev 268564)
@@ -23,33 +23,6 @@
         shouldBeFalse("'bogus-random-String' in document.body.style");
         shouldBeTrue("'cssText' in document.body.style");
         shouldBeTrue("'getPropertyCSSValue' in document.body.style");
-
-        // Test CSS property order.
-        var started;
-        var cssPropertyCount = 0;
-        var previous;
-        var seenFilter;
-        for (var p in document.body.style) {
-            if (p === "alignmentBaseline")
-                started = true;
-            if (!started)
-                continue;
-            if (p === "filter")
-                seenFilter = true;
-            if (previous && previous >= p) {
-                testFailed("Invalid CSS-mapped property order: '" + p + "' after '" + previous + "'");
-                break;
-            }
-            if (++cssPropertyCount <= 400)
-                previous = p;
-            else {
-                if (seenFilter)
-                    testPassed("The CSS property order is correct");
-                else
-                    testFailed("The 'filter' property was not enumerated");
-                break;
-            }
-        }
     </script>
     <script src=""
 </body>

Modified: trunk/LayoutTests/fast/dom/CSSStyleDeclaration/cssstyledeclaration-properties-descriptor-expected.txt (268563 => 268564)


--- trunk/LayoutTests/fast/dom/CSSStyleDeclaration/cssstyledeclaration-properties-descriptor-expected.txt	2020-10-16 00:09:37 UTC (rev 268563)
+++ trunk/LayoutTests/fast/dom/CSSStyleDeclaration/cssstyledeclaration-properties-descriptor-expected.txt	2020-10-16 00:28:16 UTC (rev 268564)
@@ -3,7 +3,8 @@
 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
 
 
-PASS descriptor['writable'] is true
+PASS descriptor['get'] is an instance of Function
+PASS descriptor['set'] is an instance of Function
 PASS descriptor['enumerable'] is true
 PASS descriptor['configurable'] is true
 PASS successfullyParsed is true

Modified: trunk/LayoutTests/fast/dom/CSSStyleDeclaration/cssstyledeclaration-properties-descriptor.html (268563 => 268564)


--- trunk/LayoutTests/fast/dom/CSSStyleDeclaration/cssstyledeclaration-properties-descriptor.html	2020-10-16 00:09:37 UTC (rev 268563)
+++ trunk/LayoutTests/fast/dom/CSSStyleDeclaration/cssstyledeclaration-properties-descriptor.html	2020-10-16 00:28:16 UTC (rev 268564)
@@ -5,8 +5,9 @@
     <script>
         description("This tests the descriptor of CSSStyleDeclaration properties.");
 
-        var descriptor = Object.getOwnPropertyDescriptor(document.body.style, 'color');
-        shouldBeTrue("descriptor['writable']");
+        var descriptor = Object.getOwnPropertyDescriptor(document.body.style.__proto__, 'color');
+        shouldBeType("descriptor['get']", "Function");
+        shouldBeType("descriptor['set']", "Function");
         shouldBeTrue("descriptor['enumerable']");
         shouldBeTrue("descriptor['configurable']");
     </script>

Modified: trunk/LayoutTests/fast/dom/domListEnumeration-expected.txt (268563 => 268564)


--- trunk/LayoutTests/fast/dom/domListEnumeration-expected.txt	2020-10-16 00:09:37 UTC (rev 268563)
+++ trunk/LayoutTests/fast/dom/domListEnumeration-expected.txt	2020-10-16 00:28:16 UTC (rev 268564)
@@ -65,14 +65,6 @@
 PASS resultArray[2].i is '2'
 PASS resultArray[2].item is cssRuleList.item(2)
 
-[object CSSStyleDeclaration]
-PASS resultArray[0].i is '0'
-PASS resultArray[0].item is cssStyleDeclaration.item(0)
-PASS resultArray[1].i is '1'
-PASS resultArray[1].item is cssStyleDeclaration.item(1)
-PASS resultArray[2].i is '2'
-PASS resultArray[2].item is cssStyleDeclaration.item(2)
-
 [object CSSValueList]
 PASS resultArray.length is 10
 PASS resultArray[0].i is '0'

Modified: trunk/LayoutTests/fast/dom/domListEnumeration.html (268563 => 268564)


--- trunk/LayoutTests/fast/dom/domListEnumeration.html	2020-10-16 00:09:37 UTC (rev 268563)
+++ trunk/LayoutTests/fast/dom/domListEnumeration.html	2020-10-16 00:28:16 UTC (rev 268564)
@@ -177,17 +177,6 @@
 shouldBe("resultArray[2].i", "'2'");
 shouldBe("resultArray[2].item", "cssRuleList.item(2)");
 
-// CSSStyleDeclaration
-//debug(escapeHTML(document.getElementsByTagName('style')));
-var cssStyleDeclaration = document.styleSheets[2].cssRules[0].style;
-resultArray = iterateList(cssStyleDeclaration);
-shouldBe("resultArray[0].i", "'0'");
-shouldBe("resultArray[0].item", "cssStyleDeclaration.item(0)");
-shouldBe("resultArray[1].i", "'1'");
-shouldBe("resultArray[1].item", "cssStyleDeclaration.item(1)");
-shouldBe("resultArray[2].i", "'2'");
-shouldBe("resultArray[2].item", "cssStyleDeclaration.item(2)");
-
 // CSSValueList
 var cssValueList = window.getComputedStyle(document.getElementsByTagName('ol')[0]).getPropertyCSSValue('border-spacing');
 resultArray = iterateList(cssValueList);

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (268563 => 268564)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2020-10-16 00:09:37 UTC (rev 268563)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2020-10-16 00:28:16 UTC (rev 268564)
@@ -1,3 +1,13 @@
+2020-10-15  Sam Weinig  <[email protected]>
+
+        CSSStyleDeclaration breaks JS spec (properties not showing up in Object.getOwnPropertyNames)
+        https://bugs.webkit.org/show_bug.cgi?id=217623
+
+        Reviewed by Darin Adler.
+
+        * web-platform-tests/css/cssom/cssstyledeclaration-properties-expected.txt:
+        Update test result now that it is passing.
+
 2020-10-14  Sergio Villar Senin  <[email protected]>
 
         [css-flexbox] flex-grow property should be animatable

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/css/cssom/cssstyledeclaration-properties-expected.txt (268563 => 268564)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/cssom/cssstyledeclaration-properties-expected.txt	2020-10-16 00:09:37 UTC (rev 268563)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/cssom/cssstyledeclaration-properties-expected.txt	2020-10-16 00:28:16 UTC (rev 268564)
@@ -1,3 +1,3 @@
 
-FAIL CSS Test: CSSStyleDeclaration properties are defined as WebIDL attributes, not using getOwnPropertyNames() assert_false: shouldn't have an own property for WebIDL attributes expected false got true
+PASS CSS Test: CSSStyleDeclaration properties are defined as WebIDL attributes, not using getOwnPropertyNames()
 

Modified: trunk/LayoutTests/js/dom/put-override-should-not-use-ic.html (268563 => 268564)


--- trunk/LayoutTests/js/dom/put-override-should-not-use-ic.html	2020-10-16 00:09:37 UTC (rev 268563)
+++ trunk/LayoutTests/js/dom/put-override-should-not-use-ic.html	2020-10-16 00:28:16 UTC (rev 268564)
@@ -8,10 +8,10 @@
 <script>
     test(function() {
         function transitioned() {
-            style = document.createElement('p').style;
+            dataset = document.createElement('p').dataset;
             for(var i = 0; i < 20; i++)
-                style['p'+i] = i;
-            return style;
+                dataset['p'+i] = i;
+            return dataset;
         }
 
         function putter(o) {

Modified: trunk/LayoutTests/transitions/transitions-parsing-expected.txt (268563 => 268564)


--- trunk/LayoutTests/transitions/transitions-parsing-expected.txt	2020-10-16 00:09:37 UTC (rev 268563)
+++ trunk/LayoutTests/transitions/transitions-parsing-expected.txt	2020-10-16 00:28:16 UTC (rev 268564)
@@ -6,8 +6,6 @@
 Valid transition-property values.
 PASS computedStyle.transitionProperty is 'all'
 PASS computedStyle.webkitTransitionProperty is 'all'
-PASS Object.keys(style).indexOf('transitionProperty') is not -1
-PASS Object.keys(style).indexOf('webkitTransitionProperty') is -1
 PASS style.transitionProperty is 'none'
 PASS computedStyle.transitionProperty is 'none'
 PASS style.webkitTransitionProperty is 'none'
@@ -100,8 +98,6 @@
 Valid transition-duration values.
 PASS computedStyle.transitionDuration is '0s'
 PASS computedStyle.webkitTransitionDuration is '0s'
-PASS Object.keys(style).indexOf('transitionDuration') is not -1
-PASS Object.keys(style).indexOf('webkitTransitionDuration') is -1
 PASS style.transitionDuration is '0s'
 PASS computedStyle.transitionDuration is '0s'
 PASS style.webkitTransitionDuration is '0s'
@@ -150,8 +146,6 @@
 Valid transition-timing-function values.
 PASS computedStyle.transitionTimingFunction is 'ease'
 PASS computedStyle.webkitTransitionTimingFunction is 'ease'
-PASS Object.keys(style).indexOf('transitionTimingFunction') is not -1
-PASS Object.keys(style).indexOf('webkitTransitionTimingFunction') is -1
 PASS style.transitionTimingFunction is 'linear'
 PASS computedStyle.transitionTimingFunction is 'linear'
 PASS style.webkitTransitionTimingFunction is 'linear'
@@ -300,8 +294,6 @@
 Valid transition-delay values.
 PASS computedStyle.transitionDelay is '0s'
 PASS computedStyle.webkitTransitionDelay is '0s'
-PASS Object.keys(style).indexOf('transitionDelay') is not -1
-PASS Object.keys(style).indexOf('webkitTransitionDelay') is -1
 PASS style.transitionDelay is '0s'
 PASS computedStyle.transitionDelay is '0s'
 PASS style.webkitTransitionDelay is '0s'
@@ -350,8 +342,6 @@
 Valid transition shorthand values.
 PASS computedStyle.transition is 'all 0s ease 0s'
 PASS computedStyle.webkitTransition is 'all 0s ease 0s'
-PASS Object.keys(style).indexOf('transition') is not -1
-PASS Object.keys(style).indexOf('webkitTransition') is -1
 PASS style.transition is 'none'
 PASS computedStyle.transition is 'none 0s ease 0s'
 PASS style.webkitTransition is 'none'

Modified: trunk/LayoutTests/transitions/transitions-parsing.html (268563 => 268564)


--- trunk/LayoutTests/transitions/transitions-parsing.html	2020-10-16 00:09:37 UTC (rev 268563)
+++ trunk/LayoutTests/transitions/transitions-parsing.html	2020-10-16 00:28:16 UTC (rev 268564)
@@ -30,8 +30,6 @@
 shouldBe("computedStyle.webkitTransitionProperty", "'all'");
 
 style.transitionProperty = "none";
-shouldNotBe("Object.keys(style).indexOf('transitionProperty')", "-1");
-shouldBe("Object.keys(style).indexOf('webkitTransitionProperty')", "-1");
 shouldBe("style.transitionProperty", "'none'");
 shouldBe("computedStyle.transitionProperty", "'none'");
 shouldBe("style.webkitTransitionProperty", "'none'");
@@ -176,8 +174,6 @@
 shouldBe("computedStyle.webkitTransitionDuration", "'0s'");
 
 style.transitionDuration = "0s";
-shouldNotBe("Object.keys(style).indexOf('transitionDuration')", "-1");
-shouldBe("Object.keys(style).indexOf('webkitTransitionDuration')", "-1");
 shouldBe("style.transitionDuration", "'0s'");
 shouldBe("computedStyle.transitionDuration", "'0s'");
 shouldBe("style.webkitTransitionDuration", "'0s'");
@@ -256,8 +252,6 @@
 shouldBe("computedStyle.webkitTransitionTimingFunction", "'ease'");
 
 style.transitionTimingFunction = "linear";
-shouldNotBe("Object.keys(style).indexOf('transitionTimingFunction')", "-1");
-shouldBe("Object.keys(style).indexOf('webkitTransitionTimingFunction')", "-1");
 shouldBe("style.transitionTimingFunction", "'linear'");
 shouldBe("computedStyle.transitionTimingFunction", "'linear'");
 shouldBe("style.webkitTransitionTimingFunction", "'linear'");
@@ -485,8 +479,6 @@
 shouldBe("computedStyle.webkitTransitionDelay", "'0s'");
 
 style.transitionDelay = "0s";
-shouldNotBe("Object.keys(style).indexOf('transitionDelay')", "-1");
-shouldBe("Object.keys(style).indexOf('webkitTransitionDelay')", "-1");
 shouldBe("style.transitionDelay", "'0s'");
 shouldBe("computedStyle.transitionDelay", "'0s'");
 shouldBe("style.webkitTransitionDelay", "'0s'");
@@ -565,8 +557,6 @@
 shouldBe("computedStyle.webkitTransition", "'all 0s ease 0s'");
 
 style.transition = "none";
-shouldNotBe("Object.keys(style).indexOf('transition')", "-1");
-shouldBe("Object.keys(style).indexOf('webkitTransition')", "-1");
 shouldBe("style.transition", "'none'");
 shouldBe("computedStyle.transition", "'none 0s ease 0s'");
 shouldBe("style.webkitTransition", "'none'");

Modified: trunk/Source/WebCore/CMakeLists.txt (268563 => 268564)


--- trunk/Source/WebCore/CMakeLists.txt	2020-10-16 00:09:37 UTC (rev 268563)
+++ trunk/Source/WebCore/CMakeLists.txt	2020-10-16 00:28:16 UTC (rev 268564)
@@ -1879,7 +1879,7 @@
 
 # Generate CSS property names
 add_custom_command(
-    OUTPUT ${WebCore_DERIVED_SOURCES_DIR}/CSSProperties.json ${WebCore_DERIVED_SOURCES_DIR}/CSSPropertyNames.h ${WebCore_DERIVED_SOURCES_DIR}/CSSPropertyNames.cpp ${WebCore_DERIVED_SOURCES_DIR}/CSSPropertyNames.gperf ${WebCore_DERIVED_SOURCES_DIR}/StyleBuilderGenerated.cpp ${WebCore_DERIVED_SOURCES_DIR}/StylePropertyShorthandFunctions.h ${WebCore_DERIVED_SOURCES_DIR}/StylePropertyShorthandFunctions.cpp
+    OUTPUT ${WebCore_DERIVED_SOURCES_DIR}/CSSProperties.json ${WebCore_DERIVED_SOURCES_DIR}/CSSPropertyNames.h ${WebCore_DERIVED_SOURCES_DIR}/CSSPropertyNames.cpp ${WebCore_DERIVED_SOURCES_DIR}/CSSPropertyNames.gperf ${WebCore_DERIVED_SOURCES_DIR}/StyleBuilderGenerated.cpp ${WebCore_DERIVED_SOURCES_DIR}/StylePropertyShorthandFunctions.h ${WebCore_DERIVED_SOURCES_DIR}/StylePropertyShorthandFunctions.cpp ${WebCore_DERIVED_SOURCES_DIR}/CSSStyleDeclaration+PropertyNames.idl
     MAIN_DEPENDENCY ${WEBCORE_DIR}/css/makeprop.pl
     DEPENDS ${WebCore_CSS_PROPERTY_NAMES}
     WORKING_DIRECTORY ${WebCore_DERIVED_SOURCES_DIR}
@@ -1889,6 +1889,7 @@
 list(APPEND WebCore_SOURCES ${WebCore_DERIVED_SOURCES_DIR}/CSSPropertyNames.cpp)
 list(APPEND WebCore_SOURCES ${WebCore_DERIVED_SOURCES_DIR}/StyleBuilderGenerated.cpp)
 list(APPEND WebCore_SOURCES ${WebCore_DERIVED_SOURCES_DIR}/StylePropertyShorthandFunctions.cpp)
+list(APPEND WebCore_IDL_FILES ${WebCore_DERIVED_SOURCES_DIR}/CSSStyleDeclaration+PropertyNames.idl)
 ADD_SOURCE_WEBCORE_DERIVED_DEPENDENCIES(${WEBCORE_DIR}/css/CSSParser.cpp CSSValueKeywords.h)
 
 # Generate CSS value keywords

Modified: trunk/Source/WebCore/ChangeLog (268563 => 268564)


--- trunk/Source/WebCore/ChangeLog	2020-10-16 00:09:37 UTC (rev 268563)
+++ trunk/Source/WebCore/ChangeLog	2020-10-16 00:28:16 UTC (rev 268564)
@@ -1,3 +1,67 @@
+2020-10-15  Sam Weinig  <[email protected]>
+
+        CSSStyleDeclaration breaks JS spec (properties not showing up in Object.getOwnPropertyNames)
+        https://bugs.webkit.org/show_bug.cgi?id=217623
+
+        Reviewed by Darin Adler.
+
+        Replace named getter/setter based implementation of access to CSSStyleDeclaration property values
+        with a generated partial interface that lists all the properties exactly.
+        
+        To keep things consistent with existing behavior, in addition to the spec'd properties, we also
+        maintain additional properties such as Epub* (in addition to the epub* properties the spec says
+        we should), and Css, css, Pos, pos, Pixel, and Pixel prefixed properties. As a follow up, we should
+        consider removing these as they are not supported by the standard or other browsers.
+
+        * CMakeLists.txt:
+        * DerivedSources-output.xcfilelist:
+        * DerivedSources.make:
+        Generate CSSStyleDeclaration+PropertyNames.idl and ensure it is compile together with the other
+        bindings.
+
+        * css/makeprop.pl:
+        Add generation of CSSStyleDeclaration+PropertyNames.idl from CSSProperties.json.
+
+        * bindings/scripts/IDLAttributes.json:
+        Remove CallNamedSetterOnlyForSupportedProperties and DefaultDefineOwnProperty extended attributes,
+        which now have no users, and add the CSSProperty extended attribute, used to avoid unnecessary
+        implementation overhead for each property. Rather, in an analogous way to EventHandlers, the bindings
+        now directly pass in the associate CSSPropertyID to an appropriate CSSStyleDeclaration function.
+
+        * bindings/scripts/CodeGeneratorJS.pm:
+        (GenerateInvokeNamedPropertySetter):
+        (GeneratePut):
+        (GeneratePutByIndex):
+        (GenerateDefineOwnProperty):
+        Remove all use of CallNamedSetterOnlyForSupportedProperties.
+
+        (InstanceOverridesDefineOwnProperty):
+        Remove support for DefaultDefineOwnProperty, which is now unused.
+
+        (ToMethodName):
+        Match the actual setting name, and don't transform names that start with CSSOM.
+
+        (GenerateAttributeGetterBodyDefinition):
+        (GenerateAttributeSetterBodyDefinition):
+        Add support for the new CSSProperty extended attribute which uses the passsed
+        value to to directly call CSSStyleDeclaration functions with a CSSPropertyID.
+
+        * css/CSSStyleDeclaration.cpp:
+        (WebCore::CSSStyleDeclaration::setPropertyValueInternal):
+        (WebCore::CSSStyleDeclaration::getPropertyValueInternalForPosOrPixelPrefixed):
+        (WebCore::CSSStyleDeclaration::setPropertyValueInternalForPosOrPixelPrefixed):
+        (WebCore::CSSStyleDeclaration::getCSSPropertyIDFromJavaScriptPropertyName):
+        (WebCore::CSSStyleDeclaration::namedItem): Deleted.
+        (WebCore::CSSStyleDeclaration::setNamedItem): Deleted.
+        (WebCore::CSSStyleDeclaration::supportedPropertyNames const): Deleted.
+        * css/CSSStyleDeclaration.h:
+        Replace old named getter/setter support code with new helpers which operate directly
+        on CSSPropertyIDs.
+
+        * css/CSSStyleDeclaration.idl:
+        Update to match the current spec (almost, still need to getPropertyPriority to not return
+        null) and remove custom named getter/setter operations.
+
 2020-10-15  Myles C. Maxfield  <[email protected]>
 
         [Cocoa] Don't change the text matrix multiple times inside FontCascade::drawGlyphs()

Modified: trunk/Source/WebCore/DerivedSources-output.xcfilelist (268563 => 268564)


--- trunk/Source/WebCore/DerivedSources-output.xcfilelist	2020-10-16 00:09:37 UTC (rev 268563)
+++ trunk/Source/WebCore/DerivedSources-output.xcfilelist	2020-10-16 00:28:16 UTC (rev 268564)
@@ -3,6 +3,7 @@
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/ByteLengthQueuingStrategyBuiltins.h
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/CSSPropertyNames.cpp
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/CSSPropertyNames.h
+$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/CSSStyleDeclaration+PropertyNames.idl
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/CSSValueKeywords.cpp
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/CSSValueKeywords.h
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/ColorData.cpp
@@ -290,6 +291,8 @@
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSCSSRule.h
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSCSSRuleList.cpp
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSCSSRuleList.h
+$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSCSSStyleDeclaration+PropertyNames.cpp
+$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSCSSStyleDeclaration+PropertyNames.h
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSCSSStyleDeclaration.cpp
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSCSSStyleDeclaration.h
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSCSSStyleRule.cpp

Modified: trunk/Source/WebCore/DerivedSources.make (268563 => 268564)


--- trunk/Source/WebCore/DerivedSources.make	2020-10-16 00:09:37 UTC (rev 268563)
+++ trunk/Source/WebCore/DerivedSources.make	2020-10-16 00:28:16 UTC (rev 268564)
@@ -1327,6 +1327,7 @@
     $(WebCore)/xml/XPathResult.idl \
     $(WebCore)/xml/XSLTProcessor.idl \
     InternalSettingsGenerated.idl \
+    CSSStyleDeclaration+PropertyNames.idl \
 #
 
 # --------
@@ -1418,6 +1419,7 @@
     StyleBuilderGenerated.cpp \
     StylePropertyShorthandFunctions.cpp \
     StylePropertyShorthandFunctions.h \
+    CSSStyleDeclaration+PropertyNames.idl \
     UserAgentStyleSheets.h \
     WebKitFontFamilyNames.cpp \
     WebKitFontFamilyNames.h \
@@ -1445,6 +1447,7 @@
     StyleBuilderGenerated.cpp \
     StylePropertyShorthandFunctions.cpp \
     StylePropertyShorthandFunctions.h \
+    CSSStyleDeclaration+PropertyNames.idl \
 #
 CSS_PROPERTY_NAME_FILES_PATTERNS = $(subst .,%,$(CSS_PROPERTY_NAME_FILES))
 

Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm (268563 => 268564)


--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm	2020-10-16 00:09:37 UTC (rev 268563)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm	2020-10-16 00:28:16 UTC (rev 268564)
@@ -1187,8 +1187,6 @@
     push(@$outputArray, $indent . "auto nativeValue = ${nativeValue};\n");
     push(@$outputArray, $indent . "RETURN_IF_EXCEPTION(throwScope, true);\n");
 
-    push(@$outputArray, $indent . "bool isPropertySupported = true;\n") if $namedSetterOperation->extendedAttributes->{CallNamedSetterOnlyForSupportedProperties};
-
     my $namedSetterFunctionName = $namedSetterOperation->name || "setNamedItem";
     my $nativeValuePassExpression = PassArgumentExpression("nativeValue", $argument);
 
@@ -1195,7 +1193,6 @@
     my @arguments = ();
     push(@arguments, "propertyNameToString(propertyName)");
     push(@arguments, $nativeValuePassExpression);
-    push(@arguments, "isPropertySupported") if $namedSetterOperation->extendedAttributes->{CallNamedSetterOnlyForSupportedProperties};
 
     my $functionString = "thisObject->wrapped().${namedSetterFunctionName}(" . join(", ", @arguments) . ")";
     push(@$outputArray, $indent . "invokeFunctorPropagatingExceptionIfNecessary(*lexicalGlobalObject, throwScope, [&] { return ${functionString}; });\n");
@@ -1250,10 +1247,6 @@
         }
 
         GenerateInvokeNamedPropertySetter($outputArray, $additionalIndent . "        ", $interface, $namedSetterOperation, "value");
-        if ($namedSetterOperation->extendedAttributes->{CallNamedSetterOnlyForSupportedProperties}) {
-            push(@$outputArray, $additionalIndent . "        if (!isPropertySupported)\n");
-            push(@$outputArray, $additionalIndent . "            return JSObject::put(thisObject, lexicalGlobalObject, propertyName, value, putPropertySlot);\n");
-        }
         push(@$outputArray, $additionalIndent . "        return true;\n");
 
         if (!$legacyOverrideBuiltins) {
@@ -1286,7 +1279,7 @@
     my $indexedSetterOperation = GetIndexedSetterOperation($interface);
     
     my $legacyOverrideBuiltins = $codeGenerator->InheritsExtendedAttribute($interface, "LegacyOverrideBuiltIns");
-    my $ellidesCallsToBase = ($namedSetterOperation && $legacyOverrideBuiltins) && !$interface->extendedAttributes->{Plugin} && !$namedSetterOperation->extendedAttributes->{CallNamedSetterOnlyForSupportedProperties};
+    my $ellidesCallsToBase = ($namedSetterOperation && $legacyOverrideBuiltins) && !$interface->extendedAttributes->{Plugin};
     
     push(@$outputArray, "bool ${className}::putByIndex(JSCell* cell, JSGlobalObject* lexicalGlobalObject, unsigned index, JSValue value, bool" . (!$ellidesCallsToBase ? " shouldThrow" : "") . ")\n");
     push(@$outputArray, "{\n");
@@ -1328,10 +1321,6 @@
         }
         
         GenerateInvokeNamedPropertySetter($outputArray, $additionalIndent . "    ", $interface, $namedSetterOperation, "value");
-        if ($namedSetterOperation->extendedAttributes->{CallNamedSetterOnlyForSupportedProperties}) {
-            push(@$outputArray, $additionalIndent . "    if (!isPropertySupported)\n");
-            push(@$outputArray, $additionalIndent . "        return JSObject::putByIndex(cell, lexicalGlobalObject, index, value, shouldThrow);\n");
-        }
         push(@$outputArray, $additionalIndent . "    return true;\n");
         
         if (!$legacyOverrideBuiltins) {
@@ -1475,10 +1464,7 @@
             
             # 2.2.2. Invoke the named property setter with P and Desc.[[Value]].
             GenerateInvokeNamedPropertySetter($outputArray, $additionalIndent . "        ", $interface, $namedSetterOperation, "propertyDescriptor.value()");
-            if ($namedSetterOperation->extendedAttributes->{CallNamedSetterOnlyForSupportedProperties}) {
-                push(@$outputArray, $additionalIndent . "    if (!isPropertySupported)\n");
-                push(@$outputArray, $additionalIndent . "        return JSObject::defineOwnProperty(object, lexicalGlobalObject, propertyName, propertyDescriptor, shouldThrow);\n");
-            }
+
             # 2.2.3. Return true.
             push(@$outputArray, $additionalIndent . "        return true;\n");
         }
@@ -2204,8 +2190,6 @@
 {
     my $interface = shift;
 
-    return 0 if $interface->extendedAttributes->{DefaultDefineOwnProperty};
-
     return $interface->extendedAttributes->{CustomDefineOwnProperty}
         || GetIndexedSetterOperation($interface)
         || GetNamedSetterOperation($interface);
@@ -3979,6 +3963,9 @@
 sub ToMethodName
 {
     my $param = shift;
+    
+    return $param if $param =~ /^CSSOM/;
+
     my $ret = lcfirst($param);
     $ret =~ s/cSS/css/ if $ret =~ /^cSS/;
     $ret =~ s/dOM/dom/ if $ret =~ /^dOM/;
@@ -5322,6 +5309,15 @@
             AddToImplIncludes("JS" . $constructorType . ".h", $conditional);
             push(@$outputArray, "    return JS" . $constructorType . "::${constructorGetter}(JSC::getVM(&lexicalGlobalObject), thisObject.globalObject());\n");
         }
+    } elsif ($attribute->extendedAttributes->{CSSProperty}) {
+        $implIncludes{"CSSPropertyNames.h"} = 1;
+        my $propertyID = $attribute->extendedAttributes->{CSSProperty};
+        
+        my $getterName = $attribute->type->isUnion ? "getPropertyValueInternalForPosOrPixelPrefixed" : "getPropertyValueInternal";
+        
+        my $toJSExpression = NativeToJSValueUsingReferences($attribute, $interface, "impl.${getterName}(CSSProperty${propertyID})", "*thisObject.globalObject()");
+        push(@$outputArray, "    auto& impl = thisObject.wrapped();\n");
+        push(@$outputArray, "    RELEASE_AND_RETURN(throwScope, (${toJSExpression}));\n");
     } else {
         if ($attribute->extendedAttributes->{CachedAttribute}) {
             push(@$outputArray, "    if (JSValue cachedValue = thisObject.m_" . $attribute->name . ".get())\n");
@@ -5466,6 +5462,23 @@
         push(@$outputArray, "    vm.heap.writeBarrier(&thisObject, value);\n");
         push(@$outputArray, "    ensureStillAliveHere(value);\n\n");
         push(@$outputArray, "    return true;\n");
+    } elsif ($attribute->extendedAttributes->{CSSProperty}) {
+        $implIncludes{"CSSPropertyNames.h"} = 1;
+
+        my $propertyID = $attribute->extendedAttributes->{CSSProperty};
+        
+        my $setterName = $attribute->type->isUnion ? "setPropertyValueInternalForPosOrPixelPrefixed" : "setPropertyValueInternal";
+        
+        my $exceptionThrower = GetAttributeExceptionThrower($interface, $attribute);
+        my $toNativeExpression = JSValueToNative($interface, $attribute, "value", $attribute->extendedAttributes->{Conditional}, "&lexicalGlobalObject", "lexicalGlobalObject", "thisObject", "*thisObject.globalObject()", $exceptionThrower);
+
+        push(@$outputArray, "    auto& impl = thisObject.wrapped();\n");
+        push(@$outputArray, "    auto nativeValue = ${toNativeExpression};\n");
+        push(@$outputArray, "    RETURN_IF_EXCEPTION(throwScope, false);\n");
+        push(@$outputArray, "    AttributeSetter::call(lexicalGlobalObject, throwScope, [&] {\n");
+        push(@$outputArray, "        return impl.${setterName}(CSSProperty${propertyID}, WTFMove(nativeValue));\n");
+        push(@$outputArray, "    });\n");
+        push(@$outputArray, "    return true;\n");
     } elsif ($isConstructor) {
         my $constructorType = $attribute->type->name;
         $constructorType =~ s/Constructor$//;

Modified: trunk/Source/WebCore/bindings/scripts/IDLAttributes.json (268563 => 268564)


--- trunk/Source/WebCore/bindings/scripts/IDLAttributes.json	2020-10-16 00:09:37 UTC (rev 268563)
+++ trunk/Source/WebCore/bindings/scripts/IDLAttributes.json	2020-10-16 00:28:16 UTC (rev 268564)
@@ -39,6 +39,10 @@
                 "url": "https://html.spec.whatwg.org/multipage/custom-elements.html#cereactions"
             }
         },
+        "CSSProperty": {
+            "contextsAllowed": ["attribute"],
+            "values": ["*"]
+        },
         "CachedAttribute": {
             "contextsAllowed": ["attribute"]
         },
@@ -49,9 +53,6 @@
         "CallbackThisObject": {
             "contextsAllowed": ["callback-function", "operation"]
         },
-        "CallNamedSetterOnlyForSupportedProperties": {
-            "contextsAllowed": ["operation"]
-        },
         "CallWith": {
             "contextsAllowed": ["attribute", "operation"],
             "values": ["Document", "ExecState", "ScriptExecutionContext", "GlobalObject", "ActiveWindow", "FirstWindow", "ResponsibleDocument", "World"],
@@ -157,9 +158,6 @@
         "Default": {
             "contextsAllowed": ["operation"]
         },
-        "DefaultDefineOwnProperty": {
-            "contextsAllowed": ["interface"]
-        },
         "DisabledByQuirk": {
             "contextsAllowed": ["interface", "dictionary", "enum", "attribute", "operation", "constant", "dictionary-member", "includes"],
             "values": ["*"],

Modified: trunk/Source/WebCore/css/CSSStyleDeclaration.cpp (268563 => 268564)


--- trunk/Source/WebCore/css/CSSStyleDeclaration.cpp	2020-10-16 00:09:37 UTC (rev 268563)
+++ trunk/Source/WebCore/css/CSSStyleDeclaration.cpp	2020-10-16 00:28:16 UTC (rev 268564)
@@ -268,48 +268,8 @@
 
 }
 
-CSSPropertyID CSSStyleDeclaration::getCSSPropertyIDFromJavaScriptPropertyName(const AtomString& propertyName)
+ExceptionOr<void> CSSStyleDeclaration::setPropertyValueInternal(CSSPropertyID propertyID, String value)
 {
-    return propertyInfoFromJavaScriptCSSPropertyName(propertyName, nullptr).propertyID;
-}
-
-Optional<Variant<String, double>> CSSStyleDeclaration::namedItem(const AtomString& propertyName)
-{
-    auto* settings = parentElement() ? &parentElement()->document().settings() : nullptr;
-    auto propertyInfo = propertyInfoFromJavaScriptCSSPropertyName(propertyName, settings);
-    if (!propertyInfo.propertyID)
-        return WTF::nullopt;
-
-    auto value = getPropertyCSSValueInternal(propertyInfo.propertyID);
-    if (!value) {
-        // If the property is a shorthand property (such as "padding"), it can only be accessed using getPropertyValue.
-        return Variant<String, double> { getPropertyValueInternal(propertyInfo.propertyID) };
-    }
-    
-    if (propertyInfo.hadPixelOrPosPrefix && is<CSSPrimitiveValue>(*value)) {
-        // Call this version of the getter so that, e.g., pixelTop returns top as a number
-        // in pixel units and posTop should does the same _if_ this is a positioned element.
-        // FIXME: If not a positioned element, MSIE documentation says posTop should return 0; this rule is not implemented.
-        return Variant<String, double> { downcast<CSSPrimitiveValue>(*value).floatValue(CSSUnitType::CSS_PX) };
-    }
-
-    return Variant<String, double> { value->cssText() };
-}
-
-ExceptionOr<void> CSSStyleDeclaration::setNamedItem(const AtomString& propertyName, String value, bool& propertySupported)
-{
-    auto* settings = parentElement() ? &parentElement()->document().settings() : nullptr;
-    auto propertyInfo = propertyInfoFromJavaScriptCSSPropertyName(propertyName, settings);
-    if (!propertyInfo.propertyID) {
-        propertySupported = false;
-        return { };
-    }
-
-    propertySupported = true;
-
-    if (propertyInfo.hadPixelOrPosPrefix)
-        value.append("px");
-
     bool important = false;
     if (DeprecatedGlobalSettings::shouldRespectPriorityInCSSAttributeSetters()) {
         auto importantIndex = value.findIgnoringASCIICase("!important");
@@ -319,7 +279,7 @@
         }
     }
 
-    auto setPropertyInternalResult = setPropertyInternal(propertyInfo.propertyID, value, important);
+    auto setPropertyInternalResult = setPropertyInternal(propertyID, value, important);
     if (setPropertyInternalResult.hasException())
         return setPropertyInternalResult.releaseException();
 
@@ -326,33 +286,38 @@
     return { };
 }
 
-Vector<AtomString> CSSStyleDeclaration::supportedPropertyNames() const
+Variant<double, String> CSSStyleDeclaration::getPropertyValueInternalForPosOrPixelPrefixed(CSSPropertyID propertyID)
 {
-    static unsigned numNames = 0;
-    static const AtomString* const cssPropertyNames = [] {
-        String names[numCSSProperties];
-        for (int i = 0; i < numCSSProperties; ++i) {
-            CSSPropertyID id = static_cast<CSSPropertyID>(firstCSSProperty + i);
-            // FIXME: Should take account for flags in settings().
-            if (isEnabledCSSProperty(id))
-                names[numNames++] = getJSPropertyName(id);
-        }
-        std::sort(&names[0], &names[numNames], WTF::codePointCompareLessThan);
-        auto* identifiers = new AtomString[numNames];
-        for (unsigned i = 0; i < numNames; ++i)
-            identifiers[i] = names[i];
-        return identifiers;
-    }();
+    auto value = getPropertyCSSValueInternal(propertyID);
+    if (!value) {
+        // If the property is a shorthand property (such as "padding"), it can only be accessed using getPropertyValue.
+        return getPropertyValueInternal(propertyID);
+    }
+    
+    if (is<CSSPrimitiveValue>(*value)) {
+        // Call this version of the getter so that, e.g., pixelTop returns top as a number
+        // in pixel units and posTop should does the same _if_ this is a positioned element.
+        // FIXME: If not a positioned element, MSIE documentation says posTop should return 0; this rule is not implemented.
+        return downcast<CSSPrimitiveValue>(*value).floatValue(CSSUnitType::CSS_PX);
+    }
 
-    Vector<AtomString> result;
-    result.reserveInitialCapacity(numNames);
+    return value->cssText();
+}
 
-    for (unsigned i = 0; i < numNames; ++i)
-        result.uncheckedAppend(cssPropertyNames[i]);
+ExceptionOr<void> CSSStyleDeclaration::setPropertyValueInternalForPosOrPixelPrefixed(CSSPropertyID propertyID, Variant<double, String> value)
+{
+    auto stringValue = WTF::switchOn(value, [&] (const auto& input) {
+        return makeString(input, "px");
+    });
 
-    return result;
+    return setPropertyValueInternal(propertyID, WTFMove(stringValue));
 }
 
+CSSPropertyID CSSStyleDeclaration::getCSSPropertyIDFromJavaScriptPropertyName(const AtomString& propertyName)
+{
+    return propertyInfoFromJavaScriptCSSPropertyName(propertyName, nullptr).propertyID;
+}
+
 String CSSStyleDeclaration::cssFloat()
 {
     return getPropertyValueInternal(CSSPropertyFloat);

Modified: trunk/Source/WebCore/css/CSSStyleDeclaration.h (268563 => 268564)


--- trunk/Source/WebCore/css/CSSStyleDeclaration.h	2020-10-16 00:09:37 UTC (rev 268563)
+++ trunk/Source/WebCore/css/CSSStyleDeclaration.h	2020-10-16 00:28:16 UTC (rev 268564)
@@ -72,12 +72,12 @@
 
     virtual CSSStyleSheet* parentStyleSheet() const { return nullptr; }
 
-    // Bindings support.
-    Optional<Variant<String, double>> namedItem(const AtomString&);
-    ExceptionOr<void> setNamedItem(const AtomString& name, String value, bool& propertySupported);
-    Vector<AtomString> supportedPropertyNames() const;
+    ExceptionOr<void> setPropertyValueInternal(CSSPropertyID, String);
+    Variant<double, String> getPropertyValueInternalForPosOrPixelPrefixed(CSSPropertyID);
+    ExceptionOr<void> setPropertyValueInternalForPosOrPixelPrefixed(CSSPropertyID, Variant<double, String>);
 
     static CSSPropertyID getCSSPropertyIDFromJavaScriptPropertyName(const AtomString&);
+
 protected:
     CSSStyleDeclaration() = default;
 };

Modified: trunk/Source/WebCore/css/CSSStyleDeclaration.idl (268563 => 268564)


--- trunk/Source/WebCore/css/CSSStyleDeclaration.idl	2020-10-16 00:09:37 UTC (rev 268563)
+++ trunk/Source/WebCore/css/CSSStyleDeclaration.idl	2020-10-16 00:28:16 UTC (rev 268564)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2006, 2007, 2009 Apple Inc. All rights reserved.
+ * Copyright (C) 2006, 2007, 2009, 2020 Apple Inc. All rights reserved.
  * Copyright (C) 2006 Samuel Weinig <[email protected]>
  *
  * This library is free software; you can redistribute it and/or
@@ -18,9 +18,10 @@
  * Boston, MA 02110-1301, USA.
  */
 
+typedef USVString CSSOMString;
+
 [
     ExportMacro=WEBCORE_EXPORT,
-    DefaultDefineOwnProperty,
     GenerateIsReachable,
     JSCustomHeader,
     JSCustomMarkFunction,
@@ -27,31 +28,19 @@
     SkipVTableValidation,
     Exposed=Window
 ] interface CSSStyleDeclaration {
-    [CEReactions] attribute DOMString cssText;
-
-    DOMString getPropertyValue(DOMString propertyName);
-
-    [CEReactions, MayThrowException] DOMString removeProperty(DOMString propertyName);
-    DOMString? getPropertyPriority(DOMString propertyName);
-
-    [CEReactions, MayThrowException] undefined setProperty(DOMString propertyName, [LegacyNullToEmptyString] DOMString value, optional [LegacyNullToEmptyString] DOMString priority = "");
-
+    [CEReactions] attribute CSSOMString cssText;
     readonly attribute unsigned long length;
-    getter DOMString item(unsigned long index);
+    getter CSSOMString item(unsigned long index);
+    CSSOMString getPropertyValue(CSSOMString property);
+    // FIXME: The return value of 'getPropertyPriority' should not be nullable.
+    CSSOMString? getPropertyPriority(CSSOMString property);
+    [CEReactions, MayThrowException] undefined setProperty(CSSOMString property, [LegacyNullToEmptyString] CSSOMString value, optional [LegacyNullToEmptyString] CSSOMString priority = "");
+    [CEReactions, MayThrowException] CSSOMString removeProperty(CSSOMString property);
     readonly attribute CSSRule? parentRule;
+    [CEReactions] attribute [LegacyNullToEmptyString] CSSOMString cssFloat;
 
-    [CEReactions] attribute [LegacyNullToEmptyString] DOMString cssFloat;
-
+    // Non-standard.
     DOMString? getPropertyShorthand(optional DOMString propertyName);
     boolean isPropertyImplicit(optional DOMString propertyName);
-
-    // Use named getters/setters for all support CSS property names. The spec says
-    // these should be normal attributes, but there are too many combinations with
-    // prefixes for this to be practical. If we remove legacy aliases, we should
-    // reconsider this decision.
-    getter (DOMString or double) (DOMString name);
-    [CEReactions, CallNamedSetterOnlyForSupportedProperties] setter undefined (DOMString name, [LegacyNullToEmptyString] DOMString value);
-
-    // This method is deprecated, and we would like to drop support for it someday
     DeprecatedCSSOMValue? getPropertyCSSValue(DOMString propertyName);
 };

Modified: trunk/Source/WebCore/css/makeprop.pl (268563 => 268564)


--- trunk/Source/WebCore/css/makeprop.pl	2020-10-16 00:09:37 UTC (rev 268563)
+++ trunk/Source/WebCore/css/makeprop.pl	2020-10-16 00:28:16 UTC (rev 268564)
@@ -1358,3 +1358,175 @@
     $gperf = $ENV{GPERF} ? $ENV{GPERF} : "gperf";
 }
 system("\"$gperf\" --key-positions=\"*\" -D -n -s 2 CSSPropertyNames.gperf --output-file=CSSPropertyNames.cpp") == 0 || die "calling gperf failed: $?";
+
+
+# Generate CSSStyleDeclaration+PropertyNames.idl
+
+# https://drafts.csswg.org/cssom/#css-property-to-idl-attribute
+sub cssPropertyToIDLAttribute($$$)
+{
+    my $property = shift;
+    my $lowercaseFirst = shift;
+    my $uppercaseFirst = shift;
+
+    my $output = "";
+    my $uppercaseNext = $uppercaseFirst;
+
+    if ($lowercaseFirst) {
+        $property = substr($property, 1);
+    }
+
+    foreach my $character (split //, $property) {
+        if ($character eq "-") {
+            $uppercaseNext = 1;
+        } elsif ($uppercaseNext) {
+            $uppercaseNext = 0;
+            $output .= uc $character;
+        } else {
+            $output .= $character;
+        }
+    }
+    
+    return $output;
+}
+
+my %namesAndAliasesToName;
+foreach my $name (@names) {
+    if (grep { $_ eq $name } @internalProprerties) {
+        next;
+    }
+    $namesAndAliasesToName{$name} = $name;
+    for my $alias (@{$nameToAliases{$name}}) {
+        $namesAndAliasesToName{$alias} = $name;
+    }
+}
+my @namesAndAliases = sort keys(%namesAndAliasesToName);
+
+open CSS_STYLE_DECLARATION_PROPERTY_NAMES_IDL, ">", "CSSStyleDeclaration+PropertyNames.idl" or die "Could not open CSSStyleDeclaration+PropertyNames.idl for writing\n";
+print CSS_STYLE_DECLARATION_PROPERTY_NAMES_IDL << "EOF";
+// This file is automatically generated from $inputFile by the makeprop.pl script. Do not edit it.
+
+typedef USVString CSSOMString;
+
+partial interface CSSStyleDeclaration {
+EOF
+ 
+print CSS_STYLE_DECLARATION_PROPERTY_NAMES_IDL << "EOF";
+    // For each CSS property property that is a supported CSS property, the following
+    // partial interface applies where camel-cased attribute is obtained by running the
+    // CSS property to IDL attribute algorithm for property.
+    // Example: font-size -> element.style.fontSize
+    // Example: -webkit-transform -> element.style.WebkitTransform
+    // [CEReactions] attribute [LegacyNullToEmptyString] CSSOMString _camel_cased_attribute;
+EOF
+
+foreach my $nameOrAlias (@namesAndAliases) {
+    my $camelCasedAttributeName = cssPropertyToIDLAttribute($nameOrAlias, 0, 0);
+    my $name = $namesAndAliasesToName{$nameOrAlias};
+    my $propertyId = $nameToId{$namesAndAliasesToName{$name}};
+    
+    my @extendedAttributeValues = ("CSSProperty=${propertyId}");
+    push(@extendedAttributeValues, "EnabledBySetting=${settingsFlags{$name}}") if $settingsFlags{$name};
+    push(@extendedAttributeValues, "EnabledAtRuntime=${runtimeFlags{$name}}") if $runtimeFlags{$name};
+    my $extendedAttributes = join(", ", @extendedAttributeValues);
+
+    print CSS_STYLE_DECLARATION_PROPERTY_NAMES_IDL "    [CEReactions, ${extendedAttributes}] attribute [LegacyNullToEmptyString] CSSOMString ${camelCasedAttributeName};\n";
+}
+
+print CSS_STYLE_DECLARATION_PROPERTY_NAMES_IDL << "EOF";
+
+    // For each CSS property property that is a supported CSS property and that begins
+    // with the string -webkit-, the following partial interface applies where webkit-cased
+    // attribute is obtained by running the CSS property to IDL attribute algorithm for
+    // property, with the lowercase first flag set.
+    // Example: -webkit-transform -> element.style.webkitTransform
+    // [CEReactions] attribute [LegacyNullToEmptyString] CSSOMString _webkit_cased_attribute;
+EOF
+
+foreach my $nameOrAlias (grep { $_ =~ /^\-webkit\-/ } @namesAndAliases) {
+    my $webkitCasedAttributeName = cssPropertyToIDLAttribute($nameOrAlias, 1, 0);
+    my $name = $namesAndAliasesToName{$nameOrAlias};
+    my $propertyId = $nameToId{$namesAndAliasesToName{$name}};
+    
+    my @extendedAttributeValues = ("CSSProperty=${propertyId}");
+    push(@extendedAttributeValues, "EnabledBySetting=${settingsFlags{$name}}") if $settingsFlags{$name};
+    push(@extendedAttributeValues, "EnabledAtRuntime=${runtimeFlags{$name}}") if $runtimeFlags{$name};
+    my $extendedAttributes = join(", ", @extendedAttributeValues);
+
+    print CSS_STYLE_DECLARATION_PROPERTY_NAMES_IDL "    [CEReactions, ${extendedAttributes}] attribute [LegacyNullToEmptyString] CSSOMString ${webkitCasedAttributeName};\n";
+}
+
+print CSS_STYLE_DECLARATION_PROPERTY_NAMES_IDL << "EOF";
+
+    // For each CSS property property that is a supported CSS property, except for
+    // properties that have no "-" (U+002D) in the property name, the following partial
+    // interface applies where dashed attribute is property.
+    // Example: font-size -> element.style['font-size']
+    // Example: -webkit-transform -> element.style.['-webkit-transform']
+    // [CEReactions] attribute [LegacyNullToEmptyString] CSSOMString _dashed_attribute;
+EOF
+foreach my $nameOrAlias (grep { $_ =~ /\-/ } @namesAndAliases) {
+    my $dashedAttributeName = $nameOrAlias;
+    my $name = $namesAndAliasesToName{$nameOrAlias};
+    my $propertyId = $nameToId{$namesAndAliasesToName{$name}};
+    
+    my @extendedAttributeValues = ("CSSProperty=${propertyId}");
+    push(@extendedAttributeValues, "EnabledBySetting=${settingsFlags{$name}}") if $settingsFlags{$name};
+    push(@extendedAttributeValues, "EnabledAtRuntime=${runtimeFlags{$name}}") if $runtimeFlags{$name};
+    my $extendedAttributes = join(", ", @extendedAttributeValues);
+
+    print CSS_STYLE_DECLARATION_PROPERTY_NAMES_IDL "    [CEReactions, ${extendedAttributes}] attribute [LegacyNullToEmptyString] CSSOMString ${dashedAttributeName};\n";
+}
+
+# Everything below here is non-standard.
+
+print CSS_STYLE_DECLARATION_PROPERTY_NAMES_IDL << "EOF";
+
+    // Non-standard. Special case properties starting with -epub- like is done for
+    // -webkit-, where attribute is obtained by running the CSS property to IDL attribute
+    // algorithm for property, with the lowercase first flag set.
+    // Example: -epub-caption-side -> element.style.epubCaptionSide
+EOF
+foreach my $nameOrAlias (grep { $_ =~ /^\-epub\-/ } @namesAndAliases) {
+    my $epubCasedAttributeName = cssPropertyToIDLAttribute($nameOrAlias, 1, 0);
+    my $name = $namesAndAliasesToName{$nameOrAlias};
+    my $propertyId = $nameToId{$namesAndAliasesToName{$name}};
+    
+    my @extendedAttributeValues = ("CSSProperty=${propertyId}");
+    push(@extendedAttributeValues, "EnabledBySetting=${settingsFlags{$name}}") if $settingsFlags{$name};
+    push(@extendedAttributeValues, "EnabledAtRuntime=${runtimeFlags{$name}}") if $runtimeFlags{$name};
+    my $extendedAttributes = join(", ", @extendedAttributeValues);
+
+    print CSS_STYLE_DECLARATION_PROPERTY_NAMES_IDL "    [CEReactions, ${extendedAttributes}] attribute [LegacyNullToEmptyString] CSSOMString ${epubCasedAttributeName};\n";
+}
+
+print CSS_STYLE_DECLARATION_PROPERTY_NAMES_IDL << "EOF";
+
+    // Non-standard. Add special cases for all properties not starting with -webkit- or -epub-
+    // that puts an new prefix of css, Css, pos, Pos, pixel and Pixel on each.
+    // Example top -> element.style.posTop
+    // Example top -> element.style.PixelTop
+EOF
+foreach my $nameOrAlias (grep { $_ !~ /^\-webkit\-|^\-epub\-/ } @namesAndAliases) {
+    my $camelCasedAttributeName = cssPropertyToIDLAttribute($nameOrAlias, 0, 1);
+    my $name = $namesAndAliasesToName{$nameOrAlias};
+    my $propertyId = $nameToId{$namesAndAliasesToName{$name}};
+    
+    my @extendedAttributeValues = ("CSSProperty=${propertyId}");
+    push(@extendedAttributeValues, "EnabledBySetting=${settingsFlags{$name}}") if $settingsFlags{$name};
+    push(@extendedAttributeValues, "EnabledAtRuntime=${runtimeFlags{$name}}") if $runtimeFlags{$name};
+    my $extendedAttributes = join(", ", @extendedAttributeValues);
+
+    print CSS_STYLE_DECLARATION_PROPERTY_NAMES_IDL "    [CEReactions, ${extendedAttributes}] attribute [LegacyNullToEmptyString] CSSOMString css${camelCasedAttributeName};\n" unless $camelCasedAttributeName eq "Float";
+    print CSS_STYLE_DECLARATION_PROPERTY_NAMES_IDL "    [CEReactions, ${extendedAttributes}] attribute [LegacyNullToEmptyString] CSSOMString Css${camelCasedAttributeName};\n" unless $camelCasedAttributeName eq "Float";
+    print CSS_STYLE_DECLARATION_PROPERTY_NAMES_IDL "    [CEReactions, ${extendedAttributes}] attribute (double or [LegacyNullToEmptyString] CSSOMString) pos${camelCasedAttributeName};\n";
+    print CSS_STYLE_DECLARATION_PROPERTY_NAMES_IDL "    [CEReactions, ${extendedAttributes}] attribute (double or [LegacyNullToEmptyString] CSSOMString) Pos${camelCasedAttributeName};\n";
+    print CSS_STYLE_DECLARATION_PROPERTY_NAMES_IDL "    [CEReactions, ${extendedAttributes}] attribute (double or [LegacyNullToEmptyString] CSSOMString) pixel${camelCasedAttributeName};\n";
+    print CSS_STYLE_DECLARATION_PROPERTY_NAMES_IDL "    [CEReactions, ${extendedAttributes}] attribute (double or [LegacyNullToEmptyString] CSSOMString) Pixel${camelCasedAttributeName};\n";
+}
+
+print CSS_STYLE_DECLARATION_PROPERTY_NAMES_IDL << "EOF";
+};
+EOF
+
+close CSS_STYLE_DECLARATION_PROPERTY_NAMES_IDL;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to