Changeset 286717 in webkit
- Timestamp:
- Dec 8, 2021, 1:25:37 PM (5 years ago)
- Location:
- branches/safari-612.4.2.1-branch/Source
- Files:
-
- 5 added
- 16 edited
-
WTF/ChangeLog (modified) (1 diff)
-
WTF/wtf/PlatformEnable.h (modified) (1 diff)
-
WebCore/PAL/ChangeLog (modified) (1 diff)
-
WebCore/PAL/pal/spi/mac/IOKitSPIMac.h (modified) (3 diffs)
-
WebKit/ChangeLog (modified) (1 diff)
-
WebKit/Platform/Logging.h (modified) (1 diff)
-
WebKit/Shared/ScrollingAccelerationCurve.cpp (added)
-
WebKit/Shared/ScrollingAccelerationCurve.h (added)
-
WebKit/Shared/mac/ScrollingAccelerationCurveMac.mm (added)
-
WebKit/Sources.txt (modified) (2 diffs)
-
WebKit/SourcesCocoa.txt (modified) (1 diff)
-
WebKit/UIProcess/WebPageProxy.cpp (modified) (4 diffs)
-
WebKit/UIProcess/WebPageProxy.h (modified) (2 diffs)
-
WebKit/WebKit.xcodeproj/project.pbxproj (modified) (5 diffs)
-
WebKit/WebProcess/WebPage/EventDispatcher.cpp (modified) (12 diffs)
-
WebKit/WebProcess/WebPage/EventDispatcher.h (modified) (6 diffs)
-
WebKit/WebProcess/WebPage/EventDispatcher.messages.in (modified) (1 diff)
-
WebKit/WebProcess/WebPage/MomentumEventDispatcher.cpp (added)
-
WebKit/WebProcess/WebPage/MomentumEventDispatcher.h (added)
-
WebKit/WebProcess/WebPage/WebPage.cpp (modified) (3 diffs)
-
WebKit/WebProcess/WebPage/WebPage.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/safari-612.4.2.1-branch/Source/WTF/ChangeLog
r286245 r286717 1 2021-12-01 Alan Coon <alancoon@apple.com> 2 3 Cherry-pick r286346. rdar://problem/85928816 4 5 Add a momentum event synthesizer 6 https://bugs.webkit.org/show_bug.cgi?id=233653 7 <rdar://problem/85571258> 8 9 Reviewed by Simon Fraser. 10 11 Source/WebCore/PAL: 12 13 * pal/spi/mac/IOKitSPIMac.h: 14 Add some SPI. 15 16 Source/WebKit: 17 18 * Platform/Logging.h: 19 Add ScrollAnimations log channel to WebKit (it already exists in WebCore). 20 21 * Shared/ScrollingAccelerationCurve.cpp: Added. 22 (WebKit::ScrollingAccelerationCurve::ScrollingAccelerationCurve): 23 (WebKit::ScrollingAccelerationCurve::interpolate): 24 (WebKit::ScrollingAccelerationCurve::computeIntermediateValuesIfNeeded): 25 (WebKit::ScrollingAccelerationCurve::evaluateQuartic): 26 (WebKit::ScrollingAccelerationCurve::accelerationFactor): 27 (WebKit::ScrollingAccelerationCurve::encode const): 28 (WebKit::ScrollingAccelerationCurve::decode): 29 (WebKit::operator<<): 30 (WebKit::ScrollingAccelerationCurve::fromNativeWheelEvent): 31 * Shared/ScrollingAccelerationCurve.h: Added. 32 (WebKit::ScrollingAccelerationCurve::operator== const): 33 (WebKit::ScrollingAccelerationCurve::operator!= const): 34 Add a class that represents a quartic scrolling acceleration curve with 35 a trailing linear tangent region, and allows interpolation between curves 36 and evaluation of the curve at a point. 37 38 * Shared/mac/ScrollingAccelerationCurveMac.mm: Added. 39 (WebKit::fromFixedPoint): 40 (WebKit::readFixedPointParameter): 41 (WebKit::fromIOHIDCurve): 42 (WebKit::fromIOHIDCurveArrayWithAcceleration): 43 (WebKit::ScrollingAccelerationCurve::fromNativeWheelEvent): 44 Given a NativeWebWheelEvent, extract its underlying platform event 45 and fetch the ScrollingAccelerationCurve for the originating device. 46 47 * Sources.txt: 48 * SourcesCocoa.txt: 49 * UIProcess/WebPageProxy.cpp: 50 (WebKit::WebPageProxy::handleWheelEvent): 51 Fetch the current ScrollingAccelerationCurve on each momentum begin event, 52 if the feature is enabled. 53 54 (WebKit::WebPageProxy::sendWheelEvent): 55 Send the ScrollingAccelerationCurve to EventDispatcher just before 56 we send the momentum begin event along, if it has changed. 57 58 (WebKit::WebPageProxy::windowScreenDidChange): 59 Keep EventDispatcher apprised of changes to the current screen of the page. 60 61 (WebKit::WebPageProxy::resetState): 62 * UIProcess/WebPageProxy.h: 63 * WebKit.xcodeproj/project.pbxproj: 64 * WebProcess/WebPage/EventDispatcher.cpp: 65 (WebKit::EventDispatcher::EventDispatcher): 66 (WebKit::EventDispatcher::internalWheelEvent): 67 Factor most of wheelEvent out into internalWheelEvent, so that 68 MomentumEventDispatcher can call internalWheelEvent(), skipping the code 69 in wheelEvent() that forwards the event... to MomentumEventDispatcher. 70 71 Also, keep track of where the event came from (UI process or MomentumEventDispatcher) 72 and avoid sending didReceiveEvent replies to the UI process for synthetic 73 events that it doesn't know about. 74 75 (WebKit::EventDispatcher::wheelEvent): 76 Forward wheel events to MomentumEventDispatcher. 77 78 (WebKit::EventDispatcher::setScrollingAccelerationCurve): 79 Forward scrolling curve changes to MomentumEventDispatcher. 80 81 (WebKit::EventDispatcher::displayWasRefreshed): 82 Forward display refresh callbacks to MomentumEventDispatcher. 83 84 (WebKit::EventDispatcher::windowScreenDidChange): 85 Forward page screen changes to MomentumEventDispatcher. 86 87 * WebProcess/WebPage/EventDispatcher.h: 88 * WebProcess/WebPage/EventDispatcher.messages.in: 89 90 * WebProcess/WebPage/WebPage.cpp: 91 (WebKit::WebPage::wheelEvent): 92 (WebKit::WebPage::dispatchWheelEventWithoutScrolling): 93 * WebProcess/WebPage/WebPage.h: 94 Don't send didReceiveEvent for synthetic events from the main thread either. 95 96 * WebProcess/WebPage/MomentumEventDispatcher.cpp: Added. 97 (WebKit::MomentumEventDispatcher::MomentumEventDispatcher): 98 (WebKit::MomentumEventDispatcher::~MomentumEventDispatcher): 99 (WebKit::MomentumEventDispatcher::eventShouldStartSyntheticMomentumPhase const): 100 If we have everything we need (a scrolling curve - which also implies 101 that the setting is enabled - and raw platform deltas), and the event 102 is a momentum begin event, we can use it to start a synthetic momentum phase. 103 104 (WebKit::MomentumEventDispatcher::handleWheelEvent): 105 Start or stop the momentum phase as appropriate. 106 Record any incoming fingers-down phase events in a rolling event history structure. 107 Block platform-event-driven events from being further handled by WebKit 108 if we are inside a synthetic momentum phase, since we'll be replacing them. 109 110 (WebKit::appKitScrollMultiplierForEvent): 111 Determine the AppKit scroll muliplier ("accelerated" vs "unaccelerated" 112 deltas in NSEvent parlance) from the event via division. 113 114 (WebKit::MomentumEventDispatcher::dispatchSyntheticMomentumEvent): 115 Dispatch a synthetic event with the given momentum phase and delta. 116 We borrow some properties from the event that initiated the momentum 117 phase (e.g. the position), and some from whatever event we've most 118 recently seen (even if we told the rest of WebKit to ignore it), so 119 that we get the most up-to-date state for e.g. the keyboard modifiers. 120 121 (WebKit::MomentumEventDispatcher::didStartMomentumPhase): 122 Record relevant information about the start event, generate the 123 momentum curve, and start a full-rate display link. Also, send a momentum 124 begin event, since we blocked the real one. 125 126 (WebKit::MomentumEventDispatcher::didEndMomentumPhase): 127 Send a momentum ended event, shut down the display link, and reset all 128 per-gesture state. 129 130 (WebKit::MomentumEventDispatcher::setScrollingAccelerationCurve): 131 Store ScrollingAccelerationCurves on a per-page basis. 132 133 (WebKit::MomentumEventDispatcher::displayID const): 134 Look up the displayID for the current gesture's page. 135 136 (WebKit::MomentumEventDispatcher::startDisplayLink): 137 (WebKit::MomentumEventDispatcher::stopDisplayLink): 138 Start and stop a display link, which will - in a roundabout manner - 139 eventually call back into displayWasRefreshed. 140 141 (WebKit::MomentumEventDispatcher::windowScreenDidChange): 142 Store DisplayIDs on a per-page basis. 143 144 (WebKit::MomentumEventDispatcher::displayWasRefreshed): 145 When the display link calls us back, emit a single momentum changed 146 event of sufficient delta to move us to the desired offset along the curve. 147 148 (WebKit::MomentumEventDispatcher::didScrollWithInterval): 149 (WebKit::MomentumEventDispatcher::didScroll): 150 Record incoming scrolling events into a rolling history deque. 151 152 (WebKit::MomentumEventDispatcher::buildOffsetTableWithInitialDelta): 153 Compute the offsets for the entire "ideal curve" table (at 60Hz) by 154 running the animation and accumulating the deltas. 155 156 (WebKit::interpolate): 157 (WebKit::MomentumEventDispatcher::offsetAtTime): 158 Interpolate along the "ideal curve" to determine the intended offset 159 at a given time. 160 161 (WebKit::momentumDecayRate): 162 (WebKit::MomentumEventDispatcher::computeNextDelta): 163 Compute the next delta given a delta (and the event history) by applying 164 a bit of exponential decay and then passing it through the 165 ScrollingAccelerationCurve. We return both the unaccelerated 166 and accelerated deltas, because the input to the next iteration of 167 computeNextDelta is the unaccelerated delta, but the delta applied 168 to the actual scroll position is the accelerated delta. 169 170 * WebProcess/WebPage/MomentumEventDispatcher.h: Added. 171 172 Source/WTF: 173 174 * wtf/PlatformEnable.h: 175 Add an ENABLE(). 176 177 git-svn-id: https://svn.webkit.org/repository/webkit/trunk@286346 268f45cc-cd09-0410-ab3c-d52691b4dbfc 178 179 2021-11-30 Tim Horton <timothy_horton@apple.com> 180 181 Add a momentum event synthesizer 182 https://bugs.webkit.org/show_bug.cgi?id=233653 183 <rdar://problem/85571258> 184 185 Reviewed by Simon Fraser. 186 187 * wtf/PlatformEnable.h: 188 Add an ENABLE(). 189 1 190 2021-11-18 Russell Epstein <repstein@apple.com> 2 191 -
branches/safari-612.4.2.1-branch/Source/WTF/wtf/PlatformEnable.h
r285465 r286717 869 869 #endif 870 870 871 #if PLATFORM(MAC) 872 #define ENABLE_MOMENTUM_EVENT_DISPATCHER 1 873 #endif 874 871 875 #if !defined(ENABLE_SCROLLING_THREAD) 872 876 #if USE(NICOSIA) -
branches/safari-612.4.2.1-branch/Source/WebCore/PAL/ChangeLog
r286712 r286717 1 2021-12-01 Alan Coon <alancoon@apple.com> 2 3 Cherry-pick r286346. rdar://problem/85928816 4 5 Add a momentum event synthesizer 6 https://bugs.webkit.org/show_bug.cgi?id=233653 7 <rdar://problem/85571258> 8 9 Reviewed by Simon Fraser. 10 11 Source/WebCore/PAL: 12 13 * pal/spi/mac/IOKitSPIMac.h: 14 Add some SPI. 15 16 Source/WebKit: 17 18 * Platform/Logging.h: 19 Add ScrollAnimations log channel to WebKit (it already exists in WebCore). 20 21 * Shared/ScrollingAccelerationCurve.cpp: Added. 22 (WebKit::ScrollingAccelerationCurve::ScrollingAccelerationCurve): 23 (WebKit::ScrollingAccelerationCurve::interpolate): 24 (WebKit::ScrollingAccelerationCurve::computeIntermediateValuesIfNeeded): 25 (WebKit::ScrollingAccelerationCurve::evaluateQuartic): 26 (WebKit::ScrollingAccelerationCurve::accelerationFactor): 27 (WebKit::ScrollingAccelerationCurve::encode const): 28 (WebKit::ScrollingAccelerationCurve::decode): 29 (WebKit::operator<<): 30 (WebKit::ScrollingAccelerationCurve::fromNativeWheelEvent): 31 * Shared/ScrollingAccelerationCurve.h: Added. 32 (WebKit::ScrollingAccelerationCurve::operator== const): 33 (WebKit::ScrollingAccelerationCurve::operator!= const): 34 Add a class that represents a quartic scrolling acceleration curve with 35 a trailing linear tangent region, and allows interpolation between curves 36 and evaluation of the curve at a point. 37 38 * Shared/mac/ScrollingAccelerationCurveMac.mm: Added. 39 (WebKit::fromFixedPoint): 40 (WebKit::readFixedPointParameter): 41 (WebKit::fromIOHIDCurve): 42 (WebKit::fromIOHIDCurveArrayWithAcceleration): 43 (WebKit::ScrollingAccelerationCurve::fromNativeWheelEvent): 44 Given a NativeWebWheelEvent, extract its underlying platform event 45 and fetch the ScrollingAccelerationCurve for the originating device. 46 47 * Sources.txt: 48 * SourcesCocoa.txt: 49 * UIProcess/WebPageProxy.cpp: 50 (WebKit::WebPageProxy::handleWheelEvent): 51 Fetch the current ScrollingAccelerationCurve on each momentum begin event, 52 if the feature is enabled. 53 54 (WebKit::WebPageProxy::sendWheelEvent): 55 Send the ScrollingAccelerationCurve to EventDispatcher just before 56 we send the momentum begin event along, if it has changed. 57 58 (WebKit::WebPageProxy::windowScreenDidChange): 59 Keep EventDispatcher apprised of changes to the current screen of the page. 60 61 (WebKit::WebPageProxy::resetState): 62 * UIProcess/WebPageProxy.h: 63 * WebKit.xcodeproj/project.pbxproj: 64 * WebProcess/WebPage/EventDispatcher.cpp: 65 (WebKit::EventDispatcher::EventDispatcher): 66 (WebKit::EventDispatcher::internalWheelEvent): 67 Factor most of wheelEvent out into internalWheelEvent, so that 68 MomentumEventDispatcher can call internalWheelEvent(), skipping the code 69 in wheelEvent() that forwards the event... to MomentumEventDispatcher. 70 71 Also, keep track of where the event came from (UI process or MomentumEventDispatcher) 72 and avoid sending didReceiveEvent replies to the UI process for synthetic 73 events that it doesn't know about. 74 75 (WebKit::EventDispatcher::wheelEvent): 76 Forward wheel events to MomentumEventDispatcher. 77 78 (WebKit::EventDispatcher::setScrollingAccelerationCurve): 79 Forward scrolling curve changes to MomentumEventDispatcher. 80 81 (WebKit::EventDispatcher::displayWasRefreshed): 82 Forward display refresh callbacks to MomentumEventDispatcher. 83 84 (WebKit::EventDispatcher::windowScreenDidChange): 85 Forward page screen changes to MomentumEventDispatcher. 86 87 * WebProcess/WebPage/EventDispatcher.h: 88 * WebProcess/WebPage/EventDispatcher.messages.in: 89 90 * WebProcess/WebPage/WebPage.cpp: 91 (WebKit::WebPage::wheelEvent): 92 (WebKit::WebPage::dispatchWheelEventWithoutScrolling): 93 * WebProcess/WebPage/WebPage.h: 94 Don't send didReceiveEvent for synthetic events from the main thread either. 95 96 * WebProcess/WebPage/MomentumEventDispatcher.cpp: Added. 97 (WebKit::MomentumEventDispatcher::MomentumEventDispatcher): 98 (WebKit::MomentumEventDispatcher::~MomentumEventDispatcher): 99 (WebKit::MomentumEventDispatcher::eventShouldStartSyntheticMomentumPhase const): 100 If we have everything we need (a scrolling curve - which also implies 101 that the setting is enabled - and raw platform deltas), and the event 102 is a momentum begin event, we can use it to start a synthetic momentum phase. 103 104 (WebKit::MomentumEventDispatcher::handleWheelEvent): 105 Start or stop the momentum phase as appropriate. 106 Record any incoming fingers-down phase events in a rolling event history structure. 107 Block platform-event-driven events from being further handled by WebKit 108 if we are inside a synthetic momentum phase, since we'll be replacing them. 109 110 (WebKit::appKitScrollMultiplierForEvent): 111 Determine the AppKit scroll muliplier ("accelerated" vs "unaccelerated" 112 deltas in NSEvent parlance) from the event via division. 113 114 (WebKit::MomentumEventDispatcher::dispatchSyntheticMomentumEvent): 115 Dispatch a synthetic event with the given momentum phase and delta. 116 We borrow some properties from the event that initiated the momentum 117 phase (e.g. the position), and some from whatever event we've most 118 recently seen (even if we told the rest of WebKit to ignore it), so 119 that we get the most up-to-date state for e.g. the keyboard modifiers. 120 121 (WebKit::MomentumEventDispatcher::didStartMomentumPhase): 122 Record relevant information about the start event, generate the 123 momentum curve, and start a full-rate display link. Also, send a momentum 124 begin event, since we blocked the real one. 125 126 (WebKit::MomentumEventDispatcher::didEndMomentumPhase): 127 Send a momentum ended event, shut down the display link, and reset all 128 per-gesture state. 129 130 (WebKit::MomentumEventDispatcher::setScrollingAccelerationCurve): 131 Store ScrollingAccelerationCurves on a per-page basis. 132 133 (WebKit::MomentumEventDispatcher::displayID const): 134 Look up the displayID for the current gesture's page. 135 136 (WebKit::MomentumEventDispatcher::startDisplayLink): 137 (WebKit::MomentumEventDispatcher::stopDisplayLink): 138 Start and stop a display link, which will - in a roundabout manner - 139 eventually call back into displayWasRefreshed. 140 141 (WebKit::MomentumEventDispatcher::windowScreenDidChange): 142 Store DisplayIDs on a per-page basis. 143 144 (WebKit::MomentumEventDispatcher::displayWasRefreshed): 145 When the display link calls us back, emit a single momentum changed 146 event of sufficient delta to move us to the desired offset along the curve. 147 148 (WebKit::MomentumEventDispatcher::didScrollWithInterval): 149 (WebKit::MomentumEventDispatcher::didScroll): 150 Record incoming scrolling events into a rolling history deque. 151 152 (WebKit::MomentumEventDispatcher::buildOffsetTableWithInitialDelta): 153 Compute the offsets for the entire "ideal curve" table (at 60Hz) by 154 running the animation and accumulating the deltas. 155 156 (WebKit::interpolate): 157 (WebKit::MomentumEventDispatcher::offsetAtTime): 158 Interpolate along the "ideal curve" to determine the intended offset 159 at a given time. 160 161 (WebKit::momentumDecayRate): 162 (WebKit::MomentumEventDispatcher::computeNextDelta): 163 Compute the next delta given a delta (and the event history) by applying 164 a bit of exponential decay and then passing it through the 165 ScrollingAccelerationCurve. We return both the unaccelerated 166 and accelerated deltas, because the input to the next iteration of 167 computeNextDelta is the unaccelerated delta, but the delta applied 168 to the actual scroll position is the accelerated delta. 169 170 * WebProcess/WebPage/MomentumEventDispatcher.h: Added. 171 172 Source/WTF: 173 174 * wtf/PlatformEnable.h: 175 Add an ENABLE(). 176 177 git-svn-id: https://svn.webkit.org/repository/webkit/trunk@286346 268f45cc-cd09-0410-ab3c-d52691b4dbfc 178 179 2021-11-30 Tim Horton <timothy_horton@apple.com> 180 181 Add a momentum event synthesizer 182 https://bugs.webkit.org/show_bug.cgi?id=233653 183 <rdar://problem/85571258> 184 185 Reviewed by Simon Fraser. 186 187 * pal/spi/mac/IOKitSPIMac.h: 188 Add some SPI. 189 1 190 2021-12-01 Alan Coon <alancoon@apple.com> 2 191 -
branches/safari-612.4.2.1-branch/Source/WebCore/PAL/pal/spi/mac/IOKitSPIMac.h
r286713 r286717 67 67 void IOHIDEventSystemClientUnregisterDeviceMatchingBlock(IOHIDEventSystemClientRef); 68 68 void IOHIDEventSystemClientScheduleWithDispatchQueue(IOHIDEventSystemClientRef, dispatch_queue_t); 69 void IOHIDEventSystemClientSetDispatchQueue(IOHIDEventSystemClientRef, dispatch_queue_t); 70 void IOHIDEventSystemClientActivate(IOHIDEventSystemClientRef); 69 71 70 72 CFTypeRef IOHIDServiceClientCopyProperty(IOHIDServiceClientRef service, CFStringRef key); … … 85 87 86 88 typedef uint32_t IOHIDEventField; 89 typedef uint64_t IOHIDEventSenderID; 87 90 88 91 #ifdef __LP64__ … … 100 103 uint64_t IOHIDEventGetTimeStamp(IOHIDEventRef); 101 104 IOHIDFloat IOHIDEventGetFloatValue(IOHIDEventRef, IOHIDEventField); 105 IOHIDEventSenderID IOHIDEventGetSenderID(IOHIDEventRef); 102 106 103 107 WTF_EXTERN_C_END -
branches/safari-612.4.2.1-branch/Source/WebKit/ChangeLog
r286716 r286717 1 2021-12-01 Alan Coon <alancoon@apple.com> 2 3 Cherry-pick r286346. rdar://problem/85928816 4 5 Add a momentum event synthesizer 6 https://bugs.webkit.org/show_bug.cgi?id=233653 7 <rdar://problem/85571258> 8 9 Reviewed by Simon Fraser. 10 11 Source/WebCore/PAL: 12 13 * pal/spi/mac/IOKitSPIMac.h: 14 Add some SPI. 15 16 Source/WebKit: 17 18 * Platform/Logging.h: 19 Add ScrollAnimations log channel to WebKit (it already exists in WebCore). 20 21 * Shared/ScrollingAccelerationCurve.cpp: Added. 22 (WebKit::ScrollingAccelerationCurve::ScrollingAccelerationCurve): 23 (WebKit::ScrollingAccelerationCurve::interpolate): 24 (WebKit::ScrollingAccelerationCurve::computeIntermediateValuesIfNeeded): 25 (WebKit::ScrollingAccelerationCurve::evaluateQuartic): 26 (WebKit::ScrollingAccelerationCurve::accelerationFactor): 27 (WebKit::ScrollingAccelerationCurve::encode const): 28 (WebKit::ScrollingAccelerationCurve::decode): 29 (WebKit::operator<<): 30 (WebKit::ScrollingAccelerationCurve::fromNativeWheelEvent): 31 * Shared/ScrollingAccelerationCurve.h: Added. 32 (WebKit::ScrollingAccelerationCurve::operator== const): 33 (WebKit::ScrollingAccelerationCurve::operator!= const): 34 Add a class that represents a quartic scrolling acceleration curve with 35 a trailing linear tangent region, and allows interpolation between curves 36 and evaluation of the curve at a point. 37 38 * Shared/mac/ScrollingAccelerationCurveMac.mm: Added. 39 (WebKit::fromFixedPoint): 40 (WebKit::readFixedPointParameter): 41 (WebKit::fromIOHIDCurve): 42 (WebKit::fromIOHIDCurveArrayWithAcceleration): 43 (WebKit::ScrollingAccelerationCurve::fromNativeWheelEvent): 44 Given a NativeWebWheelEvent, extract its underlying platform event 45 and fetch the ScrollingAccelerationCurve for the originating device. 46 47 * Sources.txt: 48 * SourcesCocoa.txt: 49 * UIProcess/WebPageProxy.cpp: 50 (WebKit::WebPageProxy::handleWheelEvent): 51 Fetch the current ScrollingAccelerationCurve on each momentum begin event, 52 if the feature is enabled. 53 54 (WebKit::WebPageProxy::sendWheelEvent): 55 Send the ScrollingAccelerationCurve to EventDispatcher just before 56 we send the momentum begin event along, if it has changed. 57 58 (WebKit::WebPageProxy::windowScreenDidChange): 59 Keep EventDispatcher apprised of changes to the current screen of the page. 60 61 (WebKit::WebPageProxy::resetState): 62 * UIProcess/WebPageProxy.h: 63 * WebKit.xcodeproj/project.pbxproj: 64 * WebProcess/WebPage/EventDispatcher.cpp: 65 (WebKit::EventDispatcher::EventDispatcher): 66 (WebKit::EventDispatcher::internalWheelEvent): 67 Factor most of wheelEvent out into internalWheelEvent, so that 68 MomentumEventDispatcher can call internalWheelEvent(), skipping the code 69 in wheelEvent() that forwards the event... to MomentumEventDispatcher. 70 71 Also, keep track of where the event came from (UI process or MomentumEventDispatcher) 72 and avoid sending didReceiveEvent replies to the UI process for synthetic 73 events that it doesn't know about. 74 75 (WebKit::EventDispatcher::wheelEvent): 76 Forward wheel events to MomentumEventDispatcher. 77 78 (WebKit::EventDispatcher::setScrollingAccelerationCurve): 79 Forward scrolling curve changes to MomentumEventDispatcher. 80 81 (WebKit::EventDispatcher::displayWasRefreshed): 82 Forward display refresh callbacks to MomentumEventDispatcher. 83 84 (WebKit::EventDispatcher::windowScreenDidChange): 85 Forward page screen changes to MomentumEventDispatcher. 86 87 * WebProcess/WebPage/EventDispatcher.h: 88 * WebProcess/WebPage/EventDispatcher.messages.in: 89 90 * WebProcess/WebPage/WebPage.cpp: 91 (WebKit::WebPage::wheelEvent): 92 (WebKit::WebPage::dispatchWheelEventWithoutScrolling): 93 * WebProcess/WebPage/WebPage.h: 94 Don't send didReceiveEvent for synthetic events from the main thread either. 95 96 * WebProcess/WebPage/MomentumEventDispatcher.cpp: Added. 97 (WebKit::MomentumEventDispatcher::MomentumEventDispatcher): 98 (WebKit::MomentumEventDispatcher::~MomentumEventDispatcher): 99 (WebKit::MomentumEventDispatcher::eventShouldStartSyntheticMomentumPhase const): 100 If we have everything we need (a scrolling curve - which also implies 101 that the setting is enabled - and raw platform deltas), and the event 102 is a momentum begin event, we can use it to start a synthetic momentum phase. 103 104 (WebKit::MomentumEventDispatcher::handleWheelEvent): 105 Start or stop the momentum phase as appropriate. 106 Record any incoming fingers-down phase events in a rolling event history structure. 107 Block platform-event-driven events from being further handled by WebKit 108 if we are inside a synthetic momentum phase, since we'll be replacing them. 109 110 (WebKit::appKitScrollMultiplierForEvent): 111 Determine the AppKit scroll muliplier ("accelerated" vs "unaccelerated" 112 deltas in NSEvent parlance) from the event via division. 113 114 (WebKit::MomentumEventDispatcher::dispatchSyntheticMomentumEvent): 115 Dispatch a synthetic event with the given momentum phase and delta. 116 We borrow some properties from the event that initiated the momentum 117 phase (e.g. the position), and some from whatever event we've most 118 recently seen (even if we told the rest of WebKit to ignore it), so 119 that we get the most up-to-date state for e.g. the keyboard modifiers. 120 121 (WebKit::MomentumEventDispatcher::didStartMomentumPhase): 122 Record relevant information about the start event, generate the 123 momentum curve, and start a full-rate display link. Also, send a momentum 124 begin event, since we blocked the real one. 125 126 (WebKit::MomentumEventDispatcher::didEndMomentumPhase): 127 Send a momentum ended event, shut down the display link, and reset all 128 per-gesture state. 129 130 (WebKit::MomentumEventDispatcher::setScrollingAccelerationCurve): 131 Store ScrollingAccelerationCurves on a per-page basis. 132 133 (WebKit::MomentumEventDispatcher::displayID const): 134 Look up the displayID for the current gesture's page. 135 136 (WebKit::MomentumEventDispatcher::startDisplayLink): 137 (WebKit::MomentumEventDispatcher::stopDisplayLink): 138 Start and stop a display link, which will - in a roundabout manner - 139 eventually call back into displayWasRefreshed. 140 141 (WebKit::MomentumEventDispatcher::windowScreenDidChange): 142 Store DisplayIDs on a per-page basis. 143 144 (WebKit::MomentumEventDispatcher::displayWasRefreshed): 145 When the display link calls us back, emit a single momentum changed 146 event of sufficient delta to move us to the desired offset along the curve. 147 148 (WebKit::MomentumEventDispatcher::didScrollWithInterval): 149 (WebKit::MomentumEventDispatcher::didScroll): 150 Record incoming scrolling events into a rolling history deque. 151 152 (WebKit::MomentumEventDispatcher::buildOffsetTableWithInitialDelta): 153 Compute the offsets for the entire "ideal curve" table (at 60Hz) by 154 running the animation and accumulating the deltas. 155 156 (WebKit::interpolate): 157 (WebKit::MomentumEventDispatcher::offsetAtTime): 158 Interpolate along the "ideal curve" to determine the intended offset 159 at a given time. 160 161 (WebKit::momentumDecayRate): 162 (WebKit::MomentumEventDispatcher::computeNextDelta): 163 Compute the next delta given a delta (and the event history) by applying 164 a bit of exponential decay and then passing it through the 165 ScrollingAccelerationCurve. We return both the unaccelerated 166 and accelerated deltas, because the input to the next iteration of 167 computeNextDelta is the unaccelerated delta, but the delta applied 168 to the actual scroll position is the accelerated delta. 169 170 * WebProcess/WebPage/MomentumEventDispatcher.h: Added. 171 172 Source/WTF: 173 174 * wtf/PlatformEnable.h: 175 Add an ENABLE(). 176 177 git-svn-id: https://svn.webkit.org/repository/webkit/trunk@286346 268f45cc-cd09-0410-ab3c-d52691b4dbfc 178 179 2021-11-30 Tim Horton <timothy_horton@apple.com> 180 181 Add a momentum event synthesizer 182 https://bugs.webkit.org/show_bug.cgi?id=233653 183 <rdar://problem/85571258> 184 185 Reviewed by Simon Fraser. 186 187 * Platform/Logging.h: 188 Add ScrollAnimations log channel to WebKit (it already exists in WebCore). 189 190 * Shared/ScrollingAccelerationCurve.cpp: Added. 191 (WebKit::ScrollingAccelerationCurve::ScrollingAccelerationCurve): 192 (WebKit::ScrollingAccelerationCurve::interpolate): 193 (WebKit::ScrollingAccelerationCurve::computeIntermediateValuesIfNeeded): 194 (WebKit::ScrollingAccelerationCurve::evaluateQuartic): 195 (WebKit::ScrollingAccelerationCurve::accelerationFactor): 196 (WebKit::ScrollingAccelerationCurve::encode const): 197 (WebKit::ScrollingAccelerationCurve::decode): 198 (WebKit::operator<<): 199 (WebKit::ScrollingAccelerationCurve::fromNativeWheelEvent): 200 * Shared/ScrollingAccelerationCurve.h: Added. 201 (WebKit::ScrollingAccelerationCurve::operator== const): 202 (WebKit::ScrollingAccelerationCurve::operator!= const): 203 Add a class that represents a quartic scrolling acceleration curve with 204 a trailing linear tangent region, and allows interpolation between curves 205 and evaluation of the curve at a point. 206 207 * Shared/mac/ScrollingAccelerationCurveMac.mm: Added. 208 (WebKit::fromFixedPoint): 209 (WebKit::readFixedPointParameter): 210 (WebKit::fromIOHIDCurve): 211 (WebKit::fromIOHIDCurveArrayWithAcceleration): 212 (WebKit::ScrollingAccelerationCurve::fromNativeWheelEvent): 213 Given a NativeWebWheelEvent, extract its underlying platform event 214 and fetch the ScrollingAccelerationCurve for the originating device. 215 216 * Sources.txt: 217 * SourcesCocoa.txt: 218 * UIProcess/WebPageProxy.cpp: 219 (WebKit::WebPageProxy::handleWheelEvent): 220 Fetch the current ScrollingAccelerationCurve on each momentum begin event, 221 if the feature is enabled. 222 223 (WebKit::WebPageProxy::sendWheelEvent): 224 Send the ScrollingAccelerationCurve to EventDispatcher just before 225 we send the momentum begin event along, if it has changed. 226 227 (WebKit::WebPageProxy::windowScreenDidChange): 228 Keep EventDispatcher apprised of changes to the current screen of the page. 229 230 (WebKit::WebPageProxy::resetState): 231 * UIProcess/WebPageProxy.h: 232 * WebKit.xcodeproj/project.pbxproj: 233 * WebProcess/WebPage/EventDispatcher.cpp: 234 (WebKit::EventDispatcher::EventDispatcher): 235 (WebKit::EventDispatcher::internalWheelEvent): 236 Factor most of wheelEvent out into internalWheelEvent, so that 237 MomentumEventDispatcher can call internalWheelEvent(), skipping the code 238 in wheelEvent() that forwards the event... to MomentumEventDispatcher. 239 240 Also, keep track of where the event came from (UI process or MomentumEventDispatcher) 241 and avoid sending didReceiveEvent replies to the UI process for synthetic 242 events that it doesn't know about. 243 244 (WebKit::EventDispatcher::wheelEvent): 245 Forward wheel events to MomentumEventDispatcher. 246 247 (WebKit::EventDispatcher::setScrollingAccelerationCurve): 248 Forward scrolling curve changes to MomentumEventDispatcher. 249 250 (WebKit::EventDispatcher::displayWasRefreshed): 251 Forward display refresh callbacks to MomentumEventDispatcher. 252 253 (WebKit::EventDispatcher::windowScreenDidChange): 254 Forward page screen changes to MomentumEventDispatcher. 255 256 * WebProcess/WebPage/EventDispatcher.h: 257 * WebProcess/WebPage/EventDispatcher.messages.in: 258 259 * WebProcess/WebPage/WebPage.cpp: 260 (WebKit::WebPage::wheelEvent): 261 (WebKit::WebPage::dispatchWheelEventWithoutScrolling): 262 * WebProcess/WebPage/WebPage.h: 263 Don't send didReceiveEvent for synthetic events from the main thread either. 264 265 * WebProcess/WebPage/MomentumEventDispatcher.cpp: Added. 266 (WebKit::MomentumEventDispatcher::MomentumEventDispatcher): 267 (WebKit::MomentumEventDispatcher::~MomentumEventDispatcher): 268 (WebKit::MomentumEventDispatcher::eventShouldStartSyntheticMomentumPhase const): 269 If we have everything we need (a scrolling curve - which also implies 270 that the setting is enabled - and raw platform deltas), and the event 271 is a momentum begin event, we can use it to start a synthetic momentum phase. 272 273 (WebKit::MomentumEventDispatcher::handleWheelEvent): 274 Start or stop the momentum phase as appropriate. 275 Record any incoming fingers-down phase events in a rolling event history structure. 276 Block platform-event-driven events from being further handled by WebKit 277 if we are inside a synthetic momentum phase, since we'll be replacing them. 278 279 (WebKit::appKitScrollMultiplierForEvent): 280 Determine the AppKit scroll muliplier ("accelerated" vs "unaccelerated" 281 deltas in NSEvent parlance) from the event via division. 282 283 (WebKit::MomentumEventDispatcher::dispatchSyntheticMomentumEvent): 284 Dispatch a synthetic event with the given momentum phase and delta. 285 We borrow some properties from the event that initiated the momentum 286 phase (e.g. the position), and some from whatever event we've most 287 recently seen (even if we told the rest of WebKit to ignore it), so 288 that we get the most up-to-date state for e.g. the keyboard modifiers. 289 290 (WebKit::MomentumEventDispatcher::didStartMomentumPhase): 291 Record relevant information about the start event, generate the 292 momentum curve, and start a full-rate display link. Also, send a momentum 293 begin event, since we blocked the real one. 294 295 (WebKit::MomentumEventDispatcher::didEndMomentumPhase): 296 Send a momentum ended event, shut down the display link, and reset all 297 per-gesture state. 298 299 (WebKit::MomentumEventDispatcher::setScrollingAccelerationCurve): 300 Store ScrollingAccelerationCurves on a per-page basis. 301 302 (WebKit::MomentumEventDispatcher::displayID const): 303 Look up the displayID for the current gesture's page. 304 305 (WebKit::MomentumEventDispatcher::startDisplayLink): 306 (WebKit::MomentumEventDispatcher::stopDisplayLink): 307 Start and stop a display link, which will - in a roundabout manner - 308 eventually call back into displayWasRefreshed. 309 310 (WebKit::MomentumEventDispatcher::windowScreenDidChange): 311 Store DisplayIDs on a per-page basis. 312 313 (WebKit::MomentumEventDispatcher::displayWasRefreshed): 314 When the display link calls us back, emit a single momentum changed 315 event of sufficient delta to move us to the desired offset along the curve. 316 317 (WebKit::MomentumEventDispatcher::didScrollWithInterval): 318 (WebKit::MomentumEventDispatcher::didScroll): 319 Record incoming scrolling events into a rolling history deque. 320 321 (WebKit::MomentumEventDispatcher::buildOffsetTableWithInitialDelta): 322 Compute the offsets for the entire "ideal curve" table (at 60Hz) by 323 running the animation and accumulating the deltas. 324 325 (WebKit::interpolate): 326 (WebKit::MomentumEventDispatcher::offsetAtTime): 327 Interpolate along the "ideal curve" to determine the intended offset 328 at a given time. 329 330 (WebKit::momentumDecayRate): 331 (WebKit::MomentumEventDispatcher::computeNextDelta): 332 Compute the next delta given a delta (and the event history) by applying 333 a bit of exponential decay and then passing it through the 334 ScrollingAccelerationCurve. We return both the unaccelerated 335 and accelerated deltas, because the input to the next iteration of 336 computeNextDelta is the unaccelerated delta, but the delta applied 337 to the actual scroll position is the accelerated delta. 338 339 * WebProcess/WebPage/MomentumEventDispatcher.h: Added. 340 1 341 2021-12-01 Alan Coon <alancoon@apple.com> 2 342 -
branches/safari-612.4.2.1-branch/Source/WebKit/Platform/Logging.h
r280811 r286717 90 90 M(Resize) \ 91 91 M(ResourceLoadStatistics) \ 92 M(ScrollAnimations) \ 92 93 M(Scrolling) \ 93 94 M(Selection) \ -
branches/safari-612.4.2.1-branch/Source/WebKit/Sources.txt
r284424 r286717 198 198 Shared/RTCNetwork.cpp 199 199 Shared/RTCPacketOptions.cpp 200 Shared/ScrollingAccelerationCurve.cpp 200 201 Shared/ServiceWorkerInitializationData.cpp 201 202 Shared/SessionState.cpp … … 723 724 WebProcess/WebPage/FindController.cpp 724 725 WebProcess/WebPage/IPCTestingAPI.cpp 726 WebProcess/WebPage/MomentumEventDispatcher.cpp 725 727 WebProcess/WebPage/PageBanner.cpp 726 728 WebProcess/WebPage/VisitedLinkTableController.cpp -
branches/safari-612.4.2.1-branch/Source/WebKit/SourcesCocoa.txt
r284953 r286717 214 214 Shared/mac/PasteboardTypes.mm 215 215 Shared/mac/PrintInfoMac.mm 216 Shared/mac/ScrollingAccelerationCurveMac.mm 216 217 Shared/mac/SecItemRequestData.cpp 217 218 Shared/mac/SecItemResponseData.cpp -
branches/safari-612.4.2.1-branch/Source/WebKit/UIProcess/WebPageProxy.cpp
r286716 r286717 2887 2887 closeOverlayedViews(); 2888 2888 2889 #if ENABLE(MOMENTUM_EVENT_DISPATCHER) 2890 // FIXME: We should not have to look this up repeatedly, but it can also change occasionally. 2891 if (event.momentumPhase() == WebWheelEvent::PhaseBegan && preferences().momentumScrollingAnimatorEnabled()) 2892 m_scrollingAccelerationCurve = ScrollingAccelerationCurve::fromNativeWheelEvent(event); 2893 #endif 2894 2889 2895 if (wheelEventCoalescer().shouldDispatchEvent(event)) { 2890 2896 auto event = wheelEventCoalescer().nextEventToDispatch(); … … 2932 2938 rubberBandableEdges.setRight(!m_backForwardList->forwardItem()); 2933 2939 } 2934 connection -> send(Messages::EventDispatcher::WheelEvent(m_webPageID, event, rubberBandableEdges), 0); 2940 2941 #if ENABLE(MOMENTUM_EVENT_DISPATCHER) 2942 if (event.momentumPhase() == WebWheelEvent::PhaseBegan && m_scrollingAccelerationCurve != m_lastSentScrollingAccelerationCurve) { 2943 connection->send(Messages::EventDispatcher::SetScrollingAccelerationCurve(m_webPageID, *m_scrollingAccelerationCurve), 0, { }, Thread::QOS::UserInteractive); 2944 m_lastSentScrollingAccelerationCurve = m_scrollingAccelerationCurve; 2945 } 2946 #endif 2947 2948 connection->send(Messages::EventDispatcher::WheelEvent(m_webPageID, event, rubberBandableEdges), 0, { }, Thread::QOS::UserInteractive); 2935 2949 2936 2950 // Manually ping the web process to check for responsiveness since our wheel … … 3994 4008 return; 3995 4009 4010 send(Messages::EventDispatcher::PageScreenDidChange(m_webPageID, displayID)); 3996 4011 send(Messages::WebPage::WindowScreenDidChange(displayID, nominalFramesPerSecond)); 3997 4012 } … … 7905 7920 m_xrSystem = nullptr; 7906 7921 } 7922 #endif 7923 7924 #if ENABLE(MOMENTUM_EVENT_DISPATCHER) 7925 m_lastSentScrollingAccelerationCurve = std::nullopt; 7907 7926 #endif 7908 7927 } -
branches/safari-612.4.2.1-branch/Source/WebKit/UIProcess/WebPageProxy.h
r286716 r286717 52 52 #include "ProcessThrottler.h" 53 53 #include "SandboxExtension.h" 54 #include "ScrollingAccelerationCurve.h" 54 55 #include "ShareableBitmap.h" 55 56 #include "ShareableResource.h" … … 3093 3094 3094 3095 bool m_needsSiteSpecificViewportQuirks { true }; 3096 3097 #if ENABLE(MOMENTUM_EVENT_DISPATCHER) 3098 std::optional<ScrollingAccelerationCurve> m_scrollingAccelerationCurve; 3099 std::optional<ScrollingAccelerationCurve> m_lastSentScrollingAccelerationCurve; 3100 #endif 3095 3101 }; 3096 3102 -
branches/safari-612.4.2.1-branch/Source/WebKit/WebKit.xcodeproj/project.pbxproj
r284953 r286717 3275 3275 2D6482492644B1AB00030335 /* RemoteLayerTreeLayers.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RemoteLayerTreeLayers.h; sourceTree = "<group>"; }; 3276 3276 2D64824A2644B1AB00030335 /* RemoteLayerTreeLayers.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = RemoteLayerTreeLayers.mm; sourceTree = "<group>"; }; 3277 2D65D194274B8E73009C4101 /* ScrollingAccelerationCurveMac.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = ScrollingAccelerationCurveMac.mm; sourceTree = "<group>"; }; 3278 2D65D195274B8E84009C4101 /* ScrollingAccelerationCurve.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ScrollingAccelerationCurve.h; sourceTree = "<group>"; }; 3279 2D65D196274B8E84009C4101 /* ScrollingAccelerationCurve.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = ScrollingAccelerationCurve.cpp; sourceTree = "<group>"; }; 3277 3280 2D6AB53F192B1C4A003A9FD1 /* WKPDFPageNumberIndicator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WKPDFPageNumberIndicator.h; path = ios/WKPDFPageNumberIndicator.h; sourceTree = "<group>"; }; 3278 3281 2D6AB540192B1C4A003A9FD1 /* WKPDFPageNumberIndicator.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = WKPDFPageNumberIndicator.mm; path = ios/WKPDFPageNumberIndicator.mm; sourceTree = "<group>"; }; … … 3557 3560 2DE9B13B2231F77C005287B7 /* _WKTextInputContextInternal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = _WKTextInputContextInternal.h; sourceTree = "<group>"; }; 3558 3561 2DEAC5CE1AC368BB00A195D8 /* _WKFindOptions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = _WKFindOptions.h; sourceTree = "<group>"; }; 3562 2DEE709D2755A46800FBF864 /* MomentumEventDispatcher.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MomentumEventDispatcher.h; sourceTree = "<group>"; }; 3563 2DEE709E2755A46800FBF864 /* MomentumEventDispatcher.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = MomentumEventDispatcher.cpp; sourceTree = "<group>"; }; 3559 3564 2DF9593418A42412009785A1 /* ViewGestureControllerIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = ViewGestureControllerIOS.mm; path = ios/ViewGestureControllerIOS.mm; sourceTree = "<group>"; }; 3560 3565 2DF9EEE31A781FB400B6CFBE /* APIFrameInfo.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = APIFrameInfo.cpp; sourceTree = "<group>"; }; … … 6896 6901 1AAB4A8C1296F0A20023952F /* SandboxExtension.h */, 6897 6902 E1E552C316AE065E004ED653 /* SandboxInitializationParameters.h */, 6903 2D65D196274B8E84009C4101 /* ScrollingAccelerationCurve.cpp */, 6904 2D65D195274B8E84009C4101 /* ScrollingAccelerationCurve.h */, 6898 6905 5C80B3DD23690F100086E6DE /* ServiceWorkerInitializationData.cpp */, 6899 6906 5C80B3DB23690D8D0086E6DE /* ServiceWorkerInitializationData.h */, … … 10072 10079 9B033E72252580F300501071 /* IPCTestingAPI.cpp */, 10073 10080 9B033E71252580F300501071 /* IPCTestingAPI.h */, 10081 2DEE709E2755A46800FBF864 /* MomentumEventDispatcher.cpp */, 10082 2DEE709D2755A46800FBF864 /* MomentumEventDispatcher.h */, 10074 10083 7C387433172F5615001BD88A /* PageBanner.cpp */, 10075 10084 7CF47FF917275C57008ACB91 /* PageBanner.h */, … … 10644 10653 C1E123B920A11572002646F4 /* PDFContextMenu.h */, 10645 10654 E1CC1B8F12D7EADF00625838 /* PrintInfoMac.mm */, 10655 2D65D194274B8E73009C4101 /* ScrollingAccelerationCurveMac.mm */, 10646 10656 51D1304F1382EAC000351EDD /* SecItemRequestData.cpp */, 10647 10657 51D130501382EAC000351EDD /* SecItemRequestData.h */, -
branches/safari-612.4.2.1-branch/Source/WebKit/WebProcess/WebPage/EventDispatcher.cpp
r286716 r286717 28 28 29 29 #include "EventDispatcherMessages.h" 30 #include "MomentumEventDispatcher.h" 30 31 #include "WebEventConversion.h" 31 32 #include "WebPage.h" … … 63 64 : m_queue(WorkQueue::create("com.apple.WebKit.EventDispatcher", WorkQueue::Type::Serial, WorkQueue::QOS::UserInteractive)) 64 65 , m_recentWheelEventDeltaFilter(WheelEventDeltaFilter::create()) 66 #if ENABLE(MOMENTUM_EVENT_DISPATCHER) 67 , m_momentumEventDispatcher(WTF::makeUnique<MomentumEventDispatcher>(*this)) 68 #endif 65 69 { 66 70 } … … 97 101 } 98 102 99 void EventDispatcher:: wheelEvent(PageIdentifier pageID, const WebWheelEvent& wheelEvent, RectEdges<bool> rubberBandableEdges)103 void EventDispatcher::internalWheelEvent(PageIdentifier pageID, const WebWheelEvent& wheelEvent, RectEdges<bool> rubberBandableEdges, WheelEventOrigin wheelEventOrigin) 100 104 { 101 105 #if PLATFORM(COCOA) || ENABLE(SCROLLING_THREAD) … … 129 133 auto scrollingTree = m_scrollingTrees.get(pageID); 130 134 if (!scrollingTree) { 131 dispatchWheelEventViaMainThread(pageID, wheelEvent, processingSteps );135 dispatchWheelEventViaMainThread(pageID, wheelEvent, processingSteps, wheelEventOrigin); 132 136 break; 133 137 } … … 144 148 scrollingTree->willProcessWheelEvent(); 145 149 146 ScrollingThread::dispatch([scrollingTree, wheelEvent, platformWheelEvent, processingSteps, pageID, protectedThis = makeRef(*this)] {150 ScrollingThread::dispatch([scrollingTree, wheelEvent, platformWheelEvent, processingSteps, pageID, wheelEventOrigin, protectedThis = makeRef(*this)] { 147 151 if (processingSteps.contains(WheelEventProcessingSteps::MainThreadForScrolling)) { 148 152 scrollingTree->willSendEventToMainThread(platformWheelEvent); 149 protectedThis->dispatchWheelEventViaMainThread(pageID, wheelEvent, processingSteps );153 protectedThis->dispatchWheelEventViaMainThread(pageID, wheelEvent, processingSteps, wheelEventOrigin); 150 154 scrollingTree->waitForEventToBeProcessedByMainThread(platformWheelEvent); 151 155 return; … … 155 159 156 160 if (result.needsMainThreadProcessing()) { 157 protectedThis->dispatchWheelEventViaMainThread(pageID, wheelEvent, result.steps );161 protectedThis->dispatchWheelEventViaMainThread(pageID, wheelEvent, result.steps, wheelEventOrigin); 158 162 if (result.steps.contains(WheelEventProcessingSteps::MainThreadForScrolling)) 159 163 return; … … 162 166 // If we scrolled on the scrolling thread (even if we send the event to the main thread for passive event handlers) 163 167 // respond to the UI process that the event was handled. 164 protectedThis->sendDidReceiveEvent(pageID, wheelEvent.type(), result.wasHandled); 168 if (wheelEventOrigin == WheelEventOrigin::UIProcess) 169 protectedThis->sendDidReceiveEvent(pageID, wheelEvent.type(), result.wasHandled); 165 170 }); 166 171 } while (false); … … 168 173 UNUSED_PARAM(rubberBandableEdges); 169 174 170 dispatchWheelEventViaMainThread(pageID, wheelEvent, processingSteps); 171 #endif 172 } 175 dispatchWheelEventViaMainThread(pageID, wheelEvent, processingSteps, wheelEventOrigin); 176 #endif 177 } 178 179 void EventDispatcher::wheelEvent(PageIdentifier pageID, const WebWheelEvent& wheelEvent, RectEdges<bool> rubberBandableEdges) 180 { 181 #if ENABLE(MOMENTUM_EVENT_DISPATCHER) 182 if (m_momentumEventDispatcher->handleWheelEvent(pageID, wheelEvent, rubberBandableEdges)) { 183 sendDidReceiveEvent(pageID, wheelEvent.type(), true); 184 return; 185 } 186 #endif 187 internalWheelEvent(pageID, wheelEvent, rubberBandableEdges, WheelEventOrigin::UIProcess); 188 } 189 190 #if ENABLE(MOMENTUM_EVENT_DISPATCHER) 191 void EventDispatcher::setScrollingAccelerationCurve(PageIdentifier pageID, std::optional<ScrollingAccelerationCurve> curve) 192 { 193 m_momentumEventDispatcher->setScrollingAccelerationCurve(pageID, curve); 194 } 195 #endif 173 196 174 197 #if ENABLE(MAC_GESTURE_EVENTS) … … 238 261 #endif 239 262 240 void EventDispatcher::dispatchWheelEventViaMainThread(WebCore::PageIdentifier pageID, const WebWheelEvent& wheelEvent, OptionSet<WheelEventProcessingSteps> processingSteps )263 void EventDispatcher::dispatchWheelEventViaMainThread(WebCore::PageIdentifier pageID, const WebWheelEvent& wheelEvent, OptionSet<WheelEventProcessingSteps> processingSteps, WheelEventOrigin wheelEventOrigin) 241 264 { 242 265 ASSERT(!RunLoop::isMain()); 243 RunLoop::main().dispatch([protectedThis = makeRef(*this), pageID, wheelEvent, steps = processingSteps - WheelEventProcessingSteps::ScrollingThread]() mutable {244 protectedThis->dispatchWheelEvent(pageID, wheelEvent, steps );266 RunLoop::main().dispatch([protectedThis = makeRef(*this), pageID, wheelEvent, wheelEventOrigin, steps = processingSteps - WheelEventProcessingSteps::ScrollingThread]() mutable { 267 protectedThis->dispatchWheelEvent(pageID, wheelEvent, steps, wheelEventOrigin); 245 268 }); 246 269 } 247 270 248 void EventDispatcher::dispatchWheelEvent(PageIdentifier pageID, const WebWheelEvent& wheelEvent, OptionSet<WheelEventProcessingSteps> processingSteps )271 void EventDispatcher::dispatchWheelEvent(PageIdentifier pageID, const WebWheelEvent& wheelEvent, OptionSet<WheelEventProcessingSteps> processingSteps, WheelEventOrigin wheelEventOrigin) 249 272 { 250 273 ASSERT(RunLoop::isMain()); … … 254 277 return; 255 278 256 webPage->wheelEvent(wheelEvent, processingSteps );279 webPage->wheelEvent(wheelEvent, processingSteps, wheelEventOrigin); 257 280 } 258 281 … … 292 315 293 316 ASSERT(!RunLoop::isMain()); 317 318 #if ENABLE(MOMENTUM_EVENT_DISPATCHER) 319 m_momentumEventDispatcher->displayWasRefreshed(displayID, displayUpdate); 320 #endif 321 294 322 notifyScrollingTreesDisplayWasRefreshed(displayID); 295 323 … … 303 331 #endif 304 332 333 void EventDispatcher::pageScreenDidChange(PageIdentifier pageID, PlatformDisplayID displayID) 334 { 335 #if ENABLE(MOMENTUM_EVENT_DISPATCHER) 336 m_momentumEventDispatcher->pageScreenDidChange(pageID, displayID); 337 #else 338 UNUSED_PARAM(pageID); 339 UNUSED_PARAM(displayID); 340 #endif 341 } 342 305 343 } // namespace WebKit -
branches/safari-612.4.2.1-branch/Source/WebKit/WebProcess/WebPage/EventDispatcher.h
r286716 r286717 52 52 namespace WebKit { 53 53 54 class MomentumEventDispatcher; 55 class ScrollingAccelerationCurve; 54 56 class WebPage; 55 57 class WebWheelEvent; … … 78 80 void notifyScrollingTreesDisplayWasRefreshed(WebCore::PlatformDisplayID); 79 81 82 enum class WheelEventOrigin : bool { UIProcess, MomentumEventDispatcher }; 83 void internalWheelEvent(WebCore::PageIdentifier, const WebWheelEvent&, WebCore::RectEdges<bool> rubberBandableEdges, WheelEventOrigin); 84 80 85 private: 81 86 EventDispatcher(); … … 86 91 // Message handlers 87 92 void wheelEvent(WebCore::PageIdentifier, const WebWheelEvent&, WebCore::RectEdges<bool> rubberBandableEdges); 93 #if ENABLE(MOMENTUM_EVENT_DISPATCHER) 94 void setScrollingAccelerationCurve(WebCore::PageIdentifier, std::optional<ScrollingAccelerationCurve>); 95 #endif 88 96 #if ENABLE(IOS_TOUCH_EVENTS) 89 97 void touchEvent(WebCore::PageIdentifier, const WebTouchEvent&, CompletionHandler<void(bool)>&&); … … 95 103 96 104 // This is called on the main thread. 97 void dispatchWheelEvent(WebCore::PageIdentifier, const WebWheelEvent&, OptionSet<WebCore::WheelEventProcessingSteps> );98 void dispatchWheelEventViaMainThread(WebCore::PageIdentifier, const WebWheelEvent&, OptionSet<WebCore::WheelEventProcessingSteps> );105 void dispatchWheelEvent(WebCore::PageIdentifier, const WebWheelEvent&, OptionSet<WebCore::WheelEventProcessingSteps>, WheelEventOrigin); 106 void dispatchWheelEventViaMainThread(WebCore::PageIdentifier, const WebWheelEvent&, OptionSet<WebCore::WheelEventProcessingSteps>, WheelEventOrigin); 99 107 100 108 #if ENABLE(IOS_TOUCH_EVENTS) … … 117 125 #endif 118 126 127 void pageScreenDidChange(WebCore::PageIdentifier, WebCore::PlatformDisplayID); 128 119 129 Ref<WorkQueue> m_queue; 120 130 … … 128 138 HashMap<WebCore::PageIdentifier, TouchEventQueue> m_touchEvents WTF_GUARDED_BY_LOCK(m_touchEventsLock); 129 139 #endif 140 141 #if ENABLE(MOMENTUM_EVENT_DISPATCHER) 142 std::unique_ptr<MomentumEventDispatcher> m_momentumEventDispatcher; 143 #endif 130 144 }; 131 145 -
branches/safari-612.4.2.1-branch/Source/WebKit/WebProcess/WebPage/EventDispatcher.messages.in
r286716 r286717 33 33 DisplayWasRefreshed(uint32_t displayID, struct WebCore::DisplayUpdate update, bool sendToMainThread) 34 34 #endif 35 36 #if ENABLE(MOMENTUM_EVENT_DISPATCHER) 37 SetScrollingAccelerationCurve(WebCore::PageIdentifier pageID, std::optional<WebKit::ScrollingAccelerationCurve> curve) 38 #endif 39 PageScreenDidChange(WebCore::PageIdentifier pageID, uint32_t displayID) 35 40 } -
branches/safari-612.4.2.1-branch/Source/WebKit/WebProcess/WebPage/WebPage.cpp
r286716 r286717 3058 3058 } 3059 3059 3060 bool WebPage::wheelEvent(const WebWheelEvent& wheelEvent, OptionSet<WheelEventProcessingSteps> processingSteps )3060 bool WebPage::wheelEvent(const WebWheelEvent& wheelEvent, OptionSet<WheelEventProcessingSteps> processingSteps, EventDispatcher::WheelEventOrigin wheelEventOrigin) 3061 3061 { 3062 3062 m_userActivity.impulse(); … … 3066 3066 bool handled = handleWheelEvent(wheelEvent, m_page.get(), processingSteps); 3067 3067 3068 if (processingSteps.contains(WheelEventProcessingSteps::MainThreadForScrolling) )3068 if (processingSteps.contains(WheelEventProcessingSteps::MainThreadForScrolling) && wheelEventOrigin == EventDispatcher::WheelEventOrigin::UIProcess) 3069 3069 send(Messages::WebPageProxy::DidReceiveEvent(static_cast<uint32_t>(wheelEvent.type()), handled)); 3070 3070 … … 3080 3080 bool isCancelable = true; 3081 3081 #endif 3082 bool handled = this->wheelEvent(wheelEvent, { isCancelable ? WheelEventProcessingSteps::MainThreadForBlockingDOMEventDispatch : WheelEventProcessingSteps::MainThreadForNonBlockingDOMEventDispatch } );3082 bool handled = this->wheelEvent(wheelEvent, { isCancelable ? WheelEventProcessingSteps::MainThreadForBlockingDOMEventDispatch : WheelEventProcessingSteps::MainThreadForNonBlockingDOMEventDispatch }, EventDispatcher::WheelEventOrigin::UIProcess); 3083 3083 completionHandler(handled); 3084 3084 } -
branches/safari-612.4.2.1-branch/Source/WebKit/WebProcess/WebPage/WebPage.h
r286716 r286717 39 39 #include "DrawingAreaInfo.h" 40 40 #include "EditingRange.h" 41 #include "EventDispatcher.h" 41 42 #include "FocusedElementInformation.h" 42 43 #include "GeolocationIdentifier.h" … … 1063 1064 #endif 1064 1065 1065 bool wheelEvent(const WebWheelEvent&, OptionSet<WebCore::WheelEventProcessingSteps> );1066 bool wheelEvent(const WebWheelEvent&, OptionSet<WebCore::WheelEventProcessingSteps>, EventDispatcher::WheelEventOrigin); 1066 1067 1067 1068 void wheelEventHandlersChanged(bool);
Note:
See TracChangeset
for help on using the changeset viewer.