Diff
Modified: releases/WebKitGTK/webkit-2.28/Source/WebCore/ChangeLog (264074 => 264075)
--- releases/WebKitGTK/webkit-2.28/Source/WebCore/ChangeLog 2020-07-08 10:06:16 UTC (rev 264074)
+++ releases/WebKitGTK/webkit-2.28/Source/WebCore/ChangeLog 2020-07-08 10:06:31 UTC (rev 264075)
@@ -1,3 +1,47 @@
+2020-03-27 Chris Lord <[email protected]>
+
+ [GTK][WPE] Enable kinetic scrolling with async rendering
+ https://bugs.webkit.org/show_bug.cgi?id=209230
+
+ Reviewed by Žan Doberšek.
+
+ Refactor ScrollAnimationKinetic so that it no longer depends on
+ ScrollableArea, uses RunLoop::Timer and is responsible for tracking
+ the history of scroll events. This allows it to be used in
+ ScrollingTree*ScrollingNodeNicosia to provide kinetic scrolling when
+ async scrolling is enabled, on GTK and WPE.
+
+ No new tests, this just enables existing functionality in more situations.
+
+ * page/scrolling/ScrollingTreeScrollingNode.cpp:
+ (WebCore::ScrollingTreeScrollingNode::scrollTo):
+ * page/scrolling/ScrollingTreeScrollingNode.h:
+ * page/scrolling/nicosia/ScrollingTreeFrameScrollingNodeNicosia.cpp:
+ (WebCore::ScrollingTreeFrameScrollingNodeNicosia::ScrollingTreeFrameScrollingNodeNicosia):
+ (WebCore::ScrollingTreeFrameScrollingNodeNicosia::handleWheelEvent):
+ (WebCore::ScrollingTreeFrameScrollingNodeNicosia::stopScrollAnimations):
+ * page/scrolling/nicosia/ScrollingTreeFrameScrollingNodeNicosia.h:
+ * page/scrolling/nicosia/ScrollingTreeOverflowScrollingNodeNicosia.cpp:
+ (WebCore::ScrollingTreeOverflowScrollingNodeNicosia::ScrollingTreeOverflowScrollingNodeNicosia):
+ (WebCore::ScrollingTreeOverflowScrollingNodeNicosia::handleWheelEvent):
+ (WebCore::ScrollingTreeOverflowScrollingNodeNicosia::stopScrollAnimations):
+ * page/scrolling/nicosia/ScrollingTreeOverflowScrollingNodeNicosia.h:
+ * platform/ScrollAnimationKinetic.cpp:
+ (WebCore::ScrollAnimationKinetic::ScrollAnimationKinetic):
+ (WebCore::ScrollAnimationKinetic::appendToScrollHistory):
+ (WebCore::ScrollAnimationKinetic::clearScrollHistory):
+ (WebCore::ScrollAnimationKinetic::computeVelocity):
+ (WebCore::ScrollAnimationKinetic::start):
+ * platform/ScrollAnimationKinetic.h:
+ * platform/generic/ScrollAnimatorGeneric.cpp:
+ (WebCore::ScrollAnimatorGeneric::ScrollAnimatorGeneric):
+ (WebCore::ScrollAnimatorGeneric::scrollToOffsetWithoutAnimation):
+ (WebCore::ScrollAnimatorGeneric::handleWheelEvent):
+ (WebCore::ScrollAnimatorGeneric::willEndLiveResize):
+ (WebCore::ScrollAnimatorGeneric::didAddVerticalScrollbar):
+ (WebCore::ScrollAnimatorGeneric::didAddHorizontalScrollbar):
+ * platform/generic/ScrollAnimatorGeneric.h:
+
2020-04-09 Antti Koivisto <[email protected]>
Use more WeakPtr in RenderTreeBuilder::FirstLetter
Modified: releases/WebKitGTK/webkit-2.28/Source/WebCore/page/scrolling/ScrollingTreeScrollingNode.cpp (264074 => 264075)
--- releases/WebKitGTK/webkit-2.28/Source/WebCore/page/scrolling/ScrollingTreeScrollingNode.cpp 2020-07-08 10:06:16 UTC (rev 264074)
+++ releases/WebKitGTK/webkit-2.28/Source/WebCore/page/scrolling/ScrollingTreeScrollingNode.cpp 2020-07-08 10:06:31 UTC (rev 264075)
@@ -164,6 +164,9 @@
if (position == m_currentScrollPosition)
return;
+ if (scrollType == ScrollType::Programmatic)
+ stopScrollAnimations();
+
scrollingTree().setIsHandlingProgrammaticScroll(scrollType == ScrollType::Programmatic);
m_currentScrollPosition = adjustedScrollPosition(position, clamp);
Modified: releases/WebKitGTK/webkit-2.28/Source/WebCore/page/scrolling/ScrollingTreeScrollingNode.h (264074 => 264075)
--- releases/WebKitGTK/webkit-2.28/Source/WebCore/page/scrolling/ScrollingTreeScrollingNode.h 2020-07-08 10:06:16 UTC (rev 264074)
+++ releases/WebKitGTK/webkit-2.28/Source/WebCore/page/scrolling/ScrollingTreeScrollingNode.h 2020-07-08 10:06:31 UTC (rev 264075)
@@ -63,6 +63,8 @@
void scrollTo(const FloatPoint&, ScrollType = ScrollType::User, ScrollClamping = ScrollClamping::Clamped);
void scrollBy(const FloatSize&, ScrollClamping = ScrollClamping::Clamped);
+ virtual void stopScrollAnimations() { };
+
void wasScrolledByDelegatedScrolling(const FloatPoint& position, Optional<FloatRect> overrideLayoutViewport = { }, ScrollingLayerPositionAction = ScrollingLayerPositionAction::Sync);
const FloatSize& scrollableAreaSize() const { return m_scrollableAreaSize; }
@@ -70,6 +72,8 @@
bool horizontalScrollbarHiddenByStyle() const { return m_scrollableAreaParameters.horizontalScrollbarHiddenByStyle; }
bool verticalScrollbarHiddenByStyle() const { return m_scrollableAreaParameters.verticalScrollbarHiddenByStyle; }
+ bool canHaveHorizontalScrollbar() const { return m_scrollableAreaParameters.horizontalScrollbarMode != ScrollbarAlwaysOff; }
+ bool canHaveVerticalScrollbar() const { return m_scrollableAreaParameters.verticalScrollbarMode != ScrollbarAlwaysOff; }
bool canHaveScrollbars() const { return m_scrollableAreaParameters.horizontalScrollbarMode != ScrollbarAlwaysOff || m_scrollableAreaParameters.verticalScrollbarMode != ScrollbarAlwaysOff; }
#if ENABLE(CSS_SCROLL_SNAP)
Modified: releases/WebKitGTK/webkit-2.28/Source/WebCore/page/scrolling/nicosia/ScrollingTreeFrameScrollingNodeNicosia.cpp (264074 => 264075)
--- releases/WebKitGTK/webkit-2.28/Source/WebCore/page/scrolling/nicosia/ScrollingTreeFrameScrollingNodeNicosia.cpp 2020-07-08 10:06:16 UTC (rev 264074)
+++ releases/WebKitGTK/webkit-2.28/Source/WebCore/page/scrolling/nicosia/ScrollingTreeFrameScrollingNodeNicosia.cpp 2020-07-08 10:06:31 UTC (rev 264075)
@@ -37,6 +37,10 @@
#include "ScrollingStateFrameScrollingNode.h"
#include "ScrollingTree.h"
+#if ENABLE(KINETIC_SCROLLING)
+#include "ScrollAnimationKinetic.h"
+#endif
+
namespace WebCore {
Ref<ScrollingTreeFrameScrollingNode> ScrollingTreeFrameScrollingNodeNicosia::create(ScrollingTree& scrollingTree, ScrollingNodeType nodeType, ScrollingNodeID nodeID)
@@ -47,6 +51,20 @@
ScrollingTreeFrameScrollingNodeNicosia::ScrollingTreeFrameScrollingNodeNicosia(ScrollingTree& scrollingTree, ScrollingNodeType nodeType, ScrollingNodeID nodeID)
: ScrollingTreeFrameScrollingNode(scrollingTree, nodeType, nodeID)
{
+#if ENABLE(KINETIC_SCROLLING)
+ m_kineticAnimation = makeUnique<ScrollAnimationKinetic>(
+ [this]() -> ScrollAnimationKinetic::ScrollExtents {
+ return { IntPoint(minimumScrollPosition()), IntPoint(maximumScrollPosition()) };
+ },
+ [this](FloatPoint&& position) {
+ auto* scrollLayer = static_cast<Nicosia::PlatformLayer*>(scrolledContentsLayer());
+ ASSERT(scrollLayer);
+ auto& compositionLayer = downcast<Nicosia::CompositionLayer>(*scrollLayer);
+
+ auto updateScope = compositionLayer.createUpdateScope();
+ scrollTo(position);
+ });
+#endif
}
ScrollingTreeFrameScrollingNodeNicosia::~ScrollingTreeFrameScrollingNodeNicosia() = default;
@@ -108,8 +126,24 @@
auto updateScope = compositionLayer.createUpdateScope();
scrollBy({ -wheelEvent.deltaX(), -wheelEvent.deltaY() });
+
+#if ENABLE(KINETIC_SCROLLING)
+ m_kineticAnimation->appendToScrollHistory(wheelEvent);
+#endif
}
+#if ENABLE(KINETIC_SCROLLING)
+ m_kineticAnimation->stop();
+ if (wheelEvent.isEndOfNonMomentumScroll()) {
+ m_kineticAnimation->start(currentScrollPosition(), m_kineticAnimation->computeVelocity(), canHaveHorizontalScrollbar(), canHaveVerticalScrollbar());
+ m_kineticAnimation->clearScrollHistory();
+ }
+ if (wheelEvent.isTransitioningToMomentumScroll()) {
+ m_kineticAnimation->start(currentScrollPosition(), wheelEvent.swipeVelocity(), canHaveHorizontalScrollbar(), canHaveVerticalScrollbar());
+ m_kineticAnimation->clearScrollHistory();
+ }
+#endif
+
scrollingTree().setOrClearLatchedNode(wheelEvent, scrollingNodeID());
// FIXME: This needs to return whether the event was handled.
@@ -116,6 +150,14 @@
return ScrollingEventResult::DidHandleEvent;
}
+void ScrollingTreeFrameScrollingNodeNicosia::stopScrollAnimations()
+{
+#if ENABLE(KINETIC_SCROLLING)
+ m_kineticAnimation->stop();
+ m_kineticAnimation->clearScrollHistory();
+#endif
+}
+
FloatPoint ScrollingTreeFrameScrollingNodeNicosia::adjustedScrollPosition(const FloatPoint& position, ScrollClamping clamping) const
{
FloatPoint scrollPosition(roundf(position.x()), roundf(position.y()));
Modified: releases/WebKitGTK/webkit-2.28/Source/WebCore/page/scrolling/nicosia/ScrollingTreeFrameScrollingNodeNicosia.h (264074 => 264075)
--- releases/WebKitGTK/webkit-2.28/Source/WebCore/page/scrolling/nicosia/ScrollingTreeFrameScrollingNodeNicosia.h 2020-07-08 10:06:16 UTC (rev 264074)
+++ releases/WebKitGTK/webkit-2.28/Source/WebCore/page/scrolling/nicosia/ScrollingTreeFrameScrollingNodeNicosia.h 2020-07-08 10:06:31 UTC (rev 264075)
@@ -39,6 +39,7 @@
}
namespace WebCore {
+class ScrollAnimationKinetic;
class ScrollingTreeFrameScrollingNodeNicosia final : public ScrollingTreeFrameScrollingNode {
public:
@@ -53,6 +54,8 @@
ScrollingEventResult handleWheelEvent(const PlatformWheelEvent&) override;
+ void stopScrollAnimations() override;
+
FloatPoint adjustedScrollPosition(const FloatPoint&, ScrollClamping) const override;
void currentScrollPositionChanged() override;
@@ -66,6 +69,10 @@
RefPtr<Nicosia::CompositionLayer> m_contentShadowLayer;
RefPtr<Nicosia::CompositionLayer> m_headerLayer;
RefPtr<Nicosia::CompositionLayer> m_footerLayer;
+
+#if ENABLE(KINETIC_SCROLLING)
+ std::unique_ptr<ScrollAnimationKinetic> m_kineticAnimation;
+#endif
};
} // namespace WebCore
Modified: releases/WebKitGTK/webkit-2.28/Source/WebCore/page/scrolling/nicosia/ScrollingTreeOverflowScrollingNodeNicosia.cpp (264074 => 264075)
--- releases/WebKitGTK/webkit-2.28/Source/WebCore/page/scrolling/nicosia/ScrollingTreeOverflowScrollingNodeNicosia.cpp 2020-07-08 10:06:16 UTC (rev 264074)
+++ releases/WebKitGTK/webkit-2.28/Source/WebCore/page/scrolling/nicosia/ScrollingTreeOverflowScrollingNodeNicosia.cpp 2020-07-08 10:06:31 UTC (rev 264075)
@@ -32,6 +32,9 @@
#if ENABLE(ASYNC_SCROLLING) && USE(NICOSIA)
#include "NicosiaPlatformLayer.h"
+#if ENABLE(KINETIC_SCROLLING)
+#include "ScrollAnimationKinetic.h"
+#endif
#include "ScrollingStateOverflowScrollingNode.h"
#include "ScrollingTree.h"
@@ -45,6 +48,20 @@
ScrollingTreeOverflowScrollingNodeNicosia::ScrollingTreeOverflowScrollingNodeNicosia(ScrollingTree& scrollingTree, ScrollingNodeID nodeID)
: ScrollingTreeOverflowScrollingNode(scrollingTree, nodeID)
{
+#if ENABLE(KINETIC_SCROLLING)
+ m_kineticAnimation = makeUnique<ScrollAnimationKinetic>(
+ [this]() -> ScrollAnimationKinetic::ScrollExtents {
+ return { IntPoint(minimumScrollPosition()), IntPoint(maximumScrollPosition()) };
+ },
+ [this](FloatPoint&& position) {
+ auto* scrollLayer = static_cast<Nicosia::PlatformLayer*>(scrolledContentsLayer());
+ ASSERT(scrollLayer);
+ auto& compositionLayer = downcast<Nicosia::CompositionLayer>(*scrollLayer);
+
+ auto updateScope = compositionLayer.createUpdateScope();
+ scrollTo(position);
+ });
+#endif
}
ScrollingTreeOverflowScrollingNodeNicosia::~ScrollingTreeOverflowScrollingNodeNicosia() = default;
@@ -94,13 +111,37 @@
auto updateScope = compositionLayer.createUpdateScope();
scrollBy({ -wheelEvent.deltaX(), -wheelEvent.deltaY() });
+
+#if ENABLE(KINETIC_SCROLLING)
+ m_kineticAnimation->appendToScrollHistory(wheelEvent);
+#endif
}
+#if ENABLE(KINETIC_SCROLLING)
+ m_kineticAnimation->stop();
+ if (wheelEvent.isEndOfNonMomentumScroll()) {
+ m_kineticAnimation->start(currentScrollPosition(), m_kineticAnimation->computeVelocity(), canHaveHorizontalScrollbar(), canHaveVerticalScrollbar());
+ m_kineticAnimation->clearScrollHistory();
+ }
+ if (wheelEvent.isTransitioningToMomentumScroll()) {
+ m_kineticAnimation->start(currentScrollPosition(), wheelEvent.swipeVelocity(), canHaveHorizontalScrollbar(), canHaveVerticalScrollbar());
+ m_kineticAnimation->clearScrollHistory();
+ }
+#endif
+
scrollingTree().setOrClearLatchedNode(wheelEvent, scrollingNodeID());
return ScrollingEventResult::DidHandleEvent;
}
+void ScrollingTreeOverflowScrollingNodeNicosia::stopScrollAnimations()
+{
+#if ENABLE(KINETIC_SCROLLING)
+ m_kineticAnimation->stop();
+ m_kineticAnimation->clearScrollHistory();
+#endif
+}
+
} // namespace WebCore
#endif // ENABLE(ASYNC_SCROLLING) && USE(NICOSIA)
Modified: releases/WebKitGTK/webkit-2.28/Source/WebCore/page/scrolling/nicosia/ScrollingTreeOverflowScrollingNodeNicosia.h (264074 => 264075)
--- releases/WebKitGTK/webkit-2.28/Source/WebCore/page/scrolling/nicosia/ScrollingTreeOverflowScrollingNodeNicosia.h 2020-07-08 10:06:16 UTC (rev 264074)
+++ releases/WebKitGTK/webkit-2.28/Source/WebCore/page/scrolling/nicosia/ScrollingTreeOverflowScrollingNodeNicosia.h 2020-07-08 10:06:31 UTC (rev 264075)
@@ -33,6 +33,7 @@
#include "ScrollingTreeOverflowScrollingNode.h"
namespace WebCore {
+class ScrollAnimationKinetic;
class ScrollingTreeOverflowScrollingNodeNicosia final : public ScrollingTreeOverflowScrollingNode {
public:
@@ -49,6 +50,12 @@
void repositionScrollingLayers() override;
ScrollingEventResult handleWheelEvent(const PlatformWheelEvent&) override;
+
+ void stopScrollAnimations() override;
+
+#if ENABLE(KINETIC_SCROLLING)
+ std::unique_ptr<ScrollAnimationKinetic> m_kineticAnimation;
+#endif
};
} // namespace WebCore
Modified: releases/WebKitGTK/webkit-2.28/Source/WebCore/platform/ScrollAnimationKinetic.cpp (264074 => 264075)
--- releases/WebKitGTK/webkit-2.28/Source/WebCore/platform/ScrollAnimationKinetic.cpp 2020-07-08 10:06:16 UTC (rev 264074)
+++ releases/WebKitGTK/webkit-2.28/Source/WebCore/platform/ScrollAnimationKinetic.cpp 2020-07-08 10:06:31 UTC (rev 264075)
@@ -26,7 +26,8 @@
#include "config.h"
#include "ScrollAnimationKinetic.h"
-#include "ScrollableArea.h"
+#include "PlatformWheelEvent.h"
+#include <wtf/glib/RunLoopSourcePriority.h>
/*
* PerAxisData is a port of GtkKineticScrolling as of GTK+ 3.20,
@@ -65,6 +66,7 @@
static const double frameRate = 60;
static const Seconds tickTime = 1_s / frameRate;
static const Seconds minimumTimerInterval { 1_ms };
+static const Seconds scrollCaptureThreshold { 150_ms };
namespace WebCore {
@@ -104,11 +106,12 @@
return m_velocity;
}
-ScrollAnimationKinetic::ScrollAnimationKinetic(ScrollableArea& scrollableArea, std::function<void(FloatPoint&&)>&& notifyPositionChangedFunction)
- : ScrollAnimation(scrollableArea)
+ScrollAnimationKinetic::ScrollAnimationKinetic(ScrollExtentsCallback&& scrollExtentsFunction, NotifyPositionChangedCallback&& notifyPositionChangedFunction)
+ : m_scrollExtentsFunction(WTFMove(scrollExtentsFunction))
, m_notifyPositionChangedFunction(WTFMove(notifyPositionChangedFunction))
- , m_animationTimer(*this, &ScrollAnimationKinetic::animationTimerFired)
+ , m_animationTimer(RunLoop::current(), this, &ScrollAnimationKinetic::animationTimerFired)
{
+ m_animationTimer.setPriority(WTF::RunLoopSourcePriority::DisplayRefreshMonitorTimer);
}
ScrollAnimationKinetic::~ScrollAnimationKinetic() = default;
@@ -120,6 +123,40 @@
m_verticalData = WTF::nullopt;
}
+void ScrollAnimationKinetic::appendToScrollHistory(const PlatformWheelEvent& event)
+{
+ m_scrollHistory.removeAllMatching([&event] (PlatformWheelEvent& otherEvent) -> bool {
+ return (event.timestamp() - otherEvent.timestamp()) > scrollCaptureThreshold;
+ });
+
+ m_scrollHistory.append(event);
+}
+
+void ScrollAnimationKinetic::clearScrollHistory()
+{
+ m_scrollHistory.clear();
+}
+
+FloatPoint ScrollAnimationKinetic::computeVelocity()
+{
+ if (m_scrollHistory.isEmpty())
+ return { };
+
+ auto first = m_scrollHistory[0].timestamp();
+ auto last = m_scrollHistory.rbegin()->timestamp();
+
+ if (last == first)
+ return { };
+
+ FloatPoint accumDelta;
+ for (const auto& scrollEvent : m_scrollHistory)
+ accumDelta += FloatPoint(scrollEvent.deltaX(), scrollEvent.deltaY());
+
+ m_scrollHistory.clear();
+
+ return FloatPoint(accumDelta.x() * -1 / (last - first).value(), accumDelta.y() * -1 / (last - first).value());
+}
+
void ScrollAnimationKinetic::start(const FloatPoint& initialPosition, const FloatPoint& velocity, bool mayHScroll, bool mayVScroll)
{
stop();
@@ -129,14 +166,15 @@
if (!velocity.x() && !velocity.y())
return;
+ auto extents = m_scrollExtentsFunction();
if (mayHScroll) {
- m_horizontalData = PerAxisData(m_scrollableArea.minimumScrollPosition().x(),
- m_scrollableArea.maximumScrollPosition().x(),
+ m_horizontalData = PerAxisData(extents.minimumScrollPosition.x(),
+ extents.maximumScrollPosition.x(),
initialPosition.x(), velocity.x());
}
if (mayVScroll) {
- m_verticalData = PerAxisData(m_scrollableArea.minimumScrollPosition().y(),
- m_scrollableArea.maximumScrollPosition().y(),
+ m_verticalData = PerAxisData(extents.minimumScrollPosition.y(),
+ extents.maximumScrollPosition.y(),
initialPosition.y(), velocity.y());
}
Modified: releases/WebKitGTK/webkit-2.28/Source/WebCore/platform/ScrollAnimationKinetic.h (264074 => 264075)
--- releases/WebKitGTK/webkit-2.28/Source/WebCore/platform/ScrollAnimationKinetic.h 2020-07-08 10:06:16 UTC (rev 264074)
+++ releases/WebKitGTK/webkit-2.28/Source/WebCore/platform/ScrollAnimationKinetic.h 2020-07-08 10:06:31 UTC (rev 264075)
@@ -27,15 +27,16 @@
#include "FloatPoint.h"
#include "ScrollAnimation.h"
-#include "Timer.h"
#include <wtf/Optional.h>
+#include <wtf/RunLoop.h>
namespace WebCore {
-class ScrollableArea;
+class PlatformWheelEvent;
-class ScrollAnimationKinetic final: public ScrollAnimation {
+class ScrollAnimationKinetic final {
+ WTF_MAKE_FAST_ALLOCATED;
private:
class PerAxisData {
public:
@@ -58,23 +59,37 @@
};
public:
- ScrollAnimationKinetic(ScrollableArea&, std::function<void(FloatPoint&&)>&& notifyPositionChangedFunction);
+ struct ScrollExtents {
+ IntPoint minimumScrollPosition;
+ IntPoint maximumScrollPosition;
+ };
+
+ using ScrollExtentsCallback = WTF::Function<ScrollExtents(void)>;
+ using NotifyPositionChangedCallback = WTF::Function<void(FloatPoint&&)>;
+
+ ScrollAnimationKinetic(ScrollExtentsCallback&&, NotifyPositionChangedCallback&&);
virtual ~ScrollAnimationKinetic();
+ void appendToScrollHistory(const PlatformWheelEvent&);
+ void clearScrollHistory();
+ FloatPoint computeVelocity();
+
void start(const FloatPoint& initialPosition, const FloatPoint& velocity, bool mayHScroll, bool mayVScroll);
+ void stop();
private:
- void stop() override;
void animationTimerFired();
- std::function<void(FloatPoint&&)> m_notifyPositionChangedFunction;
+ ScrollExtentsCallback m_scrollExtentsFunction;
+ NotifyPositionChangedCallback m_notifyPositionChangedFunction;
Optional<PerAxisData> m_horizontalData;
Optional<PerAxisData> m_verticalData;
MonotonicTime m_startTime;
- Timer m_animationTimer;
+ RunLoop::Timer<ScrollAnimationKinetic> m_animationTimer;
FloatPoint m_position;
+ Vector<PlatformWheelEvent> m_scrollHistory;
};
} // namespace WebCore
Modified: releases/WebKitGTK/webkit-2.28/Source/WebCore/platform/generic/ScrollAnimatorGeneric.cpp (264074 => 264075)
--- releases/WebKitGTK/webkit-2.28/Source/WebCore/platform/generic/ScrollAnimatorGeneric.cpp 2020-07-08 10:06:16 UTC (rev 264074)
+++ releases/WebKitGTK/webkit-2.28/Source/WebCore/platform/generic/ScrollAnimatorGeneric.cpp 2020-07-08 10:06:31 UTC (rev 264075)
@@ -40,7 +40,6 @@
static const Seconds overflowScrollbarsAnimationDuration { 1_s };
static const Seconds overflowScrollbarsAnimationHideDelay { 2_s };
-static const Seconds scrollCaptureThreshold { 150_ms };
std::unique_ptr<ScrollAnimator> ScrollAnimator::create(ScrollableArea& scrollableArea)
{
@@ -51,13 +50,17 @@
: ScrollAnimator(scrollableArea)
, m_overlayScrollbarAnimationTimer(*this, &ScrollAnimatorGeneric::overlayScrollbarAnimationTimerFired)
{
- m_kineticAnimation = makeUnique<ScrollAnimationKinetic>(m_scrollableArea, [this](FloatPoint&& position) {
+ m_kineticAnimation = makeUnique<ScrollAnimationKinetic>(
+ [this]() -> ScrollAnimationKinetic::ScrollExtents {
+ return { m_scrollableArea.minimumScrollPosition(), m_scrollableArea.maximumScrollPosition() };
+ },
+ [this](FloatPoint&& position) {
#if ENABLE(SMOOTH_SCROLLING)
- if (m_smoothAnimation)
- m_smoothAnimation->setCurrentPosition(position);
+ if (m_smoothAnimation)
+ m_smoothAnimation->setCurrentPosition(position);
#endif
- updatePosition(WTFMove(position));
- });
+ updatePosition(WTFMove(position));
+ });
#if ENABLE(SMOOTH_SCROLLING)
if (scrollableArea.scrollAnimatorEnabled())
@@ -94,7 +97,7 @@
{
FloatPoint position = ScrollableArea::scrollPositionFromOffset(offset, toFloatSize(m_scrollableArea.scrollOrigin()));
m_kineticAnimation->stop();
- m_scrollHistory.clear();
+ m_kineticAnimation->clearScrollHistory();
#if ENABLE(SMOOTH_SCROLLING)
if (m_smoothAnimation)
@@ -104,56 +107,30 @@
updatePosition(WTFMove(position));
}
-FloatPoint ScrollAnimatorGeneric::computeVelocity()
-{
- if (m_scrollHistory.isEmpty())
- return { };
-
- auto first = m_scrollHistory[0].timestamp();
- auto last = m_scrollHistory.rbegin()->timestamp();
-
- if (last == first)
- return { };
-
- FloatPoint accumDelta;
- for (const auto& scrollEvent : m_scrollHistory)
- accumDelta += FloatPoint(scrollEvent.deltaX(), scrollEvent.deltaY());
-
- m_scrollHistory.clear();
-
- return FloatPoint(accumDelta.x() * -1 / (last - first).value(), accumDelta.y() * -1 / (last - first).value());
-}
-
bool ScrollAnimatorGeneric::handleWheelEvent(const PlatformWheelEvent& event)
{
m_kineticAnimation->stop();
- m_scrollHistory.removeAllMatching([&event] (PlatformWheelEvent& otherEvent) -> bool {
- return (event.timestamp() - otherEvent.timestamp()) > scrollCaptureThreshold;
- });
-
#if ENABLE(KINETIC_SCROLLING)
if (event.isEndOfNonMomentumScroll()) {
// We don't need to add the event to the history as its delta will be (0, 0).
- static_cast<ScrollAnimationKinetic*>(m_kineticAnimation.get())->start(m_currentPosition, computeVelocity(), m_scrollableArea.horizontalScrollbar(), m_scrollableArea.verticalScrollbar());
+ m_kineticAnimation->start(m_currentPosition, m_kineticAnimation->computeVelocity(), m_scrollableArea.horizontalScrollbar(), m_scrollableArea.verticalScrollbar());
return true;
}
if (event.isTransitioningToMomentumScroll()) {
- m_scrollHistory.clear();
- static_cast<ScrollAnimationKinetic*>(m_kineticAnimation.get())->start(m_currentPosition, event.swipeVelocity(), m_scrollableArea.horizontalScrollbar(), m_scrollableArea.verticalScrollbar());
+ m_kineticAnimation->clearScrollHistory();
+ m_kineticAnimation->start(m_currentPosition, event.swipeVelocity(), m_scrollableArea.horizontalScrollbar(), m_scrollableArea.verticalScrollbar());
return true;
}
+
+ m_kineticAnimation->appendToScrollHistory(event);
#endif
- m_scrollHistory.append(event);
-
return ScrollAnimator::handleWheelEvent(event);
}
void ScrollAnimatorGeneric::willEndLiveResize()
{
- m_kineticAnimation->updateVisibleLengths();
-
#if ENABLE(SMOOTH_SCROLLING)
if (m_smoothAnimation)
m_smoothAnimation->updateVisibleLengths();
@@ -169,8 +146,6 @@
void ScrollAnimatorGeneric::didAddVerticalScrollbar(Scrollbar* scrollbar)
{
- m_kineticAnimation->updateVisibleLengths();
-
#if ENABLE(SMOOTH_SCROLLING)
if (m_smoothAnimation)
m_smoothAnimation->updateVisibleLengths();
@@ -186,8 +161,6 @@
void ScrollAnimatorGeneric::didAddHorizontalScrollbar(Scrollbar* scrollbar)
{
- m_kineticAnimation->updateVisibleLengths();
-
#if ENABLE(SMOOTH_SCROLLING)
if (m_smoothAnimation)
m_smoothAnimation->updateVisibleLengths();
Modified: releases/WebKitGTK/webkit-2.28/Source/WebCore/platform/generic/ScrollAnimatorGeneric.h (264074 => 264075)
--- releases/WebKitGTK/webkit-2.28/Source/WebCore/platform/generic/ScrollAnimatorGeneric.h 2020-07-08 10:06:16 UTC (rev 264074)
+++ releases/WebKitGTK/webkit-2.28/Source/WebCore/platform/generic/ScrollAnimatorGeneric.h 2020-07-08 10:06:31 UTC (rev 264075)
@@ -36,6 +36,7 @@
namespace WebCore {
class ScrollAnimation;
+class ScrollAnimationKinetic;
class ScrollAnimatorGeneric final : public ScrollAnimator {
public:
@@ -71,15 +72,12 @@
void hideOverlayScrollbars();
void updateOverlayScrollbarsOpacity();
- FloatPoint computeVelocity();
-
#if ENABLE(SMOOTH_SCROLLING)
void ensureSmoothScrollingAnimation();
std::unique_ptr<ScrollAnimation> m_smoothAnimation;
#endif
- std::unique_ptr<ScrollAnimation> m_kineticAnimation;
- Vector<PlatformWheelEvent> m_scrollHistory;
+ std::unique_ptr<ScrollAnimationKinetic> m_kineticAnimation;
Scrollbar* m_horizontalOverlayScrollbar { nullptr };
Scrollbar* m_verticalOverlayScrollbar { nullptr };
bool m_overlayScrollbarsLocked { false };
Modified: releases/WebKitGTK/webkit-2.28/Source/WebKit/ChangeLog (264074 => 264075)
--- releases/WebKitGTK/webkit-2.28/Source/WebKit/ChangeLog 2020-07-08 10:06:16 UTC (rev 264074)
+++ releases/WebKitGTK/webkit-2.28/Source/WebKit/ChangeLog 2020-07-08 10:06:31 UTC (rev 264075)
@@ -1,3 +1,33 @@
+2020-03-27 Chris Lord <[email protected]>
+
+ [GTK][WPE] Enable kinetic scrolling with async scrolling
+ https://bugs.webkit.org/show_bug.cgi?id=209230
+
+ Reviewed by Žan Doberšek.
+
+ Modify WPE mousewheel event delivery so that it includes the necessary
+ phases needed to infer press/release times and allow for kinetic
+ scrolling.
+
+ * Shared/NativeWebWheelEvent.h:
+ * Shared/WebEvent.h:
+ * Shared/WebWheelEvent.cpp:
+ (WebKit::WebWheelEvent::encode const):
+ (WebKit::WebWheelEvent::decode):
+ * Shared/libwpe/NativeWebWheelEventLibWPE.cpp:
+ (WebKit::NativeWebWheelEvent::NativeWebWheelEvent):
+ * Shared/libwpe/WebEventFactory.cpp:
+ (WebKit::WebEventFactory::createWebWheelEvent):
+ * Shared/libwpe/WebEventFactory.h:
+ * UIProcess/API/wpe/PageClientImpl.cpp:
+ (WebKit::PageClientImpl::doneWithTouchEvent):
+ * UIProcess/API/wpe/ScrollGestureController.cpp:
+ (WebKit::ScrollGestureController::handleEvent):
+ * UIProcess/API/wpe/ScrollGestureController.h:
+ (WebKit::ScrollGestureController::phase):
+ * UIProcess/API/wpe/WPEView.cpp:
+ (WKWPE::m_backend):
+
2020-03-26 Michael Catanzaro <[email protected]>
Syscall param sendmsg(msg.msg_iov[0]) points to uninitialised byte(s) in IPC::Connection::sendOutgoingMessage
Modified: releases/WebKitGTK/webkit-2.28/Source/WebKit/Shared/NativeWebWheelEvent.h (264074 => 264075)
--- releases/WebKitGTK/webkit-2.28/Source/WebKit/Shared/NativeWebWheelEvent.h 2020-07-08 10:06:16 UTC (rev 264074)
+++ releases/WebKitGTK/webkit-2.28/Source/WebKit/Shared/NativeWebWheelEvent.h 2020-07-08 10:06:31 UTC (rev 264075)
@@ -57,7 +57,7 @@
NativeWebWheelEvent(GdkEvent*);
NativeWebWheelEvent(GdkEvent*, WebWheelEvent::Phase, WebWheelEvent::Phase momentumPhase);
#elif USE(LIBWPE)
- NativeWebWheelEvent(struct wpe_input_axis_event*, float deviceScaleFactor);
+ NativeWebWheelEvent(struct wpe_input_axis_event*, float deviceScaleFactor, WebWheelEvent::Phase, WebWheelEvent::Phase momentumPhase);
#elif PLATFORM(WIN)
NativeWebWheelEvent(HWND, UINT message, WPARAM, LPARAM);
#endif
Modified: releases/WebKitGTK/webkit-2.28/Source/WebKit/Shared/WebEvent.h (264074 => 264075)
--- releases/WebKitGTK/webkit-2.28/Source/WebKit/Shared/WebEvent.h 2020-07-08 10:06:16 UTC (rev 264074)
+++ releases/WebKitGTK/webkit-2.28/Source/WebKit/Shared/WebEvent.h 2020-07-08 10:06:31 UTC (rev 264075)
@@ -205,7 +205,7 @@
WebWheelEvent(Type, const WebCore::IntPoint& position, const WebCore::IntPoint& globalPosition, const WebCore::FloatSize& delta, const WebCore::FloatSize& wheelTicks, Granularity, OptionSet<Modifier>, WallTime timestamp);
#if PLATFORM(COCOA)
WebWheelEvent(Type, const WebCore::IntPoint& position, const WebCore::IntPoint& globalPosition, const WebCore::FloatSize& delta, const WebCore::FloatSize& wheelTicks, Granularity, bool directionInvertedFromDevice, Phase, Phase momentumPhase, bool hasPreciseScrollingDeltas, uint32_t scrollCount, const WebCore::FloatSize& unacceleratedScrollingDelta, OptionSet<Modifier>, WallTime timestamp);
-#elif PLATFORM(GTK)
+#elif PLATFORM(GTK) || PLATFORM(WPE)
WebWheelEvent(Type, const WebCore::IntPoint& position, const WebCore::IntPoint& globalPosition, const WebCore::FloatSize& delta, const WebCore::FloatSize& wheelTicks, Phase, Phase momentumPhase, Granularity, OptionSet<Modifier>, WallTime timestamp);
#endif
Modified: releases/WebKitGTK/webkit-2.28/Source/WebKit/Shared/WebWheelEvent.cpp (264074 => 264075)
--- releases/WebKitGTK/webkit-2.28/Source/WebKit/Shared/WebWheelEvent.cpp 2020-07-08 10:06:16 UTC (rev 264074)
+++ releases/WebKitGTK/webkit-2.28/Source/WebKit/Shared/WebWheelEvent.cpp 2020-07-08 10:06:31 UTC (rev 264075)
@@ -65,7 +65,7 @@
{
ASSERT(isWheelEventType(type));
}
-#elif PLATFORM(GTK)
+#elif PLATFORM(GTK) || PLATFORM(WPE)
WebWheelEvent::WebWheelEvent(Type type, const IntPoint& position, const IntPoint& globalPosition, const FloatSize& delta, const FloatSize& wheelTicks, Phase phase, Phase momentumPhase, Granularity granularity, OptionSet<Modifier> modifiers, WallTime timestamp)
: WebEvent(type, modifiers, timestamp)
, m_position(position)
@@ -91,7 +91,7 @@
encoder << m_wheelTicks;
encoder << m_granularity;
encoder << m_directionInvertedFromDevice;
-#if PLATFORM(COCOA) || PLATFORM(GTK)
+#if PLATFORM(COCOA) || PLATFORM(GTK) || PLATFORM(WPE)
encoder << m_phase;
encoder << m_momentumPhase;
#endif
@@ -118,7 +118,7 @@
return false;
if (!decoder.decode(t.m_directionInvertedFromDevice))
return false;
-#if PLATFORM(COCOA) || PLATFORM(GTK)
+#if PLATFORM(COCOA) || PLATFORM(GTK) || PLATFORM(WPE)
if (!decoder.decode(t.m_phase))
return false;
if (!decoder.decode(t.m_momentumPhase))
Modified: releases/WebKitGTK/webkit-2.28/Source/WebKit/Shared/libwpe/NativeWebWheelEventLibWPE.cpp (264074 => 264075)
--- releases/WebKitGTK/webkit-2.28/Source/WebKit/Shared/libwpe/NativeWebWheelEventLibWPE.cpp 2020-07-08 10:06:16 UTC (rev 264074)
+++ releases/WebKitGTK/webkit-2.28/Source/WebKit/Shared/libwpe/NativeWebWheelEventLibWPE.cpp 2020-07-08 10:06:31 UTC (rev 264075)
@@ -32,8 +32,8 @@
namespace WebKit {
-NativeWebWheelEvent::NativeWebWheelEvent(struct wpe_input_axis_event* event, float deviceScaleFactor)
- : WebWheelEvent(WebEventFactory::createWebWheelEvent(event, deviceScaleFactor))
+NativeWebWheelEvent::NativeWebWheelEvent(struct wpe_input_axis_event* event, float deviceScaleFactor, WebWheelEvent::Phase phase, WebWheelEvent::Phase momentumPhase)
+ : WebWheelEvent(WebEventFactory::createWebWheelEvent(event, deviceScaleFactor, phase, momentumPhase))
{
}
Modified: releases/WebKitGTK/webkit-2.28/Source/WebKit/Shared/libwpe/WebEventFactory.cpp (264074 => 264075)
--- releases/WebKitGTK/webkit-2.28/Source/WebKit/Shared/libwpe/WebEventFactory.cpp 2020-07-08 10:06:16 UTC (rev 264074)
+++ releases/WebKitGTK/webkit-2.28/Source/WebKit/Shared/libwpe/WebEventFactory.cpp 2020-07-08 10:06:31 UTC (rev 264075)
@@ -142,7 +142,7 @@
0, 0, 0, clickCount, modifiersForEventModifiers(event->modifiers), wallTimeForEventTime(event->time));
}
-WebWheelEvent WebEventFactory::createWebWheelEvent(struct wpe_input_axis_event* event, float deviceScaleFactor)
+WebWheelEvent WebEventFactory::createWebWheelEvent(struct wpe_input_axis_event* event, float deviceScaleFactor, WebWheelEvent::Phase phase, WebWheelEvent::Phase momentumPhase)
{
WebCore::IntPoint position(event->x, event->y);
position.scale(1 / deviceScaleFactor);
@@ -168,7 +168,8 @@
}
return WebWheelEvent(WebEvent::Wheel, position, position,
- delta, wheelTicks, WebWheelEvent::ScrollByPixelWheelEvent,
+ delta, wheelTicks, phase, momentumPhase,
+ WebWheelEvent::ScrollByPixelWheelEvent,
OptionSet<WebEvent::Modifier> { }, wallTimeForEventTime(event->time));
}
#endif
@@ -200,7 +201,8 @@
};
return WebWheelEvent(WebEvent::Wheel, position, position,
- delta, wheelTicks, WebWheelEvent::ScrollByPixelWheelEvent,
+ delta, wheelTicks, phase, momentumPhase,
+ WebWheelEvent::ScrollByPixelWheelEvent,
OptionSet<WebEvent::Modifier> { }, wallTimeForEventTime(event->time));
}
Modified: releases/WebKitGTK/webkit-2.28/Source/WebKit/Shared/libwpe/WebEventFactory.h (264074 => 264075)
--- releases/WebKitGTK/webkit-2.28/Source/WebKit/Shared/libwpe/WebEventFactory.h 2020-07-08 10:06:16 UTC (rev 264074)
+++ releases/WebKitGTK/webkit-2.28/Source/WebKit/Shared/libwpe/WebEventFactory.h 2020-07-08 10:06:31 UTC (rev 264075)
@@ -40,7 +40,7 @@
public:
static WebKeyboardEvent createWebKeyboardEvent(struct wpe_input_keyboard_event*, const String&, bool handledByInputMethod, Optional<Vector<WebCore::CompositionUnderline>>&&, Optional<EditingRange>&&);
static WebMouseEvent createWebMouseEvent(struct wpe_input_pointer_event*, float deviceScaleFactor);
- static WebWheelEvent createWebWheelEvent(struct wpe_input_axis_event*, float deviceScaleFactor);
+ static WebWheelEvent createWebWheelEvent(struct wpe_input_axis_event*, float deviceScaleFactor, WebWheelEvent::Phase, WebWheelEvent::Phase momentumPhase);
#if ENABLE(TOUCH_EVENTS)
static WebTouchEvent createWebTouchEvent(struct wpe_input_touch_event*, float deviceScaleFactor);
#endif
Modified: releases/WebKitGTK/webkit-2.28/Source/WebKit/UIProcess/API/wpe/PageClientImpl.cpp (264074 => 264075)
--- releases/WebKitGTK/webkit-2.28/Source/WebKit/UIProcess/API/wpe/PageClientImpl.cpp 2020-07-08 10:06:16 UTC (rev 264074)
+++ releases/WebKitGTK/webkit-2.28/Source/WebKit/UIProcess/API/wpe/PageClientImpl.cpp 2020-07-08 10:06:31 UTC (rev 264075)
@@ -217,7 +217,7 @@
if (scrollGestureController.handleEvent(touchPoint)) {
struct wpe_input_axis_event* axisEvent = scrollGestureController.axisEvent();
if (axisEvent->type != wpe_input_axis_event_type_null)
- page.handleWheelEvent(WebKit::NativeWebWheelEvent(axisEvent, m_view.page().deviceScaleFactor()));
+ page.handleWheelEvent(WebKit::NativeWebWheelEvent(axisEvent, m_view.page().deviceScaleFactor(), WebWheelEvent::Phase::PhaseNone, WebWheelEvent::Phase::PhaseNone));
return;
}
Modified: releases/WebKitGTK/webkit-2.28/Source/WebKit/UIProcess/API/wpe/ScrollGestureController.cpp (264074 => 264075)
--- releases/WebKitGTK/webkit-2.28/Source/WebKit/UIProcess/API/wpe/ScrollGestureController.cpp 2020-07-08 10:06:16 UTC (rev 264074)
+++ releases/WebKitGTK/webkit-2.28/Source/WebKit/UIProcess/API/wpe/ScrollGestureController.cpp 2020-07-08 10:06:31 UTC (rev 264075)
@@ -69,6 +69,7 @@
#endif
m_offset.x = touchPoint->x;
m_offset.y = touchPoint->y;
+ m_phase = WebWheelEvent::Phase::PhaseChanged;
return true;
}
return false;
@@ -77,16 +78,20 @@
m_handling = false;
#if WPE_CHECK_VERSION(1, 5, 0)
m_axisEvent.base = {
- wpe_input_axis_event_type_null,
- 0, 0, 0, 0, 0, 0
+ m_axisEvent.base.type,
+ touchPoint->time, m_start.x, m_start.y,
+ 0, 0, 0
};
m_axisEvent.x_axis = m_axisEvent.y_axis = 0;
#else
m_axisEvent = {
- wpe_input_axis_event_type_null,
- 0, 0, 0, 0, 0, 0
+ m_axisEvent.type,
+ touchPoint->time, m_start.x, m_start.y,
+ 0, 0, 0
};
#endif
+ m_offset.x = m_offset.y = 0;
+ m_phase = WebWheelEvent::Phase::PhaseEnded;
return true;
}
return false;
Modified: releases/WebKitGTK/webkit-2.28/Source/WebKit/UIProcess/API/wpe/ScrollGestureController.h (264074 => 264075)
--- releases/WebKitGTK/webkit-2.28/Source/WebKit/UIProcess/API/wpe/ScrollGestureController.h 2020-07-08 10:06:16 UTC (rev 264074)
+++ releases/WebKitGTK/webkit-2.28/Source/WebKit/UIProcess/API/wpe/ScrollGestureController.h 2020-07-08 10:06:31 UTC (rev 264075)
@@ -25,6 +25,7 @@
#pragma once
+#include "WebEvent.h"
#include <wpe/wpe.h>
namespace WebKit {
@@ -43,6 +44,8 @@
#endif
}
+ WebWheelEvent::Phase phase() { return m_phase; }
+
bool isHandling() const { return m_handling; }
bool handleEvent(const struct wpe_input_touch_event_raw*);
@@ -64,6 +67,7 @@
#else
struct wpe_input_axis_event m_axisEvent;
#endif
+ WebWheelEvent::Phase m_phase { WebWheelEvent::Phase::PhaseNone };
};
} // namespace WebKit
Modified: releases/WebKitGTK/webkit-2.28/Source/WebKit/UIProcess/API/wpe/WPEView.cpp (264074 => 264075)
--- releases/WebKitGTK/webkit-2.28/Source/WebKit/UIProcess/API/wpe/WPEView.cpp 2020-07-08 10:06:16 UTC (rev 264074)
+++ releases/WebKitGTK/webkit-2.28/Source/WebKit/UIProcess/API/wpe/WPEView.cpp 2020-07-08 10:06:31 UTC (rev 264075)
@@ -161,7 +161,7 @@
[](void* data, struct wpe_input_axis_event* event)
{
auto& page = reinterpret_cast<View*>(data)->page();
- page.handleWheelEvent(WebKit::NativeWebWheelEvent(event, page.deviceScaleFactor()));
+ page.handleWheelEvent(WebKit::NativeWebWheelEvent(event, page.deviceScaleFactor(), WebWheelEvent::Phase::PhaseNone, WebWheelEvent::Phase::PhaseNone));
},
// handle_touch_event
[](void* data, struct wpe_input_touch_event* event)
@@ -175,9 +175,7 @@
if (scrollGestureController.isHandling()) {
const struct wpe_input_touch_event_raw* touchPoint = touchEvent.nativeFallbackTouchPoint();
if (touchPoint->type != wpe_input_touch_event_type_null && scrollGestureController.handleEvent(touchPoint)) {
- struct wpe_input_axis_event* axisEvent = scrollGestureController.axisEvent();
- if (axisEvent->type != wpe_input_axis_event_type_null)
- page.handleWheelEvent(WebKit::NativeWebWheelEvent(axisEvent, page.deviceScaleFactor()));
+ page.handleWheelEvent(WebKit::NativeWebWheelEvent(scrollGestureController.axisEvent(), page.deviceScaleFactor(), scrollGestureController.phase(), WebWheelEvent::Phase::PhaseNone));
return;
}
}