Title: [157642] trunk/Source/WebCore
- Revision
- 157642
- Author
- [email protected]
- Date
- 2013-10-18 12:11:08 -0700 (Fri, 18 Oct 2013)
Log Message
Rubber-banding is often not smooth on infinitely scrolling websites
https://bugs.webkit.org/show_bug.cgi?id=122985
Reviewed by Simon Fraser.
totalContentsSize is an important part of the calculation for
maximumScrollPosition(). This function is called repeatedly throughout the curve
of a rubber-band to determine the stretch amount. To keep the rubber-band
animation smooth, it should be allowed to finish its animation using the old
totalContentsSize. This patch does that by adding a new variable,
m_totalContentsSizeForRubberBand. This value should almost always be equivalent to
m_totalContentsSize. It will only vary if m_totalContentsSize has changed in the
middle of a rubber-band, and in that case, it will stay equivalent to the old
totalContentSize value until the rubber band animation finishes.
* page/scrolling/ScrollingTreeScrollingNode.cpp:
(WebCore::ScrollingTreeScrollingNode::updateBeforeChildren):
* page/scrolling/ScrollingTreeScrollingNode.h:
(WebCore::ScrollingTreeScrollingNode::totalContentsSizeForRubberBand):
(WebCore::ScrollingTreeScrollingNode::setTotalContentsSizeForRubberBand):
* page/scrolling/mac/ScrollingTreeScrollingNodeMac.mm:
(WebCore::ScrollingTreeScrollingNodeMac::stopSnapRubberbandTimer):
(WebCore::ScrollingTreeScrollingNodeMac::maximumScrollPosition):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (157641 => 157642)
--- trunk/Source/WebCore/ChangeLog 2013-10-18 17:22:55 UTC (rev 157641)
+++ trunk/Source/WebCore/ChangeLog 2013-10-18 19:11:08 UTC (rev 157642)
@@ -1,3 +1,29 @@
+2013-10-18 Beth Dakin <[email protected]>
+
+ Rubber-banding is often not smooth on infinitely scrolling websites
+ https://bugs.webkit.org/show_bug.cgi?id=122985
+
+ Reviewed by Simon Fraser.
+
+ totalContentsSize is an important part of the calculation for
+ maximumScrollPosition(). This function is called repeatedly throughout the curve
+ of a rubber-band to determine the stretch amount. To keep the rubber-band
+ animation smooth, it should be allowed to finish its animation using the old
+ totalContentsSize. This patch does that by adding a new variable,
+ m_totalContentsSizeForRubberBand. This value should almost always be equivalent to
+ m_totalContentsSize. It will only vary if m_totalContentsSize has changed in the
+ middle of a rubber-band, and in that case, it will stay equivalent to the old
+ totalContentSize value until the rubber band animation finishes.
+
+ * page/scrolling/ScrollingTreeScrollingNode.cpp:
+ (WebCore::ScrollingTreeScrollingNode::updateBeforeChildren):
+ * page/scrolling/ScrollingTreeScrollingNode.h:
+ (WebCore::ScrollingTreeScrollingNode::totalContentsSizeForRubberBand):
+ (WebCore::ScrollingTreeScrollingNode::setTotalContentsSizeForRubberBand):
+ * page/scrolling/mac/ScrollingTreeScrollingNodeMac.mm:
+ (WebCore::ScrollingTreeScrollingNodeMac::stopSnapRubberbandTimer):
+ (WebCore::ScrollingTreeScrollingNodeMac::maximumScrollPosition):
+
2013-10-18 ChangSeok Oh <[email protected]>
Unreviewed build fix for --no-svg option.
Modified: trunk/Source/WebCore/page/scrolling/ScrollingTreeScrollingNode.cpp (157641 => 157642)
--- trunk/Source/WebCore/page/scrolling/ScrollingTreeScrollingNode.cpp 2013-10-18 17:22:55 UTC (rev 157641)
+++ trunk/Source/WebCore/page/scrolling/ScrollingTreeScrollingNode.cpp 2013-10-18 19:11:08 UTC (rev 157642)
@@ -29,6 +29,7 @@
#if ENABLE(THREADED_SCROLLING)
#include "ScrollingStateTree.h"
+#include "ScrollingTree.h"
namespace WebCore {
@@ -58,8 +59,13 @@
if (state->hasChangedProperty(ScrollingStateScrollingNode::ViewportRect))
m_viewportRect = state->viewportRect();
- if (state->hasChangedProperty(ScrollingStateScrollingNode::TotalContentsSize))
+ if (state->hasChangedProperty(ScrollingStateScrollingNode::TotalContentsSize)) {
+ if (scrollingTree()->isRubberBandInProgress())
+ m_totalContentsSizeForRubberBand = m_totalContentsSize;
+ else
+ m_totalContentsSizeForRubberBand = state->totalContentsSize();
m_totalContentsSize = state->totalContentsSize();
+ }
if (state->hasChangedProperty(ScrollingStateScrollingNode::FrameScaleFactor))
m_frameScaleFactor = state->frameScaleFactor();
Modified: trunk/Source/WebCore/page/scrolling/ScrollingTreeScrollingNode.h (157641 => 157642)
--- trunk/Source/WebCore/page/scrolling/ScrollingTreeScrollingNode.h 2013-10-18 17:22:55 UTC (rev 157641)
+++ trunk/Source/WebCore/page/scrolling/ScrollingTreeScrollingNode.h 2013-10-18 19:11:08 UTC (rev 157642)
@@ -61,6 +61,12 @@
const IntRect& viewportRect() const { return m_viewportRect; }
const IntSize& totalContentsSize() const { return m_totalContentsSize; }
+ // If the totalContentsSize changes in the middle of a rubber-band, we still want to use the old totalContentsSize for the sake of
+ // computing the stretchAmount(). Using the old value will keep the animation smooth. When there is no rubber-band in progress at
+ // all, m_totalContentsSizeForRubberBand should be equivalent to m_totalContentsSize.
+ const IntSize& totalContentsSizeForRubberBand() const { return m_totalContentsSizeForRubberBand; }
+ void setTotalContentsSizeForRubberBand(const IntSize& totalContentsSizeForRubberBand) { m_totalContentsSizeForRubberBand = totalContentsSizeForRubberBand; }
+
float frameScaleFactor() const { return m_frameScaleFactor; }
ScrollElasticity horizontalScrollElasticity() const { return m_horizontalScrollElasticity; }
@@ -79,6 +85,7 @@
private:
IntRect m_viewportRect;
IntSize m_totalContentsSize;
+ IntSize m_totalContentsSizeForRubberBand;
IntPoint m_scrollOrigin;
float m_frameScaleFactor;
Modified: trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeScrollingNodeMac.mm (157641 => 157642)
--- trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeScrollingNodeMac.mm 2013-10-18 17:22:55 UTC (rev 157641)
+++ trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeScrollingNodeMac.mm 2013-10-18 19:11:08 UTC (rev 157642)
@@ -270,6 +270,9 @@
scrollingTree()->setMainFrameIsRubberBanding(false);
+ // Since the rubberband timer has stopped, totalContentsSizeForRubberBand can be synchronized with totalContentsSize.
+ setTotalContentsSizeForRubberBand(totalContentsSize());
+
CFRunLoopTimerInvalidate(m_snapRubberbandTimer.get());
m_snapRubberbandTimer = nullptr;
}
@@ -379,8 +382,8 @@
IntPoint ScrollingTreeScrollingNodeMac::maximumScrollPosition() const
{
- IntPoint position(totalContentsSize().width() - viewportRect().width(),
- totalContentsSize().height() - viewportRect().height());
+ IntPoint position(totalContentsSizeForRubberBand().width() - viewportRect().width(),
+ totalContentsSizeForRubberBand().height() - viewportRect().height());
position.clampNegativeToZero();
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes