REGRESSION (WebKit2): Programmatic scrolls in overflow-scrolling:touch don't work
authorsimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 15 Apr 2014 00:47:46 +0000 (00:47 +0000)
committersimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 15 Apr 2014 00:47:46 +0000 (00:47 +0000)
https://bugs.webkit.org/show_bug.cgi?id=131649

Reviewed by Tim Horton.

Update the UIScrollView's contentOffset when we're told that the scroll position
changed.

Also refactor slightly to have a single exception-protected block.

* UIProcess/Scrolling/ios/ScrollingTreeOverflowScrollingNodeIOS.mm:
(WebKit::ScrollingTreeOverflowScrollingNodeIOS::updateAfterChildren):

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

Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/Scrolling/ios/ScrollingTreeOverflowScrollingNodeIOS.mm

index c76fc0b..3dd0b74 100644 (file)
@@ -1,3 +1,18 @@
+2014-04-14  Simon Fraser  <simon.fraser@apple.com>
+
+        REGRESSION (WebKit2): Programmatic scrolls in overflow-scrolling:touch don't work
+        https://bugs.webkit.org/show_bug.cgi?id=131649
+
+        Reviewed by Tim Horton.
+        
+        Update the UIScrollView's contentOffset when we're told that the scroll position
+        changed.
+        
+        Also refactor slightly to have a single exception-protected block.
+
+        * UIProcess/Scrolling/ios/ScrollingTreeOverflowScrollingNodeIOS.mm:
+        (WebKit::ScrollingTreeOverflowScrollingNodeIOS::updateAfterChildren):
+
 2014-04-14  Tim Horton  <timothy_horton@apple.com>
 
         Fix the 32-bit build.
index 80da75a..42a4a7b 100644 (file)
@@ -115,24 +115,25 @@ void ScrollingTreeOverflowScrollingNodeIOS::updateAfterChildren(const ScrollingS
 
     const auto& scrollingStateNode = toScrollingStateScrollingNode(stateNode);
 
-    if (scrollingStateNode.hasChangedProperty(ScrollingStateScrollingNode::ScrollLayer)) {
+    if (scrollingStateNode.hasChangedProperty(ScrollingStateScrollingNode::ScrollLayer)
+        || scrollingStateNode.hasChangedProperty(ScrollingStateScrollingNode::TotalContentsSize)
+        || scrollingStateNode.hasChangedProperty(ScrollingStateScrollingNode::ScrollPosition)) {
         BEGIN_BLOCK_OBJC_EXCEPTIONS
         UIScrollView *scrollView = (UIScrollView *)[scrollLayer() delegate];
         ASSERT([scrollView isKindOfClass:[UIScrollView self]]);
 
-        if (!m_scrollViewDelegate)
-            m_scrollViewDelegate = adoptNS([[WKOverflowScrollViewDelegate alloc] initWithScrollingTreeNode:this]);
+        if (scrollingStateNode.hasChangedProperty(ScrollingStateScrollingNode::ScrollLayer)) {
+            if (!m_scrollViewDelegate)
+                m_scrollViewDelegate = adoptNS([[WKOverflowScrollViewDelegate alloc] initWithScrollingTreeNode:this]);
 
-        scrollView.delegate = m_scrollViewDelegate.get();
-        END_BLOCK_OBJC_EXCEPTIONS
-    }
+            scrollView.delegate = m_scrollViewDelegate.get();
+        }
 
-    if (scrollingStateNode.hasChangedProperty(ScrollingStateScrollingNode::TotalContentsSize)) {
-        BEGIN_BLOCK_OBJC_EXCEPTIONS
-        UIScrollView *scrollView = (UIScrollView *)[scrollLayer() delegate];
-        ASSERT([scrollView isKindOfClass:[UIScrollView self]]);
+        if (scrollingStateNode.hasChangedProperty(ScrollingStateScrollingNode::TotalContentsSize))
+            scrollView.contentSize = scrollingStateNode.totalContentsSize();
 
-        scrollView.contentSize = scrollingStateNode.totalContentsSize();
+        if (scrollingStateNode.hasChangedProperty(ScrollingStateScrollingNode::ScrollPosition))
+            scrollView.contentOffset = scrollingStateNode.scrollPosition();
 
         END_BLOCK_OBJC_EXCEPTIONS
     }