WebKit Bugzilla
Attachment 347610 Details for
Bug 188777
: Replace booleans for modifier keys in UIEventWithKeyState with OptionSet<Modifier>
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
WIP
wip188777.patch (text/plain), 39.50 KB, created by
Ryosuke Niwa
on 2018-08-20 21:45:49 PDT
(
hide
)
Description:
WIP
Filename:
MIME Type:
Creator:
Ryosuke Niwa
Created:
2018-08-20 21:45:49 PDT
Size:
39.50 KB
patch
obsolete
>diff --git a/Source/WebCore/dom/Element.cpp b/Source/WebCore/dom/Element.cpp >index c3ba8a7e5c9..d9cbf3821f7 100644 >--- a/Source/WebCore/dom/Element.cpp >+++ b/Source/WebCore/dom/Element.cpp >@@ -290,12 +290,12 @@ bool Element::dispatchMouseEvent(const PlatformMouseEvent& platformEvent, const > // Special case: If it's a double click event, we also send the dblclick event. This is not part > // of the DOM specs, but is used for compatibility with the ondblclick="" attribute. This is treated > // as a separate event in other DOM-compliant browsers like Firefox, and so we do the same. >+ // FIXME: Is it okay that mouseEvent may have been mutated by scripts via initMouseEvent in dispatchEvent above? > Ref<MouseEvent> doubleClickEvent = MouseEvent::create(eventNames().dblclickEvent, > mouseEvent->bubbles() ? Event::CanBubble::Yes : Event::CanBubble::No, mouseEvent->cancelable() ? Event::IsCancelable::Yes : Event::IsCancelable::No, > mouseEvent->view(), mouseEvent->detail(), > mouseEvent->screenX(), mouseEvent->screenY(), mouseEvent->clientX(), mouseEvent->clientY(), >- mouseEvent->ctrlKey(), mouseEvent->altKey(), mouseEvent->shiftKey(), mouseEvent->metaKey(), >- mouseEvent->button(), mouseEvent->buttons(), mouseEvent->syntheticClickType(), relatedTarget); >+ mouseEvent->modifierKeys(), mouseEvent->button(), mouseEvent->buttons(), mouseEvent->syntheticClickType(), relatedTarget); > > if (mouseEvent->defaultHandled()) > doubleClickEvent->setDefaultHandled(); >diff --git a/Source/WebCore/dom/KeyboardEvent.cpp b/Source/WebCore/dom/KeyboardEvent.cpp >index ad4dce4576b..3b5e9c98499 100644 >--- a/Source/WebCore/dom/KeyboardEvent.cpp >+++ b/Source/WebCore/dom/KeyboardEvent.cpp >@@ -95,8 +95,7 @@ inline KeyboardEvent::KeyboardEvent() = default; > > inline KeyboardEvent::KeyboardEvent(const PlatformKeyboardEvent& key, RefPtr<WindowProxy>&& view) > : UIEventWithKeyState(eventTypeForKeyboardEventType(key.type()), CanBubble::Yes, IsCancelable::Yes, >- key.timestamp().approximateMonotonicTime(), view.copyRef(), 0, key.ctrlKey(), key.altKey(), key.shiftKey(), key.metaKey(), >- false, key.modifiers().contains(PlatformEvent::Modifier::CapsLockKey)) >+ key.timestamp().approximateMonotonicTime(), view.copyRef(), 0, key.modifiers()) > , m_underlyingPlatformEvent(std::make_unique<PlatformKeyboardEvent>(key)) > #if ENABLE(KEYBOARD_KEY_ATTRIBUTE) > , m_key(key.key()) >@@ -160,11 +159,8 @@ void KeyboardEvent::initKeyboardEvent(const AtomicString& type, bool canBubble, > > m_keyIdentifier = keyIdentifier; > m_location = location; >- m_ctrlKey = ctrlKey; >- m_shiftKey = shiftKey; >- m_altKey = altKey; >- m_metaKey = metaKey; >- m_altGraphKey = altGraphKey; >+ >+ setModifierKeys(ctrlKey, altKey, shiftKey, metaKey, altGraphKey); > > m_charCode = std::nullopt; > m_isComposing = false; >diff --git a/Source/WebCore/dom/MouseEvent.cpp b/Source/WebCore/dom/MouseEvent.cpp >index b267de2bd08..7f8476440f2 100644 >--- a/Source/WebCore/dom/MouseEvent.cpp >+++ b/Source/WebCore/dom/MouseEvent.cpp >@@ -50,46 +50,37 @@ Ref<MouseEvent> MouseEvent::create(const AtomicString& eventType, RefPtr<WindowP > auto isCancelable = eventType != eventNames().mousemoveEvent && !isMouseEnterOrLeave ? IsCancelable::Yes : IsCancelable::No; > auto canBubble = !isMouseEnterOrLeave ? CanBubble::Yes : CanBubble::No; > >- return MouseEvent::create(eventType, canBubble, isCancelable, event.timestamp().approximateMonotonicTime(), WTFMove(view), >- detail, event.globalPosition().x(), event.globalPosition().y(), event.position().x(), event.position().y(), >+ return MouseEvent::create(eventType, canBubble, isCancelable, event.timestamp().approximateMonotonicTime(), WTFMove(view), detail, >+ event.globalPosition(), event.position(), > #if ENABLE(POINTER_LOCK) >- event.movementDelta().x(), event.movementDelta().y(), >+ event.movementDelta(), >+#else >+ { }, > #endif >- event.ctrlKey(), event.altKey(), event.shiftKey(), event.metaKey(), event.button(), event.buttons(), >- relatedTarget, event.force(), event.syntheticClickType()); >+ event.modifiers(), event.button(), event.buttons(), relatedTarget, event.force(), event.syntheticClickType()); > } > >-Ref<MouseEvent> MouseEvent::create(const AtomicString& type, CanBubble canBubble, IsCancelable cancelable, MonotonicTime timestamp, RefPtr<WindowProxy>&& view, int detail, int screenX, int screenY, int pageX, int pageY, >-#if ENABLE(POINTER_LOCK) >- int movementX, int movementY, >-#endif >- bool ctrlKey, bool altKey, bool shiftKey, bool metaKey, unsigned short button, unsigned short buttons, EventTarget* relatedTarget, double force, unsigned short syntheticClickType, DataTransfer* dataTransfer, bool isSimulated) >+Ref<MouseEvent> MouseEvent::create(const AtomicString& type, CanBubble canBubble, IsCancelable cancelable, 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) > { >- return adoptRef(*new MouseEvent(type, canBubble, cancelable, timestamp, WTFMove(view), >- detail, { screenX, screenY }, { pageX, pageY }, >-#if ENABLE(POINTER_LOCK) >- { movementX, movementY }, >-#endif >- ctrlKey, altKey, shiftKey, metaKey, button, buttons, relatedTarget, force, syntheticClickType, dataTransfer, isSimulated)); >+ return adoptRef(*new MouseEvent(type, canBubble, cancelable, timestamp, WTFMove(view), detail, >+ screenLocation, windowLocation, movementDelta, modifiers, button, buttons, relatedTarget, force, syntheticClickType, dataTransfer, isSimulated)); > } > >-Ref<MouseEvent> MouseEvent::create(const AtomicString& eventType, CanBubble canBubble, IsCancelable cancelable, RefPtr<WindowProxy>&& view, int detail, int screenX, int screenY, int clientX, int clientY, bool ctrlKey, bool altKey, bool shiftKey, bool metaKey, unsigned short button, unsigned short buttons, unsigned short syntheticClickType, EventTarget* relatedTarget) >+Ref<MouseEvent> MouseEvent::create(const AtomicString& eventType, CanBubble canBubble, IsCancelable cancelable, RefPtr<WindowProxy>&& view, int detail, >+ int screenX, int screenY, int clientX, int clientY, OptionSet<Modifier> modifiers, unsigned short button, unsigned short buttons, >+ unsigned short syntheticClickType, EventTarget* relatedTarget) > { >- return adoptRef(*new MouseEvent(eventType, canBubble, cancelable, WTFMove(view), detail, { screenX, screenY }, { clientX, clientY }, ctrlKey, altKey, shiftKey, metaKey, button, buttons, syntheticClickType, relatedTarget)); >+ return adoptRef(*new MouseEvent(eventType, canBubble, cancelable, WTFMove(view), detail, { screenX, screenY }, { clientX, clientY }, modifiers, button, buttons, syntheticClickType, relatedTarget)); > } > > MouseEvent::MouseEvent() = default; > >-MouseEvent::MouseEvent(const AtomicString& eventType, CanBubble canBubble, IsCancelable cancelable, MonotonicTime timestamp, RefPtr<WindowProxy>&& view, int detail, const IntPoint& screenLocation, const IntPoint& windowLocation, >-#if ENABLE(POINTER_LOCK) >- const IntPoint& movementDelta, >-#endif >- bool ctrlKey, bool altKey, bool shiftKey, bool metaKey, unsigned short button, unsigned short buttons, EventTarget* relatedTarget, double force, unsigned short syntheticClickType, DataTransfer* dataTransfer, bool isSimulated) >- : MouseRelatedEvent(eventType, canBubble, cancelable, timestamp, WTFMove(view), detail, screenLocation, windowLocation, >-#if ENABLE(POINTER_LOCK) >- movementDelta, >-#endif >- ctrlKey, altKey, shiftKey, metaKey, isSimulated) >+MouseEvent::MouseEvent(const AtomicString& eventType, CanBubble canBubble, IsCancelable cancelable, 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, cancelable, timestamp, WTFMove(view), detail, screenLocation, windowLocation, movementDelta, modifiers, isSimulated) > , m_button(button == (unsigned short)-1 ? 0 : button) > , m_buttons(buttons) > , m_syntheticClickType(button == (unsigned short)-1 ? 0 : syntheticClickType) >@@ -100,12 +91,9 @@ MouseEvent::MouseEvent(const AtomicString& eventType, CanBubble canBubble, IsCan > { > } > >-MouseEvent::MouseEvent(const AtomicString& eventType, CanBubble canBubble, IsCancelable cancelable, RefPtr<WindowProxy>&& view, int detail, const IntPoint& screenLocation, const IntPoint& clientLocation, bool ctrlKey, bool altKey, bool shiftKey, bool metaKey, unsigned short button, unsigned short buttons, unsigned short syntheticClickType, EventTarget* relatedTarget) >- : MouseRelatedEvent(eventType, canBubble, cancelable, MonotonicTime::now(), WTFMove(view), detail, screenLocation, { }, >-#if ENABLE(POINTER_LOCK) >- { }, >-#endif >- ctrlKey, altKey, shiftKey, metaKey, false) >+MouseEvent::MouseEvent(const AtomicString& eventType, CanBubble canBubble, IsCancelable cancelable, RefPtr<WindowProxy>&& view, int detail, >+ const IntPoint& screenLocation, const IntPoint& clientLocation, OptionSet<Modifier> modifiers, unsigned short button, unsigned short buttons, unsigned short syntheticClickType, EventTarget* relatedTarget) >+ : MouseRelatedEvent(eventType, canBubble, cancelable, MonotonicTime::now(), WTFMove(view), detail, screenLocation, { }, { }, modifiers, IsSimulated::No) > , m_button(button == (unsigned short)-1 ? 0 : button) > , m_buttons(buttons) > , m_syntheticClickType(button == (unsigned short)-1 ? 0 : syntheticClickType) >@@ -127,7 +115,8 @@ MouseEvent::MouseEvent(const AtomicString& eventType, const MouseEventInit& init > > MouseEvent::~MouseEvent() = default; > >-void MouseEvent::initMouseEvent(const AtomicString& type, bool canBubble, bool cancelable, RefPtr<WindowProxy>&& view, int detail, int screenX, int screenY, int clientX, int clientY, bool ctrlKey, bool altKey, bool shiftKey, bool metaKey, unsigned short button, EventTarget* relatedTarget) >+void MouseEvent::initMouseEvent(const AtomicString& type, bool canBubble, bool cancelable, RefPtr<WindowProxy>&& view, int detail, >+ int screenX, int screenY, int clientX, int clientY, bool ctrlKey, bool altKey, bool shiftKey, bool metaKey, unsigned short button, EventTarget* relatedTarget) > { > if (isBeingDispatched()) > return; >@@ -135,10 +124,7 @@ void MouseEvent::initMouseEvent(const AtomicString& type, bool canBubble, bool c > initUIEvent(type, canBubble, cancelable, WTFMove(view), detail); > > m_screenLocation = IntPoint(screenX, screenY); >- m_ctrlKey = ctrlKey; >- m_altKey = altKey; >- m_shiftKey = shiftKey; >- m_metaKey = metaKey; >+ setModifierKeys(ctrlKey, altKey, shiftKey, metaKey); > m_button = button == (unsigned short)-1 ? 0 : button; > m_syntheticClickType = 0; > m_buttonDown = button != (unsigned short)-1; >diff --git a/Source/WebCore/dom/MouseEvent.h b/Source/WebCore/dom/MouseEvent.h >index b03aabbbe6f..02d35c67319 100644 >--- a/Source/WebCore/dom/MouseEvent.h >+++ b/Source/WebCore/dom/MouseEvent.h >@@ -34,18 +34,14 @@ class PlatformMouseEvent; > > class MouseEvent : public MouseRelatedEvent { > public: >- WEBCORE_EXPORT static Ref<MouseEvent> create(const AtomicString& type, CanBubble, IsCancelable, MonotonicTime timestamp, >- RefPtr<WindowProxy>&&, int detail, int screenX, int screenY, int pageX, int pageY, >-#if ENABLE(POINTER_LOCK) >- int movementX, int movementY, >-#endif >- bool ctrlKey, bool altKey, bool shiftKey, bool metaKey, unsigned short button, unsigned short buttons, >- EventTarget* relatedTarget, double force, unsigned short syntheticClickType, DataTransfer* = nullptr, bool isSimulated = false); >+ WEBCORE_EXPORT static Ref<MouseEvent> create(const AtomicString& type, CanBubble, IsCancelable, 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); > > WEBCORE_EXPORT static Ref<MouseEvent> create(const AtomicString& eventType, RefPtr<WindowProxy>&&, const PlatformMouseEvent&, int detail, Node* relatedTarget); > > static Ref<MouseEvent> create(const AtomicString& eventType, CanBubble, IsCancelable, RefPtr<WindowProxy>&&, >- int detail, int screenX, int screenY, int clientX, int clientY, bool ctrlKey, bool altKey, bool shiftKey, bool metaKey, >+ int detail, int screenX, int screenY, int clientX, int clientY, OptionSet<Modifier>, > unsigned short button, unsigned short buttons, unsigned short syntheticClickType, EventTarget* relatedTarget); > > static Ref<MouseEvent> createForBindings() { return adoptRef(*new MouseEvent); } >@@ -80,18 +76,13 @@ public: > int which() const final; > > protected: >- MouseEvent(const AtomicString& type, CanBubble, IsCancelable, MonotonicTime timestamp, RefPtr<WindowProxy>&&, >- int detail, const IntPoint& screenLocation, const IntPoint& windowLocation, >-#if ENABLE(POINTER_LOCK) >- const IntPoint& movementDelta, >-#endif >- bool ctrlKey, bool altKey, bool shiftKey, bool metaKey, unsigned short button, unsigned short buttons, >- EventTarget* relatedTarget, double force, unsigned short syntheticClickType, DataTransfer*, bool isSimulated); >+ MouseEvent(const AtomicString& type, CanBubble, IsCancelable, 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); > > MouseEvent(const AtomicString& type, CanBubble, IsCancelable, RefPtr<WindowProxy>&&, > int detail, const IntPoint& screenLocation, const IntPoint& clientLocation, >- bool ctrlKey, bool altKey, bool shiftKey, bool metaKey, >- unsigned short button, unsigned short buttons, unsigned short syntheticClickType, EventTarget* relatedTarget); >+ OptionSet<Modifier>, unsigned short button, unsigned short buttons, unsigned short syntheticClickType, EventTarget* relatedTarget); > > MouseEvent(const AtomicString& type, const MouseEventInit&, IsTrusted); > >diff --git a/Source/WebCore/dom/MouseRelatedEvent.cpp b/Source/WebCore/dom/MouseRelatedEvent.cpp >index a3227a54bb4..17519d0cb19 100644 >--- a/Source/WebCore/dom/MouseRelatedEvent.cpp >+++ b/Source/WebCore/dom/MouseRelatedEvent.cpp >@@ -33,20 +33,24 @@ > > namespace WebCore { > >-MouseRelatedEvent::MouseRelatedEvent(const AtomicString& eventType, CanBubble canBubble, IsCancelable cancelable, MonotonicTime timestamp, RefPtr<WindowProxy>&& view, >- int detail, const IntPoint& screenLocation, const IntPoint& windowLocation, >-#if ENABLE(POINTER_LOCK) >- const IntPoint& movementDelta, >-#endif >- bool ctrlKey, bool altKey, bool shiftKey, bool metaKey, bool isSimulated) >- : UIEventWithKeyState(eventType, canBubble, cancelable, timestamp, WTFMove(view), detail, ctrlKey, altKey, shiftKey, metaKey, false, false) >+MouseRelatedEvent::MouseRelatedEvent(const AtomicString& eventType, CanBubble canBubble, IsCancelable isCancelable, 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, timestamp, WTFMove(view), detail, modifiers) > , m_screenLocation(screenLocation) > #if ENABLE(POINTER_LOCK) > , m_movementDelta(movementDelta) > #endif >- , m_isSimulated(isSimulated) >+ , m_isSimulated(isSimulated == IsSimulated::Yes) >+{ >+#if !ENABLE(POINTER_LOCK) >+ UNUSED_PARAM(movementDelta); >+#endif >+ init(m_isSimulated, windowLocation); >+} >+ >+MouseRelatedEvent::MouseRelatedEvent(const AtomicString& type, IsCancelable isCancelable, MonotonicTime timestamp, Ref<WindowProxy>&& view, const IntPoint& globalLocation, OptionSet<Modifier> modifiers) >+ : MouseRelatedEvent(type, CanBubble::Yes, isCancelable, timestamp, WTFMove(view), 0, globalLocation, globalLocation /* Converted in init */, { }, modifiers, IsSimulated::No) > { >- init(isSimulated, windowLocation); > } > > MouseRelatedEvent::MouseRelatedEvent(const AtomicString& eventType, const MouseRelatedEventInit& initializer, IsTrusted isTrusted) >diff --git a/Source/WebCore/dom/MouseRelatedEvent.h b/Source/WebCore/dom/MouseRelatedEvent.h >index d8f1fcdf3e1..0ab21425b7a 100644 >--- a/Source/WebCore/dom/MouseRelatedEvent.h >+++ b/Source/WebCore/dom/MouseRelatedEvent.h >@@ -38,6 +38,8 @@ struct MouseRelatedEventInit : public EventModifierInit { > // Internal only: Helper class for what's common between mouse and wheel events. > class MouseRelatedEvent : public UIEventWithKeyState { > public: >+ enum class IsSimulated : uint8_t { Yes, No }; >+ > // Note that these values are adjusted to counter the effects of zoom, so that values > // exposed via DOM APIs are invariant under zooming. > int screenX() const { return m_screenLocation.x(); } >@@ -74,12 +76,9 @@ public: > > protected: > MouseRelatedEvent() = default; >- MouseRelatedEvent(const AtomicString& type, CanBubble, IsCancelable, MonotonicTime timestamp, RefPtr<WindowProxy>&&, >- int detail, const IntPoint& screenLocation, const IntPoint& windowLocation, >-#if ENABLE(POINTER_LOCK) >- const IntPoint& movementDelta, >-#endif >- bool ctrlKey, bool altKey, bool shiftKey, bool metaKey, bool isSimulated = false); >+ MouseRelatedEvent(const AtomicString& type, CanBubble, IsCancelable, MonotonicTime, RefPtr<WindowProxy>&&, int detail, >+ const IntPoint& screenLocation, const IntPoint& windowLocation, const IntPoint& movementDelta, OptionSet<Modifier> modifiers, IsSimulated = IsSimulated::No); >+ MouseRelatedEvent(const AtomicString& type, IsCancelable, MonotonicTime, Ref<WindowProxy>&&, const IntPoint& globalLocation, OptionSet<Modifier>); > MouseRelatedEvent(const AtomicString& type, const MouseRelatedEventInit&, IsTrusted = IsTrusted::No); > > void initCoordinates(); >diff --git a/Source/WebCore/dom/SimulatedClick.cpp b/Source/WebCore/dom/SimulatedClick.cpp >index a52c1a78386..f506faf8d16 100644 >--- a/Source/WebCore/dom/SimulatedClick.cpp >+++ b/Source/WebCore/dom/SimulatedClick.cpp >@@ -44,21 +44,12 @@ public: > > private: > SimulatedMouseEvent(const AtomicString& eventType, RefPtr<WindowProxy>&& view, RefPtr<Event>&& underlyingEvent, Element& target, SimulatedClickSource source) >- : MouseEvent(eventType, CanBubble::Yes, IsCancelable::Yes, underlyingEvent ? underlyingEvent->timeStamp() : MonotonicTime::now(), WTFMove(view), 0, { }, { }, >-#if ENABLE(POINTER_LOCK) >- { }, >-#endif >- false, false, false, false, 0, 0, nullptr, 0, 0, nullptr, true) >+ : MouseEvent(eventType, CanBubble::Yes, IsCancelable::Yes, underlyingEvent ? underlyingEvent->timeStamp() : MonotonicTime::now(), WTFMove(view), /* detail */ 0, >+ { }, { }, { }, modifiersFromUnderlyingEvent(underlyingEvent), 0, 0, nullptr, 0, 0, nullptr, IsSimulated::Yes) > { > if (source == SimulatedClickSource::Bindings) > setUntrusted(); > >- if (UIEventWithKeyState* keyStateEvent = findEventWithKeyState(underlyingEvent.get())) { >- m_ctrlKey = keyStateEvent->ctrlKey(); >- m_altKey = keyStateEvent->altKey(); >- m_shiftKey = keyStateEvent->shiftKey(); >- m_metaKey = keyStateEvent->metaKey(); >- } > setUnderlyingEvent(underlyingEvent.get()); > > if (is<MouseEvent>(this->underlyingEvent())) { >@@ -75,6 +66,13 @@ private: > } > } > >+ static OptionSet<Modifier> modifiersFromUnderlyingEvent(const RefPtr<Event>& underlyingEvent) >+ { >+ UIEventWithKeyState* keyStateEvent = findEventWithKeyState(underlyingEvent.get()); >+ if (!keyStateEvent) >+ return { }; >+ return keyStateEvent->modifierKeys(); >+ } > }; > > static void simulateMouseEvent(const AtomicString& eventType, Element& element, Event* underlyingEvent, SimulatedClickSource source) >diff --git a/Source/WebCore/dom/TouchEvent.cpp b/Source/WebCore/dom/TouchEvent.cpp >index 292c84668f6..09eb5f5f88b 100644 >--- a/Source/WebCore/dom/TouchEvent.cpp >+++ b/Source/WebCore/dom/TouchEvent.cpp >@@ -37,13 +37,9 @@ namespace WebCore { > TouchEvent::TouchEvent() = default; > > TouchEvent::TouchEvent(TouchList* touches, TouchList* targetTouches, TouchList* changedTouches, const AtomicString& type, >- RefPtr<WindowProxy>&& view, int screenX, int screenY, int pageX, int pageY, bool ctrlKey, bool altKey, bool shiftKey, bool metaKey) >- : MouseRelatedEvent(type, CanBubble::Yes, IsCancelable::Yes, MonotonicTime::now(), WTFMove(view), 0, IntPoint(screenX, screenY), >- IntPoint(pageX, pageY), >-#if ENABLE(POINTER_LOCK) >- IntPoint(0, 0), >-#endif >- ctrlKey, altKey, shiftKey, metaKey) >+ RefPtr<WindowProxy>&& view, int screenX, int screenY, int pageX, int pageY, OptionSet<Modifier> modifiers) >+ : MouseRelatedEvent(type, CanBubble::Yes, IsCancelable::Yes, MonotonicTime::now(), WTFMove(view), 0, >+ IntPoint(screenX, screenY), IntPoint(pageX, pageY), IntPoint(0, 0), modifiers) > , m_touches(touches) > , m_targetTouches(targetTouches) > , m_changedTouches(changedTouches) >diff --git a/Source/WebCore/dom/TouchEvent.h b/Source/WebCore/dom/TouchEvent.h >index 85fa161f219..d0580761933 100644 >--- a/Source/WebCore/dom/TouchEvent.h >+++ b/Source/WebCore/dom/TouchEvent.h >@@ -39,15 +39,11 @@ class TouchEvent final : public MouseRelatedEvent { > public: > virtual ~TouchEvent(); > >- static Ref<TouchEvent> create(TouchList* touches, >- TouchList* targetTouches, TouchList* changedTouches, >- const AtomicString& type, RefPtr<WindowProxy>&& view, >- int screenX, int screenY, int pageX, int pageY, >- bool ctrlKey, bool altKey, bool shiftKey, bool metaKey) >+ static Ref<TouchEvent> create(TouchList* touches, TouchList* targetTouches, TouchList* changedTouches, >+ const AtomicString& type, RefPtr<WindowProxy>&& view, int screenX, int screenY, int pageX, int pageY, OptionSet<Modifier> modifiers) > { > return adoptRef(*new TouchEvent(touches, targetTouches, changedTouches, >- type, WTFMove(view), screenX, screenY, pageX, pageY, >- ctrlKey, altKey, shiftKey, metaKey)); >+ type, WTFMove(view), modifiers, screenX, screenY, pageX, pageY)); > } > static Ref<TouchEvent> createForBindings() > { >@@ -65,11 +61,8 @@ public: > return adoptRef(*new TouchEvent(type, initializer, isTrusted)); > } > >- void initTouchEvent(TouchList* touches, TouchList* targetTouches, >- TouchList* changedTouches, const AtomicString& type, >- RefPtr<WindowProxy>&&, int screenX, int screenY, >- int clientX, int clientY, >- bool ctrlKey, bool altKey, bool shiftKey, bool metaKey); >+ void initTouchEvent(TouchList* touches, TouchList* targetTouches, TouchList* changedTouches, const AtomicString& type, >+ RefPtr<WindowProxy>&&, int screenX, int screenY, int clientX, int clientY, bool ctrlKey, bool altKey, bool shiftKey, bool metaKey); > > TouchList* touches() const { return m_touches.get(); } > TouchList* targetTouches() const { return m_targetTouches.get(); } >@@ -85,11 +78,8 @@ public: > > private: > TouchEvent(); >- TouchEvent(TouchList* touches, TouchList* targetTouches, >- TouchList* changedTouches, const AtomicString& type, >- RefPtr<WindowProxy>&&, int screenX, int screenY, int pageX, >- int pageY, >- bool ctrlKey, bool altKey, bool shiftKey, bool metaKey); >+ TouchEvent(TouchList* touches, TouchList* targetTouches, TouchList* changedTouches, const AtomicString& type, >+ RefPtr<WindowProxy>&&, OptionSet<Modifier>, int screenX, int screenY, int pageX, int pageY); > TouchEvent(const AtomicString&, const Init&, IsTrusted); > > RefPtr<TouchList> m_touches; >diff --git a/Source/WebCore/dom/UIEventWithKeyState.h b/Source/WebCore/dom/UIEventWithKeyState.h >index 3668364699b..d9ca758fd98 100644 >--- a/Source/WebCore/dom/UIEventWithKeyState.h >+++ b/Source/WebCore/dom/UIEventWithKeyState.h >@@ -24,61 +24,104 @@ > #pragma once > > #include "EventModifierInit.h" >+#include "PlatformEvent.h" > #include "UIEvent.h" > > namespace WebCore { > > class UIEventWithKeyState : public UIEvent { > public: >- bool ctrlKey() const { return m_ctrlKey; } >- bool shiftKey() const { return m_shiftKey; } >- bool altKey() const { return m_altKey; } >- bool metaKey() const { return m_metaKey; } >- bool altGraphKey() const { return m_altGraphKey; } >- bool capsLockKey() const { return m_capsLockKey; } >+ using Modifier = PlatformEvent::Modifier; >+ >+ bool ctrlKey() const { return m_modifiers.contains(Modifier::CtrlKey); } >+ bool shiftKey() const { return m_modifiers.contains(Modifier::ShiftKey); } >+ bool altKey() const { return m_modifiers.contains(Modifier::AltKey); } >+ bool metaKey() const { return m_modifiers.contains(Modifier::MetaKey); } >+ bool altGraphKey() const { return m_modifiers.contains(Modifier::AltGraphKey); } >+ bool capsLockKey() const { return m_modifiers.contains(Modifier::CapsLockKey); } >+ >+ OptionSet<Modifier> modifierKeys() { return m_modifiers; } > > protected: > UIEventWithKeyState() = default; > >- UIEventWithKeyState(const AtomicString& type, CanBubble canBubble, IsCancelable cancelable, RefPtr<WindowProxy>&& view, int detail, bool ctrlKey, bool altKey, bool shiftKey, bool metaKey) >+ UIEventWithKeyState(const AtomicString& type, CanBubble canBubble, IsCancelable cancelable, RefPtr<WindowProxy>&& view, int detail, OptionSet<Modifier> modifiers) > : UIEvent(type, canBubble, cancelable, WTFMove(view), detail) >- , m_ctrlKey(ctrlKey) >- , m_altKey(altKey) >- , m_shiftKey(shiftKey) >- , m_metaKey(metaKey) >+ , m_modifiers(modifiers) > { > } > >- UIEventWithKeyState(const AtomicString& type, CanBubble canBubble, IsCancelable cancelable, MonotonicTime timestamp, RefPtr<WindowProxy>&& view, >- int detail, bool ctrlKey, bool altKey, bool shiftKey, bool metaKey, bool altGraphKey, bool capsLockKey) >- : UIEvent(type, canBubble, cancelable, timestamp, WTFMove(view), detail) >- , m_ctrlKey(ctrlKey) >- , m_altKey(altKey) >- , m_shiftKey(shiftKey) >- , m_metaKey(metaKey) >- , m_altGraphKey(altGraphKey) >- , m_capsLockKey(capsLockKey) >+ UIEventWithKeyState(const AtomicString& type, CanBubble canBubble, IsCancelable cancelable, MonotonicTime timestamp, RefPtr<WindowProxy>&& view, int detail, OptionSet<Modifier> modifiers) >+ : UIEvent(type, canBubble, cancelable, timestamp, WTFMove(view), detail) >+ , m_modifiers(modifiers) > { > } > > UIEventWithKeyState(const AtomicString& type, const EventModifierInit& initializer, IsTrusted isTrusted) > : UIEvent(type, initializer, isTrusted) >- , m_ctrlKey(initializer.ctrlKey) >- , m_altKey(initializer.altKey) >- , m_shiftKey(initializer.shiftKey) >- , m_metaKey(initializer.metaKey) >- , m_altGraphKey(initializer.modifierAltGraph) >- , m_capsLockKey(initializer.modifierCapsLock) >+ , m_modifiers(modifiersFromInitializer(initializer)) >+ { >+ } >+ >+ void setModifierKeys(bool ctrlKey, bool altKey, bool shiftKey, bool metaKey, bool altGraphKey) > { >+ OptionSet<Modifier> result; >+ if (ctrlKey) >+ result |= Modifier::CtrlKey; >+ if (altKey) >+ result |= Modifier::AltKey; >+ if (shiftKey) >+ result |= Modifier::ShiftKey; >+ if (metaKey) >+ result |= Modifier::MetaKey; >+ if (altGraphKey) >+ result |= Modifier::AltGraphKey; >+ // FIXME: Chrome or Firefox don't preserve this state. >+ if (m_modifiers & Modifier::CapsLockKey) >+ result |= Modifier::CapsLockKey; >+ m_modifiers = result; > } > >- // Expose these so init functions can set them. >- bool m_ctrlKey { false }; >- bool m_altKey { false }; >- bool m_shiftKey { false }; >- bool m_metaKey { false }; >- bool m_altGraphKey { false }; >- bool m_capsLockKey { false }; >+ void setModifierKeys(bool ctrlKey, bool altKey, bool shiftKey, bool metaKey) >+ { >+ OptionSet<Modifier> result; >+ if (ctrlKey) >+ result |= Modifier::CtrlKey; >+ if (altKey) >+ result |= Modifier::AltKey; >+ if (shiftKey) >+ result |= Modifier::ShiftKey; >+ if (metaKey) >+ result |= Modifier::MetaKey; >+ // FIXME: Chrome or Firefox don't preserve these states. >+ if (m_modifiers & Modifier::AltGraphKey) >+ result |= Modifier::AltGraphKey; >+ if (m_modifiers & Modifier::CapsLockKey) >+ result |= Modifier::CapsLockKey; >+ m_modifiers = result; >+ } >+ >+private: >+ OptionSet<Modifier> m_modifiers; >+ >+ OptionSet<Modifier> modifiersFromInitializer(const EventModifierInit& initializer) >+ { >+ OptionSet<Modifier> result; >+ if (initializer.ctrlKey) >+ result |= Modifier::CtrlKey; >+ if (initializer.altKey) >+ result |= Modifier::AltKey; >+ if (initializer.shiftKey) >+ result |= Modifier::ShiftKey; >+ if (initializer.metaKey) >+ result |= Modifier::MetaKey; >+ if (initializer.modifierAltGraph) >+ result |= Modifier::AltGraphKey; >+ if (initializer.modifierCapsLock) >+ result |= Modifier::CapsLockKey; >+ return result; >+ } >+ > }; > > UIEventWithKeyState* findEventWithKeyState(Event*); >diff --git a/Source/WebCore/dom/WheelEvent.cpp b/Source/WebCore/dom/WheelEvent.cpp >index 27677a87a5e..07223b95495 100644 >--- a/Source/WebCore/dom/WheelEvent.cpp >+++ b/Source/WebCore/dom/WheelEvent.cpp >@@ -48,11 +48,8 @@ inline WheelEvent::WheelEvent(const AtomicString& type, const Init& initializer, > } > > inline WheelEvent::WheelEvent(const PlatformWheelEvent& event, RefPtr<WindowProxy>&& view) >- : MouseEvent(eventNames().wheelEvent, CanBubble::Yes, IsCancelable::Yes, event.timestamp().approximateMonotonicTime(), WTFMove(view), 0, event.globalPosition(), event.position() >-#if ENABLE(POINTER_LOCK) >- , { } >-#endif >- , event.ctrlKey(), event.altKey(), event.shiftKey(), event.metaKey(), 0, 0, nullptr, 0, 0, nullptr, false) >+ : MouseEvent(eventNames().wheelEvent, CanBubble::Yes, IsCancelable::Yes, event.timestamp().approximateMonotonicTime(), WTFMove(view), 0, event.globalPosition(), event.position() , { } >+ , event.modifiers(), 0, 0, nullptr, 0, 0, nullptr, IsSimulated::No) > , m_wheelDelta(event.wheelTicksX() * TickMultiplier, event.wheelTicksY() * TickMultiplier) > , m_deltaX(-event.deltaX()) > , m_deltaY(-event.deltaY()) >diff --git a/Source/WebCore/page/EventHandler.cpp b/Source/WebCore/page/EventHandler.cpp >index 0631a11a651..f06dd333f37 100644 >--- a/Source/WebCore/page/EventHandler.cpp >+++ b/Source/WebCore/page/EventHandler.cpp >@@ -2213,14 +2213,15 @@ bool EventHandler::dispatchDragEvent(const AtomicString& eventType, Element& dra > return false; > > view->disableLayerFlushThrottlingTemporarilyForInteraction(); >- Ref<MouseEvent> me = MouseEvent::create(eventType, >- Event::CanBubble::Yes, Event::IsCancelable::Yes, event.timestamp().approximateMonotonicTime(), &m_frame.windowProxy(), >- 0, event.globalPosition().x(), event.globalPosition().y(), event.position().x(), event.position().y(), >+ // FIXME: Use MouseEvent::create which takes PlatformMouseEvent. >+ Ref<MouseEvent> me = MouseEvent::create(eventType, Event::CanBubble::Yes, Event::IsCancelable::Yes, event.timestamp().approximateMonotonicTime(), &m_frame.windowProxy(), 0, >+ event.globalPosition(), event.position(), > #if ENABLE(POINTER_LOCK) >- event.movementDelta().x(), event.movementDelta().y(), >+ event.movementDelta(), >+#else >+ { }, > #endif >- event.ctrlKey(), event.altKey(), event.shiftKey(), event.metaKey(), >- 0, 0, nullptr, event.force(), NoTap, &dataTransfer); >+ event.modifiers(), 0, 0, nullptr, event.force(), NoTap, &dataTransfer); > > dragTarget.dispatchEvent(me); > return me->defaultPrevented(); >@@ -4224,8 +4225,7 @@ bool EventHandler::handleTouchEvent(const PlatformTouchEvent& event) > > Ref<TouchEvent> touchEvent = > TouchEvent::create(effectiveTouches.get(), targetTouches.get(), changedTouches[state].m_touches.get(), >- stateName, downcast<Node>(*target).document().windowProxy(), >- 0, 0, 0, 0, event.ctrlKey(), event.altKey(), event.shiftKey(), event.metaKey()); >+ stateName, downcast<Node>(*target).document().windowProxy(), 0, 0, 0, 0, event.modifiers()); > target->dispatchEvent(touchEvent); > swallowedEvent = swallowedEvent || touchEvent->defaultPrevented() || touchEvent->defaultHandled(); > } >diff --git a/Source/WebCore/platform/PlatformEvent.h b/Source/WebCore/platform/PlatformEvent.h >index 635392520db..815a3c93bad 100644 >--- a/Source/WebCore/platform/PlatformEvent.h >+++ b/Source/WebCore/platform/PlatformEvent.h >@@ -70,12 +70,15 @@ public: > #endif > }; > >- enum class Modifier { >+ enum class Modifier : uint8_t { > AltKey = 1 << 0, > CtrlKey = 1 << 1, > MetaKey = 1 << 2, > ShiftKey = 1 << 3, > CapsLockKey = 1 << 4, >+ >+ // Never used in native platforms but added for initEvent >+ AltGraphKey = 1 << 5, > }; > > Type type() const { return static_cast<Type>(m_type); } >diff --git a/Source/WebCore/platform/mac/PlatformEventFactoryMac.h b/Source/WebCore/platform/mac/PlatformEventFactoryMac.h >index e2ab405f40c..2f18f959392 100644 >--- a/Source/WebCore/platform/mac/PlatformEventFactoryMac.h >+++ b/Source/WebCore/platform/mac/PlatformEventFactoryMac.h >@@ -51,7 +51,8 @@ WEBCORE_EXPORT String keyIdentifierForKeyEvent(NSEvent *); > WEBCORE_EXPORT String keyForKeyEvent(NSEvent *); > WEBCORE_EXPORT String codeForKeyEvent(NSEvent *); > WEBCORE_EXPORT WallTime eventTimeStampSince1970(NSEvent *); >- >+ >+WEBCORE_EXPORT OptionSet<PlatformEvent::Modifier> modifiersForEvent(NSEvent *); > WEBCORE_EXPORT void getWheelEventDeltas(NSEvent *, float& deltaX, float& deltaY, BOOL& continuous); > WEBCORE_EXPORT UInt8 keyCharForEvent(NSEvent *); > >diff --git a/Source/WebCore/platform/mac/PlatformEventFactoryMac.mm b/Source/WebCore/platform/mac/PlatformEventFactoryMac.mm >index 7081e124427..5985477d9e0 100644 >--- a/Source/WebCore/platform/mac/PlatformEventFactoryMac.mm >+++ b/Source/WebCore/platform/mac/PlatformEventFactoryMac.mm >@@ -661,7 +661,7 @@ static inline bool isKeyUpEvent(NSEvent *event) > return false; > } > >-static inline OptionSet<PlatformEvent::Modifier> modifiersForEvent(NSEvent *event) >+OptionSet<PlatformEvent::Modifier> modifiersForEvent(NSEvent *event) > { > OptionSet<PlatformEvent::Modifier> modifiers; > >diff --git a/Source/WebCore/testing/Internals.cpp b/Source/WebCore/testing/Internals.cpp >index 0f379618f1f..efa6aa75e64 100644 >--- a/Source/WebCore/testing/Internals.cpp >+++ b/Source/WebCore/testing/Internals.cpp >@@ -4295,6 +4295,9 @@ Vector<String> Internals::accessKeyModifiers() const > case PlatformEvent::Modifier::CapsLockKey: > accessKeyModifierStrings.append("capsLockKey"_s); > break; >+ case PlatformEvent::Modifier::AltGraphKey: >+ ASSERT_NOT_REACHED(); // AltGraph is only for DOM API. >+ break; > } > } > >diff --git a/Source/WebKit/WebProcess/WebPage/WebPage.cpp b/Source/WebKit/WebProcess/WebPage/WebPage.cpp >index 17a00649717..74be9c3b475 100644 >--- a/Source/WebKit/WebProcess/WebPage/WebPage.cpp >+++ b/Source/WebKit/WebProcess/WebPage/WebPage.cpp >@@ -1336,12 +1336,9 @@ void WebPage::navigateToPDFLinkWithSimulatedClick(const String& url, IntPoint do > return; > > const int singleClick = 1; >+ // FIXME: Set modifier keys. > RefPtr<MouseEvent> mouseEvent = MouseEvent::create(eventNames().clickEvent, Event::CanBubble::Yes, Event::IsCancelable::Yes, >- MonotonicTime::now(), nullptr, singleClick, screenPoint.x(), screenPoint.y(), documentPoint.x(), documentPoint.y(), >-#if ENABLE(POINTER_LOCK) >- 0, 0, >-#endif >- false, false, false, false, 0, 0, nullptr, 0, WebCore::NoTap, nullptr); >+ MonotonicTime::now(), nullptr, singleClick, screenPoint, documentPoint, { }, { }, 0, 0, nullptr, 0, WebCore::NoTap, nullptr); > > mainFrame->loader().urlSelected(mainFrameDocument->completeURL(url), emptyString(), mouseEvent.get(), LockHistory::No, LockBackForwardList::No, ShouldSendReferrer::MaybeSendReferrer, ShouldOpenExternalURLsPolicy::ShouldNotAllow); > } >diff --git a/Source/WebKitLegacy/ios/WebView/WebPDFViewPlaceholder.mm b/Source/WebKitLegacy/ios/WebView/WebPDFViewPlaceholder.mm >index 6332a807e48..4adf2f728a5 100644 >--- a/Source/WebKitLegacy/ios/WebView/WebPDFViewPlaceholder.mm >+++ b/Source/WebKitLegacy/ios/WebView/WebPDFViewPlaceholder.mm >@@ -479,11 +479,8 @@ static const float PAGE_HEIGHT_INSET = 4.0f * 2.0f; > return; > > // Construct an event to simulate a click. >- RefPtr<Event> event = MouseEvent::create(eventNames().clickEvent, Event::CanBubble::Yes, Event::IsCancelable::Yes, MonotonicTime::now(), 0, 1, 0, 0, 0, 0, >-#if ENABLE(POINTER_LOCK) >- 0, 0, >-#endif >- false, false, false, false, 0, 0, nullptr, 0, 0, nullptr, true); >+ RefPtr<Event> event = MouseEvent::create(eventNames().clickEvent, Event::CanBubble::Yes, Event::IsCancelable::Yes, MonotonicTime::now(), nullptr, 1, >+ { }, { }, { }, { }, 0, 0, nullptr, 0, 0, nullptr, MouseEvent::IsSimulated::Yes); > > // Call to the frame loader because this is where our security checks are made. > Frame* frame = core([_dataSource webFrame]); >diff --git a/Source/WebKitLegacy/mac/WebView/WebPDFView.mm b/Source/WebKitLegacy/mac/WebView/WebPDFView.mm >index ceb9390c6af..38010719d1e 100644 >--- a/Source/WebKitLegacy/mac/WebView/WebPDFView.mm >+++ b/Source/WebKitLegacy/mac/WebView/WebPDFView.mm >@@ -1030,15 +1030,9 @@ static BOOL isFrameInRange(WebFrame *frame, DOMRange *range) > break; > } > if (button != noButton) { >- event = MouseEvent::create(eventNames().clickEvent, Event::CanBubble::Yes, Event::IsCancelable::Yes, MonotonicTime::now(), 0, [nsEvent clickCount], 0, 0, 0, 0, >-#if ENABLE(POINTER_LOCK) >- 0, 0, >-#endif >- [nsEvent modifierFlags] & NSEventModifierFlagControl, >- [nsEvent modifierFlags] & NSEventModifierFlagOption, >- [nsEvent modifierFlags] & NSEventModifierFlagShift, >- [nsEvent modifierFlags] & NSEventModifierFlagCommand, >- button, [NSEvent pressedMouseButtons], nullptr, WebCore::ForceAtClick, 0, nullptr, true); >+ // FIXME: Why does this not use createPlatformMouseEvent. >+ event = MouseEvent::create(eventNames().clickEvent, Event::CanBubble::Yes, Event::IsCancelable::Yes, MonotonicTime::now(), nullptr, [nsEvent clickCount], { }, { }, { }, >+ modifiersForEvent(nsEvent), button, [NSEvent pressedMouseButtons], nullptr, WebCore::ForceAtClick, 0, nullptr, MouseEvent::IsSimulated::Yes); > } > > // Call to the frame loader because this is where our security checks are made.
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 188777
:
347610
|
347694
|
347711
|
347751