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 ScrollingStateFrameScrollingNode_h 27#define ScrollingStateFrameScrollingNode_h 28 29#if ENABLE(ASYNC_SCROLLING) || USE(COORDINATED_GRAPHICS) 30 31#include "Region.h" 32#include "ScrollTypes.h" 33#include "ScrollbarThemeComposite.h" 34#include "ScrollingCoordinator.h" 35#include "ScrollingStateScrollingNode.h" 36 37namespace WebCore { 38 39class Scrollbar; 40 41class ScrollingStateFrameScrollingNode final : public ScrollingStateScrollingNode { 42public: 43 static PassRefPtr<ScrollingStateFrameScrollingNode> create(ScrollingStateTree&, ScrollingNodeID); 44 45 virtual PassRefPtr<ScrollingStateNode> clone(ScrollingStateTree&); 46 47 virtual ~ScrollingStateFrameScrollingNode(); 48 49 enum ChangedProperty { 50 FrameScaleFactor = NumScrollingStateNodeBits, 51 NonFastScrollableRegion, 52 WheelEventHandlerCount, 53 ReasonsForSynchronousScrolling, 54 ScrolledContentsLayer, 55 CounterScrollingLayer, 56 InsetClipLayer, 57 ContentShadowLayer, 58 HeaderHeight, 59 FooterHeight, 60 HeaderLayer, 61 FooterLayer, 62 PainterForScrollbar, 63 BehaviorForFixedElements, 64 TopContentInset 65 }; 66 67 float frameScaleFactor() const { return m_frameScaleFactor; } 68 void setFrameScaleFactor(float); 69 70 const Region& nonFastScrollableRegion() const { return m_nonFastScrollableRegion; } 71 void setNonFastScrollableRegion(const Region&); 72 73 unsigned wheelEventHandlerCount() const { return m_wheelEventHandlerCount; } 74 void setWheelEventHandlerCount(unsigned); 75 76 SynchronousScrollingReasons synchronousScrollingReasons() const { return m_synchronousScrollingReasons; } 77 void setSynchronousScrollingReasons(SynchronousScrollingReasons); 78 79 ScrollBehaviorForFixedElements scrollBehaviorForFixedElements() const { return m_behaviorForFixed; } 80 void setScrollBehaviorForFixedElements(ScrollBehaviorForFixedElements); 81 82 int headerHeight() const { return m_headerHeight; } 83 void setHeaderHeight(int); 84 85 int footerHeight() const { return m_footerHeight; } 86 void setFooterHeight(int); 87 88 float topContentInset() const { return m_topContentInset; } 89 void setTopContentInset(float); 90 91 const LayerRepresentation& scrolledContentsLayer() const { return m_scrolledContentsLayer; } 92 void setScrolledContentsLayer(const LayerRepresentation&); 93 94 // This is a layer moved in the opposite direction to scrolling, for example for background-attachment:fixed 95 const LayerRepresentation& counterScrollingLayer() const { return m_counterScrollingLayer; } 96 void setCounterScrollingLayer(const LayerRepresentation&); 97 98 // This is a clipping layer that will scroll with the page for all y-delta scroll values between 0 99 // and topContentInset(). Once the y-deltas get beyond the content inset point, this layer no longer 100 // needs to move. If the topContentInset() is 0, this layer does not need to move at all. This is 101 // only used on the Mac. 102 const LayerRepresentation& insetClipLayer() const { return m_insetClipLayer; } 103 void setInsetClipLayer(const LayerRepresentation&); 104 105 const LayerRepresentation& contentShadowLayer() const { return m_contentShadowLayer; } 106 void setContentShadowLayer(const LayerRepresentation&); 107 108 // The header and footer layers scroll vertically with the page, they should remain fixed when scrolling horizontally. 109 const LayerRepresentation& headerLayer() const { return m_headerLayer; } 110 void setHeaderLayer(const LayerRepresentation&); 111 112 // The header and footer layers scroll vertically with the page, they should remain fixed when scrolling horizontally. 113 const LayerRepresentation& footerLayer() const { return m_footerLayer; } 114 void setFooterLayer(const LayerRepresentation&); 115 116#if PLATFORM(MAC) 117 ScrollbarPainter verticalScrollbarPainter() const { return m_verticalScrollbarPainter.get(); } 118 ScrollbarPainter horizontalScrollbarPainter() const { return m_horizontalScrollbarPainter.get(); } 119#endif 120 void setScrollbarPaintersFromScrollbars(Scrollbar* verticalScrollbar, Scrollbar* horizontalScrollbar); 121 122 virtual void dumpProperties(TextStream&, int indent) const override; 123 124private: 125 ScrollingStateFrameScrollingNode(ScrollingStateTree&, ScrollingNodeID); 126 ScrollingStateFrameScrollingNode(const ScrollingStateFrameScrollingNode&, ScrollingStateTree&); 127 128 LayerRepresentation m_counterScrollingLayer; 129 LayerRepresentation m_insetClipLayer; 130 LayerRepresentation m_scrolledContentsLayer; 131 LayerRepresentation m_contentShadowLayer; 132 LayerRepresentation m_headerLayer; 133 LayerRepresentation m_footerLayer; 134 135#if PLATFORM(MAC) 136 RetainPtr<ScrollbarPainter> m_verticalScrollbarPainter; 137 RetainPtr<ScrollbarPainter> m_horizontalScrollbarPainter; 138#endif 139 140 Region m_nonFastScrollableRegion; 141 float m_frameScaleFactor; 142 unsigned m_wheelEventHandlerCount; 143 SynchronousScrollingReasons m_synchronousScrollingReasons; 144 ScrollBehaviorForFixedElements m_behaviorForFixed; 145 int m_headerHeight; 146 int m_footerHeight; 147 FloatPoint m_requestedScrollPosition; 148 bool m_requestedScrollPositionRepresentsProgrammaticScroll; 149 float m_topContentInset; 150}; 151 152SCROLLING_STATE_NODE_TYPE_CASTS(ScrollingStateFrameScrollingNode, isFrameScrollingNode()); 153 154} // namespace WebCore 155 156#endif // ENABLE(ASYNC_SCROLLING) || USE(COORDINATED_GRAPHICS) 157 158#endif // ScrollingStateFrameScrollingNode_h 159