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#ifndef ScrollingTreeFrameScrollingNode_h 27#define ScrollingTreeFrameScrollingNode_h 28 29#if ENABLE(ASYNC_SCROLLING) 30 31#include "ScrollingTreeScrollingNode.h" 32 33namespace WebCore { 34 35class PlatformWheelEvent; 36class ScrollingTree; 37class ScrollingStateScrollingNode; 38 39class ScrollingTreeFrameScrollingNode : public ScrollingTreeScrollingNode { 40public: 41 virtual ~ScrollingTreeFrameScrollingNode(); 42 43 virtual void updateBeforeChildren(const ScrollingStateNode&) override; 44 45 // FIXME: We should implement this when we support ScrollingTreeScrollingNodes as children. 46 virtual void updateLayersAfterAncestorChange(const ScrollingTreeNode& /*changedNode*/, const FloatRect& /*fixedPositionRect*/, const FloatSize& /*cumulativeDelta*/) override { } 47 48 virtual void handleWheelEvent(const PlatformWheelEvent&) = 0; 49 virtual void setScrollPosition(const FloatPoint&); 50 virtual void setScrollPositionWithoutContentEdgeConstraints(const FloatPoint&) = 0; 51 52 virtual void updateLayersAfterViewportChange(const FloatRect& fixedPositionRect, double scale) = 0; 53 virtual void updateLayersAfterDelegatedScroll(const FloatPoint&) { } 54 55 SynchronousScrollingReasons synchronousScrollingReasons() const { return m_synchronousScrollingReasons; } 56 bool shouldUpdateScrollLayerPositionSynchronously() const { return m_synchronousScrollingReasons; } 57 58protected: 59 ScrollingTreeFrameScrollingNode(ScrollingTree&, ScrollingNodeID); 60 61 void scrollBy(const FloatSize&); 62 void scrollByWithoutContentEdgeConstraints(const FloatSize&); 63 64 float frameScaleFactor() const { return m_frameScaleFactor; } 65 int headerHeight() const { return m_headerHeight; } 66 int footerHeight() const { return m_footerHeight; } 67 float topContentInset() const { return m_topContentInset; } 68 69 ScrollBehaviorForFixedElements scrollBehaviorForFixedElements() const { return m_behaviorForFixed; } 70 71private: 72 float m_frameScaleFactor; 73 74 int m_headerHeight; 75 int m_footerHeight; 76 float m_topContentInset; 77 78 SynchronousScrollingReasons m_synchronousScrollingReasons; 79 ScrollBehaviorForFixedElements m_behaviorForFixed; 80}; 81 82SCROLLING_NODE_TYPE_CASTS(ScrollingTreeFrameScrollingNode, isFrameScrollingNode()); 83 84} // namespace WebCore 85 86#endif // ENABLE(ASYNC_SCROLLING) 87 88#endif // ScrollingTreeScrollingNode_h 89