Title: [235335] trunk/Source/WebCore
Revision
235335
Author
[email protected]
Date
2018-08-24 15:51:33 -0700 (Fri, 24 Aug 2018)

Log Message

Avoid calling setUntrusted in SimulatedMouseEvent
https://bugs.webkit.org/show_bug.cgi?id=188929

Reviewed by Simon Fraser.

Added IsTrusted flag to Event constructors instead of creating a trusted event
and making it untrusted in the constructor of SimulatedMouseEvent.

This makes EventTarget::dispatchEventForBindings the only caller of setUntrusted().

* dom/Event.cpp:
(WebCore::Event::Event):
* dom/Event.h:
* dom/KeyboardEvent.cpp:
(WebCore::KeyboardEvent::KeyboardEvent):
* dom/MouseEvent.cpp:
(WebCore::MouseEvent::create):
(WebCore::MouseEvent::MouseEvent):
* dom/MouseEvent.h:
* dom/MouseRelatedEvent.cpp:
(WebCore::MouseRelatedEvent::MouseRelatedEvent):
* dom/MouseRelatedEvent.h:
* dom/SimulatedClick.cpp:
* dom/UIEvent.cpp:
(WebCore::UIEvent::UIEvent):
* dom/UIEvent.h:
* dom/UIEventWithKeyState.h:
(WebCore::UIEventWithKeyState::UIEventWithKeyState):
* dom/WheelEvent.cpp:
(WebCore::WheelEvent::WheelEvent):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (235334 => 235335)


--- trunk/Source/WebCore/ChangeLog	2018-08-24 21:40:50 UTC (rev 235334)
+++ trunk/Source/WebCore/ChangeLog	2018-08-24 22:51:33 UTC (rev 235335)
@@ -1,3 +1,36 @@
+2018-08-24  Ryosuke Niwa  <[email protected]>
+
+        Avoid calling setUntrusted in SimulatedMouseEvent
+        https://bugs.webkit.org/show_bug.cgi?id=188929
+
+        Reviewed by Simon Fraser.
+
+        Added IsTrusted flag to Event constructors instead of creating a trusted event
+        and making it untrusted in the constructor of SimulatedMouseEvent.
+
+        This makes EventTarget::dispatchEventForBindings the only caller of setUntrusted().
+
+        * dom/Event.cpp:
+        (WebCore::Event::Event):
+        * dom/Event.h:
+        * dom/KeyboardEvent.cpp:
+        (WebCore::KeyboardEvent::KeyboardEvent):
+        * dom/MouseEvent.cpp:
+        (WebCore::MouseEvent::create):
+        (WebCore::MouseEvent::MouseEvent):
+        * dom/MouseEvent.h:
+        * dom/MouseRelatedEvent.cpp:
+        (WebCore::MouseRelatedEvent::MouseRelatedEvent):
+        * dom/MouseRelatedEvent.h:
+        * dom/SimulatedClick.cpp:
+        * dom/UIEvent.cpp:
+        (WebCore::UIEvent::UIEvent):
+        * dom/UIEvent.h:
+        * dom/UIEventWithKeyState.h:
+        (WebCore::UIEventWithKeyState::UIEventWithKeyState):
+        * dom/WheelEvent.cpp:
+        (WebCore::WheelEvent::WheelEvent):
+
 2018-08-24  Jer Noble  <[email protected]>
 
         Using Touch Bar to scrub video on Youtube results in video playback freeze

Modified: trunk/Source/WebCore/dom/Event.cpp (235334 => 235335)


--- trunk/Source/WebCore/dom/Event.cpp	2018-08-24 21:40:50 UTC (rev 235334)
+++ trunk/Source/WebCore/dom/Event.cpp	2018-08-24 22:51:33 UTC (rev 235335)
@@ -63,8 +63,8 @@
     ASSERT(!eventType.isNull());
 }
 
-Event::Event(const AtomicString& eventType, CanBubble canBubble, IsCancelable isCancelable, IsComposed isComposed, MonotonicTime timestamp)
-    : Event { timestamp, eventType, IsTrusted::Yes, canBubble, isCancelable, isComposed }
+Event::Event(const AtomicString& eventType, CanBubble canBubble, IsCancelable isCancelable, IsComposed isComposed, MonotonicTime timestamp, IsTrusted isTrusted)
+    : Event { timestamp, eventType, isTrusted, canBubble, isCancelable, isComposed }
 {
     ASSERT(!eventType.isNull());
 }

Modified: trunk/Source/WebCore/dom/Event.h (235334 => 235335)


--- trunk/Source/WebCore/dom/Event.h	2018-08-24 21:40:50 UTC (rev 235334)
+++ trunk/Source/WebCore/dom/Event.h	2018-08-24 22:51:33 UTC (rev 235335)
@@ -143,7 +143,7 @@
 protected:
     explicit Event(IsTrusted = IsTrusted::No);
     Event(const AtomicString& type, CanBubble, IsCancelable, IsComposed = IsComposed::No);
-    Event(const AtomicString& type, CanBubble, IsCancelable, IsComposed, MonotonicTime timestamp);
+    Event(const AtomicString& type, CanBubble, IsCancelable, IsComposed, MonotonicTime timestamp, IsTrusted isTrusted = IsTrusted::Yes);
     Event(const AtomicString& type, const EventInit&, IsTrusted);
 
     virtual void receivedTarget() { }

Modified: trunk/Source/WebCore/dom/KeyboardEvent.cpp (235334 => 235335)


--- trunk/Source/WebCore/dom/KeyboardEvent.cpp	2018-08-24 21:40:50 UTC (rev 235334)
+++ trunk/Source/WebCore/dom/KeyboardEvent.cpp	2018-08-24 22:51:33 UTC (rev 235335)
@@ -95,7 +95,7 @@
 
 inline KeyboardEvent::KeyboardEvent(const PlatformKeyboardEvent& key, RefPtr<WindowProxy>&& view)
     : UIEventWithKeyState(eventTypeForKeyboardEventType(key.type()), CanBubble::Yes, IsCancelable::Yes, IsComposed::Yes,
-        key.timestamp().approximateMonotonicTime(), view.copyRef(), 0, key.modifiers())
+        key.timestamp().approximateMonotonicTime(), view.copyRef(), 0, key.modifiers(), IsTrusted::Yes)
     , m_underlyingPlatformEvent(std::make_unique<PlatformKeyboardEvent>(key))
 #if ENABLE(KEYBOARD_KEY_ATTRIBUTE)
     , m_key(key.key())

Modified: trunk/Source/WebCore/dom/MouseEvent.cpp (235334 => 235335)


--- trunk/Source/WebCore/dom/MouseEvent.cpp	2018-08-24 21:40:50 UTC (rev 235334)
+++ trunk/Source/WebCore/dom/MouseEvent.cpp	2018-08-24 22:51:33 UTC (rev 235335)
@@ -62,10 +62,10 @@
 
 Ref<MouseEvent> MouseEvent::create(const AtomicString& type, CanBubble canBubble, IsCancelable isCancelable, IsComposed isComposed, MonotonicTime timestamp, RefPtr<WindowProxy>&& view, int detail,
     const IntPoint& screenLocation, const IntPoint& windowLocation, const IntPoint& movementDelta, OptionSet<Modifier> modifiers, unsigned short button, unsigned short buttons,
-    EventTarget* relatedTarget, double force, unsigned short syntheticClickType, DataTransfer* dataTransfer, IsSimulated isSimulated)
+    EventTarget* relatedTarget, double force, unsigned short syntheticClickType, DataTransfer* dataTransfer, IsSimulated isSimulated, IsTrusted isTrusted)
 {
     return adoptRef(*new MouseEvent(type, canBubble, isCancelable, isComposed, timestamp, WTFMove(view), detail,
-        screenLocation, windowLocation, movementDelta, modifiers, button, buttons, relatedTarget, force, syntheticClickType, dataTransfer, isSimulated));
+        screenLocation, windowLocation, movementDelta, modifiers, button, buttons, relatedTarget, force, syntheticClickType, dataTransfer, isSimulated, isTrusted));
 }
 
 Ref<MouseEvent> MouseEvent::create(const AtomicString& eventType, CanBubble canBubble, IsCancelable isCancelable, IsComposed isComposed, RefPtr<WindowProxy>&& view, int detail,
@@ -80,8 +80,8 @@
 MouseEvent::MouseEvent(const AtomicString& eventType, CanBubble canBubble, IsCancelable isCancelable, IsComposed isComposed,
     MonotonicTime timestamp, RefPtr<WindowProxy>&& view, int detail,
     const IntPoint& screenLocation, const IntPoint& windowLocation, const IntPoint& movementDelta, OptionSet<Modifier> modifiers, unsigned short button, unsigned short buttons,
-    EventTarget* relatedTarget, double force, unsigned short syntheticClickType, DataTransfer* dataTransfer, IsSimulated isSimulated)
-    : MouseRelatedEvent(eventType, canBubble, isCancelable, isComposed, timestamp, WTFMove(view), detail, screenLocation, windowLocation, movementDelta, modifiers, isSimulated)
+    EventTarget* relatedTarget, double force, unsigned short syntheticClickType, DataTransfer* dataTransfer, IsSimulated isSimulated, IsTrusted isTrusted)
+    : MouseRelatedEvent(eventType, canBubble, isCancelable, isComposed, timestamp, WTFMove(view), detail, screenLocation, windowLocation, movementDelta, modifiers, isSimulated, isTrusted)
     , m_button(button == (unsigned short)-1 ? 0 : button)
     , m_buttons(buttons)
     , m_syntheticClickType(button == (unsigned short)-1 ? 0 : syntheticClickType)

Modified: trunk/Source/WebCore/dom/MouseEvent.h (235334 => 235335)


--- trunk/Source/WebCore/dom/MouseEvent.h	2018-08-24 21:40:50 UTC (rev 235334)
+++ trunk/Source/WebCore/dom/MouseEvent.h	2018-08-24 22:51:33 UTC (rev 235335)
@@ -36,7 +36,7 @@
 public:
     WEBCORE_EXPORT static Ref<MouseEvent> create(const AtomicString& type, CanBubble, IsCancelable, IsComposed, MonotonicTime timestamp, RefPtr<WindowProxy>&&, int detail,
         const IntPoint& screenLocation, const IntPoint& windowLocation, const IntPoint& movementDelta, OptionSet<Modifier>, unsigned short button, unsigned short buttons,
-        EventTarget* relatedTarget, double force, unsigned short syntheticClickType, DataTransfer* = nullptr, IsSimulated = IsSimulated::No);
+        EventTarget* relatedTarget, double force, unsigned short syntheticClickType, DataTransfer* = nullptr, IsSimulated = IsSimulated::No, IsTrusted = IsTrusted::Yes);
 
     WEBCORE_EXPORT static Ref<MouseEvent> create(const AtomicString& eventType, RefPtr<WindowProxy>&&, const PlatformMouseEvent&, int detail, Node* relatedTarget);
 
@@ -78,7 +78,7 @@
 protected:
     MouseEvent(const AtomicString& type, CanBubble, IsCancelable, IsComposed, MonotonicTime timestamp, RefPtr<WindowProxy>&&, int detail,
         const IntPoint& screenLocation, const IntPoint& windowLocation, const IntPoint& movementDelta, OptionSet<Modifier>, unsigned short button, unsigned short buttons,
-        EventTarget* relatedTarget, double force, unsigned short syntheticClickType, DataTransfer*, IsSimulated);
+        EventTarget* relatedTarget, double force, unsigned short syntheticClickType, DataTransfer*, IsSimulated, IsTrusted);
 
     MouseEvent(const AtomicString& type, CanBubble, IsCancelable, IsComposed, RefPtr<WindowProxy>&&, int detail,
         const IntPoint& screenLocation, const IntPoint& clientLocation, OptionSet<Modifier>, unsigned short button, unsigned short buttons,

Modified: trunk/Source/WebCore/dom/MouseRelatedEvent.cpp (235334 => 235335)


--- trunk/Source/WebCore/dom/MouseRelatedEvent.cpp	2018-08-24 21:40:50 UTC (rev 235334)
+++ trunk/Source/WebCore/dom/MouseRelatedEvent.cpp	2018-08-24 22:51:33 UTC (rev 235335)
@@ -35,8 +35,8 @@
 
 MouseRelatedEvent::MouseRelatedEvent(const AtomicString& eventType, CanBubble canBubble, IsCancelable isCancelable, IsComposed isComposed,
     MonotonicTime timestamp, RefPtr<WindowProxy>&& view, int detail,
-    const IntPoint& screenLocation, const IntPoint& windowLocation, const IntPoint& movementDelta, OptionSet<Modifier> modifiers, IsSimulated isSimulated)
-    : UIEventWithKeyState(eventType, canBubble, isCancelable, isComposed, timestamp, WTFMove(view), detail, modifiers)
+    const IntPoint& screenLocation, const IntPoint& windowLocation, const IntPoint& movementDelta, OptionSet<Modifier> modifiers, IsSimulated isSimulated, IsTrusted isTrusted)
+    : UIEventWithKeyState(eventType, canBubble, isCancelable, isComposed, timestamp, WTFMove(view), detail, modifiers, isTrusted)
     , m_screenLocation(screenLocation)
 #if ENABLE(POINTER_LOCK)
     , m_movementDelta(movementDelta)

Modified: trunk/Source/WebCore/dom/MouseRelatedEvent.h (235334 => 235335)


--- trunk/Source/WebCore/dom/MouseRelatedEvent.h	2018-08-24 21:40:50 UTC (rev 235334)
+++ trunk/Source/WebCore/dom/MouseRelatedEvent.h	2018-08-24 22:51:33 UTC (rev 235335)
@@ -77,7 +77,8 @@
 protected:
     MouseRelatedEvent() = default;
     MouseRelatedEvent(const AtomicString& type, CanBubble, IsCancelable, IsComposed, MonotonicTime, RefPtr<WindowProxy>&&, int detail,
-        const IntPoint& screenLocation, const IntPoint& windowLocation, const IntPoint& movementDelta, OptionSet<Modifier> modifiers, IsSimulated = IsSimulated::No);
+        const IntPoint& screenLocation, const IntPoint& windowLocation, const IntPoint& movementDelta, OptionSet<Modifier> modifiers,
+        IsSimulated = IsSimulated::No, IsTrusted = IsTrusted::Yes);
     MouseRelatedEvent(const AtomicString& type, IsCancelable, MonotonicTime, RefPtr<WindowProxy>&&, const IntPoint& globalLocation, OptionSet<Modifier>);
     MouseRelatedEvent(const AtomicString& type, const MouseRelatedEventInit&, IsTrusted = IsTrusted::No);
 

Modified: trunk/Source/WebCore/dom/SimulatedClick.cpp (235334 => 235335)


--- trunk/Source/WebCore/dom/SimulatedClick.cpp	2018-08-24 21:40:50 UTC (rev 235334)
+++ trunk/Source/WebCore/dom/SimulatedClick.cpp	2018-08-24 22:51:33 UTC (rev 235335)
@@ -46,11 +46,9 @@
     SimulatedMouseEvent(const AtomicString& eventType, RefPtr<WindowProxy>&& view, RefPtr<Event>&& underlyingEvent, Element& target, SimulatedClickSource source)
         : MouseEvent(eventType, CanBubble::Yes, IsCancelable::Yes, source == SimulatedClickSource::Bindings ? IsComposed::No : IsComposed::Yes,
             underlyingEvent ? underlyingEvent->timeStamp() : MonotonicTime::now(), WTFMove(view), /* detail */ 0,
-            { }, { }, { }, modifiersFromUnderlyingEvent(underlyingEvent), 0, 0, nullptr, 0, 0, nullptr, IsSimulated::Yes)
+            { }, { }, { }, modifiersFromUnderlyingEvent(underlyingEvent), 0, 0, nullptr, 0, 0, nullptr, IsSimulated::Yes,
+            source == SimulatedClickSource::UserAgent ? IsTrusted::Yes : IsTrusted::No)
     {
-        if (source == SimulatedClickSource::Bindings)
-            setUntrusted();
-
         setUnderlyingEvent(underlyingEvent.get());
 
         if (is<MouseEvent>(this->underlyingEvent())) {

Modified: trunk/Source/WebCore/dom/UIEvent.cpp (235334 => 235335)


--- trunk/Source/WebCore/dom/UIEvent.cpp	2018-08-24 21:40:50 UTC (rev 235334)
+++ trunk/Source/WebCore/dom/UIEvent.cpp	2018-08-24 22:51:33 UTC (rev 235335)
@@ -39,8 +39,8 @@
 {
 }
 
-UIEvent::UIEvent(const AtomicString& eventType, CanBubble canBubble, IsCancelable isCancelable, IsComposed isComposed, MonotonicTime timestamp, RefPtr<WindowProxy>&& viewArg, int detailArg)
-    : Event(eventType, canBubble, isCancelable, isComposed, timestamp)
+UIEvent::UIEvent(const AtomicString& eventType, CanBubble canBubble, IsCancelable isCancelable, IsComposed isComposed, MonotonicTime timestamp, RefPtr<WindowProxy>&& viewArg, int detailArg, IsTrusted isTrusted)
+    : Event(eventType, canBubble, isCancelable, isComposed, timestamp, isTrusted)
     , m_view(WTFMove(viewArg))
     , m_detail(detailArg)
 {

Modified: trunk/Source/WebCore/dom/UIEvent.h (235334 => 235335)


--- trunk/Source/WebCore/dom/UIEvent.h	2018-08-24 21:40:50 UTC (rev 235334)
+++ trunk/Source/WebCore/dom/UIEvent.h	2018-08-24 22:51:33 UTC (rev 235335)
@@ -67,7 +67,7 @@
     UIEvent();
 
     UIEvent(const AtomicString& type, CanBubble, IsCancelable, IsComposed, RefPtr<WindowProxy>&&, int detail);
-    UIEvent(const AtomicString& type, CanBubble, IsCancelable, IsComposed, MonotonicTime timestamp, RefPtr<WindowProxy>&&, int detail);
+    UIEvent(const AtomicString& type, CanBubble, IsCancelable, IsComposed, MonotonicTime timestamp, RefPtr<WindowProxy>&&, int detail, IsTrusted = IsTrusted::Yes);
     UIEvent(const AtomicString&, const UIEventInit&);
 
 private:

Modified: trunk/Source/WebCore/dom/UIEventWithKeyState.h (235334 => 235335)


--- trunk/Source/WebCore/dom/UIEventWithKeyState.h	2018-08-24 21:40:50 UTC (rev 235334)
+++ trunk/Source/WebCore/dom/UIEventWithKeyState.h	2018-08-24 22:51:33 UTC (rev 235335)
@@ -55,8 +55,8 @@
     }
 
     UIEventWithKeyState(const AtomicString& type, CanBubble canBubble, IsCancelable cancelable, IsComposed isComposed,
-        MonotonicTime timestamp, RefPtr<WindowProxy>&& view, int detail, OptionSet<Modifier> modifiers)
-        : UIEvent(type, canBubble, cancelable, isComposed, timestamp, WTFMove(view), detail)
+        MonotonicTime timestamp, RefPtr<WindowProxy>&& view, int detail, OptionSet<Modifier> modifiers, IsTrusted isTrusted)
+        : UIEvent(type, canBubble, cancelable, isComposed, timestamp, WTFMove(view), detail, isTrusted)
         , m_modifiers(modifiers)
     {
     }

Modified: trunk/Source/WebCore/dom/WheelEvent.cpp (235334 => 235335)


--- trunk/Source/WebCore/dom/WheelEvent.cpp	2018-08-24 21:40:50 UTC (rev 235334)
+++ trunk/Source/WebCore/dom/WheelEvent.cpp	2018-08-24 22:51:33 UTC (rev 235335)
@@ -48,8 +48,8 @@
 }
 
 inline WheelEvent::WheelEvent(const PlatformWheelEvent& event, RefPtr<WindowProxy>&& view)
-    : MouseEvent(eventNames().wheelEvent, CanBubble::Yes, IsCancelable::Yes, IsComposed::Yes, event.timestamp().approximateMonotonicTime(), WTFMove(view), 0, event.globalPosition(), event.position() , { }
-        , event.modifiers(), 0, 0, nullptr, 0, 0, nullptr, IsSimulated::No)
+    : MouseEvent(eventNames().wheelEvent, CanBubble::Yes, IsCancelable::Yes, IsComposed::Yes, event.timestamp().approximateMonotonicTime(), WTFMove(view), 0,
+        event.globalPosition(), event.position() , { }, event.modifiers(), 0, 0, nullptr, 0, 0, nullptr, IsSimulated::No, IsTrusted::Yes)
     , m_wheelDelta(event.wheelTicksX() * TickMultiplier, event.wheelTicksY() * TickMultiplier)
     , m_deltaX(-event.deltaX())
     , m_deltaY(-event.deltaY())
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to