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() {
}
}
void EventTarget::EnqueueEvent(Event* event, TaskType task_type) {
void EventTarget::EnqueueEvent(Event& event, TaskType task_type) {
ExecutionContext* context = GetExecutionContext();
if (!context)
return;
probe::AsyncTaskScheduled(context, event->type(), event);
probe::AsyncTaskScheduled(context, event.type(), &event);
context->GetTaskRunner(task_type)->PostTask(
FROM_HERE,
WTF::Bind(&EventTarget::DispatchEnqueuedEvent, WrapPersistent(this),
WrapPersistent(event), WrapPersistent(context)));
WrapPersistent(&event), WrapPersistent(context)));
}
void EventTarget::DispatchEnqueuedEvent(Event* event,
......
......@@ -156,7 +156,7 @@ class CORE_EXPORT EventTarget : public ScriptWrappable {
DispatchEventResult DispatchEvent(Event&);
void EnqueueEvent(Event*, TaskType);
void EnqueueEvent(Event&, TaskType);
// dispatchEventForBindings is intended to only be called from
// javascript originated calls. This method will validate and may adjust
......
......@@ -295,7 +295,7 @@ void FrameSelection::DidSetSelectionDeprecated(
// The task source should be kDOMManipulation, but the spec doesn't say
// anything about this.
frame_->DomWindow()->EnqueueDocumentEvent(
Event::Create(EventTypeNames::selectionchange),
*Event::Create(EventTypeNames::selectionchange),
TaskType::kMiscPlatformAPI);
}
......
......@@ -460,7 +460,7 @@ void WebPluginContainerImpl::EnqueueMessageEvent(
const WebDOMMessageEvent& event) {
if (!element_->GetExecutionContext())
return;
element_->EnqueueEvent(event, TaskType::kInternalDefault);
element_->EnqueueEvent(*event, TaskType::kInternalDefault);
}
void WebPluginContainerImpl::Invalidate() {
......
......@@ -1420,9 +1420,9 @@ void ContentSecurityPolicy::DispatchViolationEvents(
if (execution_context_->IsWorkletGlobalScope())
return;
SecurityPolicyViolationEvent* event = SecurityPolicyViolationEvent::Create(
SecurityPolicyViolationEvent& event = *SecurityPolicyViolationEvent::Create(
EventTypeNames::securitypolicyviolation, violation_data);
DCHECK(event->bubbles());
DCHECK(event.bubbles());
if (execution_context_->IsDocument()) {
Document* document = ToDocument(execution_context_);
......
......@@ -338,11 +338,11 @@ Document* LocalDOMWindow::InstallNewDocument(const String& mime_type,
return document_;
}
void LocalDOMWindow::EnqueueWindowEvent(Event* event, TaskType task_type) {
void LocalDOMWindow::EnqueueWindowEvent(Event& event, TaskType task_type) {
EnqueueEvent(event, task_type);
}
void LocalDOMWindow::EnqueueDocumentEvent(Event* event, TaskType task_type) {
void LocalDOMWindow::EnqueueDocumentEvent(Event& event, TaskType task_type) {
if (document_)
document_->EnqueueEvent(event, task_type);
}
......@@ -379,7 +379,7 @@ void LocalDOMWindow::EnqueuePageshowEvent(PageshowEventPersistence persisted) {
// The task source should be kDOMManipulation, but the spec doesn't say
// anything about this.
EnqueueWindowEvent(
PageTransitionEvent::Create(EventTypeNames::pageshow, persisted),
*PageTransitionEvent::Create(EventTypeNames::pageshow, persisted),
TaskType::kMiscPlatformAPI);
return;
}
......@@ -391,7 +391,7 @@ void LocalDOMWindow::EnqueuePageshowEvent(PageshowEventPersistence persisted) {
void LocalDOMWindow::EnqueueHashchangeEvent(const String& old_url,
const String& new_url) {
// https://html.spec.whatwg.org/#history-traversal
EnqueueWindowEvent(HashChangeEvent::Create(old_url, new_url),
EnqueueWindowEvent(*HashChangeEvent::Create(old_url, new_url),
TaskType::kDOMManipulation);
}
......
......@@ -327,8 +327,8 @@ class CORE_EXPORT LocalDOMWindow final : public DOMWindow,
// recurse on its child frames.
void SendOrientationChangeEvent();
void EnqueueWindowEvent(Event*, TaskType);
void EnqueueDocumentEvent(Event*, TaskType);
void EnqueueWindowEvent(Event&, TaskType);
void EnqueueDocumentEvent(Event&, TaskType);
void EnqueuePageshowEvent(PageshowEventPersistence);
void EnqueueHashchangeEvent(const String& old_url, const String& new_url);
void EnqueuePopstateEvent(scoped_refptr<SerializedScriptValue>);
......
......@@ -245,7 +245,7 @@ ExecutionContext* TextTrackList::GetExecutionContext() const {
void TextTrackList::ScheduleTrackEvent(const AtomicString& event_name,
TextTrack* track) {
EnqueueEvent(TrackEvent::Create(event_name, track),
EnqueueEvent(*TrackEvent::Create(event_name, track),
TaskType::kMediaElementEvent);
}
......@@ -267,7 +267,7 @@ void TextTrackList::ScheduleChangeEvent() {
// ...
// Fire a simple event named change at the media element's textTracks
// attribute's TextTrackList object.
EnqueueEvent(Event::Create(EventTypeNames::change),
EnqueueEvent(*Event::Create(EventTypeNames::change),
TaskType::kMediaElementEvent);
}
......
......@@ -166,7 +166,7 @@ void PointerLockController::EnqueueEvent(const AtomicString& type,
void PointerLockController::EnqueueEvent(const AtomicString& type,
Document* document) {
if (document && document->domWindow()) {
document->domWindow()->EnqueueDocumentEvent(Event::Create(type),
document->domWindow()->EnqueueDocumentEvent(*Event::Create(type),
TaskType::kMiscPlatformAPI);
}
}
......
......@@ -107,7 +107,7 @@ void BroadcastChannel::OnMessage(BlinkCloneableMessage message) {
event = MessageEvent::CreateError(
GetExecutionContext()->GetSecurityOrigin()->ToString());
}
EnqueueEvent(event, TaskType::kPostedMessage);
EnqueueEvent(*event, TaskType::kPostedMessage);
}
void BroadcastChannel::OnError() {
......
......@@ -224,8 +224,8 @@ void StorageArea::DispatchLocalStorageEvent(
!IsEventSource(storage, source_area_instance)) {
// https://www.w3.org/TR/webstorage/#the-storage-event
local_frame->DomWindow()->EnqueueWindowEvent(
StorageEvent::Create(EventTypeNames::storage, key, old_value,
new_value, page_url, storage),
*StorageEvent::Create(EventTypeNames::storage, key, old_value,
new_value, page_url, storage),
TaskType::kDOMManipulation);
}
}
......@@ -265,8 +265,8 @@ void StorageArea::DispatchSessionStorageEvent(
!IsEventSource(storage, source_area_instance)) {
// https://www.w3.org/TR/webstorage/#the-storage-event
local_frame->DomWindow()->EnqueueWindowEvent(
StorageEvent::Create(EventTypeNames::storage, key, old_value,
new_value, page_url, storage),
*StorageEvent::Create(EventTypeNames::storage, key, old_value,
new_value, page_url, storage),
TaskType::kDOMManipulation);
}
}
......
......@@ -229,7 +229,7 @@ void NavigatorVR::EnqueueVREvent(VRDisplayEvent* event) {
return;
GetSupplementable()->GetFrame()->DomWindow()->EnqueueWindowEvent(
event, TaskType::kMiscPlatformAPI);
*event, TaskType::kMiscPlatformAPI);
}
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