Chromium Code Reviews| Index: Source/bindings/core/v8/ScriptEventListener.cpp |
| diff --git a/Source/bindings/core/v8/ScriptEventListener.cpp b/Source/bindings/core/v8/ScriptEventListener.cpp |
| index ebf102ed9f69acc56d2c1e30a022bc4f453a17e1..314b351f7278450188d9ba696369b3e05051d331 100644 |
| --- a/Source/bindings/core/v8/ScriptEventListener.cpp |
| +++ b/Source/bindings/core/v8/ScriptEventListener.cpp |
| @@ -88,69 +88,39 @@ PassRefPtrWillBeRawPtr<V8LazyEventListener> createAttributeEventListener(LocalFr |
| return V8LazyEventListener::create(name.localName(), eventParameterName, value, sourceURL, position, 0, toIsolate(frame)); |
| } |
| -static v8::MaybeLocal<v8::Function> eventListenerEffectiveFunction(v8::Isolate* isolate, v8::Local<v8::Context> context, v8::Local<v8::Object> listenerObject) |
| -{ |
| - if (listenerObject->IsFunction()) { |
| - return v8::MaybeLocal<v8::Function>(listenerObject.As<v8::Function>()); |
| - } else if (listenerObject->IsObject()) { |
| - // Try the "handleEvent" method (EventListener interface). |
| - v8::Local<v8::Value> property; |
| - if (listenerObject->Get(context, v8AtomicString(isolate, "handleEvent")).ToLocal(&property) && property->IsFunction()) |
| - return v8::MaybeLocal<v8::Function>(property.As<v8::Function>()); |
| - // Fall back to the "constructor" property. |
| - if (listenerObject->Get(context, v8AtomicString(isolate, "constructor")).ToLocal(&property) && property->IsFunction()) |
| - return v8::MaybeLocal<v8::Function>(property.As<v8::Function>()); |
| - } |
| - return v8::MaybeLocal<v8::Function>(); |
| -} |
| - |
| -ScriptValue eventListenerHandler(ExecutionContext* executionContext, EventListener* listener) |
| +v8::Local<v8::Object> eventListenerHandler(ExecutionContext* executionContext, EventListener* listener) |
| { |
| if (listener->type() != EventListener::JSEventListenerType) |
| - return ScriptValue(); |
| - |
| - v8::Isolate* isolate = toIsolate(executionContext); |
| - v8::HandleScope scope(isolate); |
| + return v8::Local<v8::Object>(); |
| V8AbstractEventListener* v8Listener = static_cast<V8AbstractEventListener*>(listener); |
| - v8::Local<v8::Context> context = toV8Context(executionContext, v8Listener->world()); |
| - v8::Context::Scope contextScope(context); |
| - v8::Local<v8::Object> function = v8Listener->getListenerObject(executionContext); |
| - if (function.IsEmpty()) |
| - return ScriptValue(); |
| - return ScriptValue(ScriptState::from(context), function); |
| + return v8Listener->getListenerObject(executionContext); |
| } |
| -ScriptState* eventListenerHandlerScriptState(LocalFrame* frame, EventListener* listener) |
| +v8::Local<v8::Function> eventListenerEffectiveFunction(v8::Isolate* isolate, v8::Local<v8::Object> handler) |
| { |
| - if (listener->type() != EventListener::JSEventListenerType) |
| - return 0; |
| - V8AbstractEventListener* v8Listener = static_cast<V8AbstractEventListener*>(listener); |
| - v8::HandleScope scope(toIsolate(frame)); |
| - v8::Local<v8::Context> v8Context = frame->script().windowProxy(v8Listener->world())->context(); |
| - return ScriptState::from(v8Context); |
| + v8::Local<v8::Function> function; |
| + if (handler->IsFunction()) { |
| + function = handler.As<v8::Function>(); |
| + } else if (handler->IsObject()) { |
| + v8::Local<v8::Value> property; |
| + // Try the "handleEvent" method (EventListener interface). |
| + if (handler->Get(handler->CreationContext(), v8AtomicString(isolate, "handleEvent")).ToLocal(&property) && property->IsFunction()) |
| + function = property.As<v8::Function>(); |
| + // Fall back to the "constructor" property. |
| + else if (handler->Get(handler->CreationContext(), v8AtomicString(isolate, "constructor")).ToLocal(&property) && property->IsFunction()) |
| + function = property.As<v8::Function>(); |
| + } |
| + if (!function.IsEmpty()) |
| + return getBoundFunction(function); |
| + return v8::Local<v8::Function>(); |
| } |
| -bool eventListenerHandlerLocation(ExecutionContext* executionContext, EventListener* listener, String& scriptId, int& lineNumber, int& columnNumber) |
| +void functionLocation(v8::Local<v8::Function> function, String& scriptId, int& lineNumber, int& columnNumber) |
|
yurys
2015/08/11 21:10:24
style: getFunctionLocation since we use return par
kozy
2015/08/12 18:02:22
Done.
|
| { |
| - if (listener->type() != EventListener::JSEventListenerType) |
| - return false; |
| - |
| - v8::HandleScope scope(toIsolate(executionContext)); |
| - V8AbstractEventListener* v8Listener = static_cast<V8AbstractEventListener*>(listener); |
| - v8::Local<v8::Context> context = toV8Context(executionContext, v8Listener->world()); |
| - v8::Context::Scope contextScope(context); |
| - v8::Local<v8::Object> object = v8Listener->getListenerObject(executionContext); |
| - if (object.IsEmpty()) |
| - return false; |
| - v8::Local<v8::Function> function; |
| - if (!eventListenerEffectiveFunction(scope.GetIsolate(), context, object).ToLocal(&function)) |
| - return false; |
| - v8::Local<v8::Function> originalFunction = getBoundFunction(function); |
| - int scriptIdValue = originalFunction->ScriptId(); |
| + int scriptIdValue = function->ScriptId(); |
| scriptId = String::number(scriptIdValue); |
| - lineNumber = originalFunction->GetScriptLineNumber(); |
| - columnNumber = originalFunction->GetScriptColumnNumber(); |
| - return true; |
| + lineNumber = function->GetScriptLineNumber(); |
| + columnNumber = function->GetScriptColumnNumber(); |
| } |
| } // namespace blink |