Index: Source/bindings/v8/custom/V8DocumentCustom.cpp |
diff --git a/Source/bindings/v8/custom/V8DocumentCustom.cpp b/Source/bindings/v8/custom/V8DocumentCustom.cpp |
index 425d5902913ae2ee48524b690fa8526a39038b60..2265abd77a2b095c895325ff7b2853a15862b9f6 100644 |
--- a/Source/bindings/v8/custom/V8DocumentCustom.cpp |
+++ b/Source/bindings/v8/custom/V8DocumentCustom.cpp |
@@ -33,6 +33,7 @@ |
#include "V8CanvasRenderingContext2D.h" |
#include "V8DOMImplementation.h" |
+#include "V8Event.h" |
#include "V8Node.h" |
#include "V8Touch.h" |
#include "V8TouchList.h" |
@@ -54,6 +55,7 @@ |
#include "core/xml/DocumentXPathEvaluator.h" |
#include "core/xml/XPathNSResolver.h" |
#include "core/xml/XPathResult.h" |
+#include "modules/InitModules.h" |
#include "wtf/RefPtr.h" |
namespace WebCore { |
@@ -83,4 +85,26 @@ void V8Document::evaluateMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& |
v8SetReturnValueFast(info, result.release(), document.get()); |
} |
+// Customize createEvent so it can call createEventModules in modules. |
+// FIXME: Use method registration approach instead. http://crbug.com/358074 |
+void V8Document::createEventMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info) |
+{ |
+ ExceptionState exceptionState(ExceptionState::ExecutionContext, "createEvent", "Document", info.Holder(), info.GetIsolate()); |
+ if (UNLIKELY(info.Length() < 1)) { |
+ throwMinimumArityTypeError(exceptionState, 1, info.Length()); |
+ return; |
+ } |
+ Document* impl = V8Document::toNative(info.Holder()); |
+ V8StringResource<> eventType; |
+ { |
+ TOSTRING_VOID_INTERNAL_NOTRYCATCH(eventType, info[0]); |
+ } |
+ RefPtrWillBeRawPtr<Event> result = createEventModules(eventType, exceptionState); |
+ if (exceptionState.hadException()) { |
+ exceptionState.throwIfNeeded(); |
+ return; |
+ } |
+ v8SetReturnValueFast(info, WTF::getPtr(result.release()), impl); |
+} |
+ |
} // namespace WebCore |