| 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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 | 49 |
| 50 namespace blink { | 50 namespace blink { |
| 51 | 51 |
| 52 class FrameHost; | 52 class FrameHost; |
| 53 class GraphicsContext; | 53 class GraphicsContext; |
| 54 class GraphicsLayer; | 54 class GraphicsLayer; |
| 55 class IntRect; | 55 class IntRect; |
| 56 class IntSize; | 56 class IntSize; |
| 57 class LocalFrame; | 57 class LocalFrame; |
| 58 | 58 |
| 59 // Represents the visual viewport the user is currently seeing the page through.
This | 59 // Represents the visual viewport the user is currently seeing the page through. |
| 60 // class corresponds to the InnerViewport on the compositor. It is a ScrollableA
rea; it's | 60 // This class corresponds to the InnerViewport on the compositor. It is a |
| 61 // offset is set through the GraphicsLayer <-> CC sync mechanisms. Its contents
is the page's | 61 // ScrollableArea; it's offset is set through the GraphicsLayer <-> CC sync |
| 62 // main FrameView, which corresponds to the outer viewport. The inner viewport i
s always contained | 62 // mechanisms. Its contents is the page's main FrameView, which corresponds to |
| 63 // in the outer viewport and can pan within it. | 63 // the outer viewport. The inner viewport is always contained in the outer |
| 64 // viewport and can pan within it. |
| 64 class CORE_EXPORT VisualViewport final | 65 class CORE_EXPORT VisualViewport final |
| 65 : public GarbageCollectedFinalized<VisualViewport>, | 66 : public GarbageCollectedFinalized<VisualViewport>, |
| 66 public GraphicsLayerClient, | 67 public GraphicsLayerClient, |
| 67 public ScrollableArea { | 68 public ScrollableArea { |
| 68 USING_GARBAGE_COLLECTED_MIXIN(VisualViewport); | 69 USING_GARBAGE_COLLECTED_MIXIN(VisualViewport); |
| 69 | 70 |
| 70 public: | 71 public: |
| 71 static VisualViewport* create(FrameHost& host) { | 72 static VisualViewport* create(FrameHost& host) { |
| 72 return new VisualViewport(host); | 73 return new VisualViewport(host); |
| 73 } | 74 } |
| 74 ~VisualViewport() override; | 75 ~VisualViewport() override; |
| 75 | 76 |
| 76 DECLARE_VIRTUAL_TRACE(); | 77 DECLARE_VIRTUAL_TRACE(); |
| 77 | 78 |
| 78 void attachToLayerTree(GraphicsLayer*); | 79 void attachToLayerTree(GraphicsLayer*); |
| 79 | 80 |
| 80 GraphicsLayer* rootGraphicsLayer() { return m_rootTransformLayer.get(); } | 81 GraphicsLayer* rootGraphicsLayer() { return m_rootTransformLayer.get(); } |
| 81 GraphicsLayer* containerLayer() { | 82 GraphicsLayer* containerLayer() { |
| 82 return m_innerViewportContainerLayer.get(); | 83 return m_innerViewportContainerLayer.get(); |
| 83 } | 84 } |
| 84 GraphicsLayer* scrollLayer() { return m_innerViewportScrollLayer.get(); } | 85 GraphicsLayer* scrollLayer() { return m_innerViewportScrollLayer.get(); } |
| 85 GraphicsLayer* pageScaleLayer() { return m_pageScaleLayer.get(); } | 86 GraphicsLayer* pageScaleLayer() { return m_pageScaleLayer.get(); } |
| 86 GraphicsLayer* overscrollElasticityLayer() { | 87 GraphicsLayer* overscrollElasticityLayer() { |
| 87 return m_overscrollElasticityLayer.get(); | 88 return m_overscrollElasticityLayer.get(); |
| 88 } | 89 } |
| 89 | 90 |
| 90 void initializeScrollbars(); | 91 void initializeScrollbars(); |
| 91 | 92 |
| 92 // Sets the location of the visual viewport relative to the outer viewport. Th
e | 93 // Sets the location of the visual viewport relative to the outer viewport. |
| 93 // coordinates are in partial CSS pixels. | 94 // The coordinates are in partial CSS pixels. |
| 94 void setLocation(const FloatPoint&); | 95 void setLocation(const FloatPoint&); |
| 95 // FIXME: This should be called moveBy | 96 // FIXME: This should be called moveBy |
| 96 void move(const FloatPoint&); | 97 void move(const FloatPoint&); |
| 97 void move(const FloatSize&); | 98 void move(const FloatSize&); |
| 98 FloatPoint location() const { return m_offset; } | 99 FloatPoint location() const { return m_offset; } |
| 99 | 100 |
| 100 // Sets the size of the inner viewport when unscaled in CSS pixels. | 101 // Sets the size of the inner viewport when unscaled in CSS pixels. |
| 101 void setSize(const IntSize&); | 102 void setSize(const IntSize&); |
| 102 IntSize size() const { return m_size; } | 103 IntSize size() const { return m_size; } |
| 103 | 104 |
| 104 // Gets the scaled size, i.e. the viewport in root view space. | 105 // Gets the scaled size, i.e. the viewport in root view space. |
| 105 FloatSize visibleSize() const; | 106 FloatSize visibleSize() const; |
| 106 | 107 |
| 107 // Resets the viewport to initial state. | 108 // Resets the viewport to initial state. |
| 108 void reset(); | 109 void reset(); |
| 109 | 110 |
| 110 // Let the viewport know that the main frame changed size (either through scre
en | 111 // Let the viewport know that the main frame changed size (either through |
| 111 // rotation on Android or window resize elsewhere). | 112 // screen rotation on Android or window resize elsewhere). |
| 112 void mainFrameDidChangeSize(); | 113 void mainFrameDidChangeSize(); |
| 113 | 114 |
| 114 // Sets scale and location in one operation, preventing intermediate clamping. | 115 // Sets scale and location in one operation, preventing intermediate clamping. |
| 115 void setScaleAndLocation(float scale, const FloatPoint& location); | 116 void setScaleAndLocation(float scale, const FloatPoint& location); |
| 116 void setScale(float); | 117 void setScale(float); |
| 117 float scale() const { return m_scale; } | 118 float scale() const { return m_scale; } |
| 118 | 119 |
| 119 // Update scale factor, magnifying or minifying by magnifyDelta, centered arou
nd | 120 // Update scale factor, magnifying or minifying by magnifyDelta, centered |
| 120 // the point specified by anchor in window coordinates. Returns false if page | 121 // around the point specified by anchor in window coordinates. Returns false |
| 121 // scale factor is left unchanged. | 122 // if page scale factor is left unchanged. |
| 122 bool magnifyScaleAroundAnchor(float magnifyDelta, const FloatPoint& anchor); | 123 bool magnifyScaleAroundAnchor(float magnifyDelta, const FloatPoint& anchor); |
| 123 | 124 |
| 124 void setScrollLayerOnScrollbars(WebLayer*) const; | 125 void setScrollLayerOnScrollbars(WebLayer*) const; |
| 125 | 126 |
| 126 // The portion of the unzoomed frame visible in the visual viewport, | 127 // The portion of the unzoomed frame visible in the visual viewport, |
| 127 // in partial CSS pixels. Relative to the main frame. | 128 // in partial CSS pixels. Relative to the main frame. |
| 128 FloatRect visibleRect() const; | 129 FloatRect visibleRect() const; |
| 129 | 130 |
| 130 // The viewport rect relative to the document origin, in partial CSS pixels. | 131 // The viewport rect relative to the document origin, in partial CSS pixels. |
| 131 // FIXME: This should be a DoubleRect since scroll offsets are now doubles. | 132 // FIXME: This should be a DoubleRect since scroll offsets are now doubles. |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 272 float m_scale; | 273 float m_scale; |
| 273 IntSize m_size; | 274 IntSize m_size; |
| 274 float m_topControlsAdjustment; | 275 float m_topControlsAdjustment; |
| 275 float m_maxPageScale; | 276 float m_maxPageScale; |
| 276 bool m_trackPinchZoomStatsForPage; | 277 bool m_trackPinchZoomStatsForPage; |
| 277 }; | 278 }; |
| 278 | 279 |
| 279 } // namespace blink | 280 } // namespace blink |
| 280 | 281 |
| 281 #endif // VisualViewport_h | 282 #endif // VisualViewport_h |
| OLD | NEW |