Sideways-scrollable RTL document has wrong initial and reload offset in WKWebView
authorsimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 19 Mar 2016 00:00:46 +0000 (00:00 +0000)
committersimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 19 Mar 2016 00:00:46 +0000 (00:00 +0000)
commit6359c0ef254ed496bb624f750e853159a8dd7ced
treedb8d096bc011fe42d7999ea338fa2aafe39683f2
parentaabfd9a0dfda21a7a584fb8a8dc0bcb0dcb20c15
Sideways-scrollable RTL document has wrong initial and reload offset in WKWebView
https://bugs.webkit.org/show_bug.cgi?id=155660
Source/WebCore:

rdar://problem/22212662

Reviewed by Tim Horton.

There were two problems with the scroll position of RTL documents on initial and reload
in WKWebView.

First, in the delegatesScrolling() code path, ScrollView::updateScrollbars() needs to
tell someone that the scroll origin changed, to trigger a scroll to the page origin.

Secondly, WKWebView had scrollPosition/scrollOffset confusion in various places.

Test: fast/scrolling/rtl-initial-scroll-position.html

* platform/ScrollView.cpp:
(WebCore::ScrollView::updateScrollbars):

Source/WebKit2:

Reviewed by Tim Horton.

There were two problems with the scroll position of RTL documents on initial and reload
in WKWebView.

First, in the delegatesScrolling() code path, ScrollView::updateScrollbars() needs to
tell someone that the scroll origin changed, to trigger a scroll to the page origin.

Secondly, WKWebView had scrollPosition/scrollOffset confusion in various places. In
the restorePageState() code path, WebCore passes an exposedRect; this patch makes
it explicit that it's an exposedContentRect, and passes scrollOrigin so that it can
be mapped into scrollOffset-relative coordinates that the UIScrollView wants.

When reloading an RTL page, there was an additional issue; restorePageState()
restored the exposedRect, but then we'd see the origin change as a programmatic scroll
to 0,0, clobbering the exposedRect. Fix by using a "_commitDidRestoreExposedRect" flag
on the WKWebView that is used to ignore the programmatic scroll in that case.

Ideally these changes would fix fast/scrolling/scroll-position-on-reload-rtl.html, but the
test still fails because of timing differences between OS X and iOS.

* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView _didCommitLayerTree:]):
(-[WKWebView _layerTreeCommitComplete]):
(-[WKWebView _restorePageStateToExposedRect:scrollOrigin:scale:]):
(-[WKWebView _scrollToContentScrollPosition:scrollOrigin:]):
(-[WKWebView _restorePageStateToExposedRect:scale:]): Deleted.
(-[WKWebView _scrollToContentOffset:scrollOrigin:]): Deleted.
* UIProcess/API/Cocoa/WKWebViewInternal.h:
* UIProcess/PageClient.h:
* UIProcess/WebPageProxy.h:
* UIProcess/WebPageProxy.messages.in:
* UIProcess/ios/PageClientImplIOS.h:
* UIProcess/ios/PageClientImplIOS.mm:
(WebKit::PageClientImpl::requestScroll):
(WebKit::PageClientImpl::layerTreeCommitComplete):
(WebKit::PageClientImpl::restorePageState):
* UIProcess/ios/WKContentView.h:
* UIProcess/ios/WKContentView.mm:
(-[WKContentView _layerTreeCommitComplete]):
* UIProcess/ios/WebPageProxyIOS.mm:
(WebKit::WebPageProxy::layerTreeCommitComplete):
(WebKit::WebPageProxy::restorePageState):
* UIProcess/mac/RemoteLayerTreeDrawingAreaProxy.mm:
(WebKit::RemoteLayerTreeDrawingAreaProxy::commitLayerTree):
* WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::WebPage::restorePageState):

LayoutTests:

Reviewed by Tim Horton.

Test for initial scroll position in an RTL page.

* fast/scrolling/rtl-initial-scroll-position-expected.html: Added.
* fast/scrolling/rtl-initial-scroll-position.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@198455 268f45cc-cd09-0410-ab3c-d52691b4dbfc
18 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/scrolling/rtl-initial-scroll-position-expected.html [new file with mode: 0644]
LayoutTests/fast/scrolling/rtl-initial-scroll-position.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/platform/ScrollView.cpp
Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm
Source/WebKit2/UIProcess/API/Cocoa/WKWebViewInternal.h
Source/WebKit2/UIProcess/PageClient.h
Source/WebKit2/UIProcess/WebPageProxy.h
Source/WebKit2/UIProcess/WebPageProxy.messages.in
Source/WebKit2/UIProcess/ios/PageClientImplIOS.h
Source/WebKit2/UIProcess/ios/PageClientImplIOS.mm
Source/WebKit2/UIProcess/ios/WKContentView.h
Source/WebKit2/UIProcess/ios/WKContentView.mm
Source/WebKit2/UIProcess/ios/WebPageProxyIOS.mm
Source/WebKit2/UIProcess/mac/RemoteLayerTreeDrawingAreaProxy.mm
Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm