Chromium Code Reviews| 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 14 matching lines...) Expand all Loading... | |
| 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 NoBaseWillBeGarbageCollectedFina lized<VisualViewport>, public GraphicsLayerClient, public ScrollableArea { | 65 class CORE_EXPORT VisualViewport final |
| 66 : public NoBaseWillBeGarbageCollectedFinalized<VisualViewport> | |
| 67 , public GraphicsLayerClient | |
| 68 , public ScriptWrappable | |
| 69 , public ScrollableArea { | |
| 65 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(VisualViewport); | 70 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(VisualViewport); |
| 71 DEFINE_WRAPPERTYPEINFO(); | |
| 66 public: | 72 public: |
| 67 static PassOwnPtrWillBeRawPtr<VisualViewport> create(FrameHost& host) | 73 static PassOwnPtrWillBeRawPtr<VisualViewport> create(FrameHost& host) |
| 68 { | 74 { |
| 69 return adoptPtrWillBeNoop(new VisualViewport(host)); | 75 return adoptPtrWillBeNoop(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 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 189 bool scrollAnimatorEnabled() const override; | 195 bool scrollAnimatorEnabled() const override; |
| 190 void scrollControlWasSetNeedsPaintInvalidation() override { } | 196 void scrollControlWasSetNeedsPaintInvalidation() override { } |
| 191 void setScrollOffset(const DoublePoint&, ScrollType) override; | 197 void setScrollOffset(const DoublePoint&, ScrollType) override; |
| 192 GraphicsLayer* layerForContainer() const override; | 198 GraphicsLayer* layerForContainer() const override; |
| 193 GraphicsLayer* layerForScrolling() const override; | 199 GraphicsLayer* layerForScrolling() const override; |
| 194 GraphicsLayer* layerForHorizontalScrollbar() const override; | 200 GraphicsLayer* layerForHorizontalScrollbar() const override; |
| 195 GraphicsLayer* layerForVerticalScrollbar() const override; | 201 GraphicsLayer* layerForVerticalScrollbar() const override; |
| 196 Widget* getWidget() override; | 202 Widget* getWidget() override; |
| 197 CompositorAnimationTimeline* compositorAnimationTimeline() const override; | 203 CompositorAnimationTimeline* compositorAnimationTimeline() const override; |
| 198 | 204 |
| 205 void updateLayoutIgnorePendingStylesheets(); | |
|
esprehn
2016/03/24 19:20:17
I'd rather you didn't proxy this method. Callers s
ymalik
2016/03/29 19:17:28
You mentioned below that this method should be pri
| |
| 206 | |
| 207 // Visual Viewport API implementation. | |
| 208 double scrollLeft(); | |
| 209 double scrollTop(); | |
| 210 void setScrollLeft(double x); | |
| 211 void setScrollTop(double y); | |
| 212 double clientWidth(); | |
| 213 double clientHeight(); | |
| 214 double pageScale(); | |
| 215 | |
| 199 // Used for gathering data on user pinch-zoom statistics. | 216 // Used for gathering data on user pinch-zoom statistics. |
| 200 void userDidChangeScale(); | 217 void userDidChangeScale(); |
| 201 void sendUMAMetrics(); | 218 void sendUMAMetrics(); |
| 202 void startTrackingPinchStats(); | 219 void startTrackingPinchStats(); |
| 203 | 220 |
| 204 // Heuristic-based function for determining if we should disable workarounds | 221 // Heuristic-based function for determining if we should disable workarounds |
| 205 // for viewing websites that are not optimized for mobile devices. | 222 // for viewing websites that are not optimized for mobile devices. |
| 206 bool shouldDisableDesktopWorkarounds() const; | 223 bool shouldDisableDesktopWorkarounds() const; |
| 207 | 224 |
| 208 private: | 225 private: |
| 209 explicit VisualViewport(FrameHost&); | 226 explicit VisualViewport(FrameHost&); |
| 210 | 227 |
| 211 bool visualViewportSuppliesScrollbars() const; | 228 bool visualViewportSuppliesScrollbars() const; |
| 212 | 229 |
| 230 void dispatchChangedEvent(); | |
| 231 | |
| 213 // GraphicsLayerClient implementation. | 232 // GraphicsLayerClient implementation. |
| 214 IntRect computeInterestRect(const GraphicsLayer*, const IntRect&) const; | 233 IntRect computeInterestRect(const GraphicsLayer*, const IntRect&) const; |
| 215 void paintContents(const GraphicsLayer*, GraphicsContext&, GraphicsLayerPain tingPhase, const IntRect&) const override; | 234 void paintContents(const GraphicsLayer*, GraphicsContext&, GraphicsLayerPain tingPhase, const IntRect&) const override; |
| 216 String debugName(const GraphicsLayer*) const override; | 235 String debugName(const GraphicsLayer*) const override; |
| 217 | 236 |
| 218 void setupScrollbar(WebScrollbar::Orientation); | 237 void setupScrollbar(WebScrollbar::Orientation); |
| 219 FloatPoint clampOffsetToBoundaries(const FloatPoint&); | 238 FloatPoint clampOffsetToBoundaries(const FloatPoint&); |
| 220 | 239 |
| 221 LocalFrame* mainFrame() const; | 240 LocalFrame* mainFrame() const; |
| 222 | 241 |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 242 float m_scale; | 261 float m_scale; |
| 243 IntSize m_size; | 262 IntSize m_size; |
| 244 float m_topControlsAdjustment; | 263 float m_topControlsAdjustment; |
| 245 float m_maxPageScale; | 264 float m_maxPageScale; |
| 246 bool m_trackPinchZoomStatsForPage; | 265 bool m_trackPinchZoomStatsForPage; |
| 247 }; | 266 }; |
| 248 | 267 |
| 249 } // namespace blink | 268 } // namespace blink |
| 250 | 269 |
| 251 #endif // VisualViewport_h | 270 #endif // VisualViewport_h |
| OLD | NEW |