| 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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 } | 48 } |
| 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 class ScrollAndScaleEmulator; |
| 58 | 59 |
| 59 // Represents the visual viewport the user is currently seeing the page through.
This | 60 // Represents the visual viewport the user is currently seeing the page through.
This |
| 60 // class corresponds to the InnerViewport on the compositor. It is a ScrollableA
rea; it's | 61 // class corresponds to the InnerViewport on the compositor. It is a ScrollableA
rea; it's |
| 61 // offset is set through the GraphicsLayer <-> CC sync mechanisms. Its contents
is the page's | 62 // offset is set through the GraphicsLayer <-> CC sync mechanisms. Its contents
is the page's |
| 62 // main FrameView, which corresponds to the outer viewport. The inner viewport i
s always contained | 63 // main FrameView, which corresponds to the outer viewport. The inner viewport i
s always contained |
| 63 // in the outer viewport and can pan within it. | 64 // in the outer 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 { |
| (...skipping 25 matching lines...) Expand all Loading... |
| 93 void initializeScrollbars(); | 94 void initializeScrollbars(); |
| 94 | 95 |
| 95 // Sets the location of the visual viewport relative to the outer viewport.
The | 96 // Sets the location of the visual viewport relative to the outer viewport.
The |
| 96 // coordinates are in partial CSS pixels. | 97 // coordinates are in partial CSS pixels. |
| 97 void setLocation(const FloatPoint&); | 98 void setLocation(const FloatPoint&); |
| 98 // FIXME: This should be called moveBy | 99 // FIXME: This should be called moveBy |
| 99 void move(const FloatPoint&); | 100 void move(const FloatPoint&); |
| 100 void move(const FloatSize&); | 101 void move(const FloatSize&); |
| 101 FloatPoint location() const { return m_offset; } | 102 FloatPoint location() const { return m_offset; } |
| 102 | 103 |
| 104 // Override the scroll location and scale with values from the emulator. Pas
sing |nullptr| clears override. |
| 105 void setScrollAndScaleEmulator(ScrollAndScaleEmulator*); |
| 106 |
| 103 // Sets the size of the inner viewport when unscaled in CSS pixels. | 107 // Sets the size of the inner viewport when unscaled in CSS pixels. |
| 104 void setSize(const IntSize&); | 108 void setSize(const IntSize&); |
| 105 IntSize size() const { return m_size; } | 109 IntSize size() const { return m_size; } |
| 106 | 110 |
| 107 // Gets the scaled size, i.e. the viewport in root view space. | 111 // Gets the scaled size, i.e. the viewport in root view space. |
| 108 FloatSize visibleSize() const; | 112 FloatSize visibleSize() const; |
| 109 | 113 |
| 110 // Resets the viewport to initial state. | 114 // Resets the viewport to initial state. |
| 111 void reset(); | 115 void reset(); |
| 112 | 116 |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 FloatPoint viewportToRootFrame(const FloatPoint&) const; | 170 FloatPoint viewportToRootFrame(const FloatPoint&) const; |
| 167 FloatPoint rootFrameToViewport(const FloatPoint&) const; | 171 FloatPoint rootFrameToViewport(const FloatPoint&) const; |
| 168 IntPoint viewportToRootFrame(const IntPoint&) const; | 172 IntPoint viewportToRootFrame(const IntPoint&) const; |
| 169 IntPoint rootFrameToViewport(const IntPoint&) const; | 173 IntPoint rootFrameToViewport(const IntPoint&) const; |
| 170 | 174 |
| 171 // ScrollableArea implementation | 175 // ScrollableArea implementation |
| 172 HostWindow* getHostWindow() const override; | 176 HostWindow* getHostWindow() const override; |
| 173 DoubleRect visibleContentRectDouble(IncludeScrollbarsInRect = ExcludeScrollb
ars) const override; | 177 DoubleRect visibleContentRectDouble(IncludeScrollbarsInRect = ExcludeScrollb
ars) const override; |
| 174 IntRect visibleContentRect(IncludeScrollbarsInRect = ExcludeScrollbars) cons
t override; | 178 IntRect visibleContentRect(IncludeScrollbarsInRect = ExcludeScrollbars) cons
t override; |
| 175 bool shouldUseIntegerScrollOffset() const override; | 179 bool shouldUseIntegerScrollOffset() const override; |
| 180 void setScrollPosition(const DoublePoint&, ScrollType, ScrollBehavior = Scro
llBehaviorInstant) override; |
| 176 LayoutRect visualRectForScrollbarParts() const override { ASSERT_NOT_REACHED
(); return LayoutRect(); } | 181 LayoutRect visualRectForScrollbarParts() const override { ASSERT_NOT_REACHED
(); return LayoutRect(); } |
| 177 bool isActive() const override { return false; } | 182 bool isActive() const override { return false; } |
| 178 int scrollSize(ScrollbarOrientation) const override; | 183 int scrollSize(ScrollbarOrientation) const override; |
| 179 bool isScrollCornerVisible() const override { return false; } | 184 bool isScrollCornerVisible() const override { return false; } |
| 180 IntRect scrollCornerRect() const override { return IntRect(); } | 185 IntRect scrollCornerRect() const override { return IntRect(); } |
| 181 IntPoint scrollPosition() const override { return flooredIntPoint(m_offset);
} | 186 IntPoint scrollPosition() const override { return flooredIntPoint(m_offset);
} |
| 182 DoublePoint scrollPositionDouble() const override { return m_offset; } | 187 DoublePoint scrollPositionDouble() const override { return m_offset; } |
| 183 IntPoint minimumScrollPosition() const override; | 188 IntPoint minimumScrollPosition() const override; |
| 189 DoublePoint minimumScrollPositionDouble() const override; |
| 184 IntPoint maximumScrollPosition() const override; | 190 IntPoint maximumScrollPosition() const override; |
| 185 DoublePoint maximumScrollPositionDouble() const override; | 191 DoublePoint maximumScrollPositionDouble() const override; |
| 186 int visibleHeight() const override { return visibleRect().height(); } | 192 int visibleHeight() const override { return visibleRect().height(); } |
| 187 int visibleWidth() const override { return visibleRect().width(); } | 193 int visibleWidth() const override { return visibleRect().width(); } |
| 188 IntSize contentsSize() const override; | 194 IntSize contentsSize() const override; |
| 189 bool scrollbarsCanBeActive() const override { return false; } | 195 bool scrollbarsCanBeActive() const override { return false; } |
| 190 IntRect scrollableAreaBoundingBox() const override; | 196 IntRect scrollableAreaBoundingBox() const override; |
| 191 bool userInputScrollable(ScrollbarOrientation) const override { return true;
} | 197 bool userInputScrollable(ScrollbarOrientation) const override { return true;
} |
| 192 bool shouldPlaceVerticalScrollbarOnLeft() const override { return false; } | 198 bool shouldPlaceVerticalScrollbarOnLeft() const override { return false; } |
| 193 bool scrollAnimatorEnabled() const override; | 199 bool scrollAnimatorEnabled() const override; |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 228 | 234 |
| 229 // GraphicsLayerClient implementation. | 235 // GraphicsLayerClient implementation. |
| 230 bool needsRepaint(const GraphicsLayer&) const { ASSERT_NOT_REACHED(); return
true; } | 236 bool needsRepaint(const GraphicsLayer&) const { ASSERT_NOT_REACHED(); return
true; } |
| 231 IntRect computeInterestRect(const GraphicsLayer*, const IntRect&) const; | 237 IntRect computeInterestRect(const GraphicsLayer*, const IntRect&) const; |
| 232 void paintContents(const GraphicsLayer*, GraphicsContext&, GraphicsLayerPain
tingPhase, const IntRect&) const override; | 238 void paintContents(const GraphicsLayer*, GraphicsContext&, GraphicsLayerPain
tingPhase, const IntRect&) const override; |
| 233 String debugName(const GraphicsLayer*) const override; | 239 String debugName(const GraphicsLayer*) const override; |
| 234 | 240 |
| 235 void setupScrollbar(WebScrollbar::Orientation); | 241 void setupScrollbar(WebScrollbar::Orientation); |
| 236 FloatPoint clampOffsetToBoundaries(const FloatPoint&); | 242 FloatPoint clampOffsetToBoundaries(const FloatPoint&); |
| 237 | 243 |
| 244 // Calculate the physical minimum/maximum scroll positions without any overr
ides applied. |
| 245 DoublePoint calculateMinimumScrollPositionDouble() const; |
| 246 DoublePoint calculateMaximumScrollPositionDouble() const; |
| 247 |
| 238 LocalFrame* mainFrame() const; | 248 LocalFrame* mainFrame() const; |
| 239 | 249 |
| 240 FrameHost& frameHost() const | 250 FrameHost& frameHost() const |
| 241 { | 251 { |
| 242 ASSERT(m_frameHost); | 252 ASSERT(m_frameHost); |
| 243 return *m_frameHost; | 253 return *m_frameHost; |
| 244 } | 254 } |
| 245 | 255 |
| 246 Member<FrameHost> m_frameHost; | 256 Member<FrameHost> m_frameHost; |
| 247 std::unique_ptr<GraphicsLayer> m_rootTransformLayer; | 257 std::unique_ptr<GraphicsLayer> m_rootTransformLayer; |
| 248 std::unique_ptr<GraphicsLayer> m_innerViewportContainerLayer; | 258 std::unique_ptr<GraphicsLayer> m_innerViewportContainerLayer; |
| 249 std::unique_ptr<GraphicsLayer> m_overscrollElasticityLayer; | 259 std::unique_ptr<GraphicsLayer> m_overscrollElasticityLayer; |
| 250 std::unique_ptr<GraphicsLayer> m_pageScaleLayer; | 260 std::unique_ptr<GraphicsLayer> m_pageScaleLayer; |
| 251 std::unique_ptr<GraphicsLayer> m_innerViewportScrollLayer; | 261 std::unique_ptr<GraphicsLayer> m_innerViewportScrollLayer; |
| 252 std::unique_ptr<GraphicsLayer> m_overlayScrollbarHorizontal; | 262 std::unique_ptr<GraphicsLayer> m_overlayScrollbarHorizontal; |
| 253 std::unique_ptr<GraphicsLayer> m_overlayScrollbarVertical; | 263 std::unique_ptr<GraphicsLayer> m_overlayScrollbarVertical; |
| 254 std::unique_ptr<WebScrollbarLayer> m_webOverlayScrollbarHorizontal; | 264 std::unique_ptr<WebScrollbarLayer> m_webOverlayScrollbarHorizontal; |
| 255 std::unique_ptr<WebScrollbarLayer> m_webOverlayScrollbarVertical; | 265 std::unique_ptr<WebScrollbarLayer> m_webOverlayScrollbarVertical; |
| 256 | 266 |
| 257 // Offset of the visual viewport from the main frame's origin, in CSS pixels
. | 267 // Offset of the visual viewport from the main frame's origin, in CSS pixels
. |
| 258 FloatPoint m_offset; | 268 FloatPoint m_offset; |
| 259 float m_scale; | 269 float m_scale; |
| 260 IntSize m_size; | 270 IntSize m_size; |
| 261 float m_topControlsAdjustment; | 271 float m_topControlsAdjustment; |
| 262 float m_maxPageScale; | 272 float m_maxPageScale; |
| 263 bool m_trackPinchZoomStatsForPage; | 273 bool m_trackPinchZoomStatsForPage; |
| 274 |
| 275 Member<ScrollAndScaleEmulator> m_scrollAndScaleEmulator; |
| 264 }; | 276 }; |
| 265 | 277 |
| 266 } // namespace blink | 278 } // namespace blink |
| 267 | 279 |
| 268 #endif // VisualViewport_h | 280 #endif // VisualViewport_h |
| OLD | NEW |