| 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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 GraphicsLayer* overscrollElasticityLayer() { | 86 GraphicsLayer* overscrollElasticityLayer() { |
| 87 return m_overscrollElasticityLayer.get(); | 87 return m_overscrollElasticityLayer.get(); |
| 88 } | 88 } |
| 89 | 89 |
| 90 void initializeScrollbars(); | 90 void initializeScrollbars(); |
| 91 | 91 |
| 92 // Sets the location of the visual viewport relative to the outer viewport. Th
e | 92 // Sets the location of the visual viewport relative to the outer viewport. Th
e |
| 93 // coordinates are in partial CSS pixels. | 93 // coordinates are in partial CSS pixels. |
| 94 void setLocation(const FloatPoint&); | 94 void setLocation(const FloatPoint&); |
| 95 // FIXME: This should be called moveBy | 95 // FIXME: This should be called moveBy |
| 96 void move(const FloatPoint&); | 96 void move(const ScrollOffset&); |
| 97 void move(const FloatSize&); | |
| 98 FloatPoint location() const { return m_offset; } | |
| 99 | 97 |
| 100 // Sets the size of the inner viewport when unscaled in CSS pixels. | 98 // Sets the size of the inner viewport when unscaled in CSS pixels. |
| 101 void setSize(const IntSize&); | 99 void setSize(const IntSize&); |
| 102 IntSize size() const { return m_size; } | 100 IntSize size() const { return m_size; } |
| 103 | 101 |
| 104 // Gets the scaled size, i.e. the viewport in root view space. | 102 // Gets the scaled size, i.e. the viewport in root view space. |
| 105 FloatSize visibleSize() const; | 103 FloatSize visibleSize() const; |
| 106 | 104 |
| 107 // Resets the viewport to initial state. | 105 // Resets the viewport to initial state. |
| 108 void reset(); | 106 void reset(); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 121 // scale factor is left unchanged. | 119 // scale factor is left unchanged. |
| 122 bool magnifyScaleAroundAnchor(float magnifyDelta, const FloatPoint& anchor); | 120 bool magnifyScaleAroundAnchor(float magnifyDelta, const FloatPoint& anchor); |
| 123 | 121 |
| 124 void setScrollLayerOnScrollbars(WebLayer*) const; | 122 void setScrollLayerOnScrollbars(WebLayer*) const; |
| 125 | 123 |
| 126 // The portion of the unzoomed frame visible in the visual viewport, | 124 // The portion of the unzoomed frame visible in the visual viewport, |
| 127 // in partial CSS pixels. Relative to the main frame. | 125 // in partial CSS pixels. Relative to the main frame. |
| 128 FloatRect visibleRect() const; | 126 FloatRect visibleRect() const; |
| 129 | 127 |
| 130 // The viewport rect relative to the document origin, in partial CSS pixels. | 128 // 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 FloatRect visibleRectInDocument() const; | 129 FloatRect visibleRectInDocument() const; |
| 133 | 130 |
| 134 // Convert the given rect in the main FrameView's coordinates into a rect | 131 // Convert the given rect in the main FrameView's coordinates into a rect |
| 135 // in the viewport. The given and returned rects are in CSS pixels, meaning | 132 // in the viewport. The given and returned rects are in CSS pixels, meaning |
| 136 // scale isn't applied. | 133 // scale isn't applied. |
| 137 FloatRect mainViewToViewportCSSPixels(const FloatRect&) const; | 134 FloatRect mainViewToViewportCSSPixels(const FloatRect&) const; |
| 138 FloatPoint viewportCSSPixelsToRootFrame(const FloatPoint&) const; | 135 FloatPoint viewportCSSPixelsToRootFrame(const FloatPoint&) const; |
| 139 | 136 |
| 140 // Clamp the given point, in document coordinates, to the maximum/minimum | 137 // Clamp the given point, in document coordinates, to the maximum/minimum |
| 141 // scroll extents of the viewport within the document. | 138 // scroll extents of the viewport within the document. |
| (...skipping 17 matching lines...) Expand all Loading... |
| 159 FloatRect rootFrameToViewport(const FloatRect&) const; | 156 FloatRect rootFrameToViewport(const FloatRect&) const; |
| 160 IntRect rootFrameToViewport(const IntRect&) const; | 157 IntRect rootFrameToViewport(const IntRect&) const; |
| 161 | 158 |
| 162 FloatPoint viewportToRootFrame(const FloatPoint&) const; | 159 FloatPoint viewportToRootFrame(const FloatPoint&) const; |
| 163 FloatPoint rootFrameToViewport(const FloatPoint&) const; | 160 FloatPoint rootFrameToViewport(const FloatPoint&) const; |
| 164 IntPoint viewportToRootFrame(const IntPoint&) const; | 161 IntPoint viewportToRootFrame(const IntPoint&) const; |
| 165 IntPoint rootFrameToViewport(const IntPoint&) const; | 162 IntPoint rootFrameToViewport(const IntPoint&) const; |
| 166 | 163 |
| 167 // ScrollableArea implementation | 164 // ScrollableArea implementation |
| 168 HostWindow* getHostWindow() const override; | 165 HostWindow* getHostWindow() const override; |
| 169 DoubleRect visibleContentRectDouble( | |
| 170 IncludeScrollbarsInRect = ExcludeScrollbars) const override; | |
| 171 IntRect visibleContentRect( | |
| 172 IncludeScrollbarsInRect = ExcludeScrollbars) const override; | |
| 173 bool shouldUseIntegerScrollOffset() const override; | 166 bool shouldUseIntegerScrollOffset() const override; |
| 174 void setScrollPosition(const DoublePoint&, | 167 void setScrollOffset(const ScrollOffset&, |
| 175 ScrollType, | 168 ScrollType, |
| 176 ScrollBehavior = ScrollBehaviorInstant) override; | 169 ScrollBehavior = ScrollBehaviorInstant) override; |
| 177 LayoutRect visualRectForScrollbarParts() const override { | 170 LayoutRect visualRectForScrollbarParts() const override { |
| 178 ASSERT_NOT_REACHED(); | 171 ASSERT_NOT_REACHED(); |
| 179 return LayoutRect(); | 172 return LayoutRect(); |
| 180 } | 173 } |
| 181 bool isActive() const override { return false; } | 174 bool isActive() const override { return false; } |
| 182 int scrollSize(ScrollbarOrientation) const override; | 175 int scrollSize(ScrollbarOrientation) const override; |
| 183 bool isScrollCornerVisible() const override { return false; } | 176 bool isScrollCornerVisible() const override { return false; } |
| 184 IntRect scrollCornerRect() const override { return IntRect(); } | 177 IntRect scrollCornerRect() const override { return IntRect(); } |
| 185 IntPoint scrollPosition() const override { return flooredIntPoint(m_offset); } | 178 IntSize scrollOffsetInt() const override { return flooredIntSize(m_offset); } |
| 186 DoublePoint scrollPositionDouble() const override { return m_offset; } | 179 ScrollOffset scrollOffset() const override { return m_offset; } |
| 187 IntPoint minimumScrollPosition() const override; | 180 IntSize minimumScrollOffsetInt() const override; |
| 188 IntPoint maximumScrollPosition() const override; | 181 IntSize maximumScrollOffsetInt() const override; |
| 189 DoublePoint maximumScrollPositionDouble() const override; | 182 ScrollOffset maximumScrollOffset() const override; |
| 190 int visibleHeight() const override { return visibleRect().height(); } | 183 int visibleHeight() const override { return visibleRect().height(); } |
| 191 int visibleWidth() const override { return visibleRect().width(); } | 184 int visibleWidth() const override { return visibleRect().width(); } |
| 192 IntSize contentsSize() const override; | 185 IntSize contentsSize() const override; |
| 193 bool scrollbarsCanBeActive() const override { return false; } | 186 bool scrollbarsCanBeActive() const override { return false; } |
| 194 IntRect scrollableAreaBoundingBox() const override; | 187 IntRect scrollableAreaBoundingBox() const override; |
| 195 bool userInputScrollable(ScrollbarOrientation) const override { return true; } | 188 bool userInputScrollable(ScrollbarOrientation) const override { return true; } |
| 196 bool shouldPlaceVerticalScrollbarOnLeft() const override { return false; } | 189 bool shouldPlaceVerticalScrollbarOnLeft() const override { return false; } |
| 197 bool scrollAnimatorEnabled() const override; | 190 bool scrollAnimatorEnabled() const override; |
| 198 void scrollControlWasSetNeedsPaintInvalidation() override {} | 191 void scrollControlWasSetNeedsPaintInvalidation() override {} |
| 199 void setScrollOffset(const DoublePoint&, ScrollType) override; | 192 void updateScrollOffset(const ScrollOffset&, ScrollType) override; |
| 200 GraphicsLayer* layerForContainer() const override; | 193 GraphicsLayer* layerForContainer() const override; |
| 201 GraphicsLayer* layerForScrolling() const override; | 194 GraphicsLayer* layerForScrolling() const override; |
| 202 GraphicsLayer* layerForHorizontalScrollbar() const override; | 195 GraphicsLayer* layerForHorizontalScrollbar() const override; |
| 203 GraphicsLayer* layerForVerticalScrollbar() const override; | 196 GraphicsLayer* layerForVerticalScrollbar() const override; |
| 204 Widget* getWidget() override; | 197 Widget* getWidget() override; |
| 205 CompositorAnimationTimeline* compositorAnimationTimeline() const override; | 198 CompositorAnimationTimeline* compositorAnimationTimeline() const override; |
| 206 | 199 |
| 207 // Visual Viewport API implementation. | 200 // Visual Viewport API implementation. |
| 208 double scrollLeft(); | 201 double scrollLeft(); |
| 209 double scrollTop(); | 202 double scrollTop(); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 238 return true; | 231 return true; |
| 239 } | 232 } |
| 240 IntRect computeInterestRect(const GraphicsLayer*, const IntRect&) const; | 233 IntRect computeInterestRect(const GraphicsLayer*, const IntRect&) const; |
| 241 void paintContents(const GraphicsLayer*, | 234 void paintContents(const GraphicsLayer*, |
| 242 GraphicsContext&, | 235 GraphicsContext&, |
| 243 GraphicsLayerPaintingPhase, | 236 GraphicsLayerPaintingPhase, |
| 244 const IntRect&) const override; | 237 const IntRect&) const override; |
| 245 String debugName(const GraphicsLayer*) const override; | 238 String debugName(const GraphicsLayer*) const override; |
| 246 | 239 |
| 247 void setupScrollbar(WebScrollbar::Orientation); | 240 void setupScrollbar(WebScrollbar::Orientation); |
| 248 FloatPoint clampOffsetToBoundaries(const FloatPoint&); | |
| 249 | 241 |
| 250 void notifyRootFrameViewport() const; | 242 void notifyRootFrameViewport() const; |
| 251 | 243 |
| 252 LocalFrame* mainFrame() const; | 244 LocalFrame* mainFrame() const; |
| 253 | 245 |
| 254 FrameHost& frameHost() const { | 246 FrameHost& frameHost() const { |
| 255 ASSERT(m_frameHost); | 247 ASSERT(m_frameHost); |
| 256 return *m_frameHost; | 248 return *m_frameHost; |
| 257 } | 249 } |
| 258 | 250 |
| 259 Member<FrameHost> m_frameHost; | 251 Member<FrameHost> m_frameHost; |
| 260 std::unique_ptr<GraphicsLayer> m_rootTransformLayer; | 252 std::unique_ptr<GraphicsLayer> m_rootTransformLayer; |
| 261 std::unique_ptr<GraphicsLayer> m_innerViewportContainerLayer; | 253 std::unique_ptr<GraphicsLayer> m_innerViewportContainerLayer; |
| 262 std::unique_ptr<GraphicsLayer> m_overscrollElasticityLayer; | 254 std::unique_ptr<GraphicsLayer> m_overscrollElasticityLayer; |
| 263 std::unique_ptr<GraphicsLayer> m_pageScaleLayer; | 255 std::unique_ptr<GraphicsLayer> m_pageScaleLayer; |
| 264 std::unique_ptr<GraphicsLayer> m_innerViewportScrollLayer; | 256 std::unique_ptr<GraphicsLayer> m_innerViewportScrollLayer; |
| 265 std::unique_ptr<GraphicsLayer> m_overlayScrollbarHorizontal; | 257 std::unique_ptr<GraphicsLayer> m_overlayScrollbarHorizontal; |
| 266 std::unique_ptr<GraphicsLayer> m_overlayScrollbarVertical; | 258 std::unique_ptr<GraphicsLayer> m_overlayScrollbarVertical; |
| 267 std::unique_ptr<WebScrollbarLayer> m_webOverlayScrollbarHorizontal; | 259 std::unique_ptr<WebScrollbarLayer> m_webOverlayScrollbarHorizontal; |
| 268 std::unique_ptr<WebScrollbarLayer> m_webOverlayScrollbarVertical; | 260 std::unique_ptr<WebScrollbarLayer> m_webOverlayScrollbarVertical; |
| 269 | 261 |
| 270 // Offset of the visual viewport from the main frame's origin, in CSS pixels. | 262 // Offset of the visual viewport from the main frame's origin, in CSS pixels. |
| 271 FloatPoint m_offset; | 263 ScrollOffset m_offset; |
| 272 float m_scale; | 264 float m_scale; |
| 273 IntSize m_size; | 265 IntSize m_size; |
| 274 float m_topControlsAdjustment; | 266 float m_topControlsAdjustment; |
| 275 float m_maxPageScale; | 267 float m_maxPageScale; |
| 276 bool m_trackPinchZoomStatsForPage; | 268 bool m_trackPinchZoomStatsForPage; |
| 277 }; | 269 }; |
| 278 | 270 |
| 279 } // namespace blink | 271 } // namespace blink |
| 280 | 272 |
| 281 #endif // VisualViewport_h | 273 #endif // VisualViewport_h |
| OLD | NEW |