diff options
Diffstat (limited to 'chromium/third_party/blink/renderer/bindings/core/v8/js_based_event_listener.cc')
-rw-r--r-- | chromium/third_party/blink/renderer/bindings/core/v8/js_based_event_listener.cc | 44 |
1 files changed, 17 insertions, 27 deletions
diff --git a/chromium/third_party/blink/renderer/bindings/core/v8/js_based_event_listener.cc b/chromium/third_party/blink/renderer/bindings/core/v8/js_based_event_listener.cc index 54a3b76f319..412bad667ca 100644 --- a/chromium/third_party/blink/renderer/bindings/core/v8/js_based_event_listener.cc +++ b/chromium/third_party/blink/renderer/bindings/core/v8/js_based_event_listener.cc @@ -16,9 +16,6 @@ namespace blink { -// extern -const V8PrivateProperty::SymbolKey kPrivatePropertyGlobalEvent; - JSBasedEventListener::JSBasedEventListener() { if (IsMainThread()) { InstanceCounters::IncrementCounter( @@ -123,25 +120,23 @@ void JSBasedEventListener::Invoke( // Step 6: Let |global| be listener callback’s associated Realm’s global // object. - v8::Local<v8::Object> global = - script_state_of_listener->GetContext()->Global(); - - // Step 8: If global is a Window object, then: - // Set currentEvent to global’s current event. - // If tuple’s item-in-shadow-tree is false, then set global’s current event to - // event. - V8PrivateProperty::Symbol event_symbol = - V8PrivateProperty::GetSymbol(isolate, kPrivatePropertyGlobalEvent); - ExecutionContext* execution_context_of_listener = - ExecutionContext::From(script_state_of_listener); - v8::Local<v8::Value> current_event; - if (execution_context_of_listener->IsDocument()) { - current_event = event_symbol.GetOrUndefined(global).ToLocalChecked(); - // Expose the event object as |window.event|, except when the event's target - // is in a V1 shadow tree. + LocalDOMWindow* window = + ToLocalDOMWindow(script_state_of_listener->GetContext()); + + // Step 7: Let |current_event| be undefined. + Event* current_event = nullptr; + + // Step 8: If |global| is a Window object, then: + if (window) { + // Step 8-1: Set |current_event| to |global|’s current event. + current_event = window->CurrentEvent(); + + // Step 8-2: If |struct|’s invocation-target-in-shadow-tree is false (i.e., + // event's target is in a V1 shadow tree), then set |global|’s current + // event to event. Node* target_node = event->target()->ToNode(); if (!(target_node && target_node->IsInV1ShadowTree())) - event_symbol.Set(global, js_event); + window->SetCurrentEvent(event); } { @@ -158,17 +153,12 @@ void JSBasedEventListener::Invoke( // Step 10-2: Set legacyOutputDidListenersThrowFlag if given. event->LegacySetDidListenersThrowFlag(); } - - // |event_symbol.Set(global, current_event)| cannot and does not have to be - // performed when the isolate is terminating. - if (isolate->IsExecutionTerminating()) - return; } // Step 12: If |global| is a Window object, then set |global|’s current event // to |current_event|. - if (execution_context_of_listener->IsDocument()) - event_symbol.Set(global, current_event); + if (window) + window->SetCurrentEvent(current_event); } std::unique_ptr<SourceLocation> JSBasedEventListener::GetSourceLocation( |