Implement MouseEvent constructor
authorharaken@chromium.org <haraken@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 24 Jan 2013 07:42:07 +0000 (07:42 +0000)
committerharaken@chromium.org <haraken@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 24 Jan 2013 07:42:07 +0000 (07:42 +0000)
https://bugs.webkit.org/show_bug.cgi?id=107630

Reviewed by Adam Barth.

Spec: https://dvcs.w3.org/hg/d4e/raw-file/tip/source_respec.htm

Source/WebCore:

The MouseEvent constructor should be implemented under a DOM4_EVENTS_CONSTRUCTOR flag.
This significantly simplifies JavaScript code to construct a MouseEvent.

Before:
  event = document.createEvent("MouseEvents");
  event.initMouseEvent("click", true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);

After:
  event = new MouseEvent("click");

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

* bindings/scripts/CodeGenerator.pm:
(IsSubType):
(IsInheritExtendedAttribute):
* bindings/scripts/CodeGeneratorV8.pm:
(GenerateHeader):
(GenerateNamedConstructorCallback):
(GenerateImplementation):
* bindings/scripts/test/V8/V8Float64Array.cpp:
(WebCore):
(WebCore::V8Float64Array::createWrapper):
* bindings/scripts/test/V8/V8TestActiveDOMObject.cpp:
(WebCore):
(WebCore::V8TestActiveDOMObject::createWrapper):
* bindings/scripts/test/V8/V8TestCustomNamedGetter.cpp:
(WebCore):
(WebCore::V8TestCustomNamedGetter::createWrapper):
* bindings/scripts/test/V8/V8TestEventConstructor.cpp:
(WebCore):
(WebCore::V8TestEventConstructor::createWrapper):
* bindings/scripts/test/V8/V8TestEventTarget.cpp:
(WebCore):
(WebCore::V8TestEventTarget::toEventTarget):
(WebCore::V8TestEventTarget::createWrapper):
* bindings/scripts/test/V8/V8TestEventTarget.h:
(V8TestEventTarget):
* bindings/scripts/test/V8/V8TestException.cpp:
(WebCore):
(WebCore::V8TestException::createWrapper):
* bindings/scripts/test/V8/V8TestInterface.cpp:
(WebCore):
(WebCore::V8TestInterface::toActiveDOMObject):
(WebCore::V8TestInterface::createWrapper):
* bindings/scripts/test/V8/V8TestMediaQueryListListener.cpp:
(WebCore):
(WebCore::V8TestMediaQueryListListener::createWrapper):
* bindings/scripts/test/V8/V8TestNamedConstructor.cpp:
(WebCore):
(WebCore::V8TestNamedConstructor::toActiveDOMObject):
(WebCore::V8TestNamedConstructor::createWrapper):
* bindings/scripts/test/V8/V8TestNode.cpp:
(WebCore):
(WebCore::V8TestNode::toEventTarget):
(WebCore::V8TestNode::createWrapper):
* bindings/scripts/test/V8/V8TestNode.h:
(V8TestNode):
* bindings/scripts/test/V8/V8TestObj.cpp:
(WebCore):
(WebCore::V8TestObj::createWrapper):
* bindings/scripts/test/V8/V8TestOverloadedConstructors.cpp:
(WebCore):
(WebCore::V8TestOverloadedConstructors::createWrapper):
* bindings/scripts/test/V8/V8TestSerializedScriptValueInterface.cpp:
(WebCore):
(WebCore::V8TestSerializedScriptValueInterface::createWrapper):
* bindings/v8/Dictionary.cpp:
(WebCore::Dictionary::get):
(WebCore):
* bindings/v8/Dictionary.h:
(Dictionary):
* bindings/v8/NPV8Object.cpp:
(WebCore::npObjectTypeInfo):
* bindings/v8/V8DOMWrapper.cpp:
(WebCore::V8DOMWrapper::isDOMWrapper):
(WebCore):
* bindings/v8/V8DOMWrapper.h:
(V8DOMWrapper):
* bindings/v8/WrapperTypeInfo.h:
(WebCore):
(WebCore::WrapperTypeInfo::toEventTarget):
(WrapperTypeInfo):
* bindings/v8/custom/V8HTMLImageElementConstructor.cpp:
(WebCore):
* dom/MouseEvent.cpp:
(WebCore::MouseEventInit::MouseEventInit):
(WebCore):
(WebCore::MouseEvent::create):
(WebCore::MouseEvent::MouseEvent):
* dom/MouseEvent.h:
(MouseEventInit):
(WebCore):
(MouseEvent):
(WebCore::MouseEvent::create):
(WebCore::MouseEvent::button):
(WebCore::MouseEvent::buttonDown):
(WebCore::MouseEvent::relatedTarget):
(WebCore::MouseEvent::setRelatedTarget):
(WebCore::MouseEvent::clipboard):
(WebCore::MouseEvent::dataTransfer):
* dom/MouseEvent.idl:

LayoutTests:

The MouseEvent constructor should be implemented under a DOM4_EVENTS_CONSTRUCTOR flag.

* fast/dom/constructed-objects-prototypes-expected.txt:
* fast/dom/dom-constructors-expected.txt:
* fast/dom/dom-constructors.html:
* fast/events/constructors/mouse-event-constructor-expected.txt: Added.
* fast/events/constructors/mouse-event-constructor.html: Added.
* platform/efl/TestExpectations:
* platform/gtk/TestExpectations:
* platform/qt/TestExpectations:
* platform/win/TestExpectations:
* platform/wincairo/TestExpectations:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@140657 268f45cc-cd09-0410-ab3c-d52691b4dbfc

39 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/dom/constructed-objects-prototypes-expected.txt
LayoutTests/fast/dom/dom-constructors-expected.txt
LayoutTests/fast/dom/dom-constructors.html
LayoutTests/fast/events/constructors/mouse-event-constructor-expected.txt [new file with mode: 0644]
LayoutTests/fast/events/constructors/mouse-event-constructor.html [new file with mode: 0644]
LayoutTests/platform/efl/TestExpectations
LayoutTests/platform/gtk/TestExpectations
LayoutTests/platform/qt/TestExpectations
LayoutTests/platform/win/TestExpectations
LayoutTests/platform/wincairo/TestExpectations
Source/WebCore/ChangeLog
Source/WebCore/bindings/scripts/CodeGenerator.pm
Source/WebCore/bindings/scripts/CodeGeneratorV8.pm
Source/WebCore/bindings/scripts/test/V8/V8Float64Array.cpp
Source/WebCore/bindings/scripts/test/V8/V8TestActiveDOMObject.cpp
Source/WebCore/bindings/scripts/test/V8/V8TestCustomNamedGetter.cpp
Source/WebCore/bindings/scripts/test/V8/V8TestEventConstructor.cpp
Source/WebCore/bindings/scripts/test/V8/V8TestEventTarget.cpp
Source/WebCore/bindings/scripts/test/V8/V8TestEventTarget.h
Source/WebCore/bindings/scripts/test/V8/V8TestException.cpp
Source/WebCore/bindings/scripts/test/V8/V8TestInterface.cpp
Source/WebCore/bindings/scripts/test/V8/V8TestMediaQueryListListener.cpp
Source/WebCore/bindings/scripts/test/V8/V8TestNamedConstructor.cpp
Source/WebCore/bindings/scripts/test/V8/V8TestNode.cpp
Source/WebCore/bindings/scripts/test/V8/V8TestNode.h
Source/WebCore/bindings/scripts/test/V8/V8TestObj.cpp
Source/WebCore/bindings/scripts/test/V8/V8TestOverloadedConstructors.cpp
Source/WebCore/bindings/scripts/test/V8/V8TestSerializedScriptValueInterface.cpp
Source/WebCore/bindings/v8/Dictionary.cpp
Source/WebCore/bindings/v8/Dictionary.h
Source/WebCore/bindings/v8/NPV8Object.cpp
Source/WebCore/bindings/v8/V8DOMWrapper.cpp
Source/WebCore/bindings/v8/V8DOMWrapper.h
Source/WebCore/bindings/v8/WrapperTypeInfo.h
Source/WebCore/bindings/v8/custom/V8HTMLImageElementConstructor.cpp
Source/WebCore/dom/MouseEvent.cpp
Source/WebCore/dom/MouseEvent.h
Source/WebCore/dom/MouseEvent.idl

index aeb1d2f..cad8e49 100644 (file)
@@ -1,3 +1,25 @@
+2013-01-23  Kentaro Hara  <haraken@chromium.org>
+
+        Implement MouseEvent constructor
+        https://bugs.webkit.org/show_bug.cgi?id=107630
+
+        Reviewed by Adam Barth.
+
+        Spec: https://dvcs.w3.org/hg/d4e/raw-file/tip/source_respec.htm
+
+        The MouseEvent constructor should be implemented under a DOM4_EVENTS_CONSTRUCTOR flag.
+
+        * fast/dom/constructed-objects-prototypes-expected.txt:
+        * fast/dom/dom-constructors-expected.txt:
+        * fast/dom/dom-constructors.html:
+        * fast/events/constructors/mouse-event-constructor-expected.txt: Added.
+        * fast/events/constructors/mouse-event-constructor.html: Added.
+        * platform/efl/TestExpectations:
+        * platform/gtk/TestExpectations:
+        * platform/qt/TestExpectations:
+        * platform/win/TestExpectations:
+        * platform/wincairo/TestExpectations:
+
 2013-01-23  Yoshifumi Inoue  <yosin@chromium.org>
 
         Unreviewed, rebaseline for Chromium-Linux and Chromium-Win
index 1170de9..cb4a29f 100644 (file)
@@ -31,6 +31,8 @@ PASS (new inner.MessageChannel()).isInner is true
 PASS (new inner.MessageChannel()).constructor.isInner is true
 PASS (new inner.MessageEvent()).isInner is true
 PASS (new inner.MessageEvent()).constructor.isInner is true
+PASS (new inner.MouseEvent()).isInner is true
+PASS (new inner.MouseEvent()).constructor.isInner is true
 PASS (new inner.Option()).isInner is true
 PASS (new inner.Option()).constructor.isInner is true
 PASS (new inner.OverflowEvent()).isInner is true
index 404a568..06d8f36 100644 (file)
@@ -96,7 +96,6 @@ PASS TryAllocate('KeyboardEvent') is 'exception'
 PASS TryAllocate('MediaList') is 'exception'
 PASS TryAllocate('MimeType') is 'exception'
 PASS TryAllocate('MimeTypeArray') is 'exception'
-PASS TryAllocate('MouseEvent') is 'exception'
 PASS TryAllocate('MutationEvent') is 'exception'
 PASS TryAllocate('NamedNodeMap') is 'exception'
 PASS TryAllocate('NodeFilter') is 'exception'
index f40bcd5..dd7abb9 100644 (file)
@@ -43,7 +43,7 @@ var objects_exception = [
     'CSSStyleDeclaration', 'CSSStyleRule', 'CSSStyleSheet',
     'CSSValue', 'CSSValueList', 'DOMImplementation',
     'HTMLCollection', 'KeyboardEvent', 'MediaList', 'MimeType',
-    'MimeTypeArray', 'MouseEvent', 'MutationEvent', 'NamedNodeMap',
+    'MimeTypeArray', 'MutationEvent', 'NamedNodeMap',
     'NodeFilter', 'NodeList', 'Plugin',
     'PluginArray', 'Range', 'Rect', 'StyleSheet', 'StyleSheetList',
     'TextEvent', 'WheelEvent', 'XPathResult', 'BarInfo',
diff --git a/LayoutTests/fast/events/constructors/mouse-event-constructor-expected.txt b/LayoutTests/fast/events/constructors/mouse-event-constructor-expected.txt
new file mode 100644 (file)
index 0000000..8bfb2de
--- /dev/null
@@ -0,0 +1,198 @@
+This tests the constructor for the MouseEvent DOM class.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS new MouseEvent('eventType').bubbles is false
+PASS new MouseEvent('eventType').cancelable is false
+PASS new MouseEvent('eventType').view is null
+PASS new MouseEvent('eventType').detail is 0
+PASS new MouseEvent('eventType', { bubbles: false }).bubbles is false
+PASS new MouseEvent('eventType', { bubbles: true }).bubbles is true
+PASS new MouseEvent('eventType', { cancelable: false }).cancelable is false
+PASS new MouseEvent('eventType', { cancelable: true }).cancelable is true
+PASS new MouseEvent('eventType', { view: window }).view is window
+PASS new MouseEvent('eventType', { view: this }).view is this
+PASS new MouseEvent('eventType', { view: testObject }).view is null
+PASS new MouseEvent('eventType', { view: document }).view is null
+PASS new MouseEvent('eventType', { view: undefined }).view is null
+PASS new MouseEvent('eventType', { view: null }).view is null
+PASS new MouseEvent('eventType', { view: false }).view is null
+PASS new MouseEvent('eventType', { view: true }).view is null
+PASS new MouseEvent('eventType', { view: '' }).view is null
+PASS new MouseEvent('eventType', { view: 'chocolate' }).view is null
+PASS new MouseEvent('eventType', { view: 12345 }).view is null
+PASS new MouseEvent('eventType', { view: 18446744073709551615 }).view is null
+PASS new MouseEvent('eventType', { view: NaN }).view is null
+PASS new MouseEvent('eventType', { view: {valueOf: function () { return window; } } }).view == window is false
+PASS new MouseEvent('eventType', { get view() { return 123; } }).view is null
+PASS new MouseEvent('eventType', { get view() { throw 'MouseEvent Error'; } }) threw exception MouseEvent Error.
+PASS new MouseEvent('eventType', { detail: 0 }).detail is 0
+PASS new MouseEvent('eventType', { detail: 2147483647 }).detail is 2147483647
+PASS new MouseEvent('eventType', { detail: -1 }).detail is -1
+PASS new MouseEvent('eventType', { detail: -2147483648 }).detail is -2147483648
+PASS new MouseEvent('eventType', { detail: 4294967295 }).detail is -1
+PASS new MouseEvent('eventType', { detail: 9007199254740991 }).detail is -1
+PASS new MouseEvent('eventType', { detail: 18446744073709551615 }).detail is 0
+PASS new MouseEvent('eventType', { detail: 123.45 }).detail is 123
+PASS new MouseEvent('eventType', { detail: NaN }).detail is 0
+PASS new MouseEvent('eventType', { detail: undefined }).detail is 0
+PASS new MouseEvent('eventType', { detail: null }).detail is 0
+PASS new MouseEvent('eventType', { detail: '' }).detail is 0
+PASS new MouseEvent('eventType', { detail: '12345' }).detail is 12345
+PASS new MouseEvent('eventType', { detail: '12345a' }).detail is 0
+PASS new MouseEvent('eventType', { detail: 'abc' }).detail is 0
+PASS new MouseEvent('eventType', { detail: [] }).detail is 0
+PASS new MouseEvent('eventType', { detail: [12345] }).detail is 12345
+PASS new MouseEvent('eventType', { detail: [12345, 67890] }).detail is 0
+PASS new MouseEvent('eventType', { detail: {} }).detail is 0
+PASS new MouseEvent('eventType', { detail: {moemoe: 12345} }).detail is 0
+PASS new MouseEvent('eventType', { detail: {valueOf: function () { return 12345; }} }).detail is 12345
+PASS new MouseEvent('eventType', { screenX: 0 }).screenX is 0
+PASS new MouseEvent('eventType', { screenX: 2147483647 }).screenX is 2147483647
+PASS new MouseEvent('eventType', { screenX: -1 }).screenX is -1
+PASS new MouseEvent('eventType', { screenX: -2147483648 }).screenX is -2147483648
+PASS new MouseEvent('eventType', { screenX: 4294967295 }).screenX is -1
+PASS new MouseEvent('eventType', { screenX: 9007199254740991 }).screenX is -1
+PASS new MouseEvent('eventType', { screenX: 18446744073709551615 }).screenX is 0
+PASS new MouseEvent('eventType', { screenX: 123.45 }).screenX is 123
+PASS new MouseEvent('eventType', { screenX: NaN }).screenX is 0
+PASS new MouseEvent('eventType', { screenX: undefined }).screenX is 0
+PASS new MouseEvent('eventType', { screenX: null }).screenX is 0
+PASS new MouseEvent('eventType', { screenX: '' }).screenX is 0
+PASS new MouseEvent('eventType', { screenX: '12345' }).screenX is 12345
+PASS new MouseEvent('eventType', { screenX: '12345a' }).screenX is 0
+PASS new MouseEvent('eventType', { screenX: 'abc' }).screenX is 0
+PASS new MouseEvent('eventType', { screenX: [] }).screenX is 0
+PASS new MouseEvent('eventType', { screenX: [12345] }).screenX is 12345
+PASS new MouseEvent('eventType', { screenX: [12345, 67890] }).screenX is 0
+PASS new MouseEvent('eventType', { screenX: {} }).screenX is 0
+PASS new MouseEvent('eventType', { screenX: {moemoe: 12345} }).screenX is 0
+PASS new MouseEvent('eventType', { screenX: {valueOf: function () { return 12345; }} }).screenX is 12345
+PASS new MouseEvent('eventType', { screenY: 0 }).screenY is 0
+PASS new MouseEvent('eventType', { screenY: 2147483647 }).screenY is 2147483647
+PASS new MouseEvent('eventType', { screenY: -1 }).screenY is -1
+PASS new MouseEvent('eventType', { screenY: -2147483648 }).screenY is -2147483648
+PASS new MouseEvent('eventType', { screenY: 4294967295 }).screenY is -1
+PASS new MouseEvent('eventType', { screenY: 9007199254740991 }).screenY is -1
+PASS new MouseEvent('eventType', { screenY: 18446744073709551615 }).screenY is 0
+PASS new MouseEvent('eventType', { screenY: 123.45 }).screenY is 123
+PASS new MouseEvent('eventType', { screenY: NaN }).screenY is 0
+PASS new MouseEvent('eventType', { screenY: undefined }).screenY is 0
+PASS new MouseEvent('eventType', { screenY: null }).screenY is 0
+PASS new MouseEvent('eventType', { screenY: '' }).screenY is 0
+PASS new MouseEvent('eventType', { screenY: '12345' }).screenY is 12345
+PASS new MouseEvent('eventType', { screenY: '12345a' }).screenY is 0
+PASS new MouseEvent('eventType', { screenY: 'abc' }).screenY is 0
+PASS new MouseEvent('eventType', { screenY: [] }).screenY is 0
+PASS new MouseEvent('eventType', { screenY: [12345] }).screenY is 12345
+PASS new MouseEvent('eventType', { screenY: [12345, 67890] }).screenY is 0
+PASS new MouseEvent('eventType', { screenY: {} }).screenY is 0
+PASS new MouseEvent('eventType', { screenY: {moemoe: 12345} }).screenY is 0
+PASS new MouseEvent('eventType', { screenY: {valueOf: function () { return 12345; }} }).screenY is 12345
+PASS new MouseEvent('eventType', { clientX: 0 }).clientX is 0
+FAIL new MouseEvent('eventType', { clientX: 2147483647 }).clientX should be 2147483647. Was -1.
+PASS new MouseEvent('eventType', { clientX: -1 }).clientX is -1
+FAIL new MouseEvent('eventType', { clientX: -2147483648 }).clientX should be -2147483648. Was 0.
+PASS new MouseEvent('eventType', { clientX: 4294967295 }).clientX is -1
+PASS new MouseEvent('eventType', { clientX: 9007199254740991 }).clientX is -1
+PASS new MouseEvent('eventType', { clientX: 18446744073709551615 }).clientX is 0
+PASS new MouseEvent('eventType', { clientX: 123.45 }).clientX is 123
+PASS new MouseEvent('eventType', { clientX: NaN }).clientX is 0
+PASS new MouseEvent('eventType', { clientX: undefined }).clientX is 0
+PASS new MouseEvent('eventType', { clientX: null }).clientX is 0
+PASS new MouseEvent('eventType', { clientX: '' }).clientX is 0
+PASS new MouseEvent('eventType', { clientX: '12345' }).clientX is 12345
+PASS new MouseEvent('eventType', { clientX: '12345a' }).clientX is 0
+PASS new MouseEvent('eventType', { clientX: 'abc' }).clientX is 0
+PASS new MouseEvent('eventType', { clientX: [] }).clientX is 0
+PASS new MouseEvent('eventType', { clientX: [12345] }).clientX is 12345
+PASS new MouseEvent('eventType', { clientX: [12345, 67890] }).clientX is 0
+PASS new MouseEvent('eventType', { clientX: {} }).clientX is 0
+PASS new MouseEvent('eventType', { clientX: {moemoe: 12345} }).clientX is 0
+PASS new MouseEvent('eventType', { clientX: {valueOf: function () { return 12345; }} }).clientX is 12345
+PASS new MouseEvent('eventType', { clientY: 0 }).clientY is 0
+FAIL new MouseEvent('eventType', { clientY: 2147483647 }).clientY should be 2147483647. Was -1.
+PASS new MouseEvent('eventType', { clientY: -1 }).clientY is -1
+FAIL new MouseEvent('eventType', { clientY: -2147483648 }).clientY should be -2147483648. Was 0.
+PASS new MouseEvent('eventType', { clientY: 4294967295 }).clientY is -1
+PASS new MouseEvent('eventType', { clientY: 9007199254740991 }).clientY is -1
+PASS new MouseEvent('eventType', { clientY: 18446744073709551615 }).clientY is 0
+PASS new MouseEvent('eventType', { clientY: 123.45 }).clientY is 123
+PASS new MouseEvent('eventType', { clientY: NaN }).clientY is 0
+PASS new MouseEvent('eventType', { clientY: undefined }).clientY is 0
+PASS new MouseEvent('eventType', { clientY: null }).clientY is 0
+PASS new MouseEvent('eventType', { clientY: '' }).clientY is 0
+PASS new MouseEvent('eventType', { clientY: '12345' }).clientY is 12345
+PASS new MouseEvent('eventType', { clientY: '12345a' }).clientY is 0
+PASS new MouseEvent('eventType', { clientY: 'abc' }).clientY is 0
+PASS new MouseEvent('eventType', { clientY: [] }).clientY is 0
+PASS new MouseEvent('eventType', { clientY: [12345] }).clientY is 12345
+PASS new MouseEvent('eventType', { clientY: [12345, 67890] }).clientY is 0
+PASS new MouseEvent('eventType', { clientY: {} }).clientY is 0
+PASS new MouseEvent('eventType', { clientY: {moemoe: 12345} }).clientY is 0
+PASS new MouseEvent('eventType', { clientY: {valueOf: function () { return 12345; }} }).clientY is 12345
+PASS new MouseEvent('eventType', { ctrlKey: false }).ctrlKey is false
+PASS new MouseEvent('eventType', { ctrlKey: true }).ctrlKey is true
+PASS new MouseEvent('eventType', { altKey: false }).altKey is false
+PASS new MouseEvent('eventType', { altKey: true }).altKey is true
+PASS new MouseEvent('eventType', { shiftKey: false }).shiftKey is false
+PASS new MouseEvent('eventType', { shiftKey: true }).shiftKey is true
+PASS new MouseEvent('eventType', { metaKey: false }).metaKey is false
+PASS new MouseEvent('eventType', { metaKey: true }).metaKey is true
+PASS new MouseEvent('eventType', { button: 0 }).button is 0
+PASS new MouseEvent('eventType', { button: 1 }).button is 1
+PASS new MouseEvent('eventType', { button: 65534 }).button is 65534
+PASS new MouseEvent('eventType', { button: 65535 }).button is 0
+PASS new MouseEvent('eventType', { button: 9007199254740991 }).button is 0
+PASS new MouseEvent('eventType', { button: -1 }).button is 0
+PASS new MouseEvent('eventType', { button: 18446744073709551615 }).button is 0
+PASS new MouseEvent('eventType', { button: 12345678901234567890 }).button is 2048
+PASS new MouseEvent('eventType', { button: 123.45 }).button is 123
+PASS new MouseEvent('eventType', { button: NaN }).button is 0
+PASS new MouseEvent('eventType', { button: undefined }).button is 0
+PASS new MouseEvent('eventType', { button: null }).button is 0
+PASS new MouseEvent('eventType', { button: '' }).button is 0
+PASS new MouseEvent('eventType', { button: '12345' }).button is 12345
+PASS new MouseEvent('eventType', { button: '12345a' }).button is 0
+PASS new MouseEvent('eventType', { button: 'abc' }).button is 0
+PASS new MouseEvent('eventType', { button: [] }).button is 0
+PASS new MouseEvent('eventType', { button: [12345] }).button is 12345
+PASS new MouseEvent('eventType', { button: [12345, 67890] }).button is 0
+PASS new MouseEvent('eventType', { button: {} }).button is 0
+PASS new MouseEvent('eventType', { button: {moemoe: 12345} }).button is 0
+PASS new MouseEvent('eventType', { button: {valueOf: function () { return 12345; }} }).button is 12345
+PASS new MouseEvent('eventType', { relatedTarget: testDiv }).relatedTarget is testDiv
+PASS new MouseEvent('eventType', { relatedTarget: document }).relatedTarget is document
+PASS new MouseEvent('eventType', { relatedTarget: xhr }).relatedTarget is xhr
+PASS new MouseEvent('eventType', { relatedTarget: testObject }).relatedTarget is null
+PASS new MouseEvent('eventType', { relatedTarget: undefined }).relatedTarget is null
+PASS new MouseEvent('eventType', { relatedTarget: null }).relatedTarget is null
+PASS new MouseEvent('eventType', { relatedTarget: false }).relatedTarget is null
+PASS new MouseEvent('eventType', { relatedTarget: true }).relatedTarget is null
+PASS new MouseEvent('eventType', { relatedTarget: '' }).relatedTarget is null
+PASS new MouseEvent('eventType', { relatedTarget: 'chocolate' }).relatedTarget is null
+PASS new MouseEvent('eventType', { relatedTarget: 12345 }).relatedTarget is null
+PASS new MouseEvent('eventType', { relatedTarget: 18446744073709551615 }).relatedTarget is null
+PASS new MouseEvent('eventType', { relatedTarget: NaN }).relatedTarget is null
+PASS new MouseEvent('eventType', { relatedTarget: {valueOf: function () { return testDiv; } } }).relatedTarget == testDiv is false
+PASS new MouseEvent('eventType', { get relatedTarget() { return 123; } }).relatedTarget is null
+PASS new MouseEvent('eventType', { get relatedTarget() { throw 'MouseEvent Error'; } }) threw exception MouseEvent Error.
+PASS new MouseEvent('eventType', { bubbles: true, cancelable: true, view: window, detail: 111, screenX: 222, screenY: 333, clientX: 444, clientY: 555, ctrlKey: true, shiftKey: true, altKey: true, metaKey: true, button: 666, relatedTarget: testDiv }).bubbles is true
+PASS new MouseEvent('eventType', { bubbles: true, cancelable: true, view: window, detail: 111, screenX: 222, screenY: 333, clientX: 444, clientY: 555, ctrlKey: true, shiftKey: true, altKey: true, metaKey: true, button: 666, relatedTarget: testDiv }).cancelable is true
+PASS new MouseEvent('eventType', { bubbles: true, cancelable: true, view: window, detail: 111, screenX: 222, screenY: 333, clientX: 444, clientY: 555, ctrlKey: true, shiftKey: true, altKey: true, metaKey: true, button: 666, relatedTarget: testDiv }).view is window
+PASS new MouseEvent('eventType', { bubbles: true, cancelable: true, view: window, detail: 111, screenX: 222, screenY: 333, clientX: 444, clientY: 555, ctrlKey: true, shiftKey: true, altKey: true, metaKey: true, button: 666, relatedTarget: testDiv }).detail is 111
+PASS new MouseEvent('eventType', { bubbles: true, cancelable: true, view: window, detail: 111, screenX: 222, screenY: 333, clientX: 444, clientY: 555, ctrlKey: true, shiftKey: true, altKey: true, metaKey: true, button: 666, relatedTarget: testDiv }).screenX is 222
+PASS new MouseEvent('eventType', { bubbles: true, cancelable: true, view: window, detail: 111, screenX: 222, screenY: 333, clientX: 444, clientY: 555, ctrlKey: true, shiftKey: true, altKey: true, metaKey: true, button: 666, relatedTarget: testDiv }).screenY is 333
+PASS new MouseEvent('eventType', { bubbles: true, cancelable: true, view: window, detail: 111, screenX: 222, screenY: 333, clientX: 444, clientY: 555, ctrlKey: true, shiftKey: true, altKey: true, metaKey: true, button: 666, relatedTarget: testDiv }).clientX is 444
+PASS new MouseEvent('eventType', { bubbles: true, cancelable: true, view: window, detail: 111, screenX: 222, screenY: 333, clientX: 444, clientY: 555, ctrlKey: true, shiftKey: true, altKey: true, metaKey: true, button: 666, relatedTarget: testDiv }).clientY is 555
+PASS new MouseEvent('eventType', { bubbles: true, cancelable: true, view: window, detail: 111, screenX: 222, screenY: 333, clientX: 444, clientY: 555, ctrlKey: true, shiftKey: true, altKey: true, metaKey: true, button: 666, relatedTarget: testDiv }).ctrlKey is true
+PASS new MouseEvent('eventType', { bubbles: true, cancelable: true, view: window, detail: 111, screenX: 222, screenY: 333, clientX: 444, clientY: 555, ctrlKey: true, shiftKey: true, altKey: true, metaKey: true, button: 666, relatedTarget: testDiv }).shiftKey is true
+PASS new MouseEvent('eventType', { bubbles: true, cancelable: true, view: window, detail: 111, screenX: 222, screenY: 333, clientX: 444, clientY: 555, ctrlKey: true, shiftKey: true, altKey: true, metaKey: true, button: 666, relatedTarget: testDiv }).altKey is true
+PASS new MouseEvent('eventType', { bubbles: true, cancelable: true, view: window, detail: 111, screenX: 222, screenY: 333, clientX: 444, clientY: 555, ctrlKey: true, shiftKey: true, altKey: true, metaKey: true, button: 666, relatedTarget: testDiv }).metaKey is true
+PASS new MouseEvent('eventType', { bubbles: true, cancelable: true, view: window, detail: 111, screenX: 222, screenY: 333, clientX: 444, clientY: 555, ctrlKey: true, shiftKey: true, altKey: true, metaKey: true, button: 666, relatedTarget: testDiv }).button is 666
+PASS new MouseEvent('eventType', { bubbles: true, cancelable: true, view: window, detail: 111, screenX: 222, screenY: 333, clientX: 444, clientY: 555, ctrlKey: true, shiftKey: true, altKey: true, metaKey: true, button: 666, relatedTarget: testDiv }).relatedTarget is testDiv
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/events/constructors/mouse-event-constructor.html b/LayoutTests/fast/events/constructors/mouse-event-constructor.html
new file mode 100644 (file)
index 0000000..bc2d953
--- /dev/null
@@ -0,0 +1,161 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src="../../js/resources/js-test-pre.js"></script>
+</head>
+<body>
+<script>
+
+description("This tests the constructor for the MouseEvent DOM class.");
+
+var testObject = {nyannyan: 123};
+var testDiv = document.createElement("div");
+var xhr = new XMLHttpRequest;
+
+// No initializer is passed.
+shouldBe("new MouseEvent('eventType').bubbles", "false");
+shouldBe("new MouseEvent('eventType').cancelable", "false");
+shouldBe("new MouseEvent('eventType').view", "null");
+shouldBe("new MouseEvent('eventType').detail", "0");
+
+// bubbles is passed.
+shouldBe("new MouseEvent('eventType', { bubbles: false }).bubbles", "false");
+shouldBe("new MouseEvent('eventType', { bubbles: true }).bubbles", "true");
+
+// cancelable is passed.
+shouldBe("new MouseEvent('eventType', { cancelable: false }).cancelable", "false");
+shouldBe("new MouseEvent('eventType', { cancelable: true }).cancelable", "true");
+
+// view is passed.
+// Window objects.
+shouldBe("new MouseEvent('eventType', { view: window }).view", "window");
+shouldBe("new MouseEvent('eventType', { view: this }).view", "this");
+
+// Non-window objects.
+shouldBe("new MouseEvent('eventType', { view: testObject }).view", "null");
+shouldBe("new MouseEvent('eventType', { view: document }).view", "null");
+shouldBe("new MouseEvent('eventType', { view: undefined }).view", "null");
+shouldBe("new MouseEvent('eventType', { view: null }).view", "null");
+shouldBe("new MouseEvent('eventType', { view: false }).view", "null");
+shouldBe("new MouseEvent('eventType', { view: true }).view", "null");
+shouldBe("new MouseEvent('eventType', { view: '' }).view", "null");
+shouldBe("new MouseEvent('eventType', { view: 'chocolate' }).view", "null");
+shouldBe("new MouseEvent('eventType', { view: 12345 }).view", "null");
+shouldBe("new MouseEvent('eventType', { view: 18446744073709551615 }).view", "null");
+shouldBe("new MouseEvent('eventType', { view: NaN }).view", "null");
+// Note that valueOf() is not called, when the left hand side is evaluated.
+shouldBeFalse("new MouseEvent('eventType', { view: {valueOf: function () { return window; } } }).view == window");
+shouldBe("new MouseEvent('eventType', { get view() { return 123; } }).view", "null");
+shouldThrow("new MouseEvent('eventType', { get view() { throw 'MouseEvent Error'; } })");
+
+// detail, screenX, screenY, clientX and clientY are passed.
+["detail", "screenX", "screenY", "clientX", "clientY"].forEach(function (attr) {
+    // numbers within the long range.
+    shouldBe("new MouseEvent('eventType', { " + attr + ": 0 })." + attr, "0");
+    shouldBe("new MouseEvent('eventType', { " + attr + ": 2147483647 })." + attr, "2147483647");
+    shouldBe("new MouseEvent('eventType', { " + attr + ": -1 })." + attr, "-1");
+    shouldBe("new MouseEvent('eventType', { " + attr + ": -2147483648 })." + attr, "-2147483648");
+
+    // numbers out of the long range.
+    shouldBe("new MouseEvent('eventType', { " + attr + ": 4294967295 })." + attr, "-1");
+    // 2^{53}-1, the largest number that can be exactly represented by double.
+    shouldBe("new MouseEvent('eventType', { " + attr + ": 9007199254740991 })." + attr, "-1");
+    // 2^{64}-1
+    shouldBe("new MouseEvent('eventType', { " + attr + ": 18446744073709551615 })." + attr, "0");
+    shouldBe("new MouseEvent('eventType', { " + attr + ": 123.45 })." + attr, "123");
+    shouldBe("new MouseEvent('eventType', { " + attr + ": NaN })." + attr, "0");
+
+    // Non-numeric values.
+    shouldBe("new MouseEvent('eventType', { " + attr + ": undefined })." + attr, "0");
+    shouldBe("new MouseEvent('eventType', { " + attr + ": null })." + attr, "0");
+    shouldBe("new MouseEvent('eventType', { " + attr + ": '' })." + attr, "0");
+    shouldBe("new MouseEvent('eventType', { " + attr + ": '12345' })." + attr, "12345");
+    shouldBe("new MouseEvent('eventType', { " + attr + ": '12345a' })." + attr, "0");
+    shouldBe("new MouseEvent('eventType', { " + attr + ": 'abc' })." + attr, "0");
+    shouldBe("new MouseEvent('eventType', { " + attr + ": [] })." + attr, "0");
+    shouldBe("new MouseEvent('eventType', { " + attr + ": [12345] })." + attr, "12345");
+    shouldBe("new MouseEvent('eventType', { " + attr + ": [12345, 67890] })." + attr, "0");
+    shouldBe("new MouseEvent('eventType', { " + attr + ": {} })." + attr, "0");
+    shouldBe("new MouseEvent('eventType', { " + attr + ": {moemoe: 12345} })." + attr, "0");
+    shouldBe("new MouseEvent('eventType', { " + attr + ": {valueOf: function () { return 12345; }} })." + attr, "12345");
+});
+
+// ctrlKey, altKey, shiftKey and metaKey are passed.
+["ctrlKey", "altKey", "shiftKey", "metaKey"].forEach(function (attr) {
+    shouldBe("new MouseEvent('eventType', { " + attr + ": false })." + attr, "false");
+    shouldBe("new MouseEvent('eventType', { " + attr + ": true })." + attr, "true");
+});
+
+// button is passed.
+// Numbers within the unsigned short range.
+shouldBe("new MouseEvent('eventType', { button: 0 }).button", "0");
+shouldBe("new MouseEvent('eventType', { button: 1 }).button", "1");
+shouldBe("new MouseEvent('eventType', { button: 65534 }).button", "65534");
+
+// Numbers that are equal to ((unsigned short)-1) should be treated as 0.
+shouldBe("new MouseEvent('eventType', { button: 65535 }).button", "0");
+shouldBe("new MouseEvent('eventType', { button: 9007199254740991 }).button", "0");
+shouldBe("new MouseEvent('eventType', { button: -1 }).button", "0");
+
+// Numbers out of the unsigned short range.
+// 2^{64}-1
+shouldBe("new MouseEvent('eventType', { button: 18446744073709551615 }).button", "0");
+shouldBe("new MouseEvent('eventType', { button: 12345678901234567890 }).button", "2048");
+shouldBe("new MouseEvent('eventType', { button: 123.45 }).button", "123");
+shouldBe("new MouseEvent('eventType', { button: NaN }).button", "0");
+
+// Non-numeric values.
+shouldBe("new MouseEvent('eventType', { button: undefined }).button", "0");
+shouldBe("new MouseEvent('eventType', { button: null }).button", "0");
+shouldBe("new MouseEvent('eventType', { button: '' }).button", "0");
+shouldBe("new MouseEvent('eventType', { button: '12345' }).button", "12345");
+shouldBe("new MouseEvent('eventType', { button: '12345a' }).button", "0");
+shouldBe("new MouseEvent('eventType', { button: 'abc' }).button", "0");
+shouldBe("new MouseEvent('eventType', { button: [] }).button", "0");
+shouldBe("new MouseEvent('eventType', { button: [12345] }).button", "12345");
+shouldBe("new MouseEvent('eventType', { button: [12345, 67890] }).button", "0");
+shouldBe("new MouseEvent('eventType', { button: {} }).button", "0");
+shouldBe("new MouseEvent('eventType', { button: {moemoe: 12345} }).button", "0");
+shouldBe("new MouseEvent('eventType', { button: {valueOf: function () { return 12345; }} }).button", "12345");
+
+// relatedTarget is passed.
+// Valid objects.
+shouldBe("new MouseEvent('eventType', { relatedTarget: testDiv }).relatedTarget", "testDiv");
+shouldBe("new MouseEvent('eventType', { relatedTarget: document }).relatedTarget", "document");
+shouldBe("new MouseEvent('eventType', { relatedTarget: xhr }).relatedTarget", "xhr");
+
+// Invalid objects.
+shouldBe("new MouseEvent('eventType', { relatedTarget: testObject }).relatedTarget", "null");
+shouldBe("new MouseEvent('eventType', { relatedTarget: undefined }).relatedTarget", "null");
+shouldBe("new MouseEvent('eventType', { relatedTarget: null }).relatedTarget", "null");
+shouldBe("new MouseEvent('eventType', { relatedTarget: false }).relatedTarget", "null");
+shouldBe("new MouseEvent('eventType', { relatedTarget: true }).relatedTarget", "null");
+shouldBe("new MouseEvent('eventType', { relatedTarget: '' }).relatedTarget", "null");
+shouldBe("new MouseEvent('eventType', { relatedTarget: 'chocolate' }).relatedTarget", "null");
+shouldBe("new MouseEvent('eventType', { relatedTarget: 12345 }).relatedTarget", "null");
+shouldBe("new MouseEvent('eventType', { relatedTarget: 18446744073709551615 }).relatedTarget", "null");
+shouldBe("new MouseEvent('eventType', { relatedTarget: NaN }).relatedTarget", "null");
+// Note that valueOf() is not called, when the left hand side is evaluated.
+shouldBeFalse("new MouseEvent('eventType', { relatedTarget: {valueOf: function () { return testDiv; } } }).relatedTarget == testDiv");
+shouldBe("new MouseEvent('eventType', { get relatedTarget() { return 123; } }).relatedTarget", "null");
+shouldThrow("new MouseEvent('eventType', { get relatedTarget() { throw 'MouseEvent Error'; } })");
+
+// All initializers are passed.
+shouldBe("new MouseEvent('eventType', { bubbles: true, cancelable: true, view: window, detail: 111, screenX: 222, screenY: 333, clientX: 444, clientY: 555, ctrlKey: true, shiftKey: true, altKey: true, metaKey: true, button: 666, relatedTarget: testDiv }).bubbles", "true");
+shouldBe("new MouseEvent('eventType', { bubbles: true, cancelable: true, view: window, detail: 111, screenX: 222, screenY: 333, clientX: 444, clientY: 555, ctrlKey: true, shiftKey: true, altKey: true, metaKey: true, button: 666, relatedTarget: testDiv }).cancelable", "true");
+shouldBe("new MouseEvent('eventType', { bubbles: true, cancelable: true, view: window, detail: 111, screenX: 222, screenY: 333, clientX: 444, clientY: 555, ctrlKey: true, shiftKey: true, altKey: true, metaKey: true, button: 666, relatedTarget: testDiv }).view", "window");
+shouldBe("new MouseEvent('eventType', { bubbles: true, cancelable: true, view: window, detail: 111, screenX: 222, screenY: 333, clientX: 444, clientY: 555, ctrlKey: true, shiftKey: true, altKey: true, metaKey: true, button: 666, relatedTarget: testDiv }).detail", "111");
+shouldBe("new MouseEvent('eventType', { bubbles: true, cancelable: true, view: window, detail: 111, screenX: 222, screenY: 333, clientX: 444, clientY: 555, ctrlKey: true, shiftKey: true, altKey: true, metaKey: true, button: 666, relatedTarget: testDiv }).screenX", "222");
+shouldBe("new MouseEvent('eventType', { bubbles: true, cancelable: true, view: window, detail: 111, screenX: 222, screenY: 333, clientX: 444, clientY: 555, ctrlKey: true, shiftKey: true, altKey: true, metaKey: true, button: 666, relatedTarget: testDiv }).screenY", "333");
+shouldBe("new MouseEvent('eventType', { bubbles: true, cancelable: true, view: window, detail: 111, screenX: 222, screenY: 333, clientX: 444, clientY: 555, ctrlKey: true, shiftKey: true, altKey: true, metaKey: true, button: 666, relatedTarget: testDiv }).clientX", "444");
+shouldBe("new MouseEvent('eventType', { bubbles: true, cancelable: true, view: window, detail: 111, screenX: 222, screenY: 333, clientX: 444, clientY: 555, ctrlKey: true, shiftKey: true, altKey: true, metaKey: true, button: 666, relatedTarget: testDiv }).clientY", "555");
+shouldBe("new MouseEvent('eventType', { bubbles: true, cancelable: true, view: window, detail: 111, screenX: 222, screenY: 333, clientX: 444, clientY: 555, ctrlKey: true, shiftKey: true, altKey: true, metaKey: true, button: 666, relatedTarget: testDiv }).ctrlKey", "true");
+shouldBe("new MouseEvent('eventType', { bubbles: true, cancelable: true, view: window, detail: 111, screenX: 222, screenY: 333, clientX: 444, clientY: 555, ctrlKey: true, shiftKey: true, altKey: true, metaKey: true, button: 666, relatedTarget: testDiv }).shiftKey", "true");
+shouldBe("new MouseEvent('eventType', { bubbles: true, cancelable: true, view: window, detail: 111, screenX: 222, screenY: 333, clientX: 444, clientY: 555, ctrlKey: true, shiftKey: true, altKey: true, metaKey: true, button: 666, relatedTarget: testDiv }).altKey", "true");
+shouldBe("new MouseEvent('eventType', { bubbles: true, cancelable: true, view: window, detail: 111, screenX: 222, screenY: 333, clientX: 444, clientY: 555, ctrlKey: true, shiftKey: true, altKey: true, metaKey: true, button: 666, relatedTarget: testDiv }).metaKey", "true");
+shouldBe("new MouseEvent('eventType', { bubbles: true, cancelable: true, view: window, detail: 111, screenX: 222, screenY: 333, clientX: 444, clientY: 555, ctrlKey: true, shiftKey: true, altKey: true, metaKey: true, button: 666, relatedTarget: testDiv }).button", "666");
+shouldBe("new MouseEvent('eventType', { bubbles: true, cancelable: true, view: window, detail: 111, screenX: 222, screenY: 333, clientX: 444, clientY: 555, ctrlKey: true, shiftKey: true, altKey: true, metaKey: true, button: 666, relatedTarget: testDiv }).relatedTarget", "testDiv");
+</script>
+<script src="../../js/resources/js-test-post.js"></script>
+</body>
+</html>
index 21dbd9d..7eed771 100644 (file)
@@ -1229,6 +1229,7 @@ webkit.org/b/95302 fast/events/constructors/speech-recognition-event-constructor
 
 # DOM4_EVENTS_CONSTRUCTOR is not yet enabled.
 webkit.org/b/107428 fast/events/constructors/ui-event-constructor.html [ Skip ]
+webkit.org/b/107428 fast/events/constructors/mouse-event-constructor.html [ Skip ]
 
 # Requires support for Web notifications
 webkit.org/b/73544 fast/notifications [ Skip ]
index d6a9f7e..3240300 100644 (file)
@@ -373,6 +373,7 @@ webkit.org/b/99057 inspector/styles/variables [ Skip ]
 
 # DOM4_EVENTS_CONSTRUCTOR is not yet enabled.
 webkit.org/b/107428 fast/events/constructors/ui-event-constructor.html [ Skip ]
+webkit.org/b/107428 fast/events/constructors/mouse-event-constructor.html [ Skip ]
 
 # No CORS support for media elements is implemented yet.
 webkit.org/b/99037 http/tests/security/video-cross-origin-readback.html [ Failure ]
index 0b554e2..2ae398f 100644 (file)
@@ -106,6 +106,7 @@ fast/forms/file/input-file-directory-upload.html
 
 # ENABLE(DOM4_EVENTS_CONSTRUCTOR) is disabled.
 fast/events/constructors/ui-event-constructor.html
+fast/events/constructors/mouse-event-constructor.html
 
 # ENABLE(INDEXED_DATABASE) is disabled.
 storage/indexeddb
index 67b2521..7e77570 100644 (file)
@@ -1212,6 +1212,7 @@ fast/images/large-size-image-crash.html
 
 # DOM4_EVENTS_CONSTRUCTOR is not yet enabled.
 fast/events/constructors/ui-event-constructor.html
+fast/events/constructors/mouse-event-constructor.html
 
 # Disable until the windows WebKit API supports injecting in the top frame only.
 # https://bugs.webkit.org/show_bug.cgi?id=41800
index 2accc1c..389448f 100644 (file)
@@ -1739,6 +1739,7 @@ fast/images/large-size-image-crash.html
 
 # DOM4_EVENTS_CONSTRUCTOR is not yet enabled.
 fast/events/constructors/ui-event-constructor.html
+fast/events/constructors/mouse-event-constructor.html
 
 # Disable until the windows WebKit API supports injecting in the top frame only.
 # https://bugs.webkit.org/show_bug.cgi?id=41800
index 69c40c3..6182f18 100644 (file)
@@ -1,3 +1,114 @@
+2013-01-23  Kentaro Hara  <haraken@chromium.org>
+
+        Implement MouseEvent constructor
+        https://bugs.webkit.org/show_bug.cgi?id=107630
+
+        Reviewed by Adam Barth.
+
+        Spec: https://dvcs.w3.org/hg/d4e/raw-file/tip/source_respec.htm
+
+        The MouseEvent constructor should be implemented under a DOM4_EVENTS_CONSTRUCTOR flag.
+        This significantly simplifies JavaScript code to construct a MouseEvent.
+
+        Before:
+          event = document.createEvent("MouseEvents");
+          event.initMouseEvent("click", true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
+
+        After:
+          event = new MouseEvent("click");
+
+        Test: fast/events/constructors/mouse-event-constructor.html
+
+        * bindings/scripts/CodeGenerator.pm:
+        (IsSubType):
+        (IsInheritExtendedAttribute):
+        * bindings/scripts/CodeGeneratorV8.pm:
+        (GenerateHeader):
+        (GenerateNamedConstructorCallback):
+        (GenerateImplementation):
+        * bindings/scripts/test/V8/V8Float64Array.cpp:
+        (WebCore):
+        (WebCore::V8Float64Array::createWrapper):
+        * bindings/scripts/test/V8/V8TestActiveDOMObject.cpp:
+        (WebCore):
+        (WebCore::V8TestActiveDOMObject::createWrapper):
+        * bindings/scripts/test/V8/V8TestCustomNamedGetter.cpp:
+        (WebCore):
+        (WebCore::V8TestCustomNamedGetter::createWrapper):
+        * bindings/scripts/test/V8/V8TestEventConstructor.cpp:
+        (WebCore):
+        (WebCore::V8TestEventConstructor::createWrapper):
+        * bindings/scripts/test/V8/V8TestEventTarget.cpp:
+        (WebCore):
+        (WebCore::V8TestEventTarget::toEventTarget):
+        (WebCore::V8TestEventTarget::createWrapper):
+        * bindings/scripts/test/V8/V8TestEventTarget.h:
+        (V8TestEventTarget):
+        * bindings/scripts/test/V8/V8TestException.cpp:
+        (WebCore):
+        (WebCore::V8TestException::createWrapper):
+        * bindings/scripts/test/V8/V8TestInterface.cpp:
+        (WebCore):
+        (WebCore::V8TestInterface::toActiveDOMObject):
+        (WebCore::V8TestInterface::createWrapper):
+        * bindings/scripts/test/V8/V8TestMediaQueryListListener.cpp:
+        (WebCore):
+        (WebCore::V8TestMediaQueryListListener::createWrapper):
+        * bindings/scripts/test/V8/V8TestNamedConstructor.cpp:
+        (WebCore):
+        (WebCore::V8TestNamedConstructor::toActiveDOMObject):
+        (WebCore::V8TestNamedConstructor::createWrapper):
+        * bindings/scripts/test/V8/V8TestNode.cpp:
+        (WebCore):
+        (WebCore::V8TestNode::toEventTarget):
+        (WebCore::V8TestNode::createWrapper):
+        * bindings/scripts/test/V8/V8TestNode.h:
+        (V8TestNode):
+        * bindings/scripts/test/V8/V8TestObj.cpp:
+        (WebCore):
+        (WebCore::V8TestObj::createWrapper):
+        * bindings/scripts/test/V8/V8TestOverloadedConstructors.cpp:
+        (WebCore):
+        (WebCore::V8TestOverloadedConstructors::createWrapper):
+        * bindings/scripts/test/V8/V8TestSerializedScriptValueInterface.cpp:
+        (WebCore):
+        (WebCore::V8TestSerializedScriptValueInterface::createWrapper):
+        * bindings/v8/Dictionary.cpp:
+        (WebCore::Dictionary::get):
+        (WebCore):
+        * bindings/v8/Dictionary.h:
+        (Dictionary):
+        * bindings/v8/NPV8Object.cpp:
+        (WebCore::npObjectTypeInfo):
+        * bindings/v8/V8DOMWrapper.cpp:
+        (WebCore::V8DOMWrapper::isDOMWrapper):
+        (WebCore):
+        * bindings/v8/V8DOMWrapper.h:
+        (V8DOMWrapper):
+        * bindings/v8/WrapperTypeInfo.h:
+        (WebCore):
+        (WebCore::WrapperTypeInfo::toEventTarget):
+        (WrapperTypeInfo):
+        * bindings/v8/custom/V8HTMLImageElementConstructor.cpp:
+        (WebCore):
+        * dom/MouseEvent.cpp:
+        (WebCore::MouseEventInit::MouseEventInit):
+        (WebCore):
+        (WebCore::MouseEvent::create):
+        (WebCore::MouseEvent::MouseEvent):
+        * dom/MouseEvent.h:
+        (MouseEventInit):
+        (WebCore):
+        (MouseEvent):
+        (WebCore::MouseEvent::create):
+        (WebCore::MouseEvent::button):
+        (WebCore::MouseEvent::buttonDown):
+        (WebCore::MouseEvent::relatedTarget):
+        (WebCore::MouseEvent::setRelatedTarget):
+        (WebCore::MouseEvent::clipboard):
+        (WebCore::MouseEvent::dataTransfer):
+        * dom/MouseEvent.idl:
+
 2013-01-23  Kent Tamura  <tkent@chromium.org>
 
         Add form-related instrumentations, and support 33+ features in FeatureObserver
index 4c78508..6de6c27 100644 (file)
@@ -732,6 +732,7 @@ sub GetVisibleInterfaceName
     return $interfaceName ? $interfaceName : $interface->name;
 }
 
+# FIXME: Rename to InheritsInterface
 sub IsSubType
 {
     my $object = shift;
@@ -745,7 +746,26 @@ sub IsSubType
         if ($currentInterface->name eq $interfaceName) {
             $found = 1;
         }
-        return "prune" if $found;
+        return 1 if $found;
+    }, 0, 1);
+
+    return $found;
+}
+
+sub InheritsExtendedAttribute
+{
+    my $object = shift;
+    my $interface = shift;
+    my $extendedAttribute = shift;
+    my $found = 0;
+
+    return 1 if $interface->extendedAttributes->{$extendedAttribute};
+    $object->ForAllParents($interface, sub {
+        my $currentInterface = shift;
+        if ($currentInterface->extendedAttributes->{$extendedAttribute}) {
+            $found = 1;
+        }
+        return 1 if $found;
     }, 0, 1);
 
     return $found;
index b7933c4..d212fac 100644 (file)
@@ -373,6 +373,10 @@ END
         push(@headerContent, "    static ActiveDOMObject* toActiveDOMObject(v8::Handle<v8::Object>);\n");
     }
 
+    if ($codeGenerator->InheritsExtendedAttribute($interface, "EventTarget")) {
+        push(@headerContent, "    static EventTarget* toEventTarget(v8::Handle<v8::Object>);\n");
+    }
+
     if ($interfaceName eq "DOMWindow") {
         push(@headerContent, <<END);
     static v8::Persistent<v8::ObjectTemplate> GetShadowObjectTemplate();
@@ -2095,10 +2099,15 @@ sub GenerateNamedConstructorCallback
     if ($interface->extendedAttributes->{"ActiveDOMObject"}) {
         $toActiveDOMObject = "${v8InterfaceName}::toActiveDOMObject";
     }
-    AddToImplIncludes("Frame.h");
 
+    my $toEventTarget = "0";
+    if ($codeGenerator->InheritsExtendedAttribute($interface, "EventTarget")) {
+        $toEventTarget = "${v8InterfaceName}::toEventTarget";
+    }
+
+    AddToImplIncludes("Frame.h");
     push(@implContent, <<END);
-WrapperTypeInfo ${v8InterfaceName}Constructor::info = { ${v8InterfaceName}Constructor::GetTemplate, ${v8InterfaceName}::derefObject, ${toActiveDOMObject}, 0, ${v8InterfaceName}::installPerContextPrototypeProperties, 0, WrapperTypeObjectPrototype };
+WrapperTypeInfo ${v8InterfaceName}Constructor::info = { ${v8InterfaceName}Constructor::GetTemplate, ${v8InterfaceName}::derefObject, $toActiveDOMObject, $toEventTarget, 0, ${v8InterfaceName}::installPerContextPrototypeProperties, 0, WrapperTypeObjectPrototype };
 
 static v8::Handle<v8::Value> ${v8InterfaceName}ConstructorCallback(const v8::Arguments& args)
 {
@@ -2618,7 +2627,8 @@ sub GenerateImplementation
 
     AddIncludesForType($interfaceName);
 
-    my $toActive = $interface->extendedAttributes->{"ActiveDOMObject"} ? "${v8InterfaceName}::toActiveDOMObject" : "0";
+    my $toActiveDOMObject = $interface->extendedAttributes->{"ActiveDOMObject"} ? "${v8InterfaceName}::toActiveDOMObject" : "0";
+    my $toEventTarget = $codeGenerator->InheritsExtendedAttribute($interface, "EventTarget") ? "${v8InterfaceName}::toEventTarget" : "0";
     my $rootForGC = NeedsCustomOpaqueRootForGC($interface) ? "${v8InterfaceName}::opaqueRootForGC" : "0";
 
     # Find the super descriptor.
@@ -2636,7 +2646,7 @@ sub GenerateImplementation
 
     my $WrapperTypePrototype = $interface->isException ? "WrapperTypeErrorPrototype" : "WrapperTypeObjectPrototype";
 
-    push(@implContentDecls, "WrapperTypeInfo ${v8InterfaceName}::info = { ${v8InterfaceName}::GetTemplate, ${v8InterfaceName}::derefObject, $toActive, $rootForGC, ${v8InterfaceName}::installPerContextPrototypeProperties, $parentClassInfo, $WrapperTypePrototype };\n\n");
+    push(@implContentDecls, "WrapperTypeInfo ${v8InterfaceName}::info = { ${v8InterfaceName}::GetTemplate, ${v8InterfaceName}::derefObject, $toActiveDOMObject, $toEventTarget, $rootForGC, ${v8InterfaceName}::installPerContextPrototypeProperties, $parentClassInfo, $WrapperTypePrototype };\n\n");
     push(@implContentDecls, "namespace ${interfaceName}V8Internal {\n\n");
 
     push(@implContentDecls, "template <typename T> void V8_USE(T) { }\n\n");
@@ -3121,6 +3131,7 @@ END
         }
         push(@implContent, <<END);
 }
+
 END
     }
 
@@ -3154,6 +3165,7 @@ END
 
         push(@implContent, <<END);
 }
+
 END
     }
 
@@ -3164,8 +3176,19 @@ END
         push(@implContent, <<END);
 ActiveDOMObject* ${v8InterfaceName}::toActiveDOMObject(v8::Handle<v8::Object> object)
 {
-    return ${returnValue};
-}      
+    return $returnValue;
+}
+
+END
+    }
+
+    if ($codeGenerator->InheritsExtendedAttribute($interface, "EventTarget")) {
+        push(@implContent, <<END);
+EventTarget* ${v8InterfaceName}::toEventTarget(v8::Handle<v8::Object> object)
+{
+    return toNative(object);
+}
+
 END
     }
 
@@ -3180,13 +3203,13 @@ v8::Persistent<v8::ObjectTemplate> V8DOMWindow::GetShadowObjectTemplate()
     }
     return V8DOMWindowShadowObjectCache;
 }
+
 END
     }
 
     GenerateToV8Converters($interface, $v8InterfaceName, $nativeType);
 
     push(@implContent, <<END);
-
 void ${v8InterfaceName}::derefObject(void* object)
 {
     static_cast<${nativeType}*>(object)->deref();
index c0c0bbf..dd33876 100644 (file)
@@ -42,7 +42,7 @@
 
 namespace WebCore {
 
-WrapperTypeInfo V8Float64Array::info = { V8Float64Array::GetTemplate, V8Float64Array::derefObject, 0, 0, V8Float64Array::installPerContextPrototypeProperties, &V8ArrayBufferView::info, WrapperTypeObjectPrototype };
+WrapperTypeInfo V8Float64Array::info = { V8Float64Array::GetTemplate, V8Float64Array::derefObject, 0, 0, 0, V8Float64Array::installPerContextPrototypeProperties, &V8ArrayBufferView::info, WrapperTypeObjectPrototype };
 
 namespace Float64ArrayV8Internal {
 
@@ -162,7 +162,6 @@ v8::Handle<v8::Object> V8Float64Array::createWrapper(PassRefPtr<Float64Array> im
         wrapperHandle.MarkIndependent();
     return wrapper;
 }
-
 void V8Float64Array::derefObject(void* object)
 {
     static_cast<Float64Array*>(object)->deref();
index cd9394b..7e76db3 100644 (file)
@@ -33,7 +33,7 @@
 
 namespace WebCore {
 
-WrapperTypeInfo V8TestActiveDOMObject::info = { V8TestActiveDOMObject::GetTemplate, V8TestActiveDOMObject::derefObject, 0, 0, V8TestActiveDOMObject::installPerContextPrototypeProperties, 0, WrapperTypeObjectPrototype };
+WrapperTypeInfo V8TestActiveDOMObject::info = { V8TestActiveDOMObject::GetTemplate, V8TestActiveDOMObject::derefObject, 0, 0, 0, V8TestActiveDOMObject::installPerContextPrototypeProperties, 0, WrapperTypeObjectPrototype };
 
 namespace TestActiveDOMObjectV8Internal {
 
@@ -189,7 +189,6 @@ v8::Handle<v8::Object> V8TestActiveDOMObject::createWrapper(PassRefPtr<TestActiv
         wrapperHandle.MarkIndependent();
     return wrapper;
 }
-
 void V8TestActiveDOMObject::derefObject(void* object)
 {
     static_cast<TestActiveDOMObject*>(object)->deref();
index b7bc75c..22ba11c 100644 (file)
@@ -32,7 +32,7 @@
 
 namespace WebCore {
 
-WrapperTypeInfo V8TestCustomNamedGetter::info = { V8TestCustomNamedGetter::GetTemplate, V8TestCustomNamedGetter::derefObject, 0, 0, V8TestCustomNamedGetter::installPerContextPrototypeProperties, 0, WrapperTypeObjectPrototype };
+WrapperTypeInfo V8TestCustomNamedGetter::info = { V8TestCustomNamedGetter::GetTemplate, V8TestCustomNamedGetter::derefObject, 0, 0, 0, V8TestCustomNamedGetter::installPerContextPrototypeProperties, 0, WrapperTypeObjectPrototype };
 
 namespace TestCustomNamedGetterV8Internal {
 
@@ -127,7 +127,6 @@ v8::Handle<v8::Object> V8TestCustomNamedGetter::createWrapper(PassRefPtr<TestCus
         wrapperHandle.MarkIndependent();
     return wrapper;
 }
-
 void V8TestCustomNamedGetter::derefObject(void* object)
 {
     static_cast<TestCustomNamedGetter*>(object)->deref();
index 4ffd4a3..620725e 100644 (file)
@@ -32,7 +32,7 @@
 
 namespace WebCore {
 
-WrapperTypeInfo V8TestEventConstructor::info = { V8TestEventConstructor::GetTemplate, V8TestEventConstructor::derefObject, 0, 0, V8TestEventConstructor::installPerContextPrototypeProperties, 0, WrapperTypeObjectPrototype };
+WrapperTypeInfo V8TestEventConstructor::info = { V8TestEventConstructor::GetTemplate, V8TestEventConstructor::derefObject, 0, 0, 0, V8TestEventConstructor::installPerContextPrototypeProperties, 0, WrapperTypeObjectPrototype };
 
 namespace TestEventConstructorV8Internal {
 
@@ -159,7 +159,6 @@ v8::Handle<v8::Object> V8TestEventConstructor::createWrapper(PassRefPtr<TestEven
         wrapperHandle.MarkIndependent();
     return wrapper;
 }
-
 void V8TestEventConstructor::derefObject(void* object)
 {
     static_cast<TestEventConstructor*>(object)->deref();
index 93d0960..e774a33 100644 (file)
@@ -36,7 +36,7 @@
 
 namespace WebCore {
 
-WrapperTypeInfo V8TestEventTarget::info = { V8TestEventTarget::GetTemplate, V8TestEventTarget::derefObject, 0, 0, V8TestEventTarget::installPerContextPrototypeProperties, 0, WrapperTypeObjectPrototype };
+WrapperTypeInfo V8TestEventTarget::info = { V8TestEventTarget::GetTemplate, V8TestEventTarget::derefObject, 0, V8TestEventTarget::toEventTarget, 0, V8TestEventTarget::installPerContextPrototypeProperties, 0, WrapperTypeObjectPrototype };
 
 namespace TestEventTargetV8Internal {
 
@@ -172,6 +172,11 @@ bool V8TestEventTarget::HasInstance(v8::Handle<v8::Value> value)
     return GetRawTemplate()->HasInstance(value);
 }
 
+EventTarget* V8TestEventTarget::toEventTarget(v8::Handle<v8::Object> object)
+{
+    return toNative(object);
+}
+
 
 v8::Handle<v8::Object> V8TestEventTarget::createWrapper(PassRefPtr<TestEventTarget> impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
 {
@@ -188,7 +193,6 @@ v8::Handle<v8::Object> V8TestEventTarget::createWrapper(PassRefPtr<TestEventTarg
         wrapperHandle.MarkIndependent();
     return wrapper;
 }
-
 void V8TestEventTarget::derefObject(void* object)
 {
     static_cast<TestEventTarget*>(object)->deref();
index b2cdecd..5ca7bc1 100644 (file)
@@ -43,6 +43,7 @@ public:
     }
     static void derefObject(void*);
     static WrapperTypeInfo info;
+    static EventTarget* toEventTarget(v8::Handle<v8::Object>);
     static v8::Handle<v8::Value> indexedPropertyGetter(uint32_t, const v8::AccessorInfo&);
     static v8::Handle<v8::Value> namedPropertyGetter(v8::Local<v8::String>, const v8::AccessorInfo&);
     static const int eventListenerCacheIndex = v8DefaultWrapperInternalFieldCount + 0;
index 5e700ac..c3f49b2 100644 (file)
@@ -31,7 +31,7 @@
 
 namespace WebCore {
 
-WrapperTypeInfo V8TestException::info = { V8TestException::GetTemplate, V8TestException::derefObject, 0, 0, V8TestException::installPerContextPrototypeProperties, 0, WrapperTypeErrorPrototype };
+WrapperTypeInfo V8TestException::info = { V8TestException::GetTemplate, V8TestException::derefObject, 0, 0, 0, V8TestException::installPerContextPrototypeProperties, 0, WrapperTypeErrorPrototype };
 
 namespace TestExceptionV8Internal {
 
@@ -118,7 +118,6 @@ v8::Handle<v8::Object> V8TestException::createWrapper(PassRefPtr<TestException>
         wrapperHandle.MarkIndependent();
     return wrapper;
 }
-
 void V8TestException::derefObject(void* object)
 {
     static_cast<TestException*>(object)->deref();
index 1caad62..de37fb6 100644 (file)
@@ -40,7 +40,7 @@
 
 namespace WebCore {
 
-WrapperTypeInfo V8TestInterface::info = { V8TestInterface::GetTemplate, V8TestInterface::derefObject, V8TestInterface::toActiveDOMObject, 0, V8TestInterface::installPerContextPrototypeProperties, 0, WrapperTypeObjectPrototype };
+WrapperTypeInfo V8TestInterface::info = { V8TestInterface::GetTemplate, V8TestInterface::derefObject, V8TestInterface::toActiveDOMObject, 0, 0, V8TestInterface::installPerContextPrototypeProperties, 0, WrapperTypeObjectPrototype };
 
 namespace TestInterfaceV8Internal {
 
@@ -330,7 +330,8 @@ bool V8TestInterface::HasInstance(v8::Handle<v8::Value> value)
 ActiveDOMObject* V8TestInterface::toActiveDOMObject(v8::Handle<v8::Object> object)
 {
     return toNative(object);
-}      
+}
+
 
 v8::Handle<v8::Object> V8TestInterface::createWrapper(PassRefPtr<TestInterface> impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
 {
@@ -347,7 +348,6 @@ v8::Handle<v8::Object> V8TestInterface::createWrapper(PassRefPtr<TestInterface>
         wrapperHandle.MarkIndependent();
     return wrapper;
 }
-
 void V8TestInterface::derefObject(void* object)
 {
     static_cast<TestInterface*>(object)->deref();
index 4241e48..2ffdc2b 100644 (file)
@@ -33,7 +33,7 @@
 
 namespace WebCore {
 
-WrapperTypeInfo V8TestMediaQueryListListener::info = { V8TestMediaQueryListListener::GetTemplate, V8TestMediaQueryListListener::derefObject, 0, 0, V8TestMediaQueryListListener::installPerContextPrototypeProperties, 0, WrapperTypeObjectPrototype };
+WrapperTypeInfo V8TestMediaQueryListListener::info = { V8TestMediaQueryListListener::GetTemplate, V8TestMediaQueryListListener::derefObject, 0, 0, 0, V8TestMediaQueryListListener::installPerContextPrototypeProperties, 0, WrapperTypeObjectPrototype };
 
 namespace TestMediaQueryListListenerV8Internal {
 
@@ -127,7 +127,6 @@ v8::Handle<v8::Object> V8TestMediaQueryListListener::createWrapper(PassRefPtr<Te
         wrapperHandle.MarkIndependent();
     return wrapper;
 }
-
 void V8TestMediaQueryListListener::derefObject(void* object)
 {
     static_cast<TestMediaQueryListListener*>(object)->deref();
index d54b3bc..f4ebe5e 100644 (file)
@@ -32,7 +32,7 @@
 
 namespace WebCore {
 
-WrapperTypeInfo V8TestNamedConstructor::info = { V8TestNamedConstructor::GetTemplate, V8TestNamedConstructor::derefObject, V8TestNamedConstructor::toActiveDOMObject, 0, V8TestNamedConstructor::installPerContextPrototypeProperties, 0, WrapperTypeObjectPrototype };
+WrapperTypeInfo V8TestNamedConstructor::info = { V8TestNamedConstructor::GetTemplate, V8TestNamedConstructor::derefObject, V8TestNamedConstructor::toActiveDOMObject, 0, 0, V8TestNamedConstructor::installPerContextPrototypeProperties, 0, WrapperTypeObjectPrototype };
 
 namespace TestNamedConstructorV8Internal {
 
@@ -40,7 +40,7 @@ template <typename T> void V8_USE(T) { }
 
 } // namespace TestNamedConstructorV8Internal
 
-WrapperTypeInfo V8TestNamedConstructorConstructor::info = { V8TestNamedConstructorConstructor::GetTemplate, V8TestNamedConstructor::derefObject, V8TestNamedConstructor::toActiveDOMObject, 0, V8TestNamedConstructor::installPerContextPrototypeProperties, 0, WrapperTypeObjectPrototype };
+WrapperTypeInfo V8TestNamedConstructorConstructor::info = { V8TestNamedConstructorConstructor::GetTemplate, V8TestNamedConstructor::derefObject, V8TestNamedConstructor::toActiveDOMObject, 0, 0, V8TestNamedConstructor::installPerContextPrototypeProperties, 0, WrapperTypeObjectPrototype };
 
 static v8::Handle<v8::Value> V8TestNamedConstructorConstructorCallback(const v8::Arguments& args)
 {
@@ -150,7 +150,8 @@ bool V8TestNamedConstructor::HasInstance(v8::Handle<v8::Value> value)
 ActiveDOMObject* V8TestNamedConstructor::toActiveDOMObject(v8::Handle<v8::Object> object)
 {
     return toNative(object);
-}      
+}
+
 
 v8::Handle<v8::Object> V8TestNamedConstructor::createWrapper(PassRefPtr<TestNamedConstructor> impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
 {
@@ -167,7 +168,6 @@ v8::Handle<v8::Object> V8TestNamedConstructor::createWrapper(PassRefPtr<TestName
         wrapperHandle.MarkIndependent();
     return wrapper;
 }
-
 void V8TestNamedConstructor::derefObject(void* object)
 {
     static_cast<TestNamedConstructor*>(object)->deref();
index bbca998..418a7ac 100644 (file)
@@ -32,7 +32,7 @@
 
 namespace WebCore {
 
-WrapperTypeInfo V8TestNode::info = { V8TestNode::GetTemplate, V8TestNode::derefObject, 0, 0, V8TestNode::installPerContextPrototypeProperties, &V8Node::info, WrapperTypeObjectPrototype };
+WrapperTypeInfo V8TestNode::info = { V8TestNode::GetTemplate, V8TestNode::derefObject, 0, V8TestNode::toEventTarget, 0, V8TestNode::installPerContextPrototypeProperties, &V8Node::info, WrapperTypeObjectPrototype };
 
 namespace TestNodeV8Internal {
 
@@ -109,6 +109,11 @@ bool V8TestNode::HasInstance(v8::Handle<v8::Value> value)
     return GetRawTemplate()->HasInstance(value);
 }
 
+EventTarget* V8TestNode::toEventTarget(v8::Handle<v8::Object> object)
+{
+    return toNative(object);
+}
+
 
 v8::Handle<v8::Object> V8TestNode::createWrapper(PassRefPtr<TestNode> impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
 {
@@ -126,7 +131,6 @@ v8::Handle<v8::Object> V8TestNode::createWrapper(PassRefPtr<TestNode> impl, v8::
         wrapperHandle.MarkIndependent();
     return wrapper;
 }
-
 void V8TestNode::derefObject(void* object)
 {
     static_cast<TestNode*>(object)->deref();
index 022d8ee..f1b0402 100644 (file)
@@ -43,6 +43,7 @@ public:
     }
     static void derefObject(void*);
     static WrapperTypeInfo info;
+    static EventTarget* toEventTarget(v8::Handle<v8::Object>);
     static v8::Handle<v8::Value> constructorCallback(const v8::Arguments&);
     static const int internalFieldCount = v8DefaultWrapperInternalFieldCount + 0;
     static void installPerContextProperties(v8::Handle<v8::Object>, TestNode*) { }
index 14f9aaf..5fe35c1 100644 (file)
@@ -74,7 +74,7 @@
 
 namespace WebCore {
 
-WrapperTypeInfo V8TestObj::info = { V8TestObj::GetTemplate, V8TestObj::derefObject, 0, 0, V8TestObj::installPerContextPrototypeProperties, 0, WrapperTypeObjectPrototype };
+WrapperTypeInfo V8TestObj::info = { V8TestObj::GetTemplate, V8TestObj::derefObject, 0, 0, 0, V8TestObj::installPerContextPrototypeProperties, 0, WrapperTypeObjectPrototype };
 
 namespace TestObjV8Internal {
 
@@ -2222,6 +2222,7 @@ void V8TestObj::installPerContextProperties(v8::Handle<v8::Object> instance, Tes
         V8DOMConfiguration::configureAttribute(instance, proto, attrData);
     }
 }
+
 void V8TestObj::installPerContextPrototypeProperties(v8::Handle<v8::Object> proto)
 {
     UNUSED_PARAM(proto);
@@ -2237,6 +2238,7 @@ void V8TestObj::installPerContextPrototypeProperties(v8::Handle<v8::Object> prot
     }
 }
 
+
 v8::Handle<v8::Object> V8TestObj::createWrapper(PassRefPtr<TestObj> impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
 {
     ASSERT(impl.get());
@@ -2252,7 +2254,6 @@ v8::Handle<v8::Object> V8TestObj::createWrapper(PassRefPtr<TestObj> impl, v8::Ha
         wrapperHandle.MarkIndependent();
     return wrapper;
 }
-
 void V8TestObj::derefObject(void* object)
 {
     static_cast<TestObj*>(object)->deref();
index e3472a9..0128ebf 100644 (file)
@@ -37,7 +37,7 @@
 
 namespace WebCore {
 
-WrapperTypeInfo V8TestOverloadedConstructors::info = { V8TestOverloadedConstructors::GetTemplate, V8TestOverloadedConstructors::derefObject, 0, 0, V8TestOverloadedConstructors::installPerContextPrototypeProperties, 0, WrapperTypeObjectPrototype };
+WrapperTypeInfo V8TestOverloadedConstructors::info = { V8TestOverloadedConstructors::GetTemplate, V8TestOverloadedConstructors::derefObject, 0, 0, 0, V8TestOverloadedConstructors::installPerContextPrototypeProperties, 0, WrapperTypeObjectPrototype };
 
 namespace TestOverloadedConstructorsV8Internal {
 
@@ -182,7 +182,6 @@ v8::Handle<v8::Object> V8TestOverloadedConstructors::createWrapper(PassRefPtr<Te
         wrapperHandle.MarkIndependent();
     return wrapper;
 }
-
 void V8TestOverloadedConstructors::derefObject(void* object)
 {
     static_cast<TestOverloadedConstructors*>(object)->deref();
index e0ae9fd..e935bda 100644 (file)
@@ -38,7 +38,7 @@
 
 namespace WebCore {
 
-WrapperTypeInfo V8TestSerializedScriptValueInterface::info = { V8TestSerializedScriptValueInterface::GetTemplate, V8TestSerializedScriptValueInterface::derefObject, 0, 0, V8TestSerializedScriptValueInterface::installPerContextPrototypeProperties, 0, WrapperTypeObjectPrototype };
+WrapperTypeInfo V8TestSerializedScriptValueInterface::info = { V8TestSerializedScriptValueInterface::GetTemplate, V8TestSerializedScriptValueInterface::derefObject, 0, 0, 0, V8TestSerializedScriptValueInterface::installPerContextPrototypeProperties, 0, WrapperTypeObjectPrototype };
 
 namespace TestSerializedScriptValueInterfaceV8Internal {
 
@@ -300,7 +300,6 @@ v8::Handle<v8::Object> V8TestSerializedScriptValueInterface::createWrapper(PassR
         wrapperHandle.MarkIndependent();
     return wrapper;
 }
-
 void V8TestSerializedScriptValueInterface::derefObject(void* object)
 {
     static_cast<TestSerializedScriptValueInterface*>(object)->deref();
index 7936b87..98990e1 100644 (file)
@@ -30,6 +30,7 @@
 #include "DOMStringList.h"
 #include "V8Binding.h"
 #include "V8DOMWindow.h"
+#include "V8EventTarget.h"
 #include "V8Storage.h"
 #include "V8Uint8Array.h"
 #include "V8Utilities.h"
@@ -458,6 +459,21 @@ bool Dictionary::get(const String& key, RefPtr<MediaStream>& value) const
 }
 #endif
 
+bool Dictionary::get(const String& key, RefPtr<EventTarget>& value) const
+{
+    v8::Local<v8::Value> v8Value;
+    if (!getKey(key, v8Value))
+        return false;
+
+    EventTarget* target = 0;
+    if (V8DOMWrapper::isDOMWrapper(v8Value)) {
+        v8::Handle<v8::Object> wrapper = v8::Handle<v8::Object>::Cast(v8Value);
+        target = toWrapperTypeInfo(wrapper)->toEventTarget(wrapper);
+    }
+    value = target;
+    return true;
+}
+
 bool Dictionary::get(const String& key, Dictionary& value) const
 {
     v8::Local<v8::Value> v8Value;
index f774a22..7650295 100644 (file)
@@ -88,6 +88,7 @@ public:
 #if ENABLE(MEDIA_STREAM)
     bool get(const String&, RefPtr<MediaStream>&) const;
 #endif
+    bool get(const String&, RefPtr<EventTarget>&) const;
     bool get(const String&, HashSet<AtomicString>&) const;
     bool get(const String&, Dictionary&) const;
     bool get(const String&, Vector<String>&) const;
index 2680b0d..afe2f62 100644 (file)
@@ -51,7 +51,7 @@ namespace WebCore {
 
 WrapperTypeInfo* npObjectTypeInfo()
 {
-    static WrapperTypeInfo typeInfo = { 0, 0, 0, 0, 0, 0, WrapperTypeObjectPrototype };
+    static WrapperTypeInfo typeInfo = { 0, 0, 0, 0, 0, 0, 0, WrapperTypeObjectPrototype };
     return &typeInfo;
 }
 
index 3c4a935..e1b7aff 100644 (file)
@@ -115,6 +115,21 @@ bool V8DOMWrapper::maybeDOMWrapper(v8::Handle<v8::Value> value)
 }
 #endif
 
+bool V8DOMWrapper::isDOMWrapper(v8::Handle<v8::Value> value)
+{
+    if (value.IsEmpty() || !value->IsObject())
+        return false;
+
+    v8::Handle<v8::Object> wrapper = v8::Handle<v8::Object>::Cast(value);
+    if (wrapper->InternalFieldCount() < v8DefaultWrapperInternalFieldCount)
+        return false;
+    ASSERT(object->GetAlignedPointerFromInternalField(v8DOMWrapperObjectIndex));
+    ASSERT(object->GetAlignedPointerFromInternalField(v8DOMWrapperTypeIndex));
+
+    // FIXME: Add class id checks.
+    return true;
+}
+
 bool V8DOMWrapper::isWrapperOfType(v8::Handle<v8::Value> value, WrapperTypeInfo* type)
 {
     if (!hasInternalField(value))
index b944f52..770f9b6 100644 (file)
@@ -62,6 +62,7 @@ namespace WebCore {
         static inline void setWrapperClass(void*, v8::Persistent<v8::Object>);
         static inline void setWrapperClass(Node*, v8::Persistent<v8::Object>);
 
+        static bool isDOMWrapper(v8::Handle<v8::Value>);
         static bool isWrapperOfType(v8::Handle<v8::Value>, WrapperTypeInfo*);
 
         // FIXME: Why is this function in V8DOMWrapper?
index ade1b8f..c4bc23c 100644 (file)
@@ -37,6 +37,7 @@ namespace WebCore {
     
     class ActiveDOMObject;
     class DOMDataStore;
+    class EventTarget;
 
     static const int v8DOMWrapperTypeIndex = 0;
     static const int v8DOMWrapperObjectIndex = 1;
@@ -48,6 +49,7 @@ namespace WebCore {
     typedef v8::Persistent<v8::FunctionTemplate> (*GetTemplateFunction)(v8::Isolate*);
     typedef void (*DerefObjectFunction)(void*);
     typedef ActiveDOMObject* (*ToActiveDOMObjectFunction)(v8::Handle<v8::Object>);
+    typedef EventTarget* (*ToEventTargetFunction)(v8::Handle<v8::Object>);
     typedef void* (*OpaqueRootForGC)(void*, v8::Persistent<v8::Object>);
     typedef void (*InstallPerContextPrototypePropertiesFunction)(v8::Handle<v8::Object>);
 
@@ -103,6 +105,13 @@ namespace WebCore {
             return toActiveDOMObjectFunction(object);
         }
 
+        EventTarget* toEventTarget(v8::Handle<v8::Object> object)
+        {
+            if (!toEventTargetFunction)
+                return 0;
+            return toEventTargetFunction(object);
+        }
+
         void* opaqueRootForGC(void* object, v8::Persistent<v8::Object> wrapper)
         {
             if (!opaqueRootForGCFunction)
@@ -113,6 +122,7 @@ namespace WebCore {
         const GetTemplateFunction getTemplateFunction;
         const DerefObjectFunction derefObjectFunction;
         const ToActiveDOMObjectFunction toActiveDOMObjectFunction;
+        const ToEventTargetFunction toEventTargetFunction;
         const OpaqueRootForGC opaqueRootForGCFunction;
         const InstallPerContextPrototypePropertiesFunction installPerContextPrototypePropertiesFunction;
         const WrapperTypeInfo* parentClass;
index cf858fa..c1f5b6e 100644 (file)
@@ -43,7 +43,7 @@
 
 namespace WebCore {
 
-WrapperTypeInfo V8HTMLImageElementConstructor::info = { V8HTMLImageElementConstructor::GetTemplate, V8HTMLImageElement::derefObject, 0, 0, V8HTMLImageElement::installPerContextPrototypeProperties, 0, WrapperTypeObjectPrototype };
+WrapperTypeInfo V8HTMLImageElementConstructor::info = { V8HTMLImageElementConstructor::GetTemplate, V8HTMLImageElement::derefObject, 0, V8HTMLImageElement::toEventTarget, 0, V8HTMLImageElement::installPerContextPrototypeProperties, 0, WrapperTypeObjectPrototype };
 
 static v8::Handle<v8::Value> v8HTMLImageElementConstructorCallback(const v8::Arguments& args)
 {
index dd13b32..695e2f7 100644 (file)
 
 namespace WebCore {
 
+MouseEventInit::MouseEventInit()
+    : screenX(0)
+    , screenY(0)
+    , clientX(0)
+    , clientY(0)
+    , ctrlKey(false)
+    , altKey(false)
+    , shiftKey(false)
+    , metaKey(false)
+    , button(0)
+    , relatedTarget(0)
+{
+}
+
+PassRefPtr<MouseEvent> MouseEvent::create(const AtomicString& type, const MouseEventInit& initializer)
+{
+    return adoptRef(new MouseEvent(type, initializer));
+}
+
 PassRefPtr<MouseEvent> MouseEvent::create(const AtomicString& eventType, PassRefPtr<AbstractView> view, const PlatformMouseEvent& event, int detail, PassRefPtr<Node> relatedTarget)
 {
     ASSERT(event.type() == PlatformEvent::MouseMoved || event.button() != NoButton);
@@ -74,6 +93,21 @@ MouseEvent::MouseEvent(const AtomicString& eventType, bool canBubble, bool cance
 {
 }
 
+MouseEvent::MouseEvent(const AtomicString& eventType, const MouseEventInit& initializer)
+    : MouseRelatedEvent(eventType, initializer.bubbles, initializer.cancelable, initializer.view, initializer.detail, IntPoint(initializer.screenX, initializer.screenY),
+        IntPoint(0 /* pageX */, 0 /* pageY */),
+#if ENABLE(POINTER_LOCK)
+        IntPoint(0 /* movementX */, 0 /* movementY */),
+#endif
+        initializer.ctrlKey, initializer.altKey, initializer.shiftKey, initializer.metaKey, false /* isSimulated */)
+    , m_button(initializer.button == (unsigned short)-1 ? 0 : initializer.button)
+    , m_buttonDown(initializer.button != (unsigned short)-1)
+    , m_relatedTarget(initializer.relatedTarget)
+    , m_clipboard(0 /* clipboard */)
+{
+    initCoordinates(IntPoint(initializer.clientX, initializer.clientY));
+}
+
 MouseEvent::~MouseEvent()
 {
 }
index 44adf2d..f9c0530 100644 (file)
@@ -33,76 +33,95 @@ namespace WebCore {
 class EventDispatcher;
 class PlatformMouseEvent;
 
-    // Introduced in DOM Level 2
-    class MouseEvent : public MouseRelatedEvent {
-    public:
-        static PassRefPtr<MouseEvent> create()
-        {
-            return adoptRef(new MouseEvent);
-        }
-        static PassRefPtr<MouseEvent> create(const AtomicString& type, bool canBubble, bool cancelable, PassRefPtr<AbstractView> view,
-            int detail, int screenX, int screenY, int pageX, int pageY,
+struct MouseEventInit : public UIEventInit {
+    MouseEventInit();
+
+    int screenX;
+    int screenY;
+    int clientX;
+    int clientY;
+    bool ctrlKey;
+    bool altKey;
+    bool shiftKey;
+    bool metaKey;
+    unsigned short button;
+    RefPtr<EventTarget> relatedTarget;
+};
+
+class MouseEvent : public MouseRelatedEvent {
+public:
+    static PassRefPtr<MouseEvent> create()
+    {
+        return adoptRef(new MouseEvent);
+    }
+
+    static PassRefPtr<MouseEvent> create(const AtomicString& type, bool canBubble, bool cancelable, PassRefPtr<AbstractView> view,
+        int detail, int screenX, int screenY, int pageX, int pageY,
 #if ENABLE(POINTER_LOCK)
-            int movementX, int movementY,
+        int movementX, int movementY,
 #endif
-            bool ctrlKey, bool altKey, bool shiftKey, bool metaKey, unsigned short button,
-            PassRefPtr<EventTarget> relatedTarget, PassRefPtr<Clipboard> clipboard = 0, bool isSimulated = false)
-        {
-            return adoptRef(new MouseEvent(type, canBubble, cancelable, view, detail, screenX, screenY, pageX, pageY,
+        bool ctrlKey, bool altKey, bool shiftKey, bool metaKey, unsigned short button,
+        PassRefPtr<EventTarget> relatedTarget, PassRefPtr<Clipboard> clipboard = 0, bool isSimulated = false)
+    {
+        return adoptRef(new MouseEvent(type, canBubble, cancelable, view, detail, screenX, screenY, pageX, pageY,
 #if ENABLE(POINTER_LOCK)
-                movementX, movementY,
+        movementX, movementY,
 #endif
-                ctrlKey, altKey, shiftKey, metaKey, button, relatedTarget, clipboard, isSimulated));
-        }
-        static PassRefPtr<MouseEvent> create(const AtomicString& eventType, PassRefPtr<AbstractView>, const PlatformMouseEvent&, int detail, PassRefPtr<Node> relatedTarget);
+        ctrlKey, altKey, shiftKey, metaKey, button, relatedTarget, clipboard, isSimulated));
+    }
+
+    static PassRefPtr<MouseEvent> create(const AtomicString& eventType, PassRefPtr<AbstractView>, const PlatformMouseEvent&, int detail, PassRefPtr<Node> relatedTarget);
+
+    static PassRefPtr<MouseEvent> create(const AtomicString& eventType, const MouseEventInit&);
 
-        virtual ~MouseEvent();
+    virtual ~MouseEvent();
 
-        void initMouseEvent(const AtomicString& type, bool canBubble, bool cancelable, PassRefPtr<AbstractView>,
-                            int detail, int screenX, int screenY, int clientX, int clientY,
-                            bool ctrlKey, bool altKey, bool shiftKey, bool metaKey,
-                            unsigned short button, PassRefPtr<EventTarget> relatedTarget);
+    void initMouseEvent(const AtomicString& type, bool canBubble, bool cancelable, PassRefPtr<AbstractView>,
+        int detail, int screenX, int screenY, int clientX, int clientY,
+        bool ctrlKey, bool altKey, bool shiftKey, bool metaKey,
+        unsigned short button, PassRefPtr<EventTarget> relatedTarget);
 
-        // WinIE uses 1,4,2 for left/middle/right but not for click (just for mousedown/up, maybe others),
-        // but we will match the standard DOM.
-        unsigned short button() const { return m_button; }
-        bool buttonDown() const { return m_buttonDown; }
-        EventTarget* relatedTarget() const { return m_relatedTarget.get(); }
-        void setRelatedTarget(PassRefPtr<EventTarget> relatedTarget) { m_relatedTarget = relatedTarget; }
+    // WinIE uses 1,4,2 for left/middle/right but not for click (just for mousedown/up, maybe others),
+    // but we will match the standard DOM.
+    unsigned short button() const { return m_button; }
+    bool buttonDown() const { return m_buttonDown; }
+    EventTarget* relatedTarget() const { return m_relatedTarget.get(); }
+    void setRelatedTarget(PassRefPtr<EventTarget> relatedTarget) { m_relatedTarget = relatedTarget; }
 
-        Clipboard* clipboard() const { return m_clipboard.get(); }
+    Clipboard* clipboard() const { return m_clipboard.get(); }
 
-        Node* toElement() const;
-        Node* fromElement() const;
+    Node* toElement() const;
+    Node* fromElement() const;
 
-        Clipboard* dataTransfer() const { return isDragEvent() ? m_clipboard.get() : 0; }
+    Clipboard* dataTransfer() const { return isDragEvent() ? m_clipboard.get() : 0; }
 
-        virtual const AtomicString& interfaceName() const;
+    virtual const AtomicString& interfaceName() const;
 
-        virtual bool isMouseEvent() const;
-        virtual bool isDragEvent() const;
-        virtual int which() const;
+    virtual bool isMouseEvent() const;
+    virtual bool isDragEvent() const;
+    virtual int which() const;
 
-        virtual PassRefPtr<Event> cloneFor(HTMLIFrameElement*) const OVERRIDE;
+    virtual PassRefPtr<Event> cloneFor(HTMLIFrameElement*) const OVERRIDE;
 
-    protected:
-        MouseEvent(const AtomicString& type, bool canBubble, bool cancelable, PassRefPtr<AbstractView>,
-                   int detail, int screenX, int screenY, int pageX, int pageY,
+protected:
+    MouseEvent(const AtomicString& type, bool canBubble, bool cancelable, PassRefPtr<AbstractView>,
+        int detail, int screenX, int screenY, int pageX, int pageY,
 #if ENABLE(POINTER_LOCK)
-                   int movementX, int movementY,
+        int movementX, int movementY,
 #endif
-                   bool ctrlKey, bool altKey, bool shiftKey, bool metaKey, unsigned short button,
-                   PassRefPtr<EventTarget> relatedTarget, PassRefPtr<Clipboard> clipboard, bool isSimulated);
-
-    protected:
-        MouseEvent();
-
-    private:
-        unsigned short m_button;
-        bool m_buttonDown;
-        RefPtr<EventTarget> m_relatedTarget;
-        RefPtr<Clipboard> m_clipboard;
-    };
+        bool ctrlKey, bool altKey, bool shiftKey, bool metaKey, unsigned short button,
+        PassRefPtr<EventTarget> relatedTarget, PassRefPtr<Clipboard>, bool isSimulated);
+
+    MouseEvent(const AtomicString& type, const MouseEventInit&);
+
+    MouseEvent();
+
+private:
+    unsigned short m_button;
+    bool m_buttonDown;
+    RefPtr<EventTarget> m_relatedTarget;
+    RefPtr<Clipboard> m_clipboard;
+};
 
 class SimulatedMouseEvent : public MouseEvent {
 public:
index c0e2f01..78728cf 100644 (file)
  * Boston, MA 02110-1301, USA.
  */
 
-// Introduced in DOM Level 2:
-interface MouseEvent : UIEvent {
-    readonly attribute long             screenX;
-    readonly attribute long             screenY;
-    readonly attribute long             clientX;
-    readonly attribute long             clientY;
-    [Conditional=POINTER_LOCK] readonly attribute long webkitMovementX;
-    [Conditional=POINTER_LOCK] readonly attribute long webkitMovementY;
-    readonly attribute boolean          ctrlKey;
-    readonly attribute boolean          shiftKey;
-    readonly attribute boolean          altKey;
-    readonly attribute boolean          metaKey;
-    readonly attribute unsigned short   button;
-    readonly attribute EventTarget      relatedTarget;
+[
+    ConstructorConditional=DOM4_EVENTS_CONSTRUCTOR,
+    ConstructorTemplate=Event
+] interface MouseEvent : UIEvent {
+    [InitializedByEventConstructor] readonly attribute long             screenX;
+    [InitializedByEventConstructor] readonly attribute long             screenY;
+    [InitializedByEventConstructor] readonly attribute long             clientX;
+    [InitializedByEventConstructor] readonly attribute long             clientY;
+    [InitializedByEventConstructor] readonly attribute boolean          ctrlKey;
+    [InitializedByEventConstructor] readonly attribute boolean          shiftKey;
+    [InitializedByEventConstructor] readonly attribute boolean          altKey;
+    [InitializedByEventConstructor] readonly attribute boolean          metaKey;
+    [InitializedByEventConstructor] readonly attribute unsigned short   button;
+    [InitializedByEventConstructor] readonly attribute EventTarget      relatedTarget;
+    [Conditional=POINTER_LOCK]      readonly attribute long             webkitMovementX;
+    [Conditional=POINTER_LOCK]      readonly attribute long             webkitMovementY;
     
     [ObjCLegacyUnnamedParameters] void initMouseEvent(in [Optional=DefaultIsUndefined] DOMString type, 
                                        in [Optional=DefaultIsUndefined] boolean canBubble,