Title: [276804] trunk/Source/WebCore
Revision
276804
Author
[email protected]
Date
2021-04-29 15:09:09 -0700 (Thu, 29 Apr 2021)

Log Message

[WebIDL] Remove [Reflect] support for constants
https://bugs.webkit.org/show_bug.cgi?id=225119

Reviewed by Sam Weinig.

While reflection of content attributes [1] is a well-known concept, using [Reflect] for
constants doesn't make much sense (as there is no HTML attribute involved) and introduces
conflicting semantics for its value: C++ enum identifier vs. HTML attribute name.

[ImplementedAs] extended attribute is a perfect fit for customizing C++ identifier;
this change expands it to constants. Using ERROR as enum identifier still breaks
Windows build due to #define conflict.

No new tests, no behavior change.

[1] https://html.spec.whatwg.org/multipage/common-dom-interfaces.html#reflecting-content-attributes-in-idl-attributes

* bindings/scripts/CodeGenerator.pm:
(GenerateCompileTimeCheckForEnumsIfNeeded):
* bindings/scripts/IDLAttributes.json:
* bindings/scripts/test/*: Updated.
* html/HTMLTrackElement.idl:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (276803 => 276804)


--- trunk/Source/WebCore/ChangeLog	2021-04-29 21:56:07 UTC (rev 276803)
+++ trunk/Source/WebCore/ChangeLog	2021-04-29 22:09:09 UTC (rev 276804)
@@ -1,3 +1,28 @@
+2021-04-29  Alexey Shvayka  <[email protected]>
+
+        [WebIDL] Remove [Reflect] support for constants
+        https://bugs.webkit.org/show_bug.cgi?id=225119
+
+        Reviewed by Sam Weinig.
+
+        While reflection of content attributes [1] is a well-known concept, using [Reflect] for
+        constants doesn't make much sense (as there is no HTML attribute involved) and introduces
+        conflicting semantics for its value: C++ enum identifier vs. HTML attribute name.
+
+        [ImplementedAs] extended attribute is a perfect fit for customizing C++ identifier;
+        this change expands it to constants. Using ERROR as enum identifier still breaks
+        Windows build due to #define conflict.
+
+        No new tests, no behavior change.
+
+        [1] https://html.spec.whatwg.org/multipage/common-dom-interfaces.html#reflecting-content-attributes-in-idl-attributes
+
+        * bindings/scripts/CodeGenerator.pm:
+        (GenerateCompileTimeCheckForEnumsIfNeeded):
+        * bindings/scripts/IDLAttributes.json:
+        * bindings/scripts/test/*: Updated.
+        * html/HTMLTrackElement.idl:
+
 2021-04-29  Aditya Keerthi  <[email protected]>
 
         REGRESSION (r275431): [iOS] fast/events/touch/ios/mouse-events-dispatch-with-touch.html is timing out

Modified: trunk/Source/WebCore/bindings/scripts/CodeGenerator.pm (276803 => 276804)


--- trunk/Source/WebCore/bindings/scripts/CodeGenerator.pm	2021-04-29 21:56:07 UTC (rev 276803)
+++ trunk/Source/WebCore/bindings/scripts/CodeGenerator.pm	2021-04-29 22:09:09 UTC (rev 276804)
@@ -1421,7 +1421,7 @@
     my @checks = ();
     foreach my $constant (@{$interface->constants}) {
         my $scope = $constant->extendedAttributes->{"ImplementedBy"} || $baseScope;
-        my $name = $constant->extendedAttributes->{"Reflect"} || $constant->name;
+        my $name = $constant->extendedAttributes->{"ImplementedAs"} || $constant->name;
         my $value = $constant->value;
         my $conditional = $constant->extendedAttributes->{"Conditional"};
         push(@checks, "#if " . $generator->GenerateConditionalStringFromAttributeValue($conditional) . "\n") if $conditional;

Modified: trunk/Source/WebCore/bindings/scripts/IDLAttributes.json (276803 => 276804)


--- trunk/Source/WebCore/bindings/scripts/IDLAttributes.json	2021-04-29 21:56:07 UTC (rev 276803)
+++ trunk/Source/WebCore/bindings/scripts/IDLAttributes.json	2021-04-29 22:09:09 UTC (rev 276804)
@@ -236,7 +236,7 @@
             "unsupported": true
         },
         "ImplementedAs": {
-            "contextsAllowed": ["interface", "dictionary", "dictionary-member", "enum", "attribute", "operation"],
+            "contextsAllowed": ["interface", "dictionary", "dictionary-member", "enum", "attribute", "operation", "constant"],
             "values": ["*"]
         },
         "ImplementedBy": {
@@ -415,7 +415,7 @@
             }
         },
         "Reflect": {
-            "contextsAllowed": ["attribute", "constant"],
+            "contextsAllowed": ["attribute"],
             "values": ["*"]
         },
         "Replaceable": {

Modified: trunk/Source/WebCore/bindings/scripts/test/TestLegacyNoInterfaceObject.idl (276803 => 276804)


--- trunk/Source/WebCore/bindings/scripts/test/TestLegacyNoInterfaceObject.idl	2021-04-29 21:56:07 UTC (rev 276803)
+++ trunk/Source/WebCore/bindings/scripts/test/TestLegacyNoInterfaceObject.idl	2021-04-29 22:09:09 UTC (rev 276804)
@@ -41,5 +41,5 @@
     static undefined staticOperation();
 
     const unsigned short CONSTANT1 = 1;
-    [Reflect=CONST_IMPL] const unsigned short CONSTANT2 = 2;
+    [ImplementedAs=CONST_IMPL] const unsigned short CONSTANT2 = 2;
 };

Modified: trunk/Source/WebCore/bindings/scripts/test/TestMixinInterface.idl (276803 => 276804)


--- trunk/Source/WebCore/bindings/scripts/test/TestMixinInterface.idl	2021-04-29 21:56:07 UTC (rev 276803)
+++ trunk/Source/WebCore/bindings/scripts/test/TestMixinInterface.idl	2021-04-29 22:09:09 UTC (rev 276804)
@@ -45,5 +45,5 @@
     [ResultField=nodes] sequence<Node> mixinResultFieldOperation();
 
     const unsigned short MIXIN_CONSTANT = 1;
-    [Reflect=CONST_IMPL] const unsigned short MIXIN_REFLECTED_CONSTANT = 2;
+    [ImplementedAs=CONST_IMPL] const unsigned short MIXIN_REFLECTED_CONSTANT = 2;
 };

Modified: trunk/Source/WebCore/bindings/scripts/test/TestObj.idl (276803 => 276804)


--- trunk/Source/WebCore/bindings/scripts/test/TestObj.idl	2021-04-29 21:56:07 UTC (rev 276803)
+++ trunk/Source/WebCore/bindings/scripts/test/TestObj.idl	2021-04-29 22:09:09 UTC (rev 276804)
@@ -372,7 +372,7 @@
     const unsigned short CONST_VALUE_12 = 0x01;
     const unsigned short CONST_VALUE_13 = 0X20;
     const unsigned short CONST_VALUE_14 = 0x1abc;
-    [Reflect=CONST_IMPL] const unsigned short CONST_JAVASCRIPT = 15;
+    [ImplementedAs=CONST_IMPL] const unsigned short CONST_JAVASCRIPT = 15;
 
     [Replaceable] readonly attribute long replaceableAttribute;
 

Modified: trunk/Source/WebCore/bindings/scripts/test/TestSupplemental.idl (276803 => 276804)


--- trunk/Source/WebCore/bindings/scripts/test/TestSupplemental.idl	2021-04-29 21:56:07 UTC (rev 276803)
+++ trunk/Source/WebCore/bindings/scripts/test/TestSupplemental.idl	2021-04-29 22:09:09 UTC (rev 276804)
@@ -47,7 +47,7 @@
     static undefined supplementalMethod4();
 
     const unsigned short SUPPLEMENTALCONSTANT1 = 1;
-    [Reflect=CONST_IMPL] const unsigned short SUPPLEMENTALCONSTANT2 = 2;
+    [ImplementedAs=CONST_IMPL] const unsigned short SUPPLEMENTALCONSTANT2 = 2;
 
     [JSBuiltin] undefined builtinFunction();
     [JSBuiltin] attribute unsigned short builtinAttribute;

Modified: trunk/Source/WebCore/html/HTMLTrackElement.idl (276803 => 276804)


--- trunk/Source/WebCore/html/HTMLTrackElement.idl	2021-04-29 21:56:07 UTC (rev 276803)
+++ trunk/Source/WebCore/html/HTMLTrackElement.idl	2021-04-29 22:09:09 UTC (rev 276804)
@@ -37,8 +37,8 @@
     const unsigned short NONE = 0;
     const unsigned short LOADING = 1;
     const unsigned short LOADED = 2;
-    // Reflect is used for ERROR because it conflicts with a windows define.
-    [Reflect=TRACK_ERROR] const unsigned short ERROR = 3;
+    // Using ERROR as enum identifier breaks Windows build due to #define conflict.
+    [ImplementedAs=TRACK_ERROR] const unsigned short ERROR = 3;
     readonly attribute unsigned short readyState;
 
     readonly attribute TextTrack track;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to