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

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

Issue 1814013002: Visual viewport API initial implementation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 14 matching lines...) Expand all
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
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 "platform/geometry/FloatPoint.h" 36 #include "platform/geometry/FloatPoint.h"
36 #include "platform/geometry/FloatRect.h" 37 #include "platform/geometry/FloatRect.h"
37 #include "platform/geometry/IntSize.h" 38 #include "platform/geometry/IntSize.h"
38 #include "platform/graphics/GraphicsLayerClient.h" 39 #include "platform/graphics/GraphicsLayerClient.h"
39 #include "platform/scroll/ScrollableArea.h" 40 #include "platform/scroll/ScrollableArea.h"
40 #include "public/platform/WebScrollbar.h" 41 #include "public/platform/WebScrollbar.h"
41 #include "public/platform/WebSize.h" 42 #include "public/platform/WebSize.h"
42 #include "wtf/OwnPtr.h" 43 #include "wtf/OwnPtr.h"
43 #include "wtf/PassOwnPtr.h" 44 #include "wtf/PassOwnPtr.h"
44 45
45 namespace blink { 46 namespace blink {
46 class WebLayerTreeView; 47 class WebLayerTreeView;
47 class WebScrollbarLayer; 48 class WebScrollbarLayer;
48 } 49 }
49 50
50 namespace blink { 51 namespace blink {
51 52
52 class FrameHost; 53 class FrameHost;
53 class GraphicsContext; 54 class GraphicsContext;
54 class GraphicsLayer; 55 class GraphicsLayer;
55 class IntRect; 56 class IntRect;
56 class IntSize; 57 class IntSize;
57 class LocalFrame; 58 class LocalFrame;
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 : public GarbageCollectedFinalized<Visual Viewport>, public GraphicsLayerClient, public ScrollableArea { 65 class CORE_EXPORT VisualViewport final
66 : public GarbageCollectedFinalized<VisualViewport>
67 , public GraphicsLayerClient
68 , public ScriptWrappable
69 , public ScrollableArea {
65 USING_GARBAGE_COLLECTED_MIXIN(VisualViewport); 70 USING_GARBAGE_COLLECTED_MIXIN(VisualViewport);
71 DEFINE_WRAPPERTYPEINFO();
66 public: 72 public:
67 static RawPtr<VisualViewport> create(FrameHost& host) 73 static RawPtr<VisualViewport> create(FrameHost& host)
68 { 74 {
69 return new VisualViewport(host); 75 return new VisualViewport(host);
70 } 76 }
71 ~VisualViewport() override; 77 ~VisualViewport() override;
72 78
73 DECLARE_VIRTUAL_TRACE(); 79 DECLARE_VIRTUAL_TRACE();
74 80
75 void attachToLayerTree(GraphicsLayer*); 81 void attachToLayerTree(GraphicsLayer*);
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 bool scrollAnimatorEnabled() const override; 196 bool scrollAnimatorEnabled() const override;
191 void scrollControlWasSetNeedsPaintInvalidation() override { } 197 void scrollControlWasSetNeedsPaintInvalidation() override { }
192 void setScrollOffset(const DoublePoint&, ScrollType) override; 198 void setScrollOffset(const DoublePoint&, ScrollType) override;
193 GraphicsLayer* layerForContainer() const override; 199 GraphicsLayer* layerForContainer() const override;
194 GraphicsLayer* layerForScrolling() const override; 200 GraphicsLayer* layerForScrolling() const override;
195 GraphicsLayer* layerForHorizontalScrollbar() const override; 201 GraphicsLayer* layerForHorizontalScrollbar() const override;
196 GraphicsLayer* layerForVerticalScrollbar() const override; 202 GraphicsLayer* layerForVerticalScrollbar() const override;
197 Widget* getWidget() override; 203 Widget* getWidget() override;
198 CompositorAnimationTimeline* compositorAnimationTimeline() const override; 204 CompositorAnimationTimeline* compositorAnimationTimeline() const override;
199 205
206 // Visual Viewport API implementation.
207 double scrollLeft();
208 double scrollTop();
209 void setScrollLeft(double x);
210 void setScrollTop(double y);
211 double clientWidth();
212 double clientHeight();
213 double pageScale();
214
200 // Used for gathering data on user pinch-zoom statistics. 215 // Used for gathering data on user pinch-zoom statistics.
201 void userDidChangeScale(); 216 void userDidChangeScale();
202 void sendUMAMetrics(); 217 void sendUMAMetrics();
203 void startTrackingPinchStats(); 218 void startTrackingPinchStats();
204 219
205 // Heuristic-based function for determining if we should disable workarounds 220 // Heuristic-based function for determining if we should disable workarounds
206 // for viewing websites that are not optimized for mobile devices. 221 // for viewing websites that are not optimized for mobile devices.
207 bool shouldDisableDesktopWorkarounds() const; 222 bool shouldDisableDesktopWorkarounds() const;
208 223
209 private: 224 private:
210 explicit VisualViewport(FrameHost&); 225 explicit VisualViewport(FrameHost&);
211 226
212 bool visualViewportSuppliesScrollbars() const; 227 bool visualViewportSuppliesScrollbars() const;
213 228
229 void updateLayoutIgnorePendingStylesheets();
230
231 void enqueueChangedEvent();
232
214 // GraphicsLayerClient implementation. 233 // GraphicsLayerClient implementation.
215 bool needsRepaint(const GraphicsLayer&) const { ASSERT_NOT_REACHED(); return true; } 234 bool needsRepaint(const GraphicsLayer&) const { ASSERT_NOT_REACHED(); return true; }
216 IntRect computeInterestRect(const GraphicsLayer*, const IntRect&) const; 235 IntRect computeInterestRect(const GraphicsLayer*, const IntRect&) const;
217 void paintContents(const GraphicsLayer*, GraphicsContext&, GraphicsLayerPain tingPhase, const IntRect&) const override; 236 void paintContents(const GraphicsLayer*, GraphicsContext&, GraphicsLayerPain tingPhase, const IntRect&) const override;
218 String debugName(const GraphicsLayer*) const override; 237 String debugName(const GraphicsLayer*) const override;
219 238
220 void setupScrollbar(WebScrollbar::Orientation); 239 void setupScrollbar(WebScrollbar::Orientation);
221 FloatPoint clampOffsetToBoundaries(const FloatPoint&); 240 FloatPoint clampOffsetToBoundaries(const FloatPoint&);
222 241
223 LocalFrame* mainFrame() const; 242 LocalFrame* mainFrame() const;
(...skipping 20 matching lines...) Expand all
244 float m_scale; 263 float m_scale;
245 IntSize m_size; 264 IntSize m_size;
246 float m_topControlsAdjustment; 265 float m_topControlsAdjustment;
247 float m_maxPageScale; 266 float m_maxPageScale;
248 bool m_trackPinchZoomStatsForPage; 267 bool m_trackPinchZoomStatsForPage;
249 }; 268 };
250 269
251 } // namespace blink 270 } // namespace blink
252 271
253 #endif // VisualViewport_h 272 #endif // VisualViewport_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/events/EventTypeNames.in ('k') | third_party/WebKit/Source/core/frame/VisualViewport.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698