Title: [94480] trunk
Revision
94480
Author
[email protected]
Date
2011-09-02 23:04:21 -0700 (Fri, 02 Sep 2011)

Log Message

Implement a CustomEvent constructor for V8
https://bugs.webkit.org/show_bug.cgi?id=67527

Patch by Kentaro Hara <[email protected]> on 2011-09-02
Reviewed by Sam Weinig.

Source/WebCore:

Test: fast/events/constructors/custom-event-constructor.html

* bindings/v8/OptionsObject.h:
(WebCore::OptionsObject::getKeyValue): Returns ScriptValue corresponding to a given key.
* bindings/v8/custom/V8EventConstructors.cpp: Added the CustomEvent constructor.
* dom/CustomEvent.idl: Added a 'V8CustomConstructor' attribute.

LayoutTests:

* platform/chromium/fast/events/constructors/custom-event-constructor-expected.txt: Updated the result.

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (94479 => 94480)


--- trunk/LayoutTests/ChangeLog	2011-09-03 05:45:08 UTC (rev 94479)
+++ trunk/LayoutTests/ChangeLog	2011-09-03 06:04:21 UTC (rev 94480)
@@ -1,3 +1,12 @@
+2011-09-02  Kentaro Hara  <[email protected]>
+
+        Implement a CustomEvent constructor for V8
+        https://bugs.webkit.org/show_bug.cgi?id=67527
+
+        Reviewed by Sam Weinig.
+
+        * platform/chromium/fast/events/constructors/custom-event-constructor-expected.txt: Updated the result.
+
 2011-09-02  Chris Marrin  <[email protected]>
 
         https://bugs.webkit.org/show_bug.cgi?id=67510

Modified: trunk/LayoutTests/platform/chromium/fast/events/constructors/custom-event-constructor-expected.txt (94479 => 94480)


--- trunk/LayoutTests/platform/chromium/fast/events/constructors/custom-event-constructor-expected.txt	2011-09-03 05:45:08 UTC (rev 94479)
+++ trunk/LayoutTests/platform/chromium/fast/events/constructors/custom-event-constructor-expected.txt	2011-09-03 06:04:21 UTC (rev 94480)
@@ -6,15 +6,15 @@
 PASS new CustomEvent('eventType').bubbles is false
 PASS new CustomEvent('eventType').cancelable is false
 FAIL new CustomEvent('eventType').detail should be null (of type object). Was undefined (of type undefined).
-FAIL new CustomEvent('eventType', { bubbles: true, cancelable: true }).bubbles should be true. Was false.
-FAIL new CustomEvent('eventType', { bubbles: true, cancelable: true }).cancelable should be true. Was false.
+PASS new CustomEvent('eventType', { bubbles: true, cancelable: true }).bubbles is true
+PASS new CustomEvent('eventType', { bubbles: true, cancelable: true }).cancelable is true
 FAIL new CustomEvent('eventType', { bubbles: true, cancelable: true }).detail should be null (of type object). Was undefined (of type undefined).
-FAIL new CustomEvent('eventType', { detail: 10 }).detail should be 10 (of type number). Was undefined (of type undefined).
-FAIL new CustomEvent('eventType', { detail: 'string' }).detail should be string (of type string). Was undefined (of type undefined).
-FAIL new CustomEvent('eventType', { detail: detailObject }).detail should be [object Object] (of type object). Was undefined (of type undefined).
-FAIL new CustomEvent('eventType', { detail: document }).detail should be [object HTMLDocument] (of type object). Was undefined (of type undefined).
-FAIL new CustomEvent('eventType', { get detail() { return true; } }).detail should be true (of type boolean). Was undefined (of type undefined).
-FAIL new CustomEvent('eventType', { get detail() { throw 'Custom Error'; } }) should throw an exception. Was [object CustomEvent].
+PASS new CustomEvent('eventType', { detail: 10 }).detail is 10
+PASS new CustomEvent('eventType', { detail: 'string' }).detail is 'string'
+PASS new CustomEvent('eventType', { detail: detailObject }).detail is detailObject
+PASS new CustomEvent('eventType', { detail: document }).detail is document
+PASS new CustomEvent('eventType', { get detail() { return true; } }).detail is true
+PASS new CustomEvent('eventType', { get detail() { throw 'Custom Error'; } }) threw exception Custom Error.
 PASS successfullyParsed is true
 
 TEST COMPLETE

Modified: trunk/Source/WebCore/ChangeLog (94479 => 94480)


--- trunk/Source/WebCore/ChangeLog	2011-09-03 05:45:08 UTC (rev 94479)
+++ trunk/Source/WebCore/ChangeLog	2011-09-03 06:04:21 UTC (rev 94480)
@@ -1,3 +1,17 @@
+2011-09-02  Kentaro Hara  <[email protected]>
+
+        Implement a CustomEvent constructor for V8
+        https://bugs.webkit.org/show_bug.cgi?id=67527
+
+        Reviewed by Sam Weinig.
+
+        Test: fast/events/constructors/custom-event-constructor.html
+
+        * bindings/v8/OptionsObject.h:
+        (WebCore::OptionsObject::getKeyValue): Returns ScriptValue corresponding to a given key.
+        * bindings/v8/custom/V8EventConstructors.cpp: Added the CustomEvent constructor.
+        * dom/CustomEvent.idl: Added a 'V8CustomConstructor' attribute.
+
 2011-09-02  Adrienne Walker  <[email protected]>
 
         [chromium] Move updateLayers from LayerRendererChromium to CCLayerTreeHost

Modified: trunk/Source/WebCore/bindings/v8/OptionsObject.h (94479 => 94480)


--- trunk/Source/WebCore/bindings/v8/OptionsObject.h	2011-09-03 05:45:08 UTC (rev 94479)
+++ trunk/Source/WebCore/bindings/v8/OptionsObject.h	2011-09-03 06:04:21 UTC (rev 94480)
@@ -27,6 +27,7 @@
 #define OptionsObject_h
 
 #include "PlatformString.h"
+#include "ScriptValue.h"
 #include <v8.h>
 
 namespace WebCore {
@@ -67,7 +68,16 @@
     {
         return getKeyString(key, value);
     }
+    bool getKeyValue(const String& key, ScriptValue& value) const
+    {
+        v8::Local<v8::Value> v8Value;
+        if (!getKey(key, v8Value))
+            return false;
 
+        value = ScriptValue(v8Value);
+        return true;
+    }
+
 private:
     bool getKey(const String& key, v8::Local<v8::Value>&) const;
 

Modified: trunk/Source/WebCore/bindings/v8/custom/V8EventConstructors.cpp (94479 => 94480)


--- trunk/Source/WebCore/bindings/v8/custom/V8EventConstructors.cpp	2011-09-03 05:45:08 UTC (rev 94479)
+++ trunk/Source/WebCore/bindings/v8/custom/V8EventConstructors.cpp	2011-09-03 06:04:21 UTC (rev 94480)
@@ -31,6 +31,7 @@
 #include "config.h"
 #include "EventConstructors.h"
 
+#include "CustomEvent.h"
 #include "Document.h"
 #include "DocumentFragment.h"
 #include "Node.h"
@@ -38,6 +39,7 @@
 #include "OptionsObject.h"
 #include "V8Binding.h"
 #include "V8BindingMacros.h"
+#include "V8CustomEvent.h"
 #include "V8Document.h"
 #include "V8Event.h"
 #include "V8Node.h"
@@ -76,7 +78,7 @@
 }
 
 #define DICTIONARY_START(EventType) \
-    static bool fill##EventType##Init(Event##Init& eventInit, const OptionsObject& options) \
+    static bool fill##EventType##Init(EventType##Init& eventInit, const OptionsObject& options) \
     {
 
 #define DICTIONARY_END(EventType) \
@@ -85,17 +87,18 @@
     \
     v8::Handle<v8::Value> V8##EventType::constructorCallback(const v8::Arguments& args) \
     { \
-      return constructV8Event<EventType, EventType##Init>(args, fill##EventType##Init, &info); \
+        return constructV8Event<EventType, EventType##Init>(args, fill##EventType##Init, &info); \
     }
 
 #define FILL_PARENT_PROPERTIES(parentEventType) \
-    if (!fill##parentEventType##Init(eventInit)) \
+    if (!fill##parentEventType##Init(eventInit, options)) \
         return false;
 
 #define FILL_PROPERTY(propertyName) \
     options.getKeyValue(#propertyName, eventInit.propertyName); // This can fail but it is OK.
 
 INSTANTIATE_INITIALIZING_CONSTRUCTOR_FOR_EVENT(DICTIONARY_START, DICTIONARY_END, FILL_PARENT_PROPERTIES, FILL_PROPERTY)
+INSTANTIATE_INITIALIZING_CONSTRUCTOR_FOR_CUSTOM_EVENT(DICTIONARY_START, DICTIONARY_END, FILL_PARENT_PROPERTIES, FILL_PROPERTY)
 
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/dom/CustomEvent.idl (94479 => 94480)


--- trunk/Source/WebCore/dom/CustomEvent.idl	2011-09-03 05:45:08 UTC (rev 94479)
+++ trunk/Source/WebCore/dom/CustomEvent.idl	2011-09-03 06:04:21 UTC (rev 94480)
@@ -29,7 +29,8 @@
     // Introduced in DOM Level 3:
     interface [
         CanBeConstructed,
-        CustomConstructFunction
+        CustomConstructFunction,
+        V8CustomConstructor
     ] CustomEvent : Event {
 
        readonly attribute DOMObject detail;
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to