Fix reload and programmatic scrolling in RTL documents
authorsimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 2 Jan 2016 04:45:36 +0000 (04:45 +0000)
committersimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 2 Jan 2016 04:45:36 +0000 (04:45 +0000)
commit69f7fe851202ea9b5584e9ea071c58140bdbfa10
treefea9e93bc8df41a16b169b63685b7c46fdd73c10
parent320ff920ea6a02706b082977bd0d7b2d2a171788
Fix reload and programmatic scrolling in RTL documents
https://bugs.webkit.org/show_bug.cgi?id=152639

Reviewed by Zalan Bujtas.
Source/WebCore:

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:

Source/WebKit2:

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):

LayoutTests:

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.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@194487 268f45cc-cd09-0410-ab3c-d52691b4dbfc
23 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/scrolling/programmatic-document-rtl-scroll-expected.html [new file with mode: 0644]
LayoutTests/fast/scrolling/programmatic-document-rtl-scroll.html [new file with mode: 0644]
LayoutTests/fast/scrolling/programmatic-document-rtl-scrollIntoView-expected.txt [new file with mode: 0644]
LayoutTests/fast/scrolling/programmatic-document-rtl-scrollIntoView.html [new file with mode: 0644]
LayoutTests/fast/scrolling/scroll-position-on-reload-rtl-expected.txt [new file with mode: 0644]
LayoutTests/fast/scrolling/scroll-position-on-reload-rtl.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/page/FrameView.cpp
Source/WebCore/page/scrolling/ScrollingTree.cpp
Source/WebCore/page/scrolling/ScrollingTreeFrameScrollingNode.cpp
Source/WebCore/page/scrolling/ScrollingTreeFrameScrollingNode.h
Source/WebCore/page/scrolling/ios/ScrollingTreeFrameScrollingNodeIOS.mm
Source/WebCore/page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.mm
Source/WebCore/platform/ScrollView.cpp
Source/WebCore/platform/ScrollView.h
Source/WebCore/platform/ScrollableArea.cpp
Source/WebCore/platform/ScrollableArea.h
Source/WebCore/rendering/RenderListBox.cpp
Source/WebCore/rendering/RenderListBox.h
Source/WebKit2/ChangeLog
Source/WebKit2/WebProcess/Plugins/PDF/DeprecatedPDFPlugin.h
Source/WebKit2/WebProcess/Plugins/PDF/DeprecatedPDFPlugin.mm