OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 15 matching lines...) Expand all Loading... |
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 */ | 29 */ |
30 | 30 |
31 #ifndef VisualViewport_h | 31 #ifndef VisualViewport_h |
32 #define VisualViewport_h | 32 #define VisualViewport_h |
33 | 33 |
34 #include "core/CoreExport.h" | 34 #include "core/CoreExport.h" |
35 #include "core/events/Event.h" | 35 #include "core/events/Event.h" |
36 #include "platform/geometry/FloatPoint.h" | |
37 #include "platform/geometry/FloatRect.h" | 36 #include "platform/geometry/FloatRect.h" |
| 37 #include "platform/geometry/FloatSize.h" |
38 #include "platform/geometry/IntSize.h" | 38 #include "platform/geometry/IntSize.h" |
39 #include "platform/graphics/GraphicsLayerClient.h" | 39 #include "platform/graphics/GraphicsLayerClient.h" |
40 #include "platform/scroll/ScrollableArea.h" | 40 #include "platform/scroll/ScrollableArea.h" |
41 #include "public/platform/WebScrollbar.h" | 41 #include "public/platform/WebScrollbar.h" |
42 #include "public/platform/WebSize.h" | 42 #include "public/platform/WebSize.h" |
43 #include <memory> | 43 #include <memory> |
44 | 44 |
45 namespace blink { | 45 namespace blink { |
46 class WebScrollbarLayer; | 46 class WebScrollbarLayer; |
47 class WebLayer; | 47 class WebLayer; |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 GraphicsLayer* overscrollElasticityLayer() { | 87 GraphicsLayer* overscrollElasticityLayer() { |
88 return m_overscrollElasticityLayer.get(); | 88 return m_overscrollElasticityLayer.get(); |
89 } | 89 } |
90 | 90 |
91 void initializeScrollbars(); | 91 void initializeScrollbars(); |
92 | 92 |
93 // Sets the location of the visual viewport relative to the outer viewport. | 93 // Sets the location of the visual viewport relative to the outer viewport. |
94 // The coordinates are in partial CSS pixels. | 94 // The coordinates are in partial CSS pixels. |
95 void setLocation(const FloatPoint&); | 95 void setLocation(const FloatPoint&); |
96 // FIXME: This should be called moveBy | 96 // FIXME: This should be called moveBy |
97 void move(const FloatPoint&); | 97 void move(const ScrollOffset&); |
98 void move(const FloatSize&); | |
99 FloatPoint location() const { return m_offset; } | |
100 | 98 |
101 // Sets the size of the inner viewport when unscaled in CSS pixels. | 99 // Sets the size of the inner viewport when unscaled in CSS pixels. |
102 void setSize(const IntSize&); | 100 void setSize(const IntSize&); |
103 IntSize size() const { return m_size; } | 101 IntSize size() const { return m_size; } |
104 | 102 |
105 // Gets the scaled size, i.e. the viewport in root view space. | 103 // Gets the scaled size, i.e. the viewport in root view space. |
106 FloatSize visibleSize() const; | 104 FloatSize visibleSize() const; |
107 | 105 |
108 // Resets the viewport to initial state. | 106 // Resets the viewport to initial state. |
109 void reset(); | 107 void reset(); |
(...skipping 12 matching lines...) Expand all Loading... |
122 // if page scale factor is left unchanged. | 120 // if page scale factor is left unchanged. |
123 bool magnifyScaleAroundAnchor(float magnifyDelta, const FloatPoint& anchor); | 121 bool magnifyScaleAroundAnchor(float magnifyDelta, const FloatPoint& anchor); |
124 | 122 |
125 void setScrollLayerOnScrollbars(WebLayer*) const; | 123 void setScrollLayerOnScrollbars(WebLayer*) const; |
126 | 124 |
127 // The portion of the unzoomed frame visible in the visual viewport, | 125 // The portion of the unzoomed frame visible in the visual viewport, |
128 // in partial CSS pixels. Relative to the main frame. | 126 // in partial CSS pixels. Relative to the main frame. |
129 FloatRect visibleRect() const; | 127 FloatRect visibleRect() const; |
130 | 128 |
131 // The viewport rect relative to the document origin, in partial CSS pixels. | 129 // The viewport rect relative to the document origin, in partial CSS pixels. |
132 // FIXME: This should be a DoubleRect since scroll offsets are now doubles. | |
133 FloatRect visibleRectInDocument() const; | 130 FloatRect visibleRectInDocument() const; |
134 | 131 |
135 // Convert the given rect in the main FrameView's coordinates into a rect | 132 // Convert the given rect in the main FrameView's coordinates into a rect |
136 // in the viewport. The given and returned rects are in CSS pixels, meaning | 133 // in the viewport. The given and returned rects are in CSS pixels, meaning |
137 // scale isn't applied. | 134 // scale isn't applied. |
138 FloatRect mainViewToViewportCSSPixels(const FloatRect&) const; | 135 FloatRect mainViewToViewportCSSPixels(const FloatRect&) const; |
139 FloatPoint viewportCSSPixelsToRootFrame(const FloatPoint&) const; | 136 FloatPoint viewportCSSPixelsToRootFrame(const FloatPoint&) const; |
140 | 137 |
141 // Clamp the given point, in document coordinates, to the maximum/minimum | 138 // Clamp the given point, in document coordinates, to the maximum/minimum |
142 // scroll extents of the viewport within the document. | 139 // scroll extents of the viewport within the document. |
(...skipping 17 matching lines...) Expand all Loading... |
160 FloatRect rootFrameToViewport(const FloatRect&) const; | 157 FloatRect rootFrameToViewport(const FloatRect&) const; |
161 IntRect rootFrameToViewport(const IntRect&) const; | 158 IntRect rootFrameToViewport(const IntRect&) const; |
162 | 159 |
163 FloatPoint viewportToRootFrame(const FloatPoint&) const; | 160 FloatPoint viewportToRootFrame(const FloatPoint&) const; |
164 FloatPoint rootFrameToViewport(const FloatPoint&) const; | 161 FloatPoint rootFrameToViewport(const FloatPoint&) const; |
165 IntPoint viewportToRootFrame(const IntPoint&) const; | 162 IntPoint viewportToRootFrame(const IntPoint&) const; |
166 IntPoint rootFrameToViewport(const IntPoint&) const; | 163 IntPoint rootFrameToViewport(const IntPoint&) const; |
167 | 164 |
168 // ScrollableArea implementation | 165 // ScrollableArea implementation |
169 HostWindow* getHostWindow() const override; | 166 HostWindow* getHostWindow() const override; |
170 DoubleRect visibleContentRectDouble( | |
171 IncludeScrollbarsInRect = ExcludeScrollbars) const override; | |
172 IntRect visibleContentRect( | |
173 IncludeScrollbarsInRect = ExcludeScrollbars) const override; | |
174 bool shouldUseIntegerScrollOffset() const override; | 167 bool shouldUseIntegerScrollOffset() const override; |
175 void setScrollPosition(const DoublePoint&, | 168 void setScrollOffset(const ScrollOffset&, |
176 ScrollType, | 169 ScrollType, |
177 ScrollBehavior = ScrollBehaviorInstant) override; | 170 ScrollBehavior = ScrollBehaviorInstant) override; |
178 LayoutRect visualRectForScrollbarParts() const override { | 171 LayoutRect visualRectForScrollbarParts() const override { |
179 ASSERT_NOT_REACHED(); | 172 ASSERT_NOT_REACHED(); |
180 return LayoutRect(); | 173 return LayoutRect(); |
181 } | 174 } |
182 bool isActive() const override { return false; } | 175 bool isActive() const override { return false; } |
183 int scrollSize(ScrollbarOrientation) const override; | 176 int scrollSize(ScrollbarOrientation) const override; |
184 bool isScrollCornerVisible() const override { return false; } | 177 bool isScrollCornerVisible() const override { return false; } |
185 IntRect scrollCornerRect() const override { return IntRect(); } | 178 IntRect scrollCornerRect() const override { return IntRect(); } |
186 IntPoint scrollPosition() const override { return flooredIntPoint(m_offset); } | 179 IntSize scrollOffsetInt() const override { return flooredIntSize(m_offset); } |
187 DoublePoint scrollPositionDouble() const override { return m_offset; } | 180 ScrollOffset scrollOffset() const override { return m_offset; } |
188 IntPoint minimumScrollPosition() const override; | 181 IntSize minimumScrollOffsetInt() const override; |
189 IntPoint maximumScrollPosition() const override; | 182 IntSize maximumScrollOffsetInt() const override; |
190 DoublePoint maximumScrollPositionDouble() const override; | 183 ScrollOffset maximumScrollOffset() const override; |
191 int visibleHeight() const override { return visibleRect().height(); } | 184 int visibleHeight() const override { return visibleRect().height(); } |
192 int visibleWidth() const override { return visibleRect().width(); } | 185 int visibleWidth() const override { return visibleRect().width(); } |
193 IntSize contentsSize() const override; | 186 IntSize contentsSize() const override; |
194 bool scrollbarsCanBeActive() const override { return false; } | 187 bool scrollbarsCanBeActive() const override { return false; } |
195 IntRect scrollableAreaBoundingBox() const override; | 188 IntRect scrollableAreaBoundingBox() const override; |
196 bool userInputScrollable(ScrollbarOrientation) const override { return true; } | 189 bool userInputScrollable(ScrollbarOrientation) const override { return true; } |
197 bool shouldPlaceVerticalScrollbarOnLeft() const override { return false; } | 190 bool shouldPlaceVerticalScrollbarOnLeft() const override { return false; } |
198 bool scrollAnimatorEnabled() const override; | 191 bool scrollAnimatorEnabled() const override; |
199 void scrollControlWasSetNeedsPaintInvalidation() override {} | 192 void scrollControlWasSetNeedsPaintInvalidation() override {} |
200 void setScrollOffset(const DoublePoint&, ScrollType) override; | 193 void updateScrollOffset(const ScrollOffset&, ScrollType) override; |
201 GraphicsLayer* layerForContainer() const override; | 194 GraphicsLayer* layerForContainer() const override; |
202 GraphicsLayer* layerForScrolling() const override; | 195 GraphicsLayer* layerForScrolling() const override; |
203 GraphicsLayer* layerForHorizontalScrollbar() const override; | 196 GraphicsLayer* layerForHorizontalScrollbar() const override; |
204 GraphicsLayer* layerForVerticalScrollbar() const override; | 197 GraphicsLayer* layerForVerticalScrollbar() const override; |
205 Widget* getWidget() override; | 198 Widget* getWidget() override; |
206 CompositorAnimationTimeline* compositorAnimationTimeline() const override; | 199 CompositorAnimationTimeline* compositorAnimationTimeline() const override; |
207 | 200 |
208 // Visual Viewport API implementation. | 201 // Visual Viewport API implementation. |
209 double scrollLeft(); | 202 double scrollLeft(); |
210 double scrollTop(); | 203 double scrollTop(); |
(...skipping 28 matching lines...) Expand all Loading... |
239 return true; | 232 return true; |
240 } | 233 } |
241 IntRect computeInterestRect(const GraphicsLayer*, const IntRect&) const; | 234 IntRect computeInterestRect(const GraphicsLayer*, const IntRect&) const; |
242 void paintContents(const GraphicsLayer*, | 235 void paintContents(const GraphicsLayer*, |
243 GraphicsContext&, | 236 GraphicsContext&, |
244 GraphicsLayerPaintingPhase, | 237 GraphicsLayerPaintingPhase, |
245 const IntRect&) const override; | 238 const IntRect&) const override; |
246 String debugName(const GraphicsLayer*) const override; | 239 String debugName(const GraphicsLayer*) const override; |
247 | 240 |
248 void setupScrollbar(WebScrollbar::Orientation); | 241 void setupScrollbar(WebScrollbar::Orientation); |
249 FloatPoint clampOffsetToBoundaries(const FloatPoint&); | |
250 | 242 |
251 void notifyRootFrameViewport() const; | 243 void notifyRootFrameViewport() const; |
252 | 244 |
253 LocalFrame* mainFrame() const; | 245 LocalFrame* mainFrame() const; |
254 | 246 |
255 FrameHost& frameHost() const { | 247 FrameHost& frameHost() const { |
256 ASSERT(m_frameHost); | 248 ASSERT(m_frameHost); |
257 return *m_frameHost; | 249 return *m_frameHost; |
258 } | 250 } |
259 | 251 |
260 Member<FrameHost> m_frameHost; | 252 Member<FrameHost> m_frameHost; |
261 std::unique_ptr<GraphicsLayer> m_rootTransformLayer; | 253 std::unique_ptr<GraphicsLayer> m_rootTransformLayer; |
262 std::unique_ptr<GraphicsLayer> m_innerViewportContainerLayer; | 254 std::unique_ptr<GraphicsLayer> m_innerViewportContainerLayer; |
263 std::unique_ptr<GraphicsLayer> m_overscrollElasticityLayer; | 255 std::unique_ptr<GraphicsLayer> m_overscrollElasticityLayer; |
264 std::unique_ptr<GraphicsLayer> m_pageScaleLayer; | 256 std::unique_ptr<GraphicsLayer> m_pageScaleLayer; |
265 std::unique_ptr<GraphicsLayer> m_innerViewportScrollLayer; | 257 std::unique_ptr<GraphicsLayer> m_innerViewportScrollLayer; |
266 std::unique_ptr<GraphicsLayer> m_overlayScrollbarHorizontal; | 258 std::unique_ptr<GraphicsLayer> m_overlayScrollbarHorizontal; |
267 std::unique_ptr<GraphicsLayer> m_overlayScrollbarVertical; | 259 std::unique_ptr<GraphicsLayer> m_overlayScrollbarVertical; |
268 std::unique_ptr<WebScrollbarLayer> m_webOverlayScrollbarHorizontal; | 260 std::unique_ptr<WebScrollbarLayer> m_webOverlayScrollbarHorizontal; |
269 std::unique_ptr<WebScrollbarLayer> m_webOverlayScrollbarVertical; | 261 std::unique_ptr<WebScrollbarLayer> m_webOverlayScrollbarVertical; |
270 | 262 |
271 // Offset of the visual viewport from the main frame's origin, in CSS pixels. | 263 // Offset of the visual viewport from the main frame's origin, in CSS pixels. |
272 FloatPoint m_offset; | 264 ScrollOffset m_offset; |
273 float m_scale; | 265 float m_scale; |
274 IntSize m_size; | 266 IntSize m_size; |
275 float m_topControlsAdjustment; | 267 float m_topControlsAdjustment; |
276 float m_maxPageScale; | 268 float m_maxPageScale; |
277 bool m_trackPinchZoomStatsForPage; | 269 bool m_trackPinchZoomStatsForPage; |
278 }; | 270 }; |
279 | 271 |
280 } // namespace blink | 272 } // namespace blink |
281 | 273 |
282 #endif // VisualViewport_h | 274 #endif // VisualViewport_h |
OLD | NEW |