1/* 2 * Copyright (C) 2014 Apple Inc. All rights reserved. 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 1. Redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer. 9 * 2. Redistributions in binary form must reproduce the above copyright 10 * notice, this list of conditions and the following disclaimer in the 11 * documentation and/or other materials provided with the distribution. 12 * 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' 14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS 17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 23 * THE POSSIBILITY OF SUCH DAMAGE. 24 */ 25 26#include "config.h" 27#include "RemoteScrollingCoordinatorProxy.h" 28 29#if PLATFORM(IOS) 30#if ENABLE(ASYNC_SCROLLING) 31 32#include "LayerRepresentation.h" 33#include "RemoteLayerTreeHost.h" 34#include "WebPageProxy.h" 35#include <WebCore/ScrollingStateFrameScrollingNode.h> 36#include <WebCore/ScrollingStateOverflowScrollingNode.h> 37#include <WebCore/ScrollingStateTree.h> 38#include <UIKit/UIView.h> 39 40using namespace WebCore; 41 42namespace WebKit { 43 44static LayerRepresentation layerRepresentationFromLayerOrView(LayerOrView *layerOrView) 45{ 46 return LayerRepresentation(layerOrView.layer); 47} 48 49void RemoteScrollingCoordinatorProxy::connectStateNodeLayers(ScrollingStateTree& stateTree, const RemoteLayerTreeHost& layerTreeHost) 50{ 51 for (auto& currNode : stateTree.nodeMap().values()) { 52 switch (currNode->nodeType()) { 53 case OverflowScrollingNode: { 54 ScrollingStateOverflowScrollingNode* scrollingStateNode = toScrollingStateOverflowScrollingNode(currNode); 55 56 if (scrollingStateNode->hasChangedProperty(ScrollingStateNode::ScrollLayer)) 57 scrollingStateNode->setLayer(layerRepresentationFromLayerOrView(layerTreeHost.getLayer(scrollingStateNode->layer()))); 58 59 if (scrollingStateNode->hasChangedProperty(ScrollingStateOverflowScrollingNode::ScrolledContentsLayer)) 60 scrollingStateNode->setScrolledContentsLayer(layerRepresentationFromLayerOrView(layerTreeHost.getLayer(scrollingStateNode->scrolledContentsLayer()))); 61 break; 62 }; 63 case FrameScrollingNode: { 64 ScrollingStateFrameScrollingNode* scrollingStateNode = toScrollingStateFrameScrollingNode(currNode); 65 66 if (scrollingStateNode->hasChangedProperty(ScrollingStateNode::ScrollLayer)) 67 scrollingStateNode->setLayer(layerRepresentationFromLayerOrView(layerTreeHost.getLayer(scrollingStateNode->layer()))); 68 69 if (scrollingStateNode->hasChangedProperty(ScrollingStateFrameScrollingNode::CounterScrollingLayer)) 70 scrollingStateNode->setCounterScrollingLayer(layerRepresentationFromLayerOrView(layerTreeHost.getLayer(scrollingStateNode->counterScrollingLayer()))); 71 72 // FIXME: we should never have header and footer layers coming from the WebProcess. 73 if (scrollingStateNode->hasChangedProperty(ScrollingStateFrameScrollingNode::HeaderLayer)) 74 scrollingStateNode->setHeaderLayer(layerRepresentationFromLayerOrView(layerTreeHost.getLayer(scrollingStateNode->headerLayer()))); 75 76 if (scrollingStateNode->hasChangedProperty(ScrollingStateFrameScrollingNode::FooterLayer)) 77 scrollingStateNode->setFooterLayer(layerRepresentationFromLayerOrView(layerTreeHost.getLayer(scrollingStateNode->footerLayer()))); 78 break; 79 } 80 case FixedNode: 81 case StickyNode: 82 if (currNode->hasChangedProperty(ScrollingStateNode::ScrollLayer)) 83 currNode->setLayer(layerRepresentationFromLayerOrView(layerTreeHost.getLayer(currNode->layer()))); 84 break; 85 } 86 } 87} 88 89FloatRect RemoteScrollingCoordinatorProxy::customFixedPositionRect() const 90{ 91 return m_webPageProxy.computeCustomFixedPositionRect(m_webPageProxy.unobscuredContentRect(), m_webPageProxy.displayedContentScale()); 92} 93 94void RemoteScrollingCoordinatorProxy::scrollingTreeNodeWillStartPanGesture() 95{ 96 m_webPageProxy.overflowScrollViewWillStartPanGesture(); 97} 98 99void RemoteScrollingCoordinatorProxy::scrollingTreeNodeWillStartScroll() 100{ 101 m_webPageProxy.overflowScrollWillStartScroll(); 102} 103 104void RemoteScrollingCoordinatorProxy::scrollingTreeNodeDidEndScroll() 105{ 106 m_webPageProxy.overflowScrollDidEndScroll(); 107} 108 109} // namespace WebKit 110 111 112#endif // ENABLE(ASYNC_SCROLLING) 113#endif // PLATFORM(IOS) 114