Transfer the non-fast-scrollable region to the UI process for iOS
https://bugs.webkit.org/show_bug.cgi?id=128293

Reviewed by Benjamin Poulain.

Source/WebCore:

Two main changes to support sending the non-fast scrollable region
to the UI process for iOS:

1. Add ScrollingCoordinator::frameViewNonFastScrollableRegionChanged(),
which is called when we've updated the touch event region (this can happen
independenly of layout). When called we just scheduled a scrolling tree
commit with the new region.

2. Avoid thinking that we have a new root node with every remote scrolling
transaction. This was a side-effect of reconstructing the scrolling state
tree in the UI process, and caused us to try to grab a nonFastScrollableRegion
from a node which never had one set.

* WebCore.exp.in:
* page/scrolling/AsyncScrollingCoordinator.cpp:
(WebCore::AsyncScrollingCoordinator::frameViewNonFastScrollableRegionChanged):
* page/scrolling/AsyncScrollingCoordinator.h:
* page/scrolling/ScrollingCoordinator.cpp:
(WebCore::ScrollingCoordinator::computeNonFastScrollableRegion):
* page/scrolling/ScrollingCoordinator.h:
(WebCore::ScrollingCoordinator::frameViewNonFastScrollableRegionChanged):
* page/scrolling/ScrollingStateTree.h:
(WebCore::ScrollingStateTree::setHasNewRootStateNode):
* page/scrolling/ScrollingTree.cpp:
(WebCore::ScrollingTree::commitNewTreeState):
(WebCore::ScrollingTree::isPointInNonFastScrollableRegion):
* page/scrolling/ScrollingTree.h:

Source/WebKit2:

Two main changes to support sending the non-fast scrollable region
to the UI process for iOS:

1. Add ScrollingCoordinator::frameViewNonFastScrollableRegionChanged(),
which is called when we've updated the touch event region (this can happen
independenly of layout). When called we just scheduled a scrolling tree
commit with the new region.

2. Avoid thinking that we have a new root node with every remote scrolling
transaction. This was a side-effect of reconstructing the scrolling state
tree in the UI process, and caused us to try to grab a nonFastScrollableRegion
from a node which never had one set.

Now that we have the non-fast scrollable region in the UI process, we can
use it to avoid sending sync messages to the web process.

* Shared/Scrolling/RemoteScrollingCoordinatorTransaction.cpp:
(ArgumentCoder<ScrollingStateScrollingNode>::encode): Encode hasNewRootNode.
(ArgumentCoder<ScrollingStateScrollingNode>::decode): Decode hasNewRootNode and set it on
the state tree.
(WebKit::RemoteScrollingCoordinatorTransaction::encode): Encode the nonFastScrollableRegion
now that we can encode Regions.
(WebKit::RemoteScrollingCoordinatorTransaction::decode): Decode the nonFastScrollableRegion
now that we can decode Regions.
* UIProcess/Scrolling/RemoteScrollingCoordinatorProxy.cpp:
(WebKit::RemoteScrollingCoordinatorProxy::isPointInNonFastScrollableRegion):
* UIProcess/Scrolling/RemoteScrollingCoordinatorProxy.h:
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::handleTouchEvent): If we're not in the non-fast scrollable region,
don't both sending touch events to the web process.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@163516 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/WebCore/page/scrolling/AsyncScrollingCoordinator.cpp b/Source/WebCore/page/scrolling/AsyncScrollingCoordinator.cpp
index 67d7109..fc7596d 100644
--- a/Source/WebCore/page/scrolling/AsyncScrollingCoordinator.cpp
+++ b/Source/WebCore/page/scrolling/AsyncScrollingCoordinator.cpp
@@ -105,6 +105,15 @@
     node->setScrollableAreaParameters(scrollParameters);
 }
 
+void AsyncScrollingCoordinator::frameViewNonFastScrollableRegionChanged(FrameView*)
+{
+    if (!m_scrollingStateTree->rootStateNode())
+        return;
+
+    Region nonFastScrollableRegion = computeNonFastScrollableRegion(&m_page->mainFrame(), IntPoint());
+    setNonFastScrollableRegionForNode(nonFastScrollableRegion, m_scrollingStateTree->rootStateNode());
+}
+
 void AsyncScrollingCoordinator::frameViewRootLayerDidChange(FrameView* frameView)
 {
     ASSERT(isMainThread());