Pass in IsComposed flag to Event constructors
authorrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 24 Aug 2018 20:14:50 +0000 (20:14 +0000)
committerrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 24 Aug 2018 20:14:50 +0000 (20:14 +0000)
commit0100f2a57f80bcd9acb4fe8bd0036681779e4a02
treee3bb2a86ed7e5b476b15ee4215798cf78a020d5c
parent90402c7737f2f5760379c2efb880b38126a454df
Pass in IsComposed flag to Event constructors
https://bugs.webkit.org/show_bug.cgi?id=188720
<rdar://problem/43580387>

Reviewed by Simon Fraser.

Source/WebCore:

This patch replaces the logic in Event::isComposed to decide whether an event is composed or not by
explicitly passing IsComposed flag to Event constructor. This decouples being composed from whether
an event is trusted and of a partciular event type, paving our way to make synthetic click event
dispatched by an author script composable in webkit.org/b/170211.

This patch also removes IsTrusted from the argument list of event constructors and create functions
to systematically eliminate the possibility of this patch making an event uncomposed by not setting
IsComposed flag.

No new tests since there should be no behavioral change.

* dom/ClipboardEvent.cpp:
(WebCore::ClipboardEvent::ClipboardEvent): A trusted ClipboardEvent is composed.
* dom/ClipboardEvent.h:
(WebCore::ClipboardEvent::ClipboardEvent): Removed IsTrusted from the variant which takes Init object
to make sure this refactoring is correct.
(WebCore::ClipboardEvent::create): Ditto.
* dom/CompositionEvent.cpp:
(WebCore::CompositionEvent::CompositionEvent): A trusted CompositionEvent is composed.
* dom/CompositionEvent.h:
* dom/Element.cpp:
(WebCore::Element::dispatchMouseEvent): A trusted dblclick event is composed (this is a non-standard
event but virtually every mouse event is composed so it makes sense to make this composed).
* dom/Event.cpp:
(WebCore::Event::Event):
(WebCore::Event::create):
(WebCore::Event::composed const): Deleted. The trival implementation moved to the header file.
* dom/Event.h:
(WebCore::Event::composed const):
* dom/FocusEvent.cpp:
(WebCore::FocusEvent::FocusEvent): A trusted Focus event is composed.
* dom/FocusEvent.h:
(WebCore::FocusEvent::create): Removed IsTrusted from Init variant for the correctness guarantee.
(WebCore::FocusEvent::FocusEvent): Ditto.
* dom/InputEvent.cpp:
(WebCore::InputEvent::create): Removed IsTrusted from Init variant for the correctness guarantee.
(WebCore::InputEvent::InputEvent): A trsuted InputEvent is composed.
* dom/InputEvent.h:
* dom/KeyboardEvent.cpp:
(WebCore::KeyboardEvent::KeyboardEvent): A trsuted KeyboardEvent is composed.
(WebCore::KeyboardEvent::create): Removed IsTrusted from Init variant for the correctness guarantee.
* dom/KeyboardEvent.h:
* dom/MouseEvent.cpp:
(WebCore::MouseEvent::create): Removed IsTrusted from Init variant for the correctness guarantee.
(WebCore::MouseEvent::MouseEvent): Explicitly take IsComposed flag from subclasses since simulated click
does not currently compose.
* dom/MouseEvent.h:
* dom/MouseRelatedEvent.cpp:
(WebCore::MouseRelatedEvent::MouseRelatedEvent): A trusted touch event is composed.
* dom/MouseRelatedEvent.h:
* dom/Node.cpp:
(WebCore::Node::dispatchDOMActivateEvent): A trusted DOMActivateEvent event is composed.
(WebCore::Node::dispatchInputEvent): A trusted input event is composed.
* dom/SimulatedClick.cpp:
(SimulatedMouseEvent::SimulatedMouseEvent): A simulated click is composed if it's a trusted event for now.
This is the bug to be fixed in webkit.org/b/170211.
* dom/TextEvent.cpp:
(WebCore::TextEvent::TextEvent): A trsuted textInput event is composed.
* dom/UIEvent.cpp:
(WebCore::UIEvent::UIEvent): Added IsComposed as an argument to the variant which creates a trusted event,
and removed IsTrusted from Init variant for the correctness guarantee.
* dom/UIEvent.h:
(WebCore::UIEvent::create): Ditto.
* dom/UIEventWithKeyState.h:
(WebCore::UIEventWithKeyState::UIEventWithKeyState): Ditto.
* dom/WheelEvent.cpp:
(WebCore::WheelEvent::WheelEvent): A trusted Wheel event, which is a subclass of MouseEvent, is composed.
(WebCore::WheelEvent::create): Removed IsTrusted from Init variant for the correctness guarantee.
* dom/WheelEvent.h:
* editing/Editor.cpp:
(WebCore::dispatchBeforeInputEvent):
(WebCore::dispatchInputEvent):
(WebCore::dispatchClipboardEvent): Call the newly added variant which takes DataTransfer directly so that
we can remove IsTrusted from the variant which takes Init for the correctness guarantee.
* page/EventHandler.cpp:
(WebCore::EventHandler::dispatchDragEvent): A trusted mouse event is composed.

Source/WebKit:

* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::navigateToPDFLinkWithSimulatedClick): A trusted click event is composed regardless of
whether it's simulated or not.

Source/WebKitLegacy/ios:

* WebView/WebPDFViewPlaceholder.mm:
(-[WebPDFViewPlaceholder simulateClickOnLinkToURL:]): A trusted click event is composed regardless
of whether it's simulated or not.

Source/WebKitLegacy/mac:

* WebView/WebPDFView.mm:
(-[WebPDFView PDFViewWillClickOnLink:withURL:]): A trusted click event is composed regardless of
whether it's simulated or not.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@235331 268f45cc-cd09-0410-ab3c-d52691b4dbfc
34 files changed:
Source/WebCore/ChangeLog
Source/WebCore/dom/ClipboardEvent.cpp
Source/WebCore/dom/ClipboardEvent.h
Source/WebCore/dom/CompositionEvent.cpp
Source/WebCore/dom/CompositionEvent.h
Source/WebCore/dom/Element.cpp
Source/WebCore/dom/Event.cpp
Source/WebCore/dom/Event.h
Source/WebCore/dom/FocusEvent.cpp
Source/WebCore/dom/FocusEvent.h
Source/WebCore/dom/InputEvent.cpp
Source/WebCore/dom/InputEvent.h
Source/WebCore/dom/KeyboardEvent.cpp
Source/WebCore/dom/KeyboardEvent.h
Source/WebCore/dom/MouseEvent.cpp
Source/WebCore/dom/MouseEvent.h
Source/WebCore/dom/MouseRelatedEvent.cpp
Source/WebCore/dom/MouseRelatedEvent.h
Source/WebCore/dom/Node.cpp
Source/WebCore/dom/SimulatedClick.cpp
Source/WebCore/dom/TextEvent.cpp
Source/WebCore/dom/UIEvent.cpp
Source/WebCore/dom/UIEvent.h
Source/WebCore/dom/UIEventWithKeyState.h
Source/WebCore/dom/WheelEvent.cpp
Source/WebCore/dom/WheelEvent.h
Source/WebCore/editing/Editor.cpp
Source/WebCore/page/EventHandler.cpp
Source/WebKit/ChangeLog
Source/WebKit/WebProcess/WebPage/WebPage.cpp
Source/WebKitLegacy/ios/ChangeLog
Source/WebKitLegacy/ios/WebView/WebPDFViewPlaceholder.mm
Source/WebKitLegacy/mac/ChangeLog
Source/WebKitLegacy/mac/WebView/WebPDFView.mm