WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
[patch]
WIP patch
diff.txt (text/plain), 11.13 KB, created by
Kentaro Hara
on 2011-08-30 17:02:10 PDT
(
hide
)
Description:
WIP patch
Filename:
MIME Type:
Creator:
Kentaro Hara
Created:
2011-08-30 17:02:10 PDT
Size:
11.13 KB
patch
obsolete
>diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog >index 53056c8..df78a70 100644 >--- a/LayoutTests/ChangeLog >+++ b/LayoutTests/ChangeLog >@@ -1,3 +1,15 @@ >+2011-08-30 Kentaro Hara <haraken@google.com> >+ >+ Implement the Event constructor for V8. >+ https://bugs.webkit.org/show_bug.cgi?id=66756 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ This patch enables fast/events/constructors/event-constructors.html, >+ since the Event consructor is now available in V8. >+ >+ * platform/chromium/test_expectations.txt: >+ > 2011-08-29 Tom Zakrajsek <tomz@codeaurora.org> > > canvas arc() missing line to start of arc if swing is zero >diff --git a/LayoutTests/platform/chromium/test_expectations.txt b/LayoutTests/platform/chromium/test_expectations.txt >index d5e30da..90bba15 100644 >--- a/LayoutTests/platform/chromium/test_expectations.txt >+++ b/LayoutTests/platform/chromium/test_expectations.txt >@@ -3669,8 +3669,5 @@ BUGWK67007 DEBUG : fast/ruby/generated-before-and-after-counter-doesnt-crash.htm > BUGWK67074 WIN LINUX DEBUG : fast/replaced/frame-removed-during-resize.html = CRASH > BUGWK67074 WIN LINUX DEBUG : scrollbars/scrollbar-buttons.html = CRASH > >-// Implement an Event constructor in V8. >-BUGWK66756 : fast/events/constructors/event-constructors.html = TEXT >- > // Started to fail on all bots after r93951. > BUGWK63878 : fast/dom/dom-constructors.html = TEXT >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 5c41dc9..92d40dc 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,26 @@ >+2011-08-30 Kentaro Hara <haraken@google.com> >+ >+ Implement the Event constructor for V8. >+ https://bugs.webkit.org/show_bug.cgi?id=66756 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ The spec of the Event constructor is here: >+ http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-event-constructor >+ This patch implements the Event constructor for V8 in V8EventConstructors.cpp, >+ similar to the implementation for JSC in JSEventConstructors.cpp. >+ >+ * WebCore.gypi: Added V8EventConstructors.cpp. >+ * WebCore.pro: Ditto. >+ * bindings/scripts/CodeGeneratorV8.pm: >+ * bindings/v8/OptionsObject.cpp: >+ (WebCore::OptionsObject::getKeyDouble): Returns a value of type double corresponding to a given key. >+ * bindings/v8/OptionsObject.h: >+ (WebCore::OptionsObject::getKeyValue): Returns a value corresnponding to a given key. >+ * bindings/v8/custom/V8EventConstructors.cpp: Added. >+ (WebCore::constructV8Event): AllowAllocation::current() means that a DOM object created by WebCore is going to be just wrapped into a V8 object. In this case, we skip the code of constructorCallback(). >+ * dom/Event.idl: Added |V8CustomConstructor|. >+ > 2011-08-29 Tom Zakrajsek <tomz@codeaurora.org> > > canvas arc() missing line to start of arc if swing is zero >diff --git a/Source/WebCore/WebCore.gypi b/Source/WebCore/WebCore.gypi >index c06ce4b..24f43a9 100644 >--- a/Source/WebCore/WebCore.gypi >+++ b/Source/WebCore/WebCore.gypi >@@ -2144,6 +2144,7 @@ > 'bindings/v8/custom/V8ElementCustom.cpp', > 'bindings/v8/custom/V8EntryCustom.cpp', > 'bindings/v8/custom/V8EntrySyncCustom.cpp', >+ 'bindings/v8/custom/V8EventConstructors.cpp', > 'bindings/v8/custom/V8EventCustom.cpp', > 'bindings/v8/custom/V8EventSourceConstructor.cpp', > 'bindings/v8/custom/V8FileReaderCustom.cpp', >diff --git a/Source/WebCore/WebCore.pro b/Source/WebCore/WebCore.pro >index 8b6c906..7782780 100644 >--- a/Source/WebCore/WebCore.pro >+++ b/Source/WebCore/WebCore.pro >@@ -79,6 +79,7 @@ v8 { > bindings/v8/custom/V8DataViewCustom.cpp \ > bindings/v8/custom/V8DeviceMotionEventCustom.cpp \ > bindings/v8/custom/V8DeviceOrientationEventCustom.cpp \ >+ bindings/v8/custom/V8EventConstructors.cpp \ > bindings/v8/custom/V8Float32ArrayCustom.cpp \ > bindings/v8/custom/V8Float64ArrayCustom.cpp \ > bindings/v8/custom/V8Int8ArrayCustom.cpp \ >diff --git a/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm b/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm >index f3c6441..da22ae3 100644 >--- a/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm >+++ b/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm >@@ -2049,7 +2049,7 @@ END > > if ($dataNode->extendedAttributes->{"CustomConstructor"} || $dataNode->extendedAttributes->{"V8CustomConstructor"} || $dataNode->extendedAttributes->{"CanBeConstructed"}) { > push(@implContent, <<END); >- desc->SetCallHandler(V8${interfaceName}::constructorCallback); >+ desc->SetCallHandler(V8${interfaceName}::constructorCallback); > END > } > >diff --git a/Source/WebCore/bindings/v8/OptionsObject.cpp b/Source/WebCore/bindings/v8/OptionsObject.cpp >index c56d885..80fa7fe 100644 >--- a/Source/WebCore/bindings/v8/OptionsObject.cpp >+++ b/Source/WebCore/bindings/v8/OptionsObject.cpp >@@ -89,6 +89,19 @@ bool OptionsObject::getKeyInt32(const String& key, int32_t& value) const > return true; > } > >+bool OptionsObject::getKeyDouble(const String& key, double& value) const >+{ >+ v8::Local<v8::Value> v8Value; >+ if (!getKey(key, v8Value)) >+ return false; >+ >+ v8::Local<v8::Number> v8Number = v8Value->ToNumber(); >+ if (v8Number.IsEmpty()) >+ return false; >+ value = v8Number->Value(); >+ return true; >+} >+ > bool OptionsObject::getKeyString(const String& key, String& value) const > { > v8::Local<v8::Value> v8Value; >diff --git a/Source/WebCore/bindings/v8/OptionsObject.h b/Source/WebCore/bindings/v8/OptionsObject.h >index cc00c87..d1be0b4 100644 >--- a/Source/WebCore/bindings/v8/OptionsObject.h >+++ b/Source/WebCore/bindings/v8/OptionsObject.h >@@ -45,11 +45,29 @@ public: > bool isUndefinedOrNull() const; > bool getKeyBool(const String& key, bool& value) const; > bool getKeyInt32(const String& key, int32_t& value) const; >+ bool getKeyDouble(const String& key, double& value) const; > bool getKeyString(const String& key, String& value) const; > bool getKeyStringWithUndefinedOrNullCheck(const String& key, String& value) const; > PassRefPtr<DOMStringList> getKeyDOMStringList(const String& key) const; > PassRefPtr<IDBKeyRange> getKeyKeyRange(const String& key) const; > >+ bool getKeyValue(const String& key, bool& value) const >+ { >+ return getKeyBool(key, value); >+ } >+ bool getKeyValue(const String& key, int32_t& value) const >+ { >+ return getKeyInt32(key, value); >+ } >+ bool getKeyValue(const String& key, double& value) const >+ { >+ return getKeyDouble(key, value); >+ } >+ bool getKeyValue(const String& key, String& value) const >+ { >+ return getKeyString(key, value); >+ } >+ > private: > bool getKey(const String& key, v8::Local<v8::Value>&) const; > >diff --git a/Source/WebCore/bindings/v8/custom/V8EventConstructors.cpp b/Source/WebCore/bindings/v8/custom/V8EventConstructors.cpp >new file mode 100644 >index 0000000..a7cf2ba >--- /dev/null >+++ b/Source/WebCore/bindings/v8/custom/V8EventConstructors.cpp >@@ -0,0 +1,100 @@ >+/* >+ * Copyright (C) 2011 Google Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions are >+ * met: >+ * >+ * * Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * * Redistributions in binary form must reproduce the above >+ * copyright notice, this list of conditions and the following disclaimer >+ * in the documentation and/or other materials provided with the >+ * distribution. >+ * * Neither the name of Google Inc. nor the names of its >+ * contributors may be used to endorse or promote products derived from >+ * this software without specific prior written permission. >+ * >+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS >+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT >+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR >+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT >+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, >+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT >+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, >+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY >+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#include "config.h" >+#include "EventConstructors.h" >+ >+#include "Document.h" >+#include "DocumentFragment.h" >+#include "Node.h" >+ >+#include "OptionsObject.h" >+#include "V8Binding.h" >+#include "V8BindingMacros.h" >+#include "V8Document.h" >+#include "V8Event.h" >+#include "V8Node.h" >+#include "V8Proxy.h" >+ >+#include <wtf/RefPtr.h> >+ >+namespace WebCore { >+ >+template<typename EventType, typename EventInitType> >+static v8::Handle<v8::Value> constructV8Event(const v8::Arguments& args, bool (*filler)(EventInitType&, const OptionsObject&), WrapperTypeInfo* info) >+{ >+ INC_STATS("DOM.Event.Constructor"); >+ >+ if (!args.IsConstructCall()) >+ return throwError("DOM object constructor cannot be called as a function.", V8Proxy::TypeError); >+ >+ if (AllowAllocation::current()) >+ return args.Holder(); >+ >+ if (args.Length() < 1) >+ return throwError("Not enough arguments", V8Proxy::TypeError); >+ >+ STRING_TO_V8PARAMETER_EXCEPTION_BLOCK(V8Parameter<>, type, args[0]); >+ EventInitType eventInit; >+ if (args.Length() >= 2) { >+ EXCEPTION_BLOCK(OptionsObject, options, args[1]); >+ if (!filler(eventInit, options)) >+ return v8::Undefined(); >+ } >+ >+ RefPtr<EventType> event = EventType::create(type, eventInit); >+ >+ V8DOMWrapper::setDOMWrapper(args.Holder(), info, event.get()); >+ return toV8(event.release(), args.Holder()); >+} >+ >+#define DICTIONARY_START(EventType) \ >+ static bool fill##EventType##Init(Event##Init& eventInit, const OptionsObject& options) \ >+ { >+ >+#define DICTIONARY_END(EventType) \ >+ return true; \ >+ } \ >+ \ >+ v8::Handle<v8::Value> V8##EventType::constructorCallback(const v8::Arguments& args) \ >+ { \ >+ return constructV8Event<EventType, EventType##Init>(args, fill##EventType##Init, &info); \ >+ } >+ >+#define FILL_PARENT_PROPERTIES(parentEventType) \ >+ if (!fill##parentEventType##Init(eventInit)) \ >+ return false; >+ >+#define FILL_PROPERTY(propertyName) \ >+ options.getKeyValue(#propertyName, eventInit.propertyName); // This can fail but it is OK. >+ >+INSTANTIATE_ALL_EVENT_INITIALIZING_CONSTRUCTORS(DICTIONARY_START, DICTIONARY_END, FILL_PARENT_PROPERTIES, FILL_PROPERTY) >+ >+} // namespace WebCore >diff --git a/Source/WebCore/dom/Event.idl b/Source/WebCore/dom/Event.idl >index c67e596..ec91a15 100644 >--- a/Source/WebCore/dom/Event.idl >+++ b/Source/WebCore/dom/Event.idl >@@ -25,6 +25,7 @@ module events { > CustomToJS, > CanBeConstructed, > CustomConstructFunction, >+ V8CustomConstructor, > NoStaticTables, > Polymorphic > ] Event {
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 66756
:
104812
|
104960
|
105584
|
105720
|
105724
|
105756
|
105787