WebKit Bugzilla
Attachment 347751 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]
Patch for landing
bug-188777-20180821190649.patch (text/plain), 47.91 KB, created by
Ryosuke Niwa
on 2018-08-21 19:06:50 PDT
(
hide
)
Description:
Patch for landing
Filename:
MIME Type:
Creator:
Ryosuke Niwa
Created:
2018-08-21 19:06:50 PDT
Size:
47.91 KB
patch
obsolete
>Subversion Revision: 235099 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 48c8b60d70b9586778527c53bfb877fdbc0e14e6..667e4df0c5286a996559ac580c0b9173ef3c8b24 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,70 @@ >+2018-08-21 Ryosuke Niwa <rniwa@webkit.org> >+ >+ Replace booleans for modifier keys in UIEventWithKeyState with OptionSet<Modifier> >+ https://bugs.webkit.org/show_bug.cgi?id=188777 >+ >+ Reviewed by Simon Fraser. >+ >+ Replaced boolean arguments and instance variables for modifier keys (ctrl, alt, shift, and meta keys) in >+ UIEventWithKeyState with OptionSet<Modifier> and isSimulated boolean in MouseRelatedEvent with IsSimulated >+ enum class. >+ >+ Also made movementDelta always compiled instead of only when ENABLE(POINTER_LOCK) to simplify the code. >+ >+ No new tests since there should be no observable behavioral change. >+ >+ * dom/Element.cpp: >+ (WebCore::Element::dispatchMouseEvent): >+ * dom/KeyboardEvent.cpp: >+ (WebCore::KeyboardEvent::KeyboardEvent): >+ (WebCore::KeyboardEvent::initKeyboardEvent): Call setModifierKeys. >+ * dom/MouseEvent.cpp: >+ (WebCore::MouseEvent::create): >+ (WebCore::MouseEvent::MouseEvent): >+ (WebCore::MouseEvent::initMouseEvent): Ditto. >+ * dom/MouseEvent.h: >+ * dom/MouseRelatedEvent.cpp: >+ (WebCore::MouseRelatedEvent::MouseRelatedEvent): Added a new variant which takes the minimum arguments >+ for gesture & touch events. In those events, detail is always set to 0, movementDelta is always set to 0,0, >+ and they are never simulated. >+ * dom/MouseRelatedEvent.h: >+ (WebCore::MouseRelatedEvent::IsSimulated): Added. >+ * dom/SimulatedClick.cpp: >+ (WebCore::SimulatedMouseEvent::SimulatedMouseEvent): Get OptionSet<Modifier> out of the underlying event >+ instead of manually setting each key state. This code now preserves the state of caps lock and alt-graph >+ keys but this is not observable because we have yet to implement getModifierState on MouseEvent. >+ (WebCore::SimulatedMouseEvent::modifiersFromUnderlyingEvent): Added. >+ * dom/TouchEvent.cpp: >+ (WebCore::TouchEvent::TouchEvent): >+ * dom/TouchEvent.h: >+ * dom/UIEventWithKeyState.h: >+ (WebCore::UIEventWithKeyState::Modifier): Alias to PlatformEvent::Modifier. >+ (WebCore::UIEventWithKeyState::ctrlKey const): Updated to use m_modifiers. >+ (WebCore::UIEventWithKeyState::shiftKey const): Ditto. >+ (WebCore::UIEventWithKeyState::altKey const): Ditto. >+ (WebCore::UIEventWithKeyState::metaKey const): Ditto. >+ (WebCore::UIEventWithKeyState::altGraphKey const): Ditto. >+ (WebCore::UIEventWithKeyState::capsLockKey const): Ditto. >+ (WebCore::UIEventWithKeyState::modifierKeys): Added. >+ (WebCore::UIEventWithKeyState::UIEventWithKeyState): Now takes OptionSet<Modifier>. >+ (WebCore::UIEventWithKeyState::setModifierKeys): Added. Used by init*Event functions in subclasses. Note that >+ these functions preseve the states of alt-graph and caps lock keys to match the existing behaviors in this >+ cleanup patch but they don't match behaviors of Chrome or Firefox. >+ (WebCore::UIEventWithKeyState::modifiersFromInitializer): Added. >+ * dom/WheelEvent.cpp: >+ (WebCore::WheelEvent::WheelEvent): Simulated::No corresponds to the last boolean being false. >+ * page/EventHandler.cpp: >+ (WebCore::EventHandler::dispatchDragEvent): >+ (WebCore::EventHandler::handleTouchEvent): >+ * platform/PlatformEvent.h: >+ (WebCore::PlatformEvent::Modifier): Added AltGraphKey. >+ * platform/mac/PlatformEventFactoryMac.h: >+ (WebCore::modifiersForEvent): Exported to be used in [WebPDFView PDFViewWillClickOnLink:withURL:]. >+ * platform/mac/PlatformEventFactoryMac.mm: >+ (WebCore::modifiersForEvent): >+ * testing/Internals.cpp: >+ (WebCore::Internals::accessKeyModifiers const): >+ > 2018-08-20 Michael Catanzaro <mcatanzaro@igalia.com> > > [CMake] Sync unified build with Cocoa ports >diff --git a/Source/WebKit/ChangeLog b/Source/WebKit/ChangeLog >index 100f12ce604731c39efdf27c9d14a051ce88be42..f01317fd796b6619ccca057bb65c8568de0fbcde 100644 >--- a/Source/WebKit/ChangeLog >+++ b/Source/WebKit/ChangeLog >@@ -1,3 +1,15 @@ >+2018-08-21 Ryosuke Niwa <rniwa@webkit.org> >+ >+ Replace booleans for modifier keys in UIEventWithKeyState with OptionSet<Modifier> >+ https://bugs.webkit.org/show_bug.cgi?id=188777 >+ >+ Reviewed by Simon Fraser. >+ >+ Added two FIXMEs. >+ >+ * WebProcess/WebPage/WebPage.cpp: >+ (WebKit::WebPage::navigateToPDFLinkWithSimulatedClick): >+ > 2018-08-20 Michael Catanzaro <mcatanzaro@igalia.com> > > [CMake] Sync unified build with Cocoa ports >diff --git a/Source/WebKitLegacy/ios/ChangeLog b/Source/WebKitLegacy/ios/ChangeLog >index 2fe7fe9fbdd0bda3eb6e3971d1c243406736fef8..8043219c0f35a9404dd4b90ebc1f302817b1c04e 100644 >--- a/Source/WebKitLegacy/ios/ChangeLog >+++ b/Source/WebKitLegacy/ios/ChangeLog >@@ -1,3 +1,16 @@ >+2018-08-21 Ryosuke Niwa <rniwa@webkit.org> >+ >+ Replace booleans for modifier keys in UIEventWithKeyState with OptionSet<Modifier> >+ https://bugs.webkit.org/show_bug.cgi?id=188777 >+ >+ Reviewed by Simon Fraser. >+ >+ Create MouseEvent::create with IsSimulated set to Yes; correspoding to the last argument >+ being "true" before the code change. >+ >+ * WebView/WebPDFViewPlaceholder.mm: >+ (-[WebPDFViewPlaceholder simulateClickOnLinkToURL:]): >+ > 2018-08-16 Ryosuke Niwa <rniwa@webkit.org> > > Replace canBubble and cancelable booleans in Event by enum classes >diff --git a/Source/WebKitLegacy/mac/ChangeLog b/Source/WebKitLegacy/mac/ChangeLog >index 98581661ba40994932aab0d77b0c4a274a97f6cd..d444b04305d3ad5cef90c36f163c682abba5b06a 100644 >--- a/Source/WebKitLegacy/mac/ChangeLog >+++ b/Source/WebKitLegacy/mac/ChangeLog >@@ -1,3 +1,18 @@ >+2018-08-21 Ryosuke Niwa <rniwa@webkit.org> >+ >+ Replace booleans for modifier keys in UIEventWithKeyState with OptionSet<Modifier> >+ https://bugs.webkit.org/show_bug.cgi?id=188777 >+ >+ Reviewed by Simon Fraser. >+ >+ Create MouseEvent::create with IsSimulated set to Yes; correspoding to the last argument >+ being "true" before the code change. >+ >+ Use modifiersForEvent to convert [nsEvent modifierFlags] to OptionSet<Modifier>. >+ >+ * WebView/WebPDFView.mm: >+ (-[WebPDFView PDFViewWillClickOnLink:withURL:]): >+ > 2018-08-17 Alex Christensen <achristensen@webkit.org> > > Add some plumbing for safe browsing >diff --git a/Source/WebCore/dom/Element.cpp b/Source/WebCore/dom/Element.cpp >index c3ba8a7e5c99b6f126782cb7c25b5f57ebceae9e..d9cbf3821f7f9b7f6d639cf8fe50a0256e85d00a 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 ad4dce4576b48e3375f55a5a0d0357b88d202a0c..3b5e9c9849988ad25336611ea33e2a8d4e7e3526 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 b267de2bd08f6ed641ff6e3fb159ebfb8e7a9c0e..7f8476440f261425ae84b685afaf43ac99da709f 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 b03aabbbe6f55f0db33773b4afe5c7e95c78d92d..02d35c67319f42185a9b7b7bd7742b6096e67fc5 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 a3227a54bb452e8c59b94f69e62662a7fe6d722a..893cc28d18116411dbef4a43f82db7f26537b66b 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, RefPtr<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 d8f1fcdf3e11b1e38eebeae7c60f4f85e88a4966..7663a1a06e82f6959d5540b75f889c20867f81cc 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, RefPtr<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 a52c1a78386c2df257dacf259a36edadf6bcd791..f506faf8d16bc7440ea740d5df8755187bb24d67 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 292c84668f6a3cda8c43ca55918323bc9890c915..53267e4421aa316f27c2e31a55b4e3920c8eff88 100644 >--- a/Source/WebCore/dom/TouchEvent.cpp >+++ b/Source/WebCore/dom/TouchEvent.cpp >@@ -37,13 +37,8 @@ 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, const IntPoint& globalLocation, OptionSet<Modifier> modifiers) >+ : MouseRelatedEvent(type, IsCancelable::Yes, MonotonicTime::now(), WTFMove(view), globalLocation, modifiers) > , m_touches(touches) > , m_targetTouches(targetTouches) > , m_changedTouches(changedTouches) >@@ -74,10 +69,7 @@ void TouchEvent::initTouchEvent(TouchList* touches, TouchList* targetTouches, > m_targetTouches = targetTouches; > m_changedTouches = changedTouches; > m_screenLocation = IntPoint(screenX, screenY); >- m_ctrlKey = ctrlKey; >- m_altKey = altKey; >- m_shiftKey = shiftKey; >- m_metaKey = metaKey; >+ setModifierKeys(ctrlKey, altKey, shiftKey, metaKey); > initCoordinates(IntPoint(clientX, clientY)); > } > >diff --git a/Source/WebCore/dom/TouchEvent.h b/Source/WebCore/dom/TouchEvent.h >index 85fa161f2196d3f2a05d9a31a117b0a1af866f99..13de0c298651ce4110e46a775cd31cac33b84eb5 100644 >--- a/Source/WebCore/dom/TouchEvent.h >+++ b/Source/WebCore/dom/TouchEvent.h >@@ -39,15 +39,10 @@ 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, const IntPoint& globalLocation, OptionSet<Modifier> modifiers) > { >- return adoptRef(*new TouchEvent(touches, targetTouches, changedTouches, >- type, WTFMove(view), screenX, screenY, pageX, pageY, >- ctrlKey, altKey, shiftKey, metaKey)); >+ return adoptRef(*new TouchEvent(touches, targetTouches, changedTouches, type, WTFMove(view), globalLocation, modifiers)); > } > static Ref<TouchEvent> createForBindings() > { >@@ -65,11 +60,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 +77,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>&&, const IntPoint& globalLocation, OptionSet<Modifier>); > 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 3668364699b93a51c8a9b8ea9615214d79387a27..d9ca758fd987bd57a8784493bd989faed064efa2 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 27677a87a5efbae633ff101f12cdbcd50b940668..07223b95495f3c94cd7049dd46fba78cce1b7443 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 0631a11a65127a7067fca9aa4ec22c048589e555..fe66ecb777722138989e323b77164287124f1d34 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(); >@@ -4222,10 +4223,8 @@ bool EventHandler::handleTouchEvent(const PlatformTouchEvent& event) > RefPtr<TouchList> targetTouches(isTouchCancelEvent ? emptyList : touchesByTarget.get(target.get())); > ASSERT(targetTouches); > >- 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()); >+ Ref<TouchEvent> touchEvent = TouchEvent::create(effectiveTouches.get(), targetTouches.get(), changedTouches[state].m_touches.get(), >+ stateName, downcast<Node>(*target).document().windowProxy(), { }, 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 635392520dbc14db114467b4c50d18c61a762b98..815a3c93bad0f3a1c6eef1d3549d5cb123b87c94 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 e2ab405f40c165600aa0535002e2764a2529409a..2f18f9593928fe93fe0735c245ca67ed68859981 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 7081e124427ee3d6de491907366087389f994838..5985477d9e05488a29040e0c243594a94997b970 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 0f379618f1fc94bf385cf3fd84d5a9bd60aa286c..efa6aa75e6431b228bb5d7c7457893ea6e56ef6f 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 17a00649717b105ed1544bb7fa4346319972fa57..c8dc47605e32bb4b5ddf49c57558eb6524578d80 100644 >--- a/Source/WebKit/WebProcess/WebPage/WebPage.cpp >+++ b/Source/WebKit/WebProcess/WebPage/WebPage.cpp >@@ -1336,12 +1336,10 @@ void WebPage::navigateToPDFLinkWithSimulatedClick(const String& url, IntPoint do > return; > > const int singleClick = 1; >+ // FIXME: Set modifier keys. >+ // FIXME: This should probably set IsSimulated::Yes. > 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 6332a807e48fe49f1b8a91957b6d42bafb1a874b..4adf2f728a5d82ffcbef60112a9015717867f7ac 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 ceb9390c6af00fd8c8c63cb54cc8808b138d4a0d..3e12dfba7da741ae3a837d4f02a30a4aba719da4 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: Use createPlatformMouseEvent instead. >+ 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