[webkit-changes] [WebKit/WebKit] 809039: Improve PlatformMouseEvent constructor to replace ...

EWS noreply at github.com
Sun Nov 20 11:58:12 PST 2022


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 809039232b9afe0013756f3b8f81cb250dbcbece
      https://github.com/WebKit/WebKit/commit/809039232b9afe0013756f3b8f81cb250dbcbece
  Author: David Kilzer <ddkilzer at apple.com>
  Date:   2022-11-20 (Sun, 20 Nov 2022)

  Changed paths:
    M Source/WebCore/dom/Element.cpp
    M Source/WebCore/page/ContextMenuController.cpp
    M Source/WebCore/page/DragController.cpp
    M Source/WebCore/page/EventHandler.cpp
    M Source/WebCore/page/ios/EventHandlerIOS.mm
    M Source/WebCore/platform/PlatformKeyboardEvent.cpp
    M Source/WebCore/platform/PlatformMouseEvent.h
    M Source/WebCore/platform/cocoa/KeyEventCocoa.mm
    M Source/WebCore/platform/gtk/PlatformKeyboardEventGtk.cpp
    M Source/WebCore/platform/libwpe/PlatformKeyboardEventLibWPE.cpp
    M Source/WebCore/platform/win/KeyEventWin.cpp
    M Source/WebKit/Shared/WebEventConversion.cpp
    M Source/WebKit/Shared/WebEventConversion.h
    M Source/WebKit/WebProcess/WebPage/WebPage.cpp
    M Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm
    M Source/WebKitLegacy/mac/WebView/WebFrame.mm
    M Source/WebKitLegacy/win/WebDropSource.cpp

  Log Message:
  -----------
  Improve PlatformMouseEvent constructor to replace four bool args with OptionSet<PlatformEvent::Modifier>
https://bugs.webkit.org/show_bug.cgi?id=248131
<rdar://102548165>

Reviewed by Michael Catanzaro.

Improve the PlatformMouseEvent constructor by replacing four
bool modifier key arguments (shift, ctrl, alt, meta) with one
OptionSet<PlatformEvent::Modifier> argument.

Previously, WebKit would convert an OptionSet<WebEventModifier>
into individual bool values (one for each modifier key), pass
these to the PlatformMouseEvent() constructor, then pass them to
the PlatformEvent() constructor, then convert them back into an
OptionSet<PlatformEvent::Modifier>.

Instead, introduce WebKit::platform(OptionSet<WebEventModifier>)
to convert to OptionSet<PlatformEvent::Modifier>, and use it to
remove duplicate code in WebEventConversion.cpp.

In WebCore, a few classes would declare four bool variables,
call PlatformKeyboardEvent::getCurrentModifierState(), call
PlatformKeyboardEvent::currentStateOfModifierKeys() which
returned an OptionSet<PlatformEvent::Modifier>, update the bool
variables and return, pass them to the PlatformMouseEvent()
constructor, then pass them to the PlatformEvent() constructor,
then convert them into an OptionSet<PlatformEvent::Modifier>.
Cut out the extra work by calling currentStateOfModifierKeys()
directly and pass to PlatformMouseEvent().

Finally, share more keyboard code by implementing
PlatformKeyboardEvent::currentStateOfModifierKeys() for all
ports.

* Source/WebCore/dom/Element.cpp:
(WebCore::Element::dispatchMouseForceWillBegin):
* Source/WebCore/page/ContextMenuController.cpp:
(WebCore::ContextMenuController::showContextMenuAt):
* Source/WebCore/page/DragController.cpp:
(WebCore::createMouseEvent):
* Source/WebCore/page/EventHandler.cpp:
(WebCore::EventHandler::sendContextMenuEventForKey):
(WebCore::EventHandler::fakeMouseMoveEventTimerFired):
* Source/WebCore/page/ios/EventHandlerIOS.mm:
(WebCore::EventHandler::tryToBeginDragAtPoint):
- Replace (false, false, false, false) with ({ }) argument.
- Use PlatformKeyboardEvent::currentStateOfModifierKeys() in
  place of PlatformKeyboardEvent::getCurrentModifierState().

* Source/WebCore/platform/PlatformKeyboardEvent.cpp:
(WebCore::PlatformKeyboardEvent::currentCapsLockState): Add.
(WebCore::PlatformKeyboardEvent::getCurrentModifierState): Add.
* Source/WebCore/platform/cocoa/KeyEventCocoa.mm:
(WebCore::PlatformKeyboardEvent::currentCapsLockState): Delete.
(WebCore::PlatformKeyboardEvent::getCurrentModifierState): Delete.
- Move currentCapsLockState() and getCurrentModifierState() from
  KeyEventCocoa.mm to PlatformKeyboardEvent.cpp since this code
  can now be shared by implementing currentStateOfModifierKeys()
  in all ports.

* Source/WebCore/platform/PlatformMouseEvent.h:
(WebCore::PlatformMouseEvent::PlatformMouseEvent):
- Update PlatformMouseEvent() constructor arguments.

* Source/WebCore/platform/gtk/PlatformKeyboardEventGtk.cpp:
(WebCore::PlatformKeyboardEvent::currentStateOfModifierKeys): Add.
(WebCore::PlatformKeyboardEvent::currentCapsLockState): Delete.
(WebCore::PlatformKeyboardEvent::getCurrentModifierState): Delete.
* Source/WebCore/platform/libwpe/PlatformKeyboardEventLibWPE.cpp:
(WebCore::PlatformKeyboardEvent::currentStateOfModifierKeys): Add.
(WebCore::PlatformKeyboardEvent::currentCapsLockState): Delete.
(WebCore::PlatformKeyboardEvent::getCurrentModifierState): Delete.
* Source/WebCore/platform/win/KeyEventWin.cpp:
(WebCore::PlatformKeyboardEvent::currentStateOfModifierKeys): Add.
(WebCore::PlatformKeyboardEvent::currentCapsLockState): Delete.
(WebCore::PlatformKeyboardEvent::getCurrentModifierState): Delete.
- Implement currentStateOfModifierKeys() in all ports by combining
  currentCapsLockState() and getCurrentModifierState().

* Source/WebKit/Shared/WebEventConversion.cpp:
(WebKit::platform): Add.
- Add conversion function from OptionSet<WebEventModifier> to
  OptionSet<PlatformEvent::Modifier>.
(WebKit::WebKit2PlatformMouseEvent::WebKit2PlatformMouseEvent):
(WebKit::WebKit2PlatformWheelEvent::WebKit2PlatformWheelEvent):
(WebKit::WebKit2PlatformKeyboardEvent::WebKit2PlatformKeyboardEvent):
(WebKit::WebKit2PlatformTouchEvent::WebKit2PlatformTouchEvent):
(WebKit::WebKit2PlatformGestureEvent::WebKit2PlatformGestureEvent):
- Use new platform() function to replace duplicate code.

* Source/WebKit/Shared/WebEventConversion.h:
(WebKit::platform): Add.
- Declare new conversion function.

* Source/WebKit/WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::contextMenuAtPointInWindow):
(WebKit::WebPage::dragEnded):
- Replace (false, false, false, false) with ({ }) argument.

* Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::dispatchSyntheticMouseMove):
(WebKit::WebPage::completeSyntheticClick):
(WebKit::WebPage::handleDoubleTapForDoubleClickAtPoint):
(WebKit::WebPage::requestAdditionalItemsForDragSession):
(WebKit::WebPage::inspectorNodeSearchMovedToPosition):
(WebKit::WebPage::dispatchSyntheticMouseEventsForSelectionGesture):
- Make use of platform() conversion function.
- Replace (false, false, false, false) with ({ }) argument.

* Source/WebKitLegacy/mac/WebView/WebFrame.mm:
(-[WebFrame _dragSourceEndedAt:operation:]):
* Source/WebKitLegacy/win/WebDropSource.cpp:
(generateMouseEvent):
- Replace (false, false, false, false) with ({ }) argument.

Canonical link: https://commits.webkit.org/256892@main




More information about the webkit-changes mailing list