Diff
Modified: trunk/LayoutTests/ChangeLog (194486 => 194487)
--- trunk/LayoutTests/ChangeLog 2016-01-02 04:44:16 UTC (rev 194486)
+++ trunk/LayoutTests/ChangeLog 2016-01-02 04:45:36 UTC (rev 194487)
@@ -1,5 +1,22 @@
2016-01-01 Simon Fraser <[email protected]>
+ Fix reload and programmatic scrolling in RTL documents
+ https://bugs.webkit.org/show_bug.cgi?id=152639
+
+ Reviewed by Zalan Bujtas.
+
+ New tests for programmatic scrolling (2 kinds!) in RTL documents, and
+ reloading a scrolled RTL document.
+
+ * fast/scrolling/programmatic-document-rtl-scroll-expected.html: Added.
+ * fast/scrolling/programmatic-document-rtl-scroll.html: Added.
+ * fast/scrolling/programmatic-document-rtl-scrollIntoView-expected.txt: Added.
+ * fast/scrolling/programmatic-document-rtl-scrollIntoView.html: Added.
+ * fast/scrolling/scroll-position-on-reload-rtl-expected.txt: Added.
+ * fast/scrolling/scroll-position-on-reload-rtl.html: Added.
+
+2016-01-01 Simon Fraser <[email protected]>
+
REGRESSION (r194448): Scrolling overflow:scroll goes too far
https://bugs.webkit.org/show_bug.cgi?id=152645
Added: trunk/LayoutTests/fast/scrolling/programmatic-document-rtl-scroll-expected.html (0 => 194487)
--- trunk/LayoutTests/fast/scrolling/programmatic-document-rtl-scroll-expected.html (rev 0)
+++ trunk/LayoutTests/fast/scrolling/programmatic-document-rtl-scroll-expected.html 2016-01-02 04:45:36 UTC (rev 194487)
@@ -0,0 +1,45 @@
+<html>
+<head>
+ <style>
+ body {
+ margin: 0;
+ }
+ .wide {
+ width: 2000px;
+ height: 10px;
+ background-color: silver;
+ }
+ .origin {
+ position: absolute;
+ top: 0;
+ left: 1200px;
+ width: 10px;
+ height: 10px;
+ background-color: blue;
+ }
+
+ #lefty {
+ position: absolute;
+ left: 1000px;
+ width: 100px;
+ height: 100px;
+ background-color: orange;
+ }
+ </style>
+ <script>
+ function runTest()
+ {
+ document.scrollingElement.scrollLeft = 1000;
+ }
+
+ window.addEventListener('load', runTest, false);
+ </script>
+</head>
+<body>
+ <div class="wide"></div>
+ <div class="origin"></div>
+ <div id="lefty"></div>
+ <div id="result">
+ </div>
+</body>
+</html>
Added: trunk/LayoutTests/fast/scrolling/programmatic-document-rtl-scroll.html (0 => 194487)
--- trunk/LayoutTests/fast/scrolling/programmatic-document-rtl-scroll.html (rev 0)
+++ trunk/LayoutTests/fast/scrolling/programmatic-document-rtl-scroll.html 2016-01-02 04:45:36 UTC (rev 194487)
@@ -0,0 +1,45 @@
+<html dir="rtl">
+<head>
+ <style>
+ body {
+ margin: 0;
+ }
+ .wide {
+ width: 2000px;
+ height: 10px;
+ background-color: silver;
+ }
+ .origin {
+ position: absolute;
+ top: 0;
+ left: 0;
+ width: 10px;
+ height: 10px;
+ background-color: blue;
+ }
+
+ #lefty {
+ position: absolute;
+ left: -200px;
+ width: 100px;
+ height: 100px;
+ background-color: orange;
+ }
+ </style>
+ <script>
+ function runTest()
+ {
+ document.scrollingElement.scrollLeft = -200;
+ }
+
+ window.addEventListener('load', runTest, false);
+ </script>
+</head>
+<body>
+ <div class="wide"></div>
+ <div class="origin"></div>
+ <div id="lefty"></div>
+ <div id="result">
+ </div>
+</body>
+</html>
Added: trunk/LayoutTests/fast/scrolling/programmatic-document-rtl-scrollIntoView-expected.txt (0 => 194487)
--- trunk/LayoutTests/fast/scrolling/programmatic-document-rtl-scrollIntoView-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/scrolling/programmatic-document-rtl-scrollIntoView-expected.txt 2016-01-02 04:45:36 UTC (rev 194487)
@@ -0,0 +1 @@
+document.scrollingElement.scrollLeft = -200
Added: trunk/LayoutTests/fast/scrolling/programmatic-document-rtl-scrollIntoView.html (0 => 194487)
--- trunk/LayoutTests/fast/scrolling/programmatic-document-rtl-scrollIntoView.html (rev 0)
+++ trunk/LayoutTests/fast/scrolling/programmatic-document-rtl-scrollIntoView.html 2016-01-02 04:45:36 UTC (rev 194487)
@@ -0,0 +1,46 @@
+<html dir="rtl">
+<head>
+ <style>
+ .wide {
+ width: 2000px;
+ height: 10px;
+ background-color: silver;
+ }
+ .origin {
+ position: absolute;
+ top: 0;
+ left: 0;
+ width: 10px;
+ height: 10px;
+ background-color: blue;
+ }
+
+ #lefty {
+ position: absolute;
+ left: -200px;
+ width: 100px;
+ height: 100px;
+ background-color: orange;
+ }
+ </style>
+ <script>
+ if (window.testRunner)
+ testRunner.dumpAsText();
+
+ function runTest()
+ {
+ document.getElementById('lefty').scrollIntoView();
+ document.getElementById('result').textContent = 'document.scrollingElement.scrollLeft = ' + document.scrollingElement.scrollLeft;
+ }
+
+ window.addEventListener('load', runTest, false);
+ </script>
+</head>
+<body>
+ <div class="wide"></div>
+ <div class="origin"></div>
+ <div id="lefty"></div>
+ <div id="result">
+ </div>
+</body>
+</html>
Added: trunk/LayoutTests/fast/scrolling/scroll-position-on-reload-rtl-expected.txt (0 => 194487)
--- trunk/LayoutTests/fast/scrolling/scroll-position-on-reload-rtl-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/scrolling/scroll-position-on-reload-rtl-expected.txt 2016-01-02 04:45:36 UTC (rev 194487)
@@ -0,0 +1 @@
+PASS: scrollLeft after reload is -200
Added: trunk/LayoutTests/fast/scrolling/scroll-position-on-reload-rtl.html (0 => 194487)
--- trunk/LayoutTests/fast/scrolling/scroll-position-on-reload-rtl.html (rev 0)
+++ trunk/LayoutTests/fast/scrolling/scroll-position-on-reload-rtl.html 2016-01-02 04:45:36 UTC (rev 194487)
@@ -0,0 +1,66 @@
+<html dir="rtl">
+<head>
+ <style>
+ .wide {
+ width: 2000px;
+ height: 10px;
+ background-color: silver;
+ }
+ .origin {
+ position: absolute;
+ top: 0;
+ left: 0;
+ width: 10px;
+ height: 10px;
+ background-color: blue;
+ }
+
+ #lefty {
+ position: absolute;
+ left: -200px;
+ width: 100px;
+ height: 100px;
+ background-color: orange;
+ }
+ </style>
+ <script>
+ var desiredScrollOffset = -200;
+ function runTest()
+ {
+ if (!window.sessionStorage)
+ return;
+
+ if (window.testRunner) {
+ testRunner.waitUntilDone();
+ testRunner.dumpAsText();
+ }
+
+ if (sessionStorage.testCompleted) {
+ window.setTimeout(function() {
+ var currentOffset = document.scrollingElement.scrollLeft;
+ if (currentOffset == desiredScrollOffset)
+ document.getElementById('result').textContent = 'PASS: scrollLeft after reload is ' + desiredScrollOffset;
+ else
+ document.getElementById('result').textContent = 'FAIL: scrollLeft after reload is ' + currentOffset + ', should be' + desiredScrollOffset;
+
+ delete sessionStorage.testCompleted;
+ if (window.testRunner)
+ testRunner.notifyDone();
+ }, 0);
+ } else {
+ document.scrollingElement.scrollLeft = desiredScrollOffset;
+ sessionStorage.testCompleted = true;
+ document.location.reload(true);
+ }
+ }
+
+ window.addEventListener('load', runTest, false);
+ </script>
+</head>
+<body>
+ <div class="wide"></div>
+ <div class="origin"></div>
+ <div id="lefty"></div>
+ <div id="result"></div>
+</body>
+</html>
Modified: trunk/Source/WebCore/ChangeLog (194486 => 194487)
--- trunk/Source/WebCore/ChangeLog 2016-01-02 04:44:16 UTC (rev 194486)
+++ trunk/Source/WebCore/ChangeLog 2016-01-02 04:45:36 UTC (rev 194487)
@@ -1,5 +1,74 @@
2016-01-01 Simon Fraser <[email protected]>
+ Fix reload and programmatic scrolling in RTL documents
+ https://bugs.webkit.org/show_bug.cgi?id=152639
+
+ Reviewed by Zalan Bujtas.
+
+ Reloading a left-scrolled RTL document would cause the content to appear
+ at an odd offset, and programmatic sideways scrolls in RTL documents also
+ jumped to the wrong location.
+
+ Fix by resolving offset/position confusion in ScrollableArea::scrollPositionChanged()
+ and the scrolling tree.
+
+ ScrollableArea::scrollPositionChanged() was erroneously passing a scrollPosition
+ to setScrollOffset().
+
+ ScrollingTreeFrameScrollingNode* were confused about offsets and positions. It
+ turns out that the layer position is just -scrollPosition, but minimumScrollPosition()
+ and maximumScrollPosition() need fixing to return positions, not offsets.
+
+ ScrollingTreeFrameScrollingNode::viewToContentsOffset() was also doing incorrect
+ math with scrollOrigin, which was detected by a failing test.
+
+ Add more logging to the Scrolling channel.
+
+ Tests: fast/scrolling/programmatic-document-rtl-scroll.html
+ fast/scrolling/programmatic-document-rtl-scrollIntoView.html
+ fast/scrolling/scroll-position-on-reload-rtl.html
+
+ * page/FrameView.cpp:
+ (WebCore::FrameView::requestScrollPositionUpdate):
+ * page/scrolling/ScrollingTree.cpp:
+ (WebCore::ScrollingTree::shouldHandleWheelEventSynchronously):
+ * page/scrolling/ScrollingTreeFrameScrollingNode.cpp:
+ (WebCore::ScrollingTreeFrameScrollingNode::scrollBy):
+ (WebCore::ScrollingTreeFrameScrollingNode::viewToContentsOffset):
+ * page/scrolling/ScrollingTreeFrameScrollingNode.h:
+ * page/scrolling/ios/ScrollingTreeFrameScrollingNodeIOS.mm:
+ (WebCore::ScrollingTreeFrameScrollingNodeIOS::scrollPosition):
+ (WebCore::ScrollingTreeFrameScrollingNodeIOS::setScrollLayerPosition):
+ (WebCore::ScrollingTreeFrameScrollingNodeIOS::updateChildNodesAfterScroll):
+ (WebCore::ScrollingTreeFrameScrollingNodeIOS::minimumScrollPosition):
+ (WebCore::ScrollingTreeFrameScrollingNodeIOS::maximumScrollPosition):
+ * page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.mm:
+ (WebCore::ScrollingTreeFrameScrollingNodeMac::immediateScrollBy):
+ (WebCore::ScrollingTreeFrameScrollingNodeMac::scrollPosition):
+ (WebCore::ScrollingTreeFrameScrollingNodeMac::setScrollPosition):
+ (WebCore::ScrollingTreeFrameScrollingNodeMac::setScrollLayerPosition):
+ (WebCore::ScrollingTreeFrameScrollingNodeMac::minimumScrollPosition):
+ (WebCore::ScrollingTreeFrameScrollingNodeMac::maximumScrollPosition):
+ * platform/ScrollView.cpp:
+ (WebCore::ScrollView::setScrollOffset):
+ (WebCore::ScrollView::scrollTo):
+ (WebCore::ScrollView::setScrollPosition):
+ (WebCore::ScrollView::updateScrollbars):
+ * platform/ScrollView.h:
+ * platform/ScrollableArea.cpp:
+ (WebCore::ScrollableArea::scrollPositionChanged):
+ (WebCore::ScrollableArea::setScrollOffsetFromAnimation):
+ (WebCore::ScrollableArea::scrollPositionFromOffset):
+ (WebCore::ScrollableArea::scrollOffsetFromPosition):
+ * platform/ScrollableArea.h:
+ (WebCore::ScrollableArea::scrollPositionFromOffset):
+ (WebCore::ScrollableArea::scrollOffsetFromPosition):
+ * rendering/RenderListBox.cpp:
+ (WebCore::RenderListBox::setScrollOffset):
+ * rendering/RenderListBox.h:
+
+2016-01-01 Simon Fraser <[email protected]>
+
REGRESSION (r194448): Scrolling overflow:scroll goes too far
https://bugs.webkit.org/show_bug.cgi?id=152645
Modified: trunk/Source/WebCore/page/FrameView.cpp (194486 => 194487)
--- trunk/Source/WebCore/page/FrameView.cpp 2016-01-02 04:44:16 UTC (rev 194486)
+++ trunk/Source/WebCore/page/FrameView.cpp 2016-01-02 04:45:36 UTC (rev 194487)
@@ -2353,6 +2353,8 @@
bool FrameView::requestScrollPositionUpdate(const ScrollPosition& position)
{
+ LOG_WITH_STREAM(Scrolling, stream << "FrameView::requestScrollPositionUpdate " << position);
+
#if ENABLE(ASYNC_SCROLLING)
if (TiledBacking* tiledBacking = this->tiledBacking())
tiledBacking->prepopulateRect(FloatRect(position, visibleContentRect().size()));
Modified: trunk/Source/WebCore/page/scrolling/ScrollingTree.cpp (194486 => 194487)
--- trunk/Source/WebCore/page/scrolling/ScrollingTree.cpp 2016-01-02 04:44:16 UTC (rev 194486)
+++ trunk/Source/WebCore/page/scrolling/ScrollingTree.cpp 2016-01-02 04:45:36 UTC (rev 194487)
@@ -28,12 +28,14 @@
#if ENABLE(ASYNC_SCROLLING)
+#include "Logging.h"
#include "PlatformWheelEvent.h"
#include "ScrollingStateTree.h"
#include "ScrollingTreeFrameScrollingNode.h"
#include "ScrollingTreeNode.h"
#include "ScrollingTreeOverflowScrollingNode.h"
#include "ScrollingTreeScrollingNode.h"
+#include "TextStream.h"
#include <wtf/TemporaryChange.h>
namespace WebCore {
@@ -61,9 +63,11 @@
if (!m_nonFastScrollableRegion.isEmpty() && m_rootNode) {
ScrollingTreeFrameScrollingNode& frameScrollingNode = downcast<ScrollingTreeFrameScrollingNode>(*m_rootNode);
- // FIXME: This is not correct for non-default scroll origins.
FloatPoint position = wheelEvent.position();
position.move(frameScrollingNode.viewToContentsOffset(m_mainFrameScrollPosition));
+
+ LOG_WITH_STREAM(Scrolling, stream << "ScrollingTree::shouldHandleWheelEventSynchronously: wheelEvent at " << wheelEvent.position() << " mapped to content point " << position << ", in non-fast region " << m_nonFastScrollableRegion.contains(roundedIntPoint(position)));
+
if (m_nonFastScrollableRegion.contains(roundedIntPoint(position)))
return true;
}
Modified: trunk/Source/WebCore/page/scrolling/ScrollingTreeFrameScrollingNode.cpp (194486 => 194487)
--- trunk/Source/WebCore/page/scrolling/ScrollingTreeFrameScrollingNode.cpp 2016-01-02 04:44:16 UTC (rev 194486)
+++ trunk/Source/WebCore/page/scrolling/ScrollingTreeFrameScrollingNode.cpp 2016-01-02 04:45:36 UTC (rev 194487)
@@ -70,9 +70,9 @@
m_fixedElementsLayoutRelativeToFrame = state.fixedElementsLayoutRelativeToFrame();
}
-void ScrollingTreeFrameScrollingNode::scrollBy(const FloatSize& offset)
+void ScrollingTreeFrameScrollingNode::scrollBy(const FloatSize& delta)
{
- setScrollPosition(scrollPosition() + offset);
+ setScrollPosition(scrollPosition() + delta);
}
void ScrollingTreeFrameScrollingNode::scrollByWithoutContentEdgeConstraints(const FloatSize& offset)
@@ -86,9 +86,9 @@
setScrollPositionWithoutContentEdgeConstraints(newScrollPosition);
}
-FloatSize ScrollingTreeFrameScrollingNode::viewToContentsOffset(const FloatPoint& scrollOffset) const
+FloatSize ScrollingTreeFrameScrollingNode::viewToContentsOffset(const FloatPoint& scrollPosition) const
{
- return toFloatSize(scrollOffset) - toFloatSize(scrollOrigin()) - FloatSize(0, headerHeight() + topContentInset());
+ return toFloatSize(scrollPosition) - FloatSize(0, headerHeight() + topContentInset());
}
} // namespace WebCore
Modified: trunk/Source/WebCore/page/scrolling/ScrollingTreeFrameScrollingNode.h (194486 => 194487)
--- trunk/Source/WebCore/page/scrolling/ScrollingTreeFrameScrollingNode.h 2016-01-02 04:44:16 UTC (rev 194486)
+++ trunk/Source/WebCore/page/scrolling/ScrollingTreeFrameScrollingNode.h 2016-01-02 04:45:36 UTC (rev 194487)
@@ -56,7 +56,7 @@
bool shouldUpdateScrollLayerPositionSynchronously() const { return m_synchronousScrollingReasons; }
bool fixedElementsLayoutRelativeToFrame() const { return m_fixedElementsLayoutRelativeToFrame; }
- FloatSize viewToContentsOffset(const FloatPoint& scrollOffset) const;
+ FloatSize viewToContentsOffset(const FloatPoint& scrollPosition) const;
protected:
ScrollingTreeFrameScrollingNode(ScrollingTree&, ScrollingNodeID);
Modified: trunk/Source/WebCore/page/scrolling/ios/ScrollingTreeFrameScrollingNodeIOS.mm (194486 => 194487)
--- trunk/Source/WebCore/page/scrolling/ios/ScrollingTreeFrameScrollingNodeIOS.mm 2016-01-02 04:44:16 UTC (rev 194486)
+++ trunk/Source/WebCore/page/scrolling/ios/ScrollingTreeFrameScrollingNodeIOS.mm 2016-01-02 04:45:36 UTC (rev 194487)
@@ -102,8 +102,7 @@
if (shouldUpdateScrollLayerPositionSynchronously())
return m_probableMainThreadScrollPosition;
- CGPoint scrollLayerPosition = m_scrollLayer.get().position;
- return IntPoint(-scrollLayerPosition.x + scrollOrigin().x(), -scrollLayerPosition.y + scrollOrigin().y());
+ return -m_scrollLayer.get().position;
}
void ScrollingTreeFrameScrollingNodeIOS::setScrollPositionWithoutContentEdgeConstraints(const FloatPoint& scrollPosition)
@@ -121,7 +120,7 @@
void ScrollingTreeFrameScrollingNodeIOS::setScrollLayerPosition(const FloatPoint& scrollPosition)
{
ASSERT(!shouldUpdateScrollLayerPositionSynchronously());
- [m_scrollLayer setPosition:CGPointMake(-scrollPosition.x() + scrollOrigin().x(), -scrollPosition.y() + scrollOrigin().y())];
+ [m_scrollLayer setPosition:-scrollPosition];
updateChildNodesAfterScroll(scrollPosition);
}
@@ -146,9 +145,8 @@
void ScrollingTreeFrameScrollingNodeIOS::updateChildNodesAfterScroll(const FloatPoint& scrollPosition)
{
ScrollBehaviorForFixedElements behaviorForFixed = scrollBehaviorForFixedElements();
- FloatPoint scrollOffset = scrollPosition - toIntSize(scrollOrigin());
- FloatRect viewportRect(FloatPoint(), scrollableAreaSize());
- FloatPoint scrollPositionForFixedChildren = FrameView::scrollPositionForFixedPosition(enclosingLayoutRect(viewportRect), LayoutSize(totalContentsSize()), LayoutPoint(scrollOffset), scrollOrigin(), frameScaleFactor(), fixedElementsLayoutRelativeToFrame(), behaviorForFixed, headerHeight(), footerHeight());
+ FloatRect viewportRect(scrollPosition, scrollableAreaSize());
+ FloatPoint scrollPositionForFixedChildren = FrameView::scrollPositionForFixedPosition(enclosingLayoutRect(viewportRect), LayoutSize(totalContentsSize()), LayoutPoint(scrollPosition), scrollOrigin(), frameScaleFactor(), fixedElementsLayoutRelativeToFrame(), behaviorForFixed, headerHeight(), footerHeight());
[m_counterScrollingLayer setPosition:scrollPositionForFixedChildren];
@@ -158,7 +156,7 @@
// then we should recompute scrollPositionForFixedChildren for the banner with a scale factor of 1.
float horizontalScrollOffsetForBanner = scrollPositionForFixedChildren.x();
if (frameScaleFactor() != 1)
- horizontalScrollOffsetForBanner = FrameView::scrollPositionForFixedPosition(enclosingLayoutRect(viewportRect), LayoutSize(totalContentsSize()), LayoutPoint(scrollOffset), scrollOrigin(), 1, fixedElementsLayoutRelativeToFrame(), behaviorForFixed, headerHeight(), footerHeight()).x();
+ horizontalScrollOffsetForBanner = FrameView::scrollPositionForFixedPosition(enclosingLayoutRect(viewportRect), LayoutSize(totalContentsSize()), LayoutPoint(scrollPosition), scrollOrigin(), 1, fixedElementsLayoutRelativeToFrame(), behaviorForFixed, headerHeight(), footerHeight()).x();
if (m_headerLayer)
[m_headerLayer setPosition:FloatPoint(horizontalScrollOffsetForBanner, 0)];
@@ -175,7 +173,7 @@
if (!parent())
fixedPositionRect = scrollingTree().fixedPositionRect();
else
- fixedPositionRect = FloatRect(scrollOffset, scrollableAreaSize());
+ fixedPositionRect = FloatRect(scrollPosition, scrollableAreaSize());
for (auto& child : *m_children)
child->updateLayersAfterAncestorChange(*this, fixedPositionRect, FloatSize());
@@ -183,7 +181,7 @@
FloatPoint ScrollingTreeFrameScrollingNodeIOS::minimumScrollPosition() const
{
- FloatPoint position;
+ FloatPoint position = ScrollableArea::scrollPositionFromOffset(FloatPoint(), toFloatSize(scrollOrigin()));
if (scrollingTree().rootNode() == this && scrollingTree().scrollPinningBehavior() == PinToBottom)
position.setY(maximumScrollPosition().y());
@@ -193,9 +191,7 @@
FloatPoint ScrollingTreeFrameScrollingNodeIOS::maximumScrollPosition() const
{
- FloatPoint position(totalContentsSizeForRubberBand().width() - scrollableAreaSize().width(),
- totalContentsSizeForRubberBand().height() - scrollableAreaSize().height());
-
+ FloatPoint position = ScrollableArea::scrollPositionFromOffset(FloatPoint(totalContentsSizeForRubberBand() - scrollableAreaSize()), toFloatSize(scrollOrigin()));
position = position.expandedTo(FloatPoint());
if (scrollingTree().rootNode() == this && scrollingTree().scrollPinningBehavior() == PinToTop)
Modified: trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.mm (194486 => 194487)
--- trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.mm 2016-01-02 04:44:16 UTC (rev 194486)
+++ trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.mm 2016-01-02 04:45:36 UTC (rev 194487)
@@ -33,10 +33,12 @@
#import "Logging.h"
#import "NSScrollerImpDetails.h"
#import "PlatformWheelEvent.h"
+#import "ScrollableArea.h"
#import "ScrollingCoordinator.h"
#import "ScrollingTree.h"
#import "ScrollingStateTree.h"
#import "Settings.h"
+#import "TextStream.h"
#import "TileController.h"
#import "WebLayer.h"
@@ -328,9 +330,9 @@
return roundedIntPoint(scrollPosition());
}
-void ScrollingTreeFrameScrollingNodeMac::immediateScrollBy(const FloatSize& offset)
+void ScrollingTreeFrameScrollingNodeMac::immediateScrollBy(const FloatSize& delta)
{
- scrollBy(offset);
+ scrollBy(delta);
}
void ScrollingTreeFrameScrollingNodeMac::immediateScrollByWithoutContentEdgeConstraints(const FloatSize& offset)
@@ -364,12 +366,13 @@
if (shouldUpdateScrollLayerPositionSynchronously())
return m_probableMainThreadScrollPosition;
- CGPoint scrollLayerPosition = m_scrollLayer.get().position;
- return FloatPoint(-scrollLayerPosition.x + scrollOrigin().x(), -scrollLayerPosition.y + scrollOrigin().y());
+ return -m_scrollLayer.get().position;
}
void ScrollingTreeFrameScrollingNodeMac::setScrollPosition(const FloatPoint& scrollPosition)
{
+ LOG_WITH_STREAM(Scrolling, stream << "ScrollingTreeFrameScrollingNodeMac::setScrollPosition " << scrollPosition << " scrollPosition(): " << this->scrollPosition() << " min: " << minimumScrollPosition() << " max: " << maximumScrollPosition());
+
// Scroll deltas can be non-integral with some input devices, so scrollPosition may not be integral.
// FIXME: when we support half-pixel scroll positions on Retina displays, this will need to round to half pixels.
FloatPoint roundedPosition(roundf(scrollPosition.x()), roundf(scrollPosition.y()));
@@ -397,13 +400,13 @@
void ScrollingTreeFrameScrollingNodeMac::setScrollLayerPosition(const FloatPoint& position)
{
ASSERT(!shouldUpdateScrollLayerPositionSynchronously());
- m_scrollLayer.get().position = CGPointMake(-position.x() + scrollOrigin().x(), -position.y() + scrollOrigin().y());
+ m_scrollLayer.get().position = -position;
+
ScrollBehaviorForFixedElements behaviorForFixed = scrollBehaviorForFixedElements();
- LayoutPoint scrollOffset = LayoutPoint(position) - toLayoutSize(scrollOrigin());
- FloatRect viewportRect(FloatPoint(), scrollableAreaSize());
+ FloatRect viewportRect(position, scrollableAreaSize());
- FloatPoint scrollPositionForFixedChildren = FrameView::scrollPositionForFixedPosition(enclosingLayoutRect(viewportRect), LayoutSize(totalContentsSize()), scrollOffset, scrollOrigin(), frameScaleFactor(),
+ FloatPoint scrollPositionForFixedChildren = FrameView::scrollPositionForFixedPosition(enclosingLayoutRect(viewportRect), LayoutSize(totalContentsSize()), LayoutPoint(position), scrollOrigin(), frameScaleFactor(),
fixedElementsLayoutRelativeToFrame(), behaviorForFixed, headerHeight(), footerHeight());
if (m_counterScrollingLayer)
@@ -424,7 +427,7 @@
// then we should recompute scrollOffsetForFixedChildren for the banner with a scale factor of 1.
float horizontalScrollOffsetForBanner = scrollPositionForFixedChildren.x();
if (frameScaleFactor() != 1)
- horizontalScrollOffsetForBanner = FrameView::scrollPositionForFixedPosition(enclosingLayoutRect(viewportRect), LayoutSize(totalContentsSize()), scrollOffset, scrollOrigin(), 1, fixedElementsLayoutRelativeToFrame(), behaviorForFixed, headerHeight(), footerHeight()).x();
+ horizontalScrollOffsetForBanner = FrameView::scrollPositionForFixedPosition(enclosingLayoutRect(viewportRect), LayoutSize(totalContentsSize()), LayoutPoint(position), scrollOrigin(), 1, fixedElementsLayoutRelativeToFrame(), behaviorForFixed, headerHeight(), footerHeight()).x();
if (m_headerLayer)
m_headerLayer.get().position = FloatPoint(horizontalScrollOffsetForBanner, FrameView::yPositionForHeaderLayer(position, topContentInset));
@@ -472,7 +475,7 @@
FloatPoint ScrollingTreeFrameScrollingNodeMac::minimumScrollPosition() const
{
- FloatPoint position;
+ FloatPoint position = ScrollableArea::scrollPositionFromOffset(FloatPoint(), toFloatSize(scrollOrigin()));
if (scrollingTree().rootNode() == this && scrollingTree().scrollPinningBehavior() == PinToBottom)
position.setY(maximumScrollPosition().y());
@@ -482,7 +485,7 @@
FloatPoint ScrollingTreeFrameScrollingNodeMac::maximumScrollPosition() const
{
- FloatPoint position(totalContentsSizeForRubberBand() - scrollableAreaSize());
+ FloatPoint position = ScrollableArea::scrollPositionFromOffset(FloatPoint(totalContentsSizeForRubberBand() - scrollableAreaSize()), toFloatSize(scrollOrigin()));
position = position.expandedTo(FloatPoint());
if (scrollingTree().rootNode() == this && scrollingTree().scrollPinningBehavior() == PinToTop)
Modified: trunk/Source/WebCore/platform/ScrollView.cpp (194486 => 194487)
--- trunk/Source/WebCore/platform/ScrollView.cpp 2016-01-02 04:44:16 UTC (rev 194486)
+++ trunk/Source/WebCore/platform/ScrollView.cpp 2016-01-02 04:45:36 UTC (rev 194487)
@@ -429,8 +429,10 @@
{
}
-void ScrollView::setScrollOffset(const IntPoint& offset)
+void ScrollView::setScrollOffset(const ScrollOffset& offset)
{
+ LOG_WITH_STREAM(Scrolling, stream << "ScrollView::setScrollOffset " << offset);
+
IntPoint constrainedOffset = offset;
if (constrainsScrollingToContentEdge())
constrainedOffset = constrainedOffset.constrainedBetween(IntPoint(), maximumScrollOffset());
@@ -471,6 +473,8 @@
void ScrollView::scrollTo(const ScrollPosition& newPosition)
{
+ LOG_WITH_STREAM(Scrolling, stream << "ScrollView::scrollTo " << newPosition << " min: " << minimumScrollPosition() << " max: " << maximumScrollPosition());
+
IntSize scrollDelta = newPosition - m_scrollPosition;
if (scrollDelta.isZero())
return;
@@ -515,6 +519,8 @@
void ScrollView::setScrollPosition(const ScrollPosition& scrollPosition)
{
+ LOG_WITH_STREAM(Scrolling, stream << "ScrollView::setScrollPosition " << scrollPosition);
+
if (prohibitsScrolling())
return;
@@ -568,6 +574,8 @@
void ScrollView::updateScrollbars(const ScrollPosition& desiredPosition)
{
+ LOG_WITH_STREAM(Scrolling, stream << "ScrollView::updateScrollbars " << desiredPosition);
+
if (m_inUpdateScrollbars || prohibitsScrolling() || platformWidget() || delegatesScrolling())
return;
Modified: trunk/Source/WebCore/platform/ScrollView.h (194486 => 194487)
--- trunk/Source/WebCore/platform/ScrollView.h 2016-01-02 04:44:16 UTC (rev 194486)
+++ trunk/Source/WebCore/platform/ScrollView.h 2016-01-02 04:45:36 UTC (rev 194487)
@@ -67,7 +67,7 @@
// ScrollableArea functions.
virtual int scrollSize(ScrollbarOrientation) const override;
virtual int scrollPosition(Scrollbar*) const override;
- WEBCORE_EXPORT virtual void setScrollOffset(const IntPoint&) override;
+ WEBCORE_EXPORT virtual void setScrollOffset(const ScrollOffset&) override;
virtual bool isScrollCornerVisible() const override;
virtual void scrollbarStyleChanged(ScrollbarStyle, bool forceUpdate) override;
Modified: trunk/Source/WebCore/platform/ScrollableArea.cpp (194486 => 194487)
--- trunk/Source/WebCore/platform/ScrollableArea.cpp 2016-01-02 04:44:16 UTC (rev 194486)
+++ trunk/Source/WebCore/platform/ScrollableArea.cpp 2016-01-02 04:45:36 UTC (rev 194487)
@@ -151,11 +151,11 @@
scrollAnimator().setCurrentPosition(position);
}
-void ScrollableArea::scrollPositionChanged(const IntPoint& position)
+void ScrollableArea::scrollPositionChanged(const ScrollPosition& position)
{
IntPoint oldPosition = scrollPosition();
// Tell the derived class to scroll its contents.
- setScrollOffset(position);
+ setScrollOffset(scrollOffsetFromPosition(position));
Scrollbar* verticalScrollbar = this->verticalScrollbar();
@@ -207,17 +207,18 @@
#endif
// NOTE: Only called from Internals for testing.
-void ScrollableArea::setScrollOffsetFromInternals(const IntPoint& offset)
+void ScrollableArea::setScrollOffsetFromInternals(const ScrollOffset& offset)
{
setScrollOffsetFromAnimation(offset);
}
-void ScrollableArea::setScrollOffsetFromAnimation(const IntPoint& offset)
+void ScrollableArea::setScrollOffsetFromAnimation(const ScrollOffset& offset)
{
- if (requestScrollPositionUpdate(offset))
+ ScrollPosition position = scrollPositionFromOffset(offset);
+ if (requestScrollPositionUpdate(position))
return;
- scrollPositionChanged(offset);
+ scrollPositionChanged(position);
}
void ScrollableArea::willStartLiveResize()
@@ -549,12 +550,12 @@
ScrollPosition ScrollableArea::scrollPositionFromOffset(ScrollOffset offset) const
{
- return IntPoint(toIntSize(offset) - toIntSize(m_scrollOrigin));
+ return scrollPositionFromOffset(offset, toIntSize(m_scrollOrigin));
}
ScrollOffset ScrollableArea::scrollOffsetFromPosition(ScrollPosition position) const
{
- return IntPoint(toIntSize(position) + toIntSize(m_scrollOrigin));
+ return scrollOffsetFromPosition(position, toIntSize(m_scrollOrigin));
}
bool ScrollableArea::scrolledToTop() const
Modified: trunk/Source/WebCore/platform/ScrollableArea.h (194486 => 194487)
--- trunk/Source/WebCore/platform/ScrollableArea.h 2016-01-02 04:44:16 UTC (rev 194486)
+++ trunk/Source/WebCore/platform/ScrollableArea.h 2016-01-02 04:45:36 UTC (rev 194487)
@@ -193,6 +193,18 @@
WEBCORE_EXPORT ScrollPosition scrollPositionFromOffset(ScrollOffset) const;
WEBCORE_EXPORT ScrollOffset scrollOffsetFromPosition(ScrollPosition) const;
+ template<typename PositionType, typename SizeType>
+ static PositionType scrollPositionFromOffset(PositionType offset, SizeType scrollOrigin)
+ {
+ return offset - scrollOrigin;
+ }
+
+ template<typename PositionType, typename SizeType>
+ static PositionType scrollOffsetFromPosition(PositionType position, SizeType scrollOrigin)
+ {
+ return position + scrollOrigin;
+ }
+
WEBCORE_EXPORT virtual bool scrolledToTop() const;
WEBCORE_EXPORT virtual bool scrolledToBottom() const;
WEBCORE_EXPORT virtual bool scrolledToLeft() const;
@@ -249,7 +261,7 @@
virtual bool scrollAnimatorEnabled() const { return false; }
// NOTE: Only called from Internals for testing.
- WEBCORE_EXPORT void setScrollOffsetFromInternals(const IntPoint&);
+ WEBCORE_EXPORT void setScrollOffsetFromInternals(const ScrollOffset&);
WEBCORE_EXPORT static LayoutPoint constrainScrollPositionForOverhang(const LayoutRect& visibleContentRect, const LayoutSize& totalContentsSize, const LayoutPoint& scrollPosition, const LayoutPoint& scrollOrigin, int headerHeight, int footetHeight);
LayoutPoint constrainScrollPositionForOverhang(const LayoutPoint& scrollPosition);
@@ -312,15 +324,15 @@
private:
WEBCORE_EXPORT virtual IntRect visibleContentRectInternal(VisibleContentRectIncludesScrollbars, VisibleContentRectBehavior) const;
- void scrollPositionChanged(const IntPoint&);
+ void scrollPositionChanged(const ScrollPosition&);
// NOTE: Only called from the ScrollAnimator.
friend class ScrollAnimator;
- void setScrollOffsetFromAnimation(const IntPoint&);
+ void setScrollOffsetFromAnimation(const ScrollOffset&);
// This function should be overriden by subclasses to perform the actual
// scroll of the content.
- virtual void setScrollOffset(const IntPoint&) = 0;
+ virtual void setScrollOffset(const ScrollOffset&) = 0;
mutable std::unique_ptr<ScrollAnimator> m_scrollAnimator;
Modified: trunk/Source/WebCore/rendering/RenderListBox.cpp (194486 => 194487)
--- trunk/Source/WebCore/rendering/RenderListBox.cpp 2016-01-02 04:44:16 UTC (rev 194486)
+++ trunk/Source/WebCore/rendering/RenderListBox.cpp 2016-01-02 04:45:36 UTC (rev 194487)
@@ -608,7 +608,7 @@
return m_indexOffset;
}
-void RenderListBox::setScrollOffset(const IntPoint& offset)
+void RenderListBox::setScrollOffset(const ScrollOffset& offset)
{
scrollTo(offset.y());
}
Modified: trunk/Source/WebCore/rendering/RenderListBox.h (194486 => 194487)
--- trunk/Source/WebCore/rendering/RenderListBox.h 2016-01-02 04:44:16 UTC (rev 194486)
+++ trunk/Source/WebCore/rendering/RenderListBox.h 2016-01-02 04:45:36 UTC (rev 194487)
@@ -111,7 +111,7 @@
// ScrollableArea interface.
virtual int scrollSize(ScrollbarOrientation) const override;
virtual int scrollPosition(Scrollbar*) const override;
- virtual void setScrollOffset(const IntPoint&) override;
+ virtual void setScrollOffset(const ScrollOffset&) override;
virtual void invalidateScrollbarRect(Scrollbar*, const IntRect&) override;
virtual bool isActive() const override;
virtual bool isScrollCornerVisible() const override { return false; } // We don't support resize on list boxes yet. If we did these would have to change.
Modified: trunk/Source/WebKit2/ChangeLog (194486 => 194487)
--- trunk/Source/WebKit2/ChangeLog 2016-01-02 04:44:16 UTC (rev 194486)
+++ trunk/Source/WebKit2/ChangeLog 2016-01-02 04:45:36 UTC (rev 194487)
@@ -1,3 +1,33 @@
+2016-01-01 Simon Fraser <[email protected]>
+
+ Fix reload and programmatic scrolling in RTL documents
+ https://bugs.webkit.org/show_bug.cgi?id=152639
+
+ Reviewed by Zalan Bujtas.
+
+ Reloading a left-scrolled RTL document would cause the content to appear
+ at an odd offset, and programmatic sideways scrolls in RTL documents also
+ jumped to the wrong location.
+
+ Fix by resolving offset/position confusion in ScrollableArea::scrollPositionChanged()
+ and the scrolling tree.
+
+ ScrollableArea::scrollPositionChanged() was erroneously passing a scrollPosition
+ to setScrollOffset().
+
+ ScrollingTreeFrameScrollingNode* were confused about offsets and positions. It
+ turns out that the layer position is just -scrollPosition, but minimumScrollPosition()
+ and maximumScrollPosition() need fixing to return positions, not offsets.
+
+ ScrollingTreeFrameScrollingNode::viewToContentsOffset() was also doing incorrect
+ math with scrollOrigin, which was detected by a failing test.
+
+ Add more logging to the Scrolling channel.
+
+ * WebProcess/Plugins/PDF/DeprecatedPDFPlugin.h:
+ * WebProcess/Plugins/PDF/DeprecatedPDFPlugin.mm:
+ (WebKit::PDFPlugin::setScrollOffset):
+
2016-01-01 Michael Catanzaro <[email protected]>
[SOUP] REGRESSION(r192761): Broke resource URIs for applications that use g_resource_load in a web extension
Modified: trunk/Source/WebKit2/WebProcess/Plugins/PDF/DeprecatedPDFPlugin.h (194486 => 194487)
--- trunk/Source/WebKit2/WebProcess/Plugins/PDF/DeprecatedPDFPlugin.h 2016-01-02 04:44:16 UTC (rev 194486)
+++ trunk/Source/WebKit2/WebProcess/Plugins/PDF/DeprecatedPDFPlugin.h 2016-01-02 04:45:36 UTC (rev 194487)
@@ -189,7 +189,7 @@
virtual bool isScrollableOrRubberbandable() override { return true; }
virtual bool hasScrollableOrRubberbandableAncestor() override { return true; }
virtual WebCore::IntRect scrollableAreaBoundingBox(bool* = nullptr) const override;
- virtual void setScrollOffset(const WebCore::IntPoint&) override;
+ virtual void setScrollOffset(const WebCore::ScrollOffset&) override;
virtual void invalidateScrollbarRect(WebCore::Scrollbar*, const WebCore::IntRect&) override;
virtual void invalidateScrollCornerRect(const WebCore::IntRect&) override;
virtual WebCore::IntPoint lastKnownMousePosition() const override { return m_lastMousePositionInPluginCoordinates; }
Modified: trunk/Source/WebKit2/WebProcess/Plugins/PDF/DeprecatedPDFPlugin.mm (194486 => 194487)
--- trunk/Source/WebKit2/WebProcess/Plugins/PDF/DeprecatedPDFPlugin.mm 2016-01-02 04:44:16 UTC (rev 194486)
+++ trunk/Source/WebKit2/WebProcess/Plugins/PDF/DeprecatedPDFPlugin.mm 2016-01-02 04:45:36 UTC (rev 194487)
@@ -1538,7 +1538,7 @@
return false;
}
-void PDFPlugin::setScrollOffset(const IntPoint& offset)
+void PDFPlugin::setScrollOffset(const ScrollOffset& offset)
{
m_scrollOffset = IntSize(offset.x(), offset.y());