| Index: Source/bindings/core/v8/custom/V8EventTargetCustom.cpp
|
| diff --git a/Source/bindings/core/v8/custom/V8EventTargetCustom.cpp b/Source/bindings/core/v8/custom/V8EventTargetCustom.cpp
|
| index e49d1da5be0a0a93614eb3d6f4b59a7f1e64c423..b221b20afdedb32dec2913cc1621ff9485c0e3d5 100644
|
| --- a/Source/bindings/core/v8/custom/V8EventTargetCustom.cpp
|
| +++ b/Source/bindings/core/v8/custom/V8EventTargetCustom.cpp
|
| @@ -31,20 +31,98 @@
|
| #include "config.h"
|
| #include "bindings/core/v8/V8EventTarget.h"
|
|
|
| -#include "bindings/core/v8/V8Window.h"
|
| +#include "bindings/core/v8/BindingSecurity.h"
|
| +#include "bindings/core/v8/V8EventListenerList.h"
|
| +#include "core/frame/LocalDOMWindow.h"
|
|
|
| namespace blink {
|
|
|
| -void V8EventTarget::addEventListenerMethodEpilogueCustom(const v8::FunctionCallbackInfo<v8::Value>& info, EventTarget* impl)
|
| +static void addEventListenerMethodEpilogue(const v8::FunctionCallbackInfo<v8::Value>& info, EventTarget* impl)
|
| {
|
| if (info.Length() >= 2 && info[1]->IsObject() && !impl->toNode())
|
| addHiddenValueToArray(info.GetIsolate(), info.Holder(), info[1], V8EventTarget::eventListenerCacheIndex);
|
| }
|
|
|
| -void V8EventTarget::removeEventListenerMethodEpilogueCustom(const v8::FunctionCallbackInfo<v8::Value>& info, EventTarget* impl)
|
| +void V8EventTarget::addEventListenerMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
|
| +{
|
| + ExceptionState exceptionState(ExceptionState::ExecutionContext, "addEventListener", "EventTarget", info.Holder(), info.GetIsolate());
|
| + EventTarget* impl = V8EventTarget::toImpl(info.Holder());
|
| + if (LocalDOMWindow* window = impl->toDOMWindow()) {
|
| + if (!BindingSecurity::shouldAllowAccessToFrame(info.GetIsolate(), window->frame(), exceptionState)) {
|
| + exceptionState.throwIfNeeded();
|
| + return;
|
| + }
|
| + if (!window->document())
|
| + return;
|
| + }
|
| + V8StringResource<TreatNullAsNullString> type;
|
| + RefPtr<EventListener> listener;
|
| + bool capture;
|
| + {
|
| + if (UNLIKELY(info.Length() <= 0)) {
|
| + impl->addEventListener();
|
| + addEventListenerMethodEpilogue(info, impl);
|
| + return;
|
| + }
|
| + type = info[0];
|
| + if (!type.prepare())
|
| + return;
|
| + listener = V8EventListenerList::getEventListener(ScriptState::current(info.GetIsolate()), info[1], false, ListenerFindOrCreate);
|
| + if (UNLIKELY(info.Length() <= 2)) {
|
| + impl->addEventListener(type, listener);
|
| + addEventListenerMethodEpilogue(info, impl);
|
| + return;
|
| + }
|
| + capture = toBoolean(info.GetIsolate(), info[2], exceptionState);
|
| + if (exceptionState.throwIfNeeded())
|
| + return;
|
| + }
|
| + impl->addEventListener(type, listener, capture);
|
| + addEventListenerMethodEpilogue(info, impl);
|
| +}
|
| +
|
| +static void removeEventListenerMethodEpilogue(const v8::FunctionCallbackInfo<v8::Value>& info, EventTarget* impl)
|
| {
|
| if (info.Length() >= 2 && info[1]->IsObject() && !impl->toNode())
|
| removeHiddenValueFromArray(info.GetIsolate(), info.Holder(), info[1], V8EventTarget::eventListenerCacheIndex);
|
| }
|
|
|
| +void V8EventTarget::removeEventListenerMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
|
| +{
|
| + ExceptionState exceptionState(ExceptionState::ExecutionContext, "removeEventListener", "EventTarget", info.Holder(), info.GetIsolate());
|
| + EventTarget* impl = V8EventTarget::toImpl(info.Holder());
|
| + if (LocalDOMWindow* window = impl->toDOMWindow()) {
|
| + if (!BindingSecurity::shouldAllowAccessToFrame(info.GetIsolate(), window->frame(), exceptionState)) {
|
| + exceptionState.throwIfNeeded();
|
| + return;
|
| + }
|
| + if (!window->document())
|
| + return;
|
| + }
|
| + V8StringResource<TreatNullAsNullString> type;
|
| + RefPtr<EventListener> listener;
|
| + bool capture;
|
| + {
|
| + if (UNLIKELY(info.Length() <= 0)) {
|
| + impl->removeEventListener();
|
| + removeEventListenerMethodEpilogue(info, impl);
|
| + return;
|
| + }
|
| + type = info[0];
|
| + if (!type.prepare())
|
| + return;
|
| + listener = V8EventListenerList::getEventListener(ScriptState::current(info.GetIsolate()), info[1], false, ListenerFindOnly);
|
| + if (UNLIKELY(info.Length() <= 2)) {
|
| + impl->removeEventListener(type, listener);
|
| + removeEventListenerMethodEpilogue(info, impl);
|
| + return;
|
| + }
|
| + capture = toBoolean(info.GetIsolate(), info[2], exceptionState);
|
| + if (exceptionState.throwIfNeeded())
|
| + return;
|
| + }
|
| + impl->removeEventListener(type, listener, capture);
|
| + removeEventListenerMethodEpilogue(info, impl);
|
| +}
|
| +
|
| } // namespace blink
|
|
|