Commit a617bafe authored by Hayato Ito's avatar Hayato Ito Committed by Commit Bot

Use a reference for EventTarget::EnqueueEvent's event parameter

As part of http://crbug.com/871637.

This CL also touches LocalDOMWindow::{EnqueueWindowEvent, EnqueueDocumentEvent} as necessary.

Bug: 871637
Cq-Include-Trybots: luci.chromium.try:linux_layout_tests_layout_ng;luci.chromium.try:win_optional_gpu_tests_rel
Change-Id: I7c21419c27c4a59b2b4de541e5b2cb9a3001e98a
Reviewed-on: https://chromium-review.googlesource.com/1166616
Commit-Queue: Hayato Ito <hayato@chromium.org>
Reviewed-by: default avatarKent Tamura <tkent@chromium.org>
Cr-Commit-Position: refs/heads/master@{#581487}
parent 521a9d2d
...@@ -907,15 +907,15 @@ void EventTarget::RemoveAllEventListeners() { ...@@ -907,15 +907,15 @@ void EventTarget::RemoveAllEventListeners() {
} }
} }
void EventTarget::EnqueueEvent(Event* event, TaskType task_type) { void EventTarget::EnqueueEvent(Event& event, TaskType task_type) {
ExecutionContext* context = GetExecutionContext(); ExecutionContext* context = GetExecutionContext();
if (!context) if (!context)
return; return;
probe::AsyncTaskScheduled(context, event->type(), event); probe::AsyncTaskScheduled(context, event.type(), &event);
context->GetTaskRunner(task_type)->PostTask( context->GetTaskRunner(task_type)->PostTask(
FROM_HERE, FROM_HERE,
WTF::Bind(&EventTarget::DispatchEnqueuedEvent, WrapPersistent(this), WTF::Bind(&EventTarget::DispatchEnqueuedEvent, WrapPersistent(this),
WrapPersistent(event), WrapPersistent(context))); WrapPersistent(&event), WrapPersistent(context)));
} }
void EventTarget::DispatchEnqueuedEvent(Event* event, void EventTarget::DispatchEnqueuedEvent(Event* event,
......
...@@ -156,7 +156,7 @@ class CORE_EXPORT EventTarget : public ScriptWrappable { ...@@ -156,7 +156,7 @@ class CORE_EXPORT EventTarget : public ScriptWrappable {
DispatchEventResult DispatchEvent(Event&); DispatchEventResult DispatchEvent(Event&);
void EnqueueEvent(Event*, TaskType); void EnqueueEvent(Event&, TaskType);
// dispatchEventForBindings is intended to only be called from // dispatchEventForBindings is intended to only be called from
// javascript originated calls. This method will validate and may adjust // javascript originated calls. This method will validate and may adjust
......
...@@ -295,7 +295,7 @@ void FrameSelection::DidSetSelectionDeprecated( ...@@ -295,7 +295,7 @@ void FrameSelection::DidSetSelectionDeprecated(
// The task source should be kDOMManipulation, but the spec doesn't say // The task source should be kDOMManipulation, but the spec doesn't say
// anything about this. // anything about this.
frame_->DomWindow()->EnqueueDocumentEvent( frame_->DomWindow()->EnqueueDocumentEvent(
Event::Create(EventTypeNames::selectionchange), *Event::Create(EventTypeNames::selectionchange),
TaskType::kMiscPlatformAPI); TaskType::kMiscPlatformAPI);
} }
......
...@@ -460,7 +460,7 @@ void WebPluginContainerImpl::EnqueueMessageEvent( ...@@ -460,7 +460,7 @@ void WebPluginContainerImpl::EnqueueMessageEvent(
const WebDOMMessageEvent& event) { const WebDOMMessageEvent& event) {
if (!element_->GetExecutionContext()) if (!element_->GetExecutionContext())
return; return;
element_->EnqueueEvent(event, TaskType::kInternalDefault); element_->EnqueueEvent(*event, TaskType::kInternalDefault);
} }
void WebPluginContainerImpl::Invalidate() { void WebPluginContainerImpl::Invalidate() {
......
...@@ -1420,9 +1420,9 @@ void ContentSecurityPolicy::DispatchViolationEvents( ...@@ -1420,9 +1420,9 @@ void ContentSecurityPolicy::DispatchViolationEvents(
if (execution_context_->IsWorkletGlobalScope()) if (execution_context_->IsWorkletGlobalScope())
return; return;
SecurityPolicyViolationEvent* event = SecurityPolicyViolationEvent::Create( SecurityPolicyViolationEvent& event = *SecurityPolicyViolationEvent::Create(
EventTypeNames::securitypolicyviolation, violation_data); EventTypeNames::securitypolicyviolation, violation_data);
DCHECK(event->bubbles()); DCHECK(event.bubbles());
if (execution_context_->IsDocument()) { if (execution_context_->IsDocument()) {
Document* document = ToDocument(execution_context_); Document* document = ToDocument(execution_context_);
......
...@@ -338,11 +338,11 @@ Document* LocalDOMWindow::InstallNewDocument(const String& mime_type, ...@@ -338,11 +338,11 @@ Document* LocalDOMWindow::InstallNewDocument(const String& mime_type,
return document_; return document_;
} }
void LocalDOMWindow::EnqueueWindowEvent(Event* event, TaskType task_type) { void LocalDOMWindow::EnqueueWindowEvent(Event& event, TaskType task_type) {
EnqueueEvent(event, task_type); EnqueueEvent(event, task_type);
} }
void LocalDOMWindow::EnqueueDocumentEvent(Event* event, TaskType task_type) { void LocalDOMWindow::EnqueueDocumentEvent(Event& event, TaskType task_type) {
if (document_) if (document_)
document_->EnqueueEvent(event, task_type); document_->EnqueueEvent(event, task_type);
} }
...@@ -379,7 +379,7 @@ void LocalDOMWindow::EnqueuePageshowEvent(PageshowEventPersistence persisted) { ...@@ -379,7 +379,7 @@ void LocalDOMWindow::EnqueuePageshowEvent(PageshowEventPersistence persisted) {
// The task source should be kDOMManipulation, but the spec doesn't say // The task source should be kDOMManipulation, but the spec doesn't say
// anything about this. // anything about this.
EnqueueWindowEvent( EnqueueWindowEvent(
PageTransitionEvent::Create(EventTypeNames::pageshow, persisted), *PageTransitionEvent::Create(EventTypeNames::pageshow, persisted),
TaskType::kMiscPlatformAPI); TaskType::kMiscPlatformAPI);
return; return;
} }
...@@ -391,7 +391,7 @@ void LocalDOMWindow::EnqueuePageshowEvent(PageshowEventPersistence persisted) { ...@@ -391,7 +391,7 @@ void LocalDOMWindow::EnqueuePageshowEvent(PageshowEventPersistence persisted) {
void LocalDOMWindow::EnqueueHashchangeEvent(const String& old_url, void LocalDOMWindow::EnqueueHashchangeEvent(const String& old_url,
const String& new_url) { const String& new_url) {
// https://html.spec.whatwg.org/#history-traversal // https://html.spec.whatwg.org/#history-traversal
EnqueueWindowEvent(HashChangeEvent::Create(old_url, new_url), EnqueueWindowEvent(*HashChangeEvent::Create(old_url, new_url),
TaskType::kDOMManipulation); TaskType::kDOMManipulation);
} }
......
...@@ -327,8 +327,8 @@ class CORE_EXPORT LocalDOMWindow final : public DOMWindow, ...@@ -327,8 +327,8 @@ class CORE_EXPORT LocalDOMWindow final : public DOMWindow,
// recurse on its child frames. // recurse on its child frames.
void SendOrientationChangeEvent(); void SendOrientationChangeEvent();
void EnqueueWindowEvent(Event*, TaskType); void EnqueueWindowEvent(Event&, TaskType);
void EnqueueDocumentEvent(Event*, TaskType); void EnqueueDocumentEvent(Event&, TaskType);
void EnqueuePageshowEvent(PageshowEventPersistence); void EnqueuePageshowEvent(PageshowEventPersistence);
void EnqueueHashchangeEvent(const String& old_url, const String& new_url); void EnqueueHashchangeEvent(const String& old_url, const String& new_url);
void EnqueuePopstateEvent(scoped_refptr<SerializedScriptValue>); void EnqueuePopstateEvent(scoped_refptr<SerializedScriptValue>);
......
...@@ -245,7 +245,7 @@ ExecutionContext* TextTrackList::GetExecutionContext() const { ...@@ -245,7 +245,7 @@ ExecutionContext* TextTrackList::GetExecutionContext() const {
void TextTrackList::ScheduleTrackEvent(const AtomicString& event_name, void TextTrackList::ScheduleTrackEvent(const AtomicString& event_name,
TextTrack* track) { TextTrack* track) {
EnqueueEvent(TrackEvent::Create(event_name, track), EnqueueEvent(*TrackEvent::Create(event_name, track),
TaskType::kMediaElementEvent); TaskType::kMediaElementEvent);
} }
...@@ -267,7 +267,7 @@ void TextTrackList::ScheduleChangeEvent() { ...@@ -267,7 +267,7 @@ void TextTrackList::ScheduleChangeEvent() {
// ... // ...
// Fire a simple event named change at the media element's textTracks // Fire a simple event named change at the media element's textTracks
// attribute's TextTrackList object. // attribute's TextTrackList object.
EnqueueEvent(Event::Create(EventTypeNames::change), EnqueueEvent(*Event::Create(EventTypeNames::change),
TaskType::kMediaElementEvent); TaskType::kMediaElementEvent);
} }
......
...@@ -166,7 +166,7 @@ void PointerLockController::EnqueueEvent(const AtomicString& type, ...@@ -166,7 +166,7 @@ void PointerLockController::EnqueueEvent(const AtomicString& type,
void PointerLockController::EnqueueEvent(const AtomicString& type, void PointerLockController::EnqueueEvent(const AtomicString& type,
Document* document) { Document* document) {
if (document && document->domWindow()) { if (document && document->domWindow()) {
document->domWindow()->EnqueueDocumentEvent(Event::Create(type), document->domWindow()->EnqueueDocumentEvent(*Event::Create(type),
TaskType::kMiscPlatformAPI); TaskType::kMiscPlatformAPI);
} }
} }
......
...@@ -107,7 +107,7 @@ void BroadcastChannel::OnMessage(BlinkCloneableMessage message) { ...@@ -107,7 +107,7 @@ void BroadcastChannel::OnMessage(BlinkCloneableMessage message) {
event = MessageEvent::CreateError( event = MessageEvent::CreateError(
GetExecutionContext()->GetSecurityOrigin()->ToString()); GetExecutionContext()->GetSecurityOrigin()->ToString());
} }
EnqueueEvent(event, TaskType::kPostedMessage); EnqueueEvent(*event, TaskType::kPostedMessage);
} }
void BroadcastChannel::OnError() { void BroadcastChannel::OnError() {
......
...@@ -224,8 +224,8 @@ void StorageArea::DispatchLocalStorageEvent( ...@@ -224,8 +224,8 @@ void StorageArea::DispatchLocalStorageEvent(
!IsEventSource(storage, source_area_instance)) { !IsEventSource(storage, source_area_instance)) {
// https://www.w3.org/TR/webstorage/#the-storage-event // https://www.w3.org/TR/webstorage/#the-storage-event
local_frame->DomWindow()->EnqueueWindowEvent( local_frame->DomWindow()->EnqueueWindowEvent(
StorageEvent::Create(EventTypeNames::storage, key, old_value, *StorageEvent::Create(EventTypeNames::storage, key, old_value,
new_value, page_url, storage), new_value, page_url, storage),
TaskType::kDOMManipulation); TaskType::kDOMManipulation);
} }
} }
...@@ -265,8 +265,8 @@ void StorageArea::DispatchSessionStorageEvent( ...@@ -265,8 +265,8 @@ void StorageArea::DispatchSessionStorageEvent(
!IsEventSource(storage, source_area_instance)) { !IsEventSource(storage, source_area_instance)) {
// https://www.w3.org/TR/webstorage/#the-storage-event // https://www.w3.org/TR/webstorage/#the-storage-event
local_frame->DomWindow()->EnqueueWindowEvent( local_frame->DomWindow()->EnqueueWindowEvent(
StorageEvent::Create(EventTypeNames::storage, key, old_value, *StorageEvent::Create(EventTypeNames::storage, key, old_value,
new_value, page_url, storage), new_value, page_url, storage),
TaskType::kDOMManipulation); TaskType::kDOMManipulation);
} }
} }
......
...@@ -229,7 +229,7 @@ void NavigatorVR::EnqueueVREvent(VRDisplayEvent* event) { ...@@ -229,7 +229,7 @@ void NavigatorVR::EnqueueVREvent(VRDisplayEvent* event) {
return; return;
GetSupplementable()->GetFrame()->DomWindow()->EnqueueWindowEvent( GetSupplementable()->GetFrame()->DomWindow()->EnqueueWindowEvent(
event, TaskType::kMiscPlatformAPI); *event, TaskType::kMiscPlatformAPI);
} }
void NavigatorVR::DispatchVREvent(VRDisplayEvent* event) { void NavigatorVR::DispatchVREvent(VRDisplayEvent* event) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment