WK2: Programatic scroll requests during scroll or zoom animation to reveal focused...
authorenrica@apple.com <enrica@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 7 May 2014 22:42:46 +0000 (22:42 +0000)
committerenrica@apple.com <enrica@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 7 May 2014 22:42:46 +0000 (22:42 +0000)
https://bugs.webkit.org/show_bug.cgi?id=132657
<rdar://problem/16468462>

Reviewed by Benjamin Poulain.

With the scrolling model we use on iOS, a programatic scroll
request can be received while we are still animating to reveal

Source/WebCore:
the focused input element. The WebProcess is unaware that the
scroll position is being changed in the UIProcess, and does not
honor the scroll request from JavaScript.
This is patch changes the behavior for clients using scroll delegates
to always send the scroll request to the UIProcess without checking
the current scroll position.

* page/FrameView.h:
* platform/ScrollView.cpp:
(WebCore::ScrollView::setScrollPosition):
* platform/ScrollView.h:
(WebCore::ScrollView::inProgrammaticScroll):

Source/WebKit2:
the focused input element. Changing the scroll offset while animating
leads to unpredictable results. We now cancel the animation if
a programatic scroll request is received.

* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView _scrollToContentOffset:WebCore::]):
* WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::WebPage::getAssistedNodeInformation):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@168447 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/page/FrameView.h
Source/WebCore/platform/ScrollView.cpp
Source/WebCore/platform/ScrollView.h
Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm
Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm

index 549dac6..6921f97 100644 (file)
@@ -1,3 +1,26 @@
+2014-05-07  Enrica Casucci  <enrica@apple.com>
+
+        WK2: Programatic scroll requests during scroll or zoom animation to reveal focused element are ignored.
+        https://bugs.webkit.org/show_bug.cgi?id=132657
+        <rdar://problem/16468462>
+
+        Reviewed by Benjamin Poulain.
+
+        With the scrolling model we use on iOS, a programatic scroll
+        request can be received while we are still animating to reveal
+        the focused input element. The WebProcess is unaware that the
+        scroll position is being changed in the UIProcess, and does not
+        honor the scroll request from JavaScript.
+        This is patch changes the behavior for clients using scroll delegates
+        to always send the scroll request to the UIProcess without checking
+        the current scroll position.
+
+        * page/FrameView.h:
+        * platform/ScrollView.cpp:
+        (WebCore::ScrollView::setScrollPosition):
+        * platform/ScrollView.h:
+        (WebCore::ScrollView::inProgrammaticScroll):
+
 2014-05-07  Brent Fulgham  <bfulgham@apple.com>
 
         [Mac, iOS] REGRESSION: WK2 YouTube support
index 1767b8a..b57ef49 100644 (file)
@@ -442,7 +442,7 @@ public:
     const Pagination& pagination() const;
     void setPagination(const Pagination&);
     
-    bool inProgrammaticScroll() const { return m_inProgrammaticScroll; }
+    bool inProgrammaticScroll() const override { return m_inProgrammaticScroll; }
     void setInProgrammaticScroll(bool programmaticScroll) { m_inProgrammaticScroll = programmaticScroll; }
 
 #if ENABLE(CSS_DEVICE_ADAPTATION)
index a317039..facece7 100644 (file)
@@ -506,7 +506,7 @@ void ScrollView::setScrollPosition(const IntPoint& scrollPoint)
 
     IntPoint newScrollPosition = adjustScrollPositionWithinRange(scrollPoint);
 
-    if (newScrollPosition == scrollPosition())
+    if ((!delegatesScrolling() || !inProgrammaticScroll()) && newScrollPosition == scrollPosition())
         return;
 
     if (requestScrollPositionUpdate(newScrollPosition))
index dd91454..1493e78 100644 (file)
@@ -192,6 +192,8 @@ public:
     LegacyTileCache* legacyTileCache();
 #endif
 
+    virtual bool inProgrammaticScroll() const { return false; }
+
     // visibleContentRect().size() is computed from unscaledUnobscuredVisibleContentSize() divided by the value of visibleContentScaleFactor.
     // visibleContentScaleFactor is usually 1, except when the setting delegatesPageScaling is true and the
     // ScrollView is the main frame; in that case, visibleContentScaleFactor is equal to the page's pageScaleFactor.
index 6506746..49d616a 100644 (file)
@@ -1,3 +1,22 @@
+2014-05-07  Enrica Casucci  <enrica@apple.com>
+
+        WK2: Programatic scroll requests during scroll or zoom animation to reveal focused element are ignored.
+        https://bugs.webkit.org/show_bug.cgi?id=132657
+        <rdar://problem/16468462>
+
+        Reviewed by Benjamin Poulain.
+
+        With the scrolling model we use on iOS, a programatic scroll
+        request can be received while we are still animating to reveal
+        the focused input element. Changing the scroll offset while animating
+        leads to unpredictable results. We now cancel the animation if
+        a programatic scroll request is received.
+
+        * UIProcess/API/Cocoa/WKWebView.mm:
+        (-[WKWebView _scrollToContentOffset:WebCore::]):
+        * WebProcess/WebPage/ios/WebPageIOS.mm:
+        (WebKit::WebPage::getAssistedNodeInformation):
+
 2014-05-07  Simon Fraser  <simon.fraser@apple.com>
 
         [iOS WK2] Speculative fix for crash in PlatformCALayerRemote::recursiveBuildTransaction
index 2e5bcc5..2ed7757 100644 (file)
@@ -561,6 +561,8 @@ static WebCore::FloatPoint constrainContentOffset(WebCore::FloatPoint contentOff
     if (_isAnimatingResize)
         return;
 
+    [_scrollView _stopScrollingAndZoomingAnimations];
+
     WebCore::FloatPoint scaledOffset = contentOffset;
     CGFloat zoomScale = contentZoomScale(self);
     scaledOffset.scale(zoomScale, zoomScale);
index 38fadfe..999605e 100644 (file)
@@ -1738,6 +1738,8 @@ void WebPage::focusNextAssistedNode(bool isForward)
 
 void WebPage::getAssistedNodeInformation(AssistedNodeInformation& information)
 {
+    layoutIfNeeded();
+
     if (RenderObject* renderer = m_assistedNode->renderer())
         information.elementRect = m_page->focusController().focusedOrMainFrame().view()->contentsToRootView(renderer->absoluteBoundingBoxRect());
     else