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 16 matching lines...) Expand all Loading... |
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 <memory> | 34 #include <memory> |
35 #include "core/CoreExport.h" | 35 #include "core/CoreExport.h" |
36 #include "core/events/Event.h" | 36 #include "core/events/Event.h" |
37 #include "core/frame/FrameHost.h" | |
38 #include "platform/geometry/FloatRect.h" | 37 #include "platform/geometry/FloatRect.h" |
39 #include "platform/geometry/FloatSize.h" | 38 #include "platform/geometry/FloatSize.h" |
40 #include "platform/geometry/IntSize.h" | 39 #include "platform/geometry/IntSize.h" |
41 #include "platform/graphics/GraphicsLayerClient.h" | 40 #include "platform/graphics/GraphicsLayerClient.h" |
42 #include "platform/scroll/ScrollableArea.h" | 41 #include "platform/scroll/ScrollableArea.h" |
43 #include "public/platform/WebScrollbar.h" | 42 #include "public/platform/WebScrollbar.h" |
44 #include "public/platform/WebSize.h" | 43 #include "public/platform/WebSize.h" |
45 | 44 |
46 namespace blink { | 45 namespace blink { |
47 class WebScrollbarLayer; | 46 class WebScrollbarLayer; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 // +- PLC::m_layerForVerticalScrollbar | 81 // +- PLC::m_layerForVerticalScrollbar |
83 // +- PLC::m_layerForScrollCorner (non-overlay only) | 82 // +- PLC::m_layerForScrollCorner (non-overlay only) |
84 // | 83 // |
85 class CORE_EXPORT VisualViewport final | 84 class CORE_EXPORT VisualViewport final |
86 : public GarbageCollectedFinalized<VisualViewport>, | 85 : public GarbageCollectedFinalized<VisualViewport>, |
87 public GraphicsLayerClient, | 86 public GraphicsLayerClient, |
88 public ScrollableArea { | 87 public ScrollableArea { |
89 USING_GARBAGE_COLLECTED_MIXIN(VisualViewport); | 88 USING_GARBAGE_COLLECTED_MIXIN(VisualViewport); |
90 | 89 |
91 public: | 90 public: |
92 static VisualViewport* create(FrameHost& host) { | 91 static VisualViewport* create(Page& host) { return new VisualViewport(host); } |
93 return new VisualViewport(host); | |
94 } | |
95 ~VisualViewport() override; | 92 ~VisualViewport() override; |
96 | 93 |
97 DECLARE_VIRTUAL_TRACE(); | 94 DECLARE_VIRTUAL_TRACE(); |
98 | 95 |
99 void createLayerTree(); | 96 void createLayerTree(); |
100 void attachLayerTree(GraphicsLayer*); | 97 void attachLayerTree(GraphicsLayer*); |
101 | 98 |
102 GraphicsLayer* rootGraphicsLayer() { return m_rootTransformLayer.get(); } | 99 GraphicsLayer* rootGraphicsLayer() { return m_rootTransformLayer.get(); } |
103 GraphicsLayer* containerLayer() { | 100 GraphicsLayer* containerLayer() { |
104 return m_innerViewportContainerLayer.get(); | 101 return m_innerViewportContainerLayer.get(); |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
229 // Used for gathering data on user pinch-zoom statistics. | 226 // Used for gathering data on user pinch-zoom statistics. |
230 void userDidChangeScale(); | 227 void userDidChangeScale(); |
231 void sendUMAMetrics(); | 228 void sendUMAMetrics(); |
232 void startTrackingPinchStats(); | 229 void startTrackingPinchStats(); |
233 | 230 |
234 // Heuristic-based function for determining if we should disable workarounds | 231 // Heuristic-based function for determining if we should disable workarounds |
235 // for viewing websites that are not optimized for mobile devices. | 232 // for viewing websites that are not optimized for mobile devices. |
236 bool shouldDisableDesktopWorkarounds() const; | 233 bool shouldDisableDesktopWorkarounds() const; |
237 | 234 |
238 private: | 235 private: |
239 explicit VisualViewport(FrameHost&); | 236 explicit VisualViewport(Page&); |
240 | 237 |
241 bool didSetScaleOrLocation(float scale, const FloatPoint& location); | 238 bool didSetScaleOrLocation(float scale, const FloatPoint& location); |
242 | 239 |
243 bool visualViewportSuppliesScrollbars() const; | 240 bool visualViewportSuppliesScrollbars() const; |
244 | 241 |
245 void updateStyleAndLayoutIgnorePendingStylesheets(); | 242 void updateStyleAndLayoutIgnorePendingStylesheets(); |
246 | 243 |
247 void enqueueScrollEvent(); | 244 void enqueueScrollEvent(); |
248 void enqueueResizeEvent(); | 245 void enqueueResizeEvent(); |
249 | 246 |
250 // GraphicsLayerClient implementation. | 247 // GraphicsLayerClient implementation. |
251 bool needsRepaint(const GraphicsLayer&) const { | 248 bool needsRepaint(const GraphicsLayer&) const { |
252 ASSERT_NOT_REACHED(); | 249 ASSERT_NOT_REACHED(); |
253 return true; | 250 return true; |
254 } | 251 } |
255 IntRect computeInterestRect(const GraphicsLayer*, const IntRect&) const; | 252 IntRect computeInterestRect(const GraphicsLayer*, const IntRect&) const; |
256 void paintContents(const GraphicsLayer*, | 253 void paintContents(const GraphicsLayer*, |
257 GraphicsContext&, | 254 GraphicsContext&, |
258 GraphicsLayerPaintingPhase, | 255 GraphicsLayerPaintingPhase, |
259 const IntRect&) const override; | 256 const IntRect&) const override; |
260 String debugName(const GraphicsLayer*) const override; | 257 String debugName(const GraphicsLayer*) const override; |
261 | 258 |
262 void setupScrollbar(WebScrollbar::Orientation); | 259 void setupScrollbar(WebScrollbar::Orientation); |
263 | 260 |
264 void notifyRootFrameViewport() const; | 261 void notifyRootFrameViewport() const; |
265 | 262 |
266 LocalFrame* mainFrame() const; | 263 LocalFrame* mainFrame() const; |
267 | 264 |
268 Page& page() const { | 265 Page& page() const { |
269 DCHECK(m_frameHost); | 266 DCHECK(m_page); |
270 return m_frameHost->page(); | 267 return *m_page; |
271 } | 268 } |
272 | 269 |
273 Member<FrameHost> m_frameHost; | 270 Member<Page> m_page; |
274 std::unique_ptr<GraphicsLayer> m_rootTransformLayer; | 271 std::unique_ptr<GraphicsLayer> m_rootTransformLayer; |
275 std::unique_ptr<GraphicsLayer> m_innerViewportContainerLayer; | 272 std::unique_ptr<GraphicsLayer> m_innerViewportContainerLayer; |
276 std::unique_ptr<GraphicsLayer> m_overscrollElasticityLayer; | 273 std::unique_ptr<GraphicsLayer> m_overscrollElasticityLayer; |
277 std::unique_ptr<GraphicsLayer> m_pageScaleLayer; | 274 std::unique_ptr<GraphicsLayer> m_pageScaleLayer; |
278 std::unique_ptr<GraphicsLayer> m_innerViewportScrollLayer; | 275 std::unique_ptr<GraphicsLayer> m_innerViewportScrollLayer; |
279 std::unique_ptr<GraphicsLayer> m_overlayScrollbarHorizontal; | 276 std::unique_ptr<GraphicsLayer> m_overlayScrollbarHorizontal; |
280 std::unique_ptr<GraphicsLayer> m_overlayScrollbarVertical; | 277 std::unique_ptr<GraphicsLayer> m_overlayScrollbarVertical; |
281 std::unique_ptr<WebScrollbarLayer> m_webOverlayScrollbarHorizontal; | 278 std::unique_ptr<WebScrollbarLayer> m_webOverlayScrollbarHorizontal; |
282 std::unique_ptr<WebScrollbarLayer> m_webOverlayScrollbarVertical; | 279 std::unique_ptr<WebScrollbarLayer> m_webOverlayScrollbarVertical; |
283 | 280 |
284 // Offset of the visual viewport from the main frame's origin, in CSS pixels. | 281 // Offset of the visual viewport from the main frame's origin, in CSS pixels. |
285 ScrollOffset m_offset; | 282 ScrollOffset m_offset; |
286 float m_scale; | 283 float m_scale; |
287 IntSize m_size; | 284 IntSize m_size; |
288 float m_browserControlsAdjustment; | 285 float m_browserControlsAdjustment; |
289 float m_maxPageScale; | 286 float m_maxPageScale; |
290 bool m_trackPinchZoomStatsForPage; | 287 bool m_trackPinchZoomStatsForPage; |
291 }; | 288 }; |
292 | 289 |
293 } // namespace blink | 290 } // namespace blink |
294 | 291 |
295 #endif // VisualViewport_h | 292 #endif // VisualViewport_h |
OLD | NEW |