Title: [270347] trunk/Source/WebCore
Revision
270347
Author
[email protected]
Date
2020-12-02 08:05:56 -0800 (Wed, 02 Dec 2020)

Log Message

Optimize padding in EventHandler and platform event classes
https://bugs.webkit.org/show_bug.cgi?id=219420

Reviewed by Ryosuke Niwa.

Organize the member variables in EventHandler a bit better, to minimize padding
and avoid redundant #ifdefs. This shrinks it from 632 bytes to 576 bytes.

Minimize padding in the Platform*Event classes.

* page/EventHandler.h:
* platform/PlatformEvent.h:
(WebCore::PlatformEvent::PlatformEvent):
* platform/PlatformKeyboardEvent.h:
(WebCore::PlatformKeyboardEvent::PlatformKeyboardEvent):
* platform/PlatformMouseEvent.h:
(WebCore::PlatformMouseEvent::PlatformMouseEvent):
* platform/PlatformWheelEvent.h:
(WebCore::PlatformWheelEvent::m_wheelTicksY):
(WebCore::PlatformWheelEvent::m_granularity): Deleted.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (270346 => 270347)


--- trunk/Source/WebCore/ChangeLog	2020-12-02 15:46:24 UTC (rev 270346)
+++ trunk/Source/WebCore/ChangeLog	2020-12-02 16:05:56 UTC (rev 270347)
@@ -1,3 +1,26 @@
+2020-12-02  Simon Fraser  <[email protected]>
+
+        Optimize padding in EventHandler and platform event classes
+        https://bugs.webkit.org/show_bug.cgi?id=219420
+
+        Reviewed by Ryosuke Niwa.
+
+        Organize the member variables in EventHandler a bit better, to minimize padding
+        and avoid redundant #ifdefs. This shrinks it from 632 bytes to 576 bytes.
+
+        Minimize padding in the Platform*Event classes.
+
+        * page/EventHandler.h:
+        * platform/PlatformEvent.h:
+        (WebCore::PlatformEvent::PlatformEvent):
+        * platform/PlatformKeyboardEvent.h:
+        (WebCore::PlatformKeyboardEvent::PlatformKeyboardEvent):
+        * platform/PlatformMouseEvent.h:
+        (WebCore::PlatformMouseEvent::PlatformMouseEvent):
+        * platform/PlatformWheelEvent.h:
+        (WebCore::PlatformWheelEvent::m_wheelTicksY):
+        (WebCore::PlatformWheelEvent::m_granularity): Deleted.
+
 2020-12-02  Aditya Keerthi  <[email protected]>
 
         REGRESSION: [iOS] imported/w3c/web-platform-tests/css/css-ui/appearance-revert-001.tentative.html is a flaky image failure

Modified: trunk/Source/WebCore/page/EventHandler.h (270346 => 270347)


--- trunk/Source/WebCore/page/EventHandler.h	2020-12-02 15:46:24 UTC (rev 270346)
+++ trunk/Source/WebCore/page/EventHandler.h	2020-12-02 16:05:56 UTC (rev 270347)
@@ -115,7 +115,7 @@
 enum AppendTrailingWhitespace { ShouldAppendTrailingWhitespace, DontAppendTrailingWhitespace };
 enum CheckDragHysteresis { ShouldCheckDragHysteresis, DontCheckDragHysteresis };
 
-enum class ImmediateActionStage {
+enum class ImmediateActionStage : uint8_t {
     None,
     PerformedHitTest,
     ActionUpdated,
@@ -517,45 +517,32 @@
     bool canMouseDownStartSelect(const MouseEventWithHitTestResults&);
 
     Frame& m_frame;
+    RefPtr<Node> m_mousePressNode;
+    Timer m_hoverTimer;
+    std::unique_ptr<AutoscrollController> m_autoscrollController;
+    RenderLayer* m_resizeLayer { nullptr };
 
+    double m_maxMouseMovedDuration { 0 };
+
     bool m_mousePressed { false };
     bool m_capturesDragging { false };
-    RefPtr<Node> m_mousePressNode;
-
     bool m_mouseDownMayStartSelect { false };
-
-#if ENABLE(DRAG_SUPPORT)
-    bool m_mouseDownMayStartDrag { false };
-    bool m_dragMayStartSelectionInstead { false };
-#endif
-
     bool m_mouseDownDelegatedFocus { false };
     bool m_mouseDownWasSingleClickInSelection { false };
-    enum SelectionInitiationState { HaveNotStartedSelection, PlacedCaret, ExtendedSelection };
-    SelectionInitiationState m_selectionInitiationState { HaveNotStartedSelection };
-
-#if ENABLE(DRAG_SUPPORT)
-    LayoutPoint m_dragStartPosition;
-#endif
-
-    Timer m_hoverTimer;
     bool m_hasScheduledCursorUpdate { false };
-
-    std::unique_ptr<AutoscrollController> m_autoscrollController;
     bool m_mouseDownMayStartAutoscroll { false };
     bool m_mouseDownWasInSubframe { false };
-
-#if !ENABLE(IOS_TOUCH_EVENTS)
-    Timer m_fakeMouseMoveEventTimer;
-#endif
-
+    bool m_didStartDrag { false };
+    bool m_isHandlingWheelEvent { false };
+    bool m_currentWheelEventAllowsScrolling { true };
     bool m_svgPan { false };
+    bool m_eventHandlerWillResetCapturingMouseEventsElement { false };
 
-    RenderLayer* m_resizeLayer { nullptr };
+    enum SelectionInitiationState : uint8_t { HaveNotStartedSelection, PlacedCaret, ExtendedSelection };
+    SelectionInitiationState m_selectionInitiationState { HaveNotStartedSelection };
+    ImmediateActionStage m_immediateActionStage { ImmediateActionStage::None };
 
     RefPtr<Element> m_capturingMouseEventsElement;
-    bool m_eventHandlerWillResetCapturingMouseEventsElement { false };
-    
     RefPtr<Element> m_elementUnderMouse;
     RefPtr<Element> m_lastElementUnderMouse;
     RefPtr<Frame> m_lastMouseMoveEventSubframe;
@@ -562,41 +549,14 @@
     WeakPtr<Scrollbar> m_lastScrollbarUnderMouse;
     Cursor m_currentMouseCursor;
 
-    int m_clickCount { 0 };
     RefPtr<Node> m_clickNode;
-
-#if ENABLE(IOS_GESTURE_EVENTS)
-    float m_gestureInitialDiameter { GestureUnknown };
-    float m_gestureInitialRotation { GestureUnknown };
-#endif
-
-#if ENABLE(IOS_GESTURE_EVENTS) || ENABLE(MAC_GESTURE_EVENTS)
-    float m_gestureLastDiameter { GestureUnknown };
-    float m_gestureLastRotation { GestureUnknown };
-    EventTargetSet m_gestureTargets;
-#endif
-
-#if ENABLE(MAC_GESTURE_EVENTS)
-    bool m_hasActiveGesture { false };
-#endif
-
-#if ENABLE(IOS_TOUCH_EVENTS)
-    unsigned m_firstTouchID { InvalidTouchIdentifier };
-
-    TouchArray m_touches;
-    RefPtr<Frame> m_touchEventTargetSubframe;
-#endif
-
-#if ENABLE(DRAG_SUPPORT)
-    RefPtr<Element> m_dragTarget;
-    bool m_shouldOnlyFireDragOverEvent { false };
-#endif
-    
     RefPtr<HTMLFrameSetElement> m_frameSetBeingResized;
 
     LayoutSize m_offsetFromResizeCorner; // In the coords of m_resizeLayer.
     
-    bool m_mousePositionIsUnknown { true };
+    int m_clickCount { 0 };
+    bool m_mousePositionIsUnknown { true }; // FIXME: Use Optional<> instead.
+
     IntPoint m_lastKnownMousePosition; // Same coordinates as PlatformMouseEvent::position().
     IntPoint m_lastKnownMouseGlobalPosition;
     IntPoint m_mouseDownContentsPosition;
@@ -604,16 +564,26 @@
     PlatformMouseEvent m_mouseDownEvent;
     PlatformMouseEvent m_lastPlatformMouseEvent;
 
-#if PLATFORM(COCOA)
-    NSView *m_mouseDownView { nullptr };
-    bool m_sendingEventToSubview { false };
-    Optional<WheelScrollGestureState> m_wheelScrollGestureState;
+#if !ENABLE(IOS_TOUCH_EVENTS)
+    Timer m_fakeMouseMoveEventTimer;
 #endif
 
-#if PLATFORM(MAC)
-    int m_activationEventNumber { -1 };
+#if ENABLE(CURSOR_VISIBILITY)
+    Timer m_autoHideCursorTimer;
 #endif
 
+#if ENABLE(DRAG_SUPPORT)
+    LayoutPoint m_dragStartPosition;
+    RefPtr<Element> m_dragTarget;
+    bool m_mouseDownMayStartDrag { false };
+    bool m_dragMayStartSelectionInstead { false };
+    bool m_shouldOnlyFireDragOverEvent { false };
+#endif
+
+#if ENABLE(MAC_GESTURE_EVENTS)
+    bool m_hasActiveGesture { false };
+#endif
+
 #if ENABLE(TOUCH_EVENTS) && !ENABLE(IOS_TOUCH_EVENTS)
     using TouchTargetMap = HashMap<int, RefPtr<EventTarget>>;
     TouchTargetMap m_originatingTouchPointTargets;
@@ -622,19 +592,36 @@
     bool m_touchPressed { false };
 #endif
 
-#if ENABLE(IOS_TOUCH_EVENTS)
-    unsigned touchIdentifierForMouseEvents { 0 };
+#if ENABLE(IOS_GESTURE_EVENTS)
+    float m_gestureInitialDiameter { GestureUnknown };
+    float m_gestureInitialRotation { GestureUnknown };
 #endif
 
+#if ENABLE(IOS_GESTURE_EVENTS) || ENABLE(MAC_GESTURE_EVENTS)
+    float m_gestureLastDiameter { GestureUnknown };
+    float m_gestureLastRotation { GestureUnknown };
+    EventTargetSet m_gestureTargets;
+#endif
+
 #if ENABLE(IOS_TOUCH_EVENTS)
+    unsigned m_firstTouchID { InvalidTouchIdentifier };
+    unsigned touchIdentifierForMouseEvents { 0 };
     unsigned m_touchIdentifierForPrimaryTouch { 0 };
+
+    TouchArray m_touches;
+    RefPtr<Frame> m_touchEventTargetSubframe;
 #endif
 
-    double m_maxMouseMovedDuration { 0 };
-    bool m_didStartDrag { false };
-    bool m_isHandlingWheelEvent { false };
-    bool m_currentWheelEventAllowsScrolling { true };
+#if PLATFORM(COCOA)
+    NSView *m_mouseDownView { nullptr };
+    Optional<WheelScrollGestureState> m_wheelScrollGestureState;
+    bool m_sendingEventToSubview { false };
+#endif
 
+#if PLATFORM(MAC)
+    int m_activationEventNumber { -1 };
+#endif
+
 #if PLATFORM(IOS_FAMILY)
     bool m_shouldAllowMouseDownToStartDrag { false };
     bool m_isAutoscrolling { false };
@@ -641,12 +628,6 @@
     IntPoint m_targetAutoscrollPositionInUnscrolledRootViewCoordinates;
     Optional<IntPoint> m_initialTargetAutoscrollPositionInUnscrolledRootViewCoordinates;
 #endif
-
-#if ENABLE(CURSOR_VISIBILITY)
-    Timer m_autoHideCursorTimer;
-#endif
-
-    ImmediateActionStage m_immediateActionStage { ImmediateActionStage::None };
 };
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/platform/PlatformEvent.h (270346 => 270347)


--- trunk/Source/WebCore/platform/PlatformEvent.h	2020-12-02 15:46:24 UTC (rev 270346)
+++ trunk/Source/WebCore/platform/PlatformEvent.h	2020-12-02 16:05:56 UTC (rev 270347)
@@ -110,15 +110,15 @@
     }
 
     PlatformEvent(Type type, OptionSet<Modifier> modifiers, WallTime timestamp)
-        : m_type(type)
+        : m_timestamp(timestamp)
+        , m_type(type)
         , m_modifiers(modifiers)
-        , m_timestamp(timestamp)
     {
     }
 
     PlatformEvent(Type type, bool shiftKey, bool ctrlKey, bool altKey, bool metaKey, WallTime timestamp)
-        : m_type(type)
-        , m_timestamp(timestamp)
+        : m_timestamp(timestamp)
+        , m_type(type)
     {
         if (shiftKey)
             m_modifiers.add(Modifier::ShiftKey);
@@ -134,9 +134,9 @@
     // delete a PlatformEvent.
     ~PlatformEvent() = default;
 
+    WallTime m_timestamp;
     unsigned m_type;
     OptionSet<Modifier> m_modifiers;
-    WallTime m_timestamp;
 };
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/platform/PlatformKeyboardEvent.h (270346 => 270347)


--- trunk/Source/WebCore/platform/PlatformKeyboardEvent.h	2020-12-02 15:46:24 UTC (rev 270346)
+++ trunk/Source/WebCore/platform/PlatformKeyboardEvent.h	2020-12-02 16:05:56 UTC (rev 270347)
@@ -48,10 +48,6 @@
     public:
         PlatformKeyboardEvent()
             : PlatformEvent(PlatformEvent::KeyDown)
-            , m_windowsVirtualKeyCode(0)
-            , m_autoRepeat(false)
-            , m_isKeypad(false)
-            , m_isSystemKey(false)
         {
         }
 
@@ -58,6 +54,9 @@
         PlatformKeyboardEvent(Type type, const String& text, const String& unmodifiedText, const String& key, const String& code,
         const String& keyIdentifier, int windowsVirtualKeyCode, bool isAutoRepeat, bool isKeypad, bool isSystemKey, OptionSet<Modifier> modifiers, WallTime timestamp)
             : PlatformEvent(type, modifiers, timestamp)
+            , m_autoRepeat(isAutoRepeat)
+            , m_isKeypad(isKeypad)
+            , m_isSystemKey(isSystemKey)
             , m_text(text)
             , m_unmodifiedText(unmodifiedText)
             , m_key(key)
@@ -64,9 +63,6 @@
             , m_code(code)
             , m_keyIdentifier(keyIdentifier)
             , m_windowsVirtualKeyCode(windowsVirtualKeyCode)
-            , m_autoRepeat(isAutoRepeat)
-            , m_isKeypad(isKeypad)
-            , m_isSystemKey(isSystemKey)
         {
         }
 
@@ -151,12 +147,18 @@
 #endif
 
     protected:
+        bool m_autoRepeat { false };
+        bool m_isKeypad { false };
+        bool m_isSystemKey { false };
+
         String m_text;
         String m_unmodifiedText;
         String m_key;
         String m_code;
         String m_keyIdentifier;
-        int m_windowsVirtualKeyCode;
+        int m_windowsVirtualKeyCode { 0 };
+
+        bool m_isSyntheticEvent { false };
 #if USE(APPKIT) || USE(UIKIT_KEYBOARD_ADDITIONS) || PLATFORM(GTK) || USE(LIBWPE)
         bool m_handledByInputMethod { false };
 #endif
@@ -170,11 +172,6 @@
 #elif PLATFORM(GTK)
         Vector<String> m_commands;
 #endif
-        bool m_autoRepeat;
-        bool m_isKeypad;
-        bool m_isSystemKey;
-        
-        bool m_isSyntheticEvent { false };
 
 #if PLATFORM(COCOA)
 #if !PLATFORM(IOS_FAMILY)

Modified: trunk/Source/WebCore/platform/PlatformMouseEvent.h (270346 => 270347)


--- trunk/Source/WebCore/platform/PlatformMouseEvent.h	2020-12-02 15:46:24 UTC (rev 270346)
+++ trunk/Source/WebCore/platform/PlatformMouseEvent.h	2020-12-02 16:05:56 UTC (rev 270347)
@@ -51,13 +51,13 @@
         PlatformMouseEvent(const IntPoint& position, const IntPoint& globalPosition, MouseButton button, PlatformEvent::Type type,
                            int clickCount, bool shiftKey, bool ctrlKey, bool altKey, bool metaKey, WallTime timestamp, double force, SyntheticClickType syntheticClickType, PointerID pointerId = mousePointerID)
             : PlatformEvent(type, shiftKey, ctrlKey, altKey, metaKey, timestamp)
+            , m_button(button)
+            , m_syntheticClickType(syntheticClickType)
             , m_position(position)
             , m_globalPosition(globalPosition)
-            , m_button(button)
-            , m_clickCount(clickCount)
             , m_force(force)
-            , m_syntheticClickType(syntheticClickType)
             , m_pointerId(pointerId)
+            , m_clickCount(clickCount)
         {
         }
 
@@ -89,19 +89,19 @@
 #endif
 
     protected:
+        MouseButton m_button { NoButton };
+        SyntheticClickType m_syntheticClickType { NoTap };
+
         IntPoint m_position;
         IntPoint m_globalPosition;
 #if ENABLE(POINTER_LOCK)
         IntPoint m_movementDelta;
 #endif
-        MouseButton m_button { NoButton };
-        unsigned short m_buttons { 0 };
+        double m_force { 0 };
+        PointerID m_pointerId { mousePointerID };
         int m_clickCount { 0 };
         unsigned m_modifierFlags { 0 };
-        double m_force { 0 };
-        SyntheticClickType m_syntheticClickType { NoTap };
-        PointerID m_pointerId { mousePointerID };
-
+        unsigned short m_buttons { 0 };
 #if PLATFORM(MAC)
         int m_eventNumber { 0 };
         int m_menuTypeForEvent { 0 };

Modified: trunk/Source/WebCore/platform/PlatformWheelEvent.h (270346 => 270347)


--- trunk/Source/WebCore/platform/PlatformWheelEvent.h	2020-12-02 15:46:24 UTC (rev 270346)
+++ trunk/Source/WebCore/platform/PlatformWheelEvent.h	2020-12-02 16:05:56 UTC (rev 270347)
@@ -96,6 +96,7 @@
 
     PlatformWheelEvent(IntPoint position, IntPoint globalPosition, float deltaX, float deltaY, float wheelTicksX, float wheelTicksY, PlatformWheelEventGranularity granularity, bool shiftKey, bool ctrlKey, bool altKey, bool metaKey)
         : PlatformEvent(PlatformEvent::Wheel, shiftKey, ctrlKey, altKey, metaKey, { })
+        , m_granularity(granularity)
         , m_position(position)
         , m_globalPosition(globalPosition)
         , m_deltaX(deltaX)
@@ -102,7 +103,6 @@
         , m_deltaY(deltaY)
         , m_wheelTicksX(wheelTicksX)
         , m_wheelTicksY(wheelTicksY)
-        , m_granularity(granularity)
     {
     }
 
@@ -176,6 +176,10 @@
 #endif
 
 protected:
+    PlatformWheelEventGranularity m_granularity { ScrollByPixelWheelEvent };
+    bool m_directionInvertedFromDevice { false };
+    bool m_hasPreciseScrollingDeltas { false };
+
     IntPoint m_position;
     IntPoint m_globalPosition;
     float m_deltaX { 0 };
@@ -182,8 +186,6 @@
     float m_deltaY { 0 };
     float m_wheelTicksX { 0 };
     float m_wheelTicksY { 0 };
-    PlatformWheelEventGranularity m_granularity { ScrollByPixelWheelEvent };
-    bool m_directionInvertedFromDevice { false };
 
     // Scrolling velocity in pixels per second.
     FloatSize m_scrollingVelocity;
@@ -192,7 +194,6 @@
     PlatformWheelEventPhase m_phase { PlatformWheelEventPhase::None };
     PlatformWheelEventPhase m_momentumPhase { PlatformWheelEventPhase::None };
 #endif
-    bool m_hasPreciseScrollingDeltas { false };
 #if PLATFORM(COCOA)
     unsigned m_scrollCount { 0 };
     float m_unacceleratedScrollingDeltaX { 0 };
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to