Title: [162755] trunk/Source/WebCore
- Revision
- 162755
- Author
- bfulg...@apple.com
- Date
- 2014-01-24 20:33:48 -0800 (Fri, 24 Jan 2014)
Log Message
Improve latching behavior for wheel events
https://bugs.webkit.org/show_bug.cgi?id=127386
<rdar://problem/12176858>
Reviewed by Simon Fraser.
* page/scrolling/ScrollingTree.cpp:
(WebCore::ScrollingTree::ScrollingTree): Initialize new values used for tracking
scroll latching state.
(WebCore::ScrollingTree::shouldHandleWheelEventSynchronously): Check for an existing
latched node and stay in fast scrolling mode if possible.
(WebCore::ScrollingTree::removeDestroyedNodes): Clear latched node if it's being removed.
(WebCore::ScrollingTree::latchedNode): Added
(WebCore::ScrollingTree::setLatchedNode): Added
(WebCore::ScrollingTree::clearLatchedNode): Added
* page/scrolling/ScrollingTree.h:
(WebCore::ScrollingTree::hasLatchedNode): Added
* page/scrolling/mac/ScrollingTreeScrollingNodeMac.mm:
(WebCore::shouldConsiderLatching): Added
(WebCore::ScrollingTreeScrollingNodeMac::handleWheelEvent): Determine latching state
based on wheel event state and position of mouse pointer in the document.
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (162754 => 162755)
--- trunk/Source/WebCore/ChangeLog 2014-01-25 03:38:35 UTC (rev 162754)
+++ trunk/Source/WebCore/ChangeLog 2014-01-25 04:33:48 UTC (rev 162755)
@@ -1,3 +1,27 @@
+2014-01-24 Brent Fulgham <bfulg...@apple.com>
+
+ Improve latching behavior for wheel events
+ https://bugs.webkit.org/show_bug.cgi?id=127386
+ <rdar://problem/12176858>
+
+ Reviewed by Simon Fraser.
+
+ * page/scrolling/ScrollingTree.cpp:
+ (WebCore::ScrollingTree::ScrollingTree): Initialize new values used for tracking
+ scroll latching state.
+ (WebCore::ScrollingTree::shouldHandleWheelEventSynchronously): Check for an existing
+ latched node and stay in fast scrolling mode if possible.
+ (WebCore::ScrollingTree::removeDestroyedNodes): Clear latched node if it's being removed.
+ (WebCore::ScrollingTree::latchedNode): Added
+ (WebCore::ScrollingTree::setLatchedNode): Added
+ (WebCore::ScrollingTree::clearLatchedNode): Added
+ * page/scrolling/ScrollingTree.h:
+ (WebCore::ScrollingTree::hasLatchedNode): Added
+ * page/scrolling/mac/ScrollingTreeScrollingNodeMac.mm:
+ (WebCore::shouldConsiderLatching): Added
+ (WebCore::ScrollingTreeScrollingNodeMac::handleWheelEvent): Determine latching state
+ based on wheel event state and position of mouse pointer in the document.
+
2014-01-24 Anders Carlsson <ander...@apple.com>
Another attempted build fix.
Modified: trunk/Source/WebCore/page/scrolling/ScrollingTree.cpp (162754 => 162755)
--- trunk/Source/WebCore/page/scrolling/ScrollingTree.cpp 2014-01-25 03:38:35 UTC (rev 162754)
+++ trunk/Source/WebCore/page/scrolling/ScrollingTree.cpp 2014-01-25 04:33:48 UTC (rev 162755)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2012, 2013 Apple Inc. All rights reserved.
+ * Copyright (C) 2012, 2013, 2014 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -48,6 +48,7 @@
, m_mainFramePinnedToTheBottom(false)
, m_mainFrameIsRubberBanding(false)
, m_scrollPinningBehavior(DoNotPin)
+ , m_latchedNode(0)
, m_scrollingPerformanceLoggingEnabled(false)
, m_isHandlingProgrammaticScroll(false)
{
@@ -59,10 +60,14 @@
bool ScrollingTree::shouldHandleWheelEventSynchronously(const PlatformWheelEvent& wheelEvent)
{
+ // This method is invoked by the event handling thread
MutexLocker lock(m_mutex);
if (m_hasWheelEventHandlers)
return true;
+
+ if (hasLatchedNode())
+ return false;
if (!m_nonFastScrollableRegion.isEmpty()) {
// FIXME: This is not correct for non-default scroll origins.
@@ -174,14 +179,18 @@
void ScrollingTree::removeDestroyedNodes(const ScrollingStateTree& stateTree)
{
- const Vector<ScrollingNodeID>& removedNodes = stateTree.removedNodes();
- size_t size = removedNodes.size();
- for (size_t i = 0; i < size; ++i) {
- ScrollingTreeNode* node = m_nodeMap.take(removedNodes[i]);
+ for (const auto& removedNode : stateTree.removedNodes()) {
+ ScrollingTreeNode* node = m_nodeMap.take(removedNode);
+ if (!node)
+ continue;
+
// Never destroy the root node. There will be a new root node in the state tree, and we will
// associate it with our existing root node in updateTreeFromStateNode().
- if (node && node->parent())
+ if (node->parent())
m_rootNode->removeChild(node);
+
+ if (node->scrollingNodeID() == m_latchedNode)
+ clearLatchedNode();
}
}
@@ -315,6 +324,24 @@
return m_scrollingPerformanceLoggingEnabled;
}
+ScrollingNodeID ScrollingTree::latchedNode()
+{
+ MutexLocker locker(m_mutex);
+ return m_latchedNode;
+}
+
+void ScrollingTree::setLatchedNode(ScrollingNodeID node)
+{
+ MutexLocker locker(m_mutex);
+ m_latchedNode = node;
+}
+
+void ScrollingTree::clearLatchedNode()
+{
+ MutexLocker locker(m_mutex);
+ m_latchedNode = 0;
+}
+
} // namespace WebCore
#endif // ENABLE(ASYNC_SCROLLING)
Modified: trunk/Source/WebCore/page/scrolling/ScrollingTree.h (162754 => 162755)
--- trunk/Source/WebCore/page/scrolling/ScrollingTree.h 2014-01-25 03:38:35 UTC (rev 162754)
+++ trunk/Source/WebCore/page/scrolling/ScrollingTree.h 2014-01-25 04:33:48 UTC (rev 162755)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2012, 2013 Apple Inc. All rights reserved.
+ * Copyright (C) 2012, 2013, 2014 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -99,6 +99,12 @@
ScrollingTreeScrollingNode* rootNode() const { return m_rootNode.get(); }
+ ScrollingNodeID latchedNode();
+ void setLatchedNode(ScrollingNodeID);
+ void clearLatchedNode();
+
+ bool hasLatchedNode() const { return m_latchedNode; }
+
protected:
void setMainFrameScrollPosition(IntPoint);
virtual void handleWheelEvent(const PlatformWheelEvent&);
@@ -132,6 +138,7 @@
bool m_mainFramePinnedToTheBottom;
bool m_mainFrameIsRubberBanding;
ScrollPinningBehavior m_scrollPinningBehavior;
+ ScrollingNodeID m_latchedNode;
bool m_scrollingPerformanceLoggingEnabled;
Modified: trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeScrollingNodeMac.mm (162754 => 162755)
--- trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeScrollingNodeMac.mm 2014-01-25 03:38:35 UTC (rev 162754)
+++ trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeScrollingNodeMac.mm 2014-01-25 04:33:48 UTC (rev 162755)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2012 Apple Inc. All rights reserved.
+ * Copyright (C) 2012, 2014 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -128,12 +128,22 @@
updateMainFramePinState(scrollPosition());
}
+static bool shouldConsiderLatching(const PlatformWheelEvent& wheelEvent)
+{
+ return wheelEvent.phase() == PlatformWheelEventPhaseBegan
+ || wheelEvent.phase() == PlatformWheelEventPhaseMayBegin;
+}
+
void ScrollingTreeScrollingNodeMac::handleWheelEvent(const PlatformWheelEvent& wheelEvent)
{
if (!canHaveScrollbars())
return;
m_scrollElasticityController.handleWheelEvent(wheelEvent);
+
+ if (shouldConsiderLatching(wheelEvent))
+ scrollingTree().setLatchedNode(scrollingNodeID());
+
scrollingTree().handleWheelEventPhase(wheelEvent.phase());
}
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes