Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5)

Side by Side Diff: third_party/WebKit/Source/core/frame/VisualViewport.h

Issue 2387883002: Use float for scroll offset. (Closed)
Patch Set: Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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&); 97 FloatPoint location() const { return FloatPoint(m_offset); }
bokan 2016/10/02 19:47:51 This should return a ScrollOffset but if you want
szager1 2016/10/05 07:43:36 No time like the present! I got rid of this metho
98 FloatPoint location() const { return m_offset; }
99 98
100 // 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.
101 void setSize(const IntSize&); 100 void setSize(const IntSize&);
102 IntSize size() const { return m_size; } 101 IntSize size() const { return m_size; }
103 102
104 // 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.
105 FloatSize visibleSize() const; 104 FloatSize visibleSize() const;
106 105
107 // Resets the viewport to initial state. 106 // Resets the viewport to initial state.
108 void reset(); 107 void reset();
(...skipping 12 matching lines...) Expand all
121 // scale factor is left unchanged. 120 // scale factor is left unchanged.
122 bool magnifyScaleAroundAnchor(float magnifyDelta, const FloatPoint& anchor); 121 bool magnifyScaleAroundAnchor(float magnifyDelta, const FloatPoint& anchor);
123 122
124 void setScrollLayerOnScrollbars(WebLayer*) const; 123 void setScrollLayerOnScrollbars(WebLayer*) const;
125 124
126 // The portion of the unzoomed frame visible in the visual viewport, 125 // The portion of the unzoomed frame visible in the visual viewport,
127 // in partial CSS pixels. Relative to the main frame. 126 // in partial CSS pixels. Relative to the main frame.
128 FloatRect visibleRect() const; 127 FloatRect visibleRect() const;
129 128
130 // 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.
131 // FIXME: This should be a DoubleRect since scroll offsets are now doubles.
132 FloatRect visibleRectInDocument() const; 130 FloatRect visibleRectInDocument() const;
133 131
134 // 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
135 // 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
136 // scale isn't applied. 134 // scale isn't applied.
137 FloatRect mainViewToViewportCSSPixels(const FloatRect&) const; 135 FloatRect mainViewToViewportCSSPixels(const FloatRect&) const;
138 FloatPoint viewportCSSPixelsToRootFrame(const FloatPoint&) const; 136 FloatPoint viewportCSSPixelsToRootFrame(const FloatPoint&) const;
139 137
140 // Clamp the given point, in document coordinates, to the maximum/minimum 138 // Clamp the given point, in document coordinates, to the maximum/minimum
141 // scroll extents of the viewport within the document. 139 // scroll extents of the viewport within the document.
(...skipping 17 matching lines...) Expand all
159 FloatRect rootFrameToViewport(const FloatRect&) const; 157 FloatRect rootFrameToViewport(const FloatRect&) const;
160 IntRect rootFrameToViewport(const IntRect&) const; 158 IntRect rootFrameToViewport(const IntRect&) const;
161 159
162 FloatPoint viewportToRootFrame(const FloatPoint&) const; 160 FloatPoint viewportToRootFrame(const FloatPoint&) const;
163 FloatPoint rootFrameToViewport(const FloatPoint&) const; 161 FloatPoint rootFrameToViewport(const FloatPoint&) const;
164 IntPoint viewportToRootFrame(const IntPoint&) const; 162 IntPoint viewportToRootFrame(const IntPoint&) const;
165 IntPoint rootFrameToViewport(const IntPoint&) const; 163 IntPoint rootFrameToViewport(const IntPoint&) const;
166 164
167 // ScrollableArea implementation 165 // ScrollableArea implementation
168 HostWindow* getHostWindow() const override; 166 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; 167 bool shouldUseIntegerScrollOffset() const override;
174 void setScrollPosition(const DoublePoint&, 168 void setScrollOffset(const ScrollOffset&,
175 ScrollType, 169 ScrollType,
176 ScrollBehavior = ScrollBehaviorInstant) override; 170 ScrollBehavior = ScrollBehaviorInstant) override;
177 LayoutRect visualRectForScrollbarParts() const override { 171 LayoutRect visualRectForScrollbarParts() const override {
178 ASSERT_NOT_REACHED(); 172 ASSERT_NOT_REACHED();
179 return LayoutRect(); 173 return LayoutRect();
180 } 174 }
181 bool isActive() const override { return false; } 175 bool isActive() const override { return false; }
182 int scrollSize(ScrollbarOrientation) const override; 176 int scrollSize(ScrollbarOrientation) const override;
183 bool isScrollCornerVisible() const override { return false; } 177 bool isScrollCornerVisible() const override { return false; }
184 IntRect scrollCornerRect() const override { return IntRect(); } 178 IntRect scrollCornerRect() const override { return IntRect(); }
185 IntPoint scrollPosition() const override { return flooredIntPoint(m_offset); } 179 IntSize scrollOffsetInt() const override { return flooredIntSize(m_offset); }
186 DoublePoint scrollPositionDouble() const override { return m_offset; } 180 ScrollOffset scrollOffset() const override { return m_offset; }
187 IntPoint minimumScrollPosition() const override; 181 IntSize minimumScrollOffsetInt() const override;
188 IntPoint maximumScrollPosition() const override; 182 IntSize maximumScrollOffsetInt() const override;
189 DoublePoint maximumScrollPositionDouble() const override; 183 ScrollOffset maximumScrollOffset() const override;
190 int visibleHeight() const override { return visibleRect().height(); } 184 int visibleHeight() const override { return visibleRect().height(); }
191 int visibleWidth() const override { return visibleRect().width(); } 185 int visibleWidth() const override { return visibleRect().width(); }
192 IntSize contentsSize() const override; 186 IntSize contentsSize() const override;
193 bool scrollbarsCanBeActive() const override { return false; } 187 bool scrollbarsCanBeActive() const override { return false; }
194 IntRect scrollableAreaBoundingBox() const override; 188 IntRect scrollableAreaBoundingBox() const override;
195 bool userInputScrollable(ScrollbarOrientation) const override { return true; } 189 bool userInputScrollable(ScrollbarOrientation) const override { return true; }
196 bool shouldPlaceVerticalScrollbarOnLeft() const override { return false; } 190 bool shouldPlaceVerticalScrollbarOnLeft() const override { return false; }
197 bool scrollAnimatorEnabled() const override; 191 bool scrollAnimatorEnabled() const override;
198 void scrollControlWasSetNeedsPaintInvalidation() override {} 192 void scrollControlWasSetNeedsPaintInvalidation() override {}
199 void updateScrollPosition(const DoublePoint&, ScrollType) override; 193 void updateScrollOffset(const ScrollOffset&, ScrollType) override;
200 GraphicsLayer* layerForContainer() const override; 194 GraphicsLayer* layerForContainer() const override;
201 GraphicsLayer* layerForScrolling() const override; 195 GraphicsLayer* layerForScrolling() const override;
202 GraphicsLayer* layerForHorizontalScrollbar() const override; 196 GraphicsLayer* layerForHorizontalScrollbar() const override;
203 GraphicsLayer* layerForVerticalScrollbar() const override; 197 GraphicsLayer* layerForVerticalScrollbar() const override;
204 Widget* getWidget() override; 198 Widget* getWidget() override;
205 CompositorAnimationTimeline* compositorAnimationTimeline() const override; 199 CompositorAnimationTimeline* compositorAnimationTimeline() const override;
206 200
207 // Visual Viewport API implementation. 201 // Visual Viewport API implementation.
208 double scrollLeft(); 202 float scrollLeft();
bokan 2016/10/02 19:47:51 these should stay double since they're Web exposed
szager1 2016/10/05 07:43:36 Done.
209 double scrollTop(); 203 float scrollTop();
210 double clientWidth(); 204 float clientWidth();
211 double clientHeight(); 205 float clientHeight();
212 double pageScale(); 206 double pageScale();
213 207
214 // Used for gathering data on user pinch-zoom statistics. 208 // Used for gathering data on user pinch-zoom statistics.
215 void userDidChangeScale(); 209 void userDidChangeScale();
216 void sendUMAMetrics(); 210 void sendUMAMetrics();
217 void startTrackingPinchStats(); 211 void startTrackingPinchStats();
218 212
219 // Heuristic-based function for determining if we should disable workarounds 213 // Heuristic-based function for determining if we should disable workarounds
220 // for viewing websites that are not optimized for mobile devices. 214 // for viewing websites that are not optimized for mobile devices.
221 bool shouldDisableDesktopWorkarounds() const; 215 bool shouldDisableDesktopWorkarounds() const;
(...skipping 16 matching lines...) Expand all
238 return true; 232 return true;
239 } 233 }
240 IntRect computeInterestRect(const GraphicsLayer*, const IntRect&) const; 234 IntRect computeInterestRect(const GraphicsLayer*, const IntRect&) const;
241 void paintContents(const GraphicsLayer*, 235 void paintContents(const GraphicsLayer*,
242 GraphicsContext&, 236 GraphicsContext&,
243 GraphicsLayerPaintingPhase, 237 GraphicsLayerPaintingPhase,
244 const IntRect&) const override; 238 const IntRect&) const override;
245 String debugName(const GraphicsLayer*) const override; 239 String debugName(const GraphicsLayer*) const override;
246 240
247 void setupScrollbar(WebScrollbar::Orientation); 241 void setupScrollbar(WebScrollbar::Orientation);
248 FloatPoint clampOffsetToBoundaries(const FloatPoint&);
249 242
250 void notifyRootFrameViewport() const; 243 void notifyRootFrameViewport() const;
251 244
252 LocalFrame* mainFrame() const; 245 LocalFrame* mainFrame() const;
253 246
254 FrameHost& frameHost() const { 247 FrameHost& frameHost() const {
255 ASSERT(m_frameHost); 248 ASSERT(m_frameHost);
256 return *m_frameHost; 249 return *m_frameHost;
257 } 250 }
258 251
259 Member<FrameHost> m_frameHost; 252 Member<FrameHost> m_frameHost;
260 std::unique_ptr<GraphicsLayer> m_rootTransformLayer; 253 std::unique_ptr<GraphicsLayer> m_rootTransformLayer;
261 std::unique_ptr<GraphicsLayer> m_innerViewportContainerLayer; 254 std::unique_ptr<GraphicsLayer> m_innerViewportContainerLayer;
262 std::unique_ptr<GraphicsLayer> m_overscrollElasticityLayer; 255 std::unique_ptr<GraphicsLayer> m_overscrollElasticityLayer;
263 std::unique_ptr<GraphicsLayer> m_pageScaleLayer; 256 std::unique_ptr<GraphicsLayer> m_pageScaleLayer;
264 std::unique_ptr<GraphicsLayer> m_innerViewportScrollLayer; 257 std::unique_ptr<GraphicsLayer> m_innerViewportScrollLayer;
265 std::unique_ptr<GraphicsLayer> m_overlayScrollbarHorizontal; 258 std::unique_ptr<GraphicsLayer> m_overlayScrollbarHorizontal;
266 std::unique_ptr<GraphicsLayer> m_overlayScrollbarVertical; 259 std::unique_ptr<GraphicsLayer> m_overlayScrollbarVertical;
267 std::unique_ptr<WebScrollbarLayer> m_webOverlayScrollbarHorizontal; 260 std::unique_ptr<WebScrollbarLayer> m_webOverlayScrollbarHorizontal;
268 std::unique_ptr<WebScrollbarLayer> m_webOverlayScrollbarVertical; 261 std::unique_ptr<WebScrollbarLayer> m_webOverlayScrollbarVertical;
269 262
270 // 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.
271 FloatPoint m_offset; 264 ScrollOffset m_offset;
272 float m_scale; 265 float m_scale;
273 IntSize m_size; 266 IntSize m_size;
274 float m_topControlsAdjustment; 267 float m_topControlsAdjustment;
275 float m_maxPageScale; 268 float m_maxPageScale;
276 bool m_trackPinchZoomStatsForPage; 269 bool m_trackPinchZoomStatsForPage;
277 }; 270 };
278 271
279 } // namespace blink 272 } // namespace blink
280 273
281 #endif // VisualViewport_h 274 #endif // VisualViewport_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698