Title: [199316] trunk/Source/WebCore
Revision
199316
Author
[email protected]
Date
2016-04-11 16:00:02 -0700 (Mon, 11 Apr 2016)

Log Message

[WebIDL] Add support for [ImplementedAs] for EventHandler attributes
https://bugs.webkit.org/show_bug.cgi?id=156421

Reviewed by Darin Adler.

Add support for [ImplementedAs] for EventHandler attributes so we can
get rid of some ugly name hard-coding in the bindings generator.

* Modules/notifications/Notification.idl:
* bindings/scripts/CodeGeneratorJS.pm:
(EventHandlerAttributeEventName):
* bindings/scripts/test/JS/JSTestObj.cpp:
(WebCore::jsTestObjOnwebkitfoo):
(WebCore::setJSTestObjOnwebkitfoo):
* bindings/scripts/test/TestObj.idl:
* dom/Element.idl:
* page/DOMWindow.idl:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (199315 => 199316)


--- trunk/Source/WebCore/ChangeLog	2016-04-11 22:43:42 UTC (rev 199315)
+++ trunk/Source/WebCore/ChangeLog	2016-04-11 23:00:02 UTC (rev 199316)
@@ -1,3 +1,23 @@
+2016-04-11  Chris Dumez  <[email protected]>
+
+        [WebIDL] Add support for [ImplementedAs] for EventHandler attributes
+        https://bugs.webkit.org/show_bug.cgi?id=156421
+
+        Reviewed by Darin Adler.
+
+        Add support for [ImplementedAs] for EventHandler attributes so we can
+        get rid of some ugly name hard-coding in the bindings generator.
+
+        * Modules/notifications/Notification.idl:
+        * bindings/scripts/CodeGeneratorJS.pm:
+        (EventHandlerAttributeEventName):
+        * bindings/scripts/test/JS/JSTestObj.cpp:
+        (WebCore::jsTestObjOnwebkitfoo):
+        (WebCore::setJSTestObjOnwebkitfoo):
+        * bindings/scripts/test/TestObj.idl:
+        * dom/Element.idl:
+        * page/DOMWindow.idl:
+
 2016-04-11  Jeremy Jones  <[email protected]>
 
         When clearing cache, also clear AVFoundation cache.

Modified: trunk/Source/WebCore/Modules/notifications/Notification.idl (199315 => 199316)


--- trunk/Source/WebCore/Modules/notifications/Notification.idl	2016-04-11 22:43:42 UTC (rev 199315)
+++ trunk/Source/WebCore/Modules/notifications/Notification.idl	2016-04-11 23:00:02 UTC (rev 199316)
@@ -47,7 +47,7 @@
 
     attribute EventHandler onclick;
     attribute EventHandler onclose;
-    attribute EventHandler ondisplay;
+    [ImplementedAs=onshow] attribute EventHandler ondisplay;
     attribute EventHandler onerror;
     attribute EventHandler onshow;
 

Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm (199315 => 199316)


--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm	2016-04-11 22:43:42 UTC (rev 199315)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm	2016-04-11 23:00:02 UTC (rev 199316)
@@ -139,20 +139,11 @@
 sub EventHandlerAttributeEventName
 {
     my $attribute = shift;
+    my $eventType = $attribute->signature->extendedAttributes->{"ImplementedAs"} || $attribute->signature->name;
 
     # Remove the "on" prefix.
-    my $eventType = substr($attribute->signature->name, 2);
+    $eventType = substr($eventType, 2);
 
-    # FIXME: Consider adding a property in the IDL file instead of hard coding these names.
-
-    $eventType = "show" if $eventType eq "display";
-
-    # Note: These four names exist in HTMLElement.cpp.
-    $eventType = "webkitAnimationEnd" if $eventType eq "webkitanimationend";
-    $eventType = "webkitAnimationIteration" if $eventType eq "webkitanimationiteration";
-    $eventType = "webkitAnimationStart" if $eventType eq "webkitanimationstart";
-    $eventType = "webkitTransitionEnd" if $eventType eq "webkittransitionend";
-
     return "eventNames().${eventType}Event";
 }
 

Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp (199315 => 199316)


--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp	2016-04-11 22:43:42 UTC (rev 199315)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp	2016-04-11 23:00:02 UTC (rev 199316)
@@ -286,6 +286,8 @@
 bool setJSTestObjCustomAttr(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
 JSC::EncodedJSValue jsTestObjOnfoo(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
 bool setJSTestObjOnfoo(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
+JSC::EncodedJSValue jsTestObjOnwebkitfoo(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
+bool setJSTestObjOnwebkitfoo(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
 JSC::EncodedJSValue jsTestObjWithScriptStateAttribute(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
 bool setJSTestObjWithScriptStateAttribute(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
 JSC::EncodedJSValue jsTestObjWithCallWithAndSetterCallWithAttribute(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
@@ -585,6 +587,7 @@
     { 0, 0, NoIntrinsic, { 0, 0 } },
 #endif
     { "onfoo", CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjOnfoo), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTestObjOnfoo) } },
+    { "onwebkitfoo", CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjOnwebkitfoo), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTestObjOnwebkitfoo) } },
     { "withScriptStateAttribute", CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjWithScriptStateAttribute), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTestObjWithScriptStateAttribute) } },
     { "withCallWithAndSetterCallWithAttribute", CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjWithCallWithAndSetterCallWithAttribute), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTestObjWithCallWithAndSetterCallWithAttribute) } },
     { "withScriptExecutionContextAttribute", CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjWithScriptExecutionContextAttribute), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTestObjWithScriptExecutionContextAttribute) } },
@@ -1486,6 +1489,20 @@
 }
 
 
+EncodedJSValue jsTestObjOnwebkitfoo(ExecState* state, EncodedJSValue thisValue, PropertyName)
+{
+    UNUSED_PARAM(state);
+    UNUSED_PARAM(thisValue);
+    JSValue decodedThisValue = JSValue::decode(thisValue);
+    auto* castedThis = jsDynamicCast<JSTestObj*>(decodedThisValue);
+    if (UNLIKELY(!castedThis)) {
+        return throwGetterTypeError(*state, "TestObj", "onwebkitfoo");
+    }
+    UNUSED_PARAM(state);
+    return JSValue::encode(eventHandlerAttribute(castedThis->wrapped(), eventNames().fooEvent));
+}
+
+
 EncodedJSValue jsTestObjWithScriptStateAttribute(ExecState* state, EncodedJSValue thisValue, PropertyName)
 {
     UNUSED_PARAM(state);
@@ -2718,6 +2735,19 @@
 }
 
 
+bool setJSTestObjOnwebkitfoo(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
+{
+    JSValue value = JSValue::decode(encodedValue);
+    UNUSED_PARAM(thisValue);
+    JSTestObj* castedThis = jsDynamicCast<JSTestObj*>(JSValue::decode(thisValue));
+    if (UNLIKELY(!castedThis)) {
+        return throwSetterTypeError(*state, "TestObj", "onwebkitfoo");
+    }
+    setEventHandlerAttribute(*state, *castedThis, castedThis->wrapped(), eventNames().fooEvent, value);
+    return true;
+}
+
+
 bool setJSTestObjWithScriptStateAttribute(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
 {
     JSValue value = JSValue::decode(encodedValue);

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


--- trunk/Source/WebCore/bindings/scripts/test/TestObj.idl	2016-04-11 22:43:42 UTC (rev 199315)
+++ trunk/Source/WebCore/bindings/scripts/test/TestObj.idl	2016-04-11 23:00:02 UTC (rev 199316)
@@ -149,6 +149,7 @@
     void addEventListener(DOMString type, EventListener listener, optional boolean useCapture);
     void removeEventListener(DOMString type, EventListener listener, optional boolean useCapture);
     attribute EventHandler onfoo;
+    [ImplementedAs=onfoo] attribute EventHandler onwebkitfoo;
 
     // 'CallWith' extended attribute
     [CallWith=ScriptState] void withScriptStateVoid();

Modified: trunk/Source/WebCore/dom/Element.idl (199315 => 199316)


--- trunk/Source/WebCore/dom/Element.idl	2016-04-11 22:43:42 UTC (rev 199315)
+++ trunk/Source/WebCore/dom/Element.idl	2016-04-11 23:00:02 UTC (rev 199316)
@@ -196,10 +196,10 @@
     [NotEnumerable] attribute EventHandler onanimationiteration;
     [NotEnumerable] attribute EventHandler onanimationstart;
     [NotEnumerable] attribute EventHandler ontransitionend;
-    [NotEnumerable] attribute EventHandler onwebkitanimationend;
-    [NotEnumerable] attribute EventHandler onwebkitanimationiteration;
-    [NotEnumerable] attribute EventHandler onwebkitanimationstart;
-    [NotEnumerable] attribute EventHandler onwebkittransitionend;
+    [NotEnumerable, ImplementedAs=onwebkitAnimationEnd] attribute EventHandler onwebkitanimationend;
+    [NotEnumerable, ImplementedAs=onwebkitAnimationIteration] attribute EventHandler onwebkitanimationiteration;
+    [NotEnumerable, ImplementedAs=onwebkitAnimationStart] attribute EventHandler onwebkitanimationstart;
+    [NotEnumerable, ImplementedAs=onwebkitTransitionEnd] attribute EventHandler onwebkittransitionend;
     [NotEnumerable, Conditional=IOS_GESTURE_EVENTS] attribute EventHandler ongesturechange;
     [NotEnumerable, Conditional=IOS_GESTURE_EVENTS] attribute EventHandler ongestureend;
     [NotEnumerable, Conditional=IOS_GESTURE_EVENTS] attribute EventHandler ongesturestart;

Modified: trunk/Source/WebCore/page/DOMWindow.idl (199315 => 199316)


--- trunk/Source/WebCore/page/DOMWindow.idl	2016-04-11 22:43:42 UTC (rev 199315)
+++ trunk/Source/WebCore/page/DOMWindow.idl	2016-04-11 23:00:02 UTC (rev 199316)
@@ -212,10 +212,10 @@
     [NotEnumerable] attribute EventHandler onanimationiteration;
     [NotEnumerable] attribute EventHandler onanimationstart;
     [NotEnumerable] attribute EventHandler ontransitionend;
-    [NotEnumerable] attribute EventHandler onwebkitanimationend;
-    [NotEnumerable] attribute EventHandler onwebkitanimationiteration;
-    [NotEnumerable] attribute EventHandler onwebkitanimationstart;
-    [NotEnumerable] attribute EventHandler onwebkittransitionend;
+    [NotEnumerable, ImplementedAs=onwebkitAnimationEnd] attribute EventHandler onwebkitanimationend;
+    [NotEnumerable, ImplementedAs=onwebkitAnimationIteration] attribute EventHandler onwebkitanimationiteration;
+    [NotEnumerable, ImplementedAs=onwebkitAnimationStart] attribute EventHandler onwebkitanimationstart;
+    [NotEnumerable, ImplementedAs=onwebkitTransitionEnd] attribute EventHandler onwebkittransitionend;
     [NotEnumerable, Conditional=IOS_GESTURE_EVENTS] attribute EventHandler ongesturechange;
     [NotEnumerable, Conditional=IOS_GESTURE_EVENTS] attribute EventHandler ongestureend;
     [NotEnumerable, Conditional=IOS_GESTURE_EVENTS] attribute EventHandler ongesturestart;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to