1/*
2 * Copyright (C) 2014, 2016 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#pragma once
27
28#if ENABLE(ASYNC_SCROLLING)
29
30#include "EventTrackingRegions.h"
31#include "ScrollTypes.h"
32#include "ScrollbarThemeComposite.h"
33#include "ScrollingCoordinator.h"
34#include "ScrollingStateScrollingNode.h"
35
36namespace WebCore {
37
38class Scrollbar;
39
40class ScrollingStateFrameScrollingNode final : public ScrollingStateScrollingNode {
41public:
42 static Ref<ScrollingStateFrameScrollingNode> create(ScrollingStateTree&, ScrollingNodeType, ScrollingNodeID);
43
44 Ref<ScrollingStateNode> clone(ScrollingStateTree&) override;
45
46 virtual ~ScrollingStateFrameScrollingNode();
47
48 enum ChangedProperty {
49 FrameScaleFactor = NumScrollingStateNodeBits,
50 EventTrackingRegion,
51 ReasonsForSynchronousScrolling,
52 RootContentsLayer,
53 ScrolledContentsLayer,
54 CounterScrollingLayer,
55 InsetClipLayer,
56 ContentShadowLayer,
57 HeaderHeight,
58 FooterHeight,
59 HeaderLayer,
60 FooterLayer,
61 BehaviorForFixedElements,
62 TopContentInset,
63 FixedElementsLayoutRelativeToFrame,
64 AsyncFrameOrOverflowScrollingEnabled,
65 LayoutViewport,
66 MinLayoutViewportOrigin,
67 MaxLayoutViewportOrigin,
68 };
69
70 float frameScaleFactor() const { return m_frameScaleFactor; }
71 WEBCORE_EXPORT void setFrameScaleFactor(float);
72
73 const EventTrackingRegions& eventTrackingRegions() const { return m_eventTrackingRegions; }
74 WEBCORE_EXPORT void setEventTrackingRegions(const EventTrackingRegions&);
75
76 SynchronousScrollingReasons synchronousScrollingReasons() const { return m_synchronousScrollingReasons; }
77 WEBCORE_EXPORT void setSynchronousScrollingReasons(SynchronousScrollingReasons);
78
79 ScrollBehaviorForFixedElements scrollBehaviorForFixedElements() const { return m_behaviorForFixed; }
80 WEBCORE_EXPORT void setScrollBehaviorForFixedElements(ScrollBehaviorForFixedElements);
81
82 FloatRect layoutViewport() const { return m_layoutViewport; };
83 WEBCORE_EXPORT void setLayoutViewport(const FloatRect&);
84
85 FloatPoint minLayoutViewportOrigin() const { return m_minLayoutViewportOrigin; }
86 WEBCORE_EXPORT void setMinLayoutViewportOrigin(const FloatPoint&);
87
88 FloatPoint maxLayoutViewportOrigin() const { return m_maxLayoutViewportOrigin; }
89 WEBCORE_EXPORT void setMaxLayoutViewportOrigin(const FloatPoint&);
90
91 int headerHeight() const { return m_headerHeight; }
92 WEBCORE_EXPORT void setHeaderHeight(int);
93
94 int footerHeight() const { return m_footerHeight; }
95 WEBCORE_EXPORT void setFooterHeight(int);
96
97 float topContentInset() const { return m_topContentInset; }
98 WEBCORE_EXPORT void setTopContentInset(float);
99
100 const LayerRepresentation& rootContentsLayer() const { return m_rootContentsLayer; }
101 WEBCORE_EXPORT void setRootContentsLayer(const LayerRepresentation&);
102
103 // This is a layer moved in the opposite direction to scrolling, for example for background-attachment:fixed
104 const LayerRepresentation& counterScrollingLayer() const { return m_counterScrollingLayer; }
105 WEBCORE_EXPORT void setCounterScrollingLayer(const LayerRepresentation&);
106
107 // This is a clipping layer that will scroll with the page for all y-delta scroll values between 0
108 // and topContentInset(). Once the y-deltas get beyond the content inset point, this layer no longer
109 // needs to move. If the topContentInset() is 0, this layer does not need to move at all. This is
110 // only used on the Mac.
111 const LayerRepresentation& insetClipLayer() const { return m_insetClipLayer; }
112 WEBCORE_EXPORT void setInsetClipLayer(const LayerRepresentation&);
113
114 const LayerRepresentation& contentShadowLayer() const { return m_contentShadowLayer; }
115 WEBCORE_EXPORT void setContentShadowLayer(const LayerRepresentation&);
116
117 // The header and footer layers scroll vertically with the page, they should remain fixed when scrolling horizontally.
118 const LayerRepresentation& headerLayer() const { return m_headerLayer; }
119 WEBCORE_EXPORT void setHeaderLayer(const LayerRepresentation&);
120
121 // The header and footer layers scroll vertically with the page, they should remain fixed when scrolling horizontally.
122 const LayerRepresentation& footerLayer() const { return m_footerLayer; }
123 WEBCORE_EXPORT void setFooterLayer(const LayerRepresentation&);
124
125 // These are more like Settings, and should probably move to the Scrolling{State}Tree itself.
126 bool fixedElementsLayoutRelativeToFrame() const { return m_fixedElementsLayoutRelativeToFrame; }
127 WEBCORE_EXPORT void setFixedElementsLayoutRelativeToFrame(bool);
128
129 bool asyncFrameOrOverflowScrollingEnabled() const { return m_asyncFrameOrOverflowScrollingEnabled; }
130 void setAsyncFrameOrOverflowScrollingEnabled(bool);
131
132 void dumpProperties(WTF::TextStream&, ScrollingStateTreeAsTextBehavior) const override;
133
134private:
135 ScrollingStateFrameScrollingNode(ScrollingStateTree&, ScrollingNodeType, ScrollingNodeID);
136 ScrollingStateFrameScrollingNode(const ScrollingStateFrameScrollingNode&, ScrollingStateTree&);
137
138 void setAllPropertiesChanged() override;
139
140 LayerRepresentation m_rootContentsLayer;
141 LayerRepresentation m_counterScrollingLayer;
142 LayerRepresentation m_insetClipLayer;
143 LayerRepresentation m_contentShadowLayer;
144 LayerRepresentation m_headerLayer;
145 LayerRepresentation m_footerLayer;
146
147 EventTrackingRegions m_eventTrackingRegions;
148
149 FloatRect m_layoutViewport;
150 FloatPoint m_minLayoutViewportOrigin;
151 FloatPoint m_maxLayoutViewportOrigin;
152
153 float m_frameScaleFactor { 1 };
154 float m_topContentInset { 0 };
155 int m_headerHeight { 0 };
156 int m_footerHeight { 0 };
157 SynchronousScrollingReasons m_synchronousScrollingReasons { 0 };
158 ScrollBehaviorForFixedElements m_behaviorForFixed { StickToDocumentBounds };
159 bool m_fixedElementsLayoutRelativeToFrame { false };
160 bool m_asyncFrameOrOverflowScrollingEnabled { false };
161};
162
163} // namespace WebCore
164
165SPECIALIZE_TYPE_TRAITS_SCROLLING_STATE_NODE(ScrollingStateFrameScrollingNode, isFrameScrollingNode())
166
167#endif // ENABLE(ASYNC_SCROLLING)
168