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

Side by Side Diff: Source/core/frame/PinchViewport.h

Issue 225303014: [Pinch-to-zoom] Moved scale factor into PinchViewport (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fixed layout test breakage Created 6 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
« no previous file with comments | « Source/core/frame/FrameView.cpp ('k') | Source/core/frame/PinchViewport.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 13 matching lines...) Expand all
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
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 PinchViewport_h 31 #ifndef PinchViewport_h
32 #define PinchViewport_h 32 #define PinchViewport_h
33 33
34 #include "platform/geometry/FloatPoint.h"
35 #include "platform/geometry/FloatRect.h"
34 #include "platform/geometry/IntSize.h" 36 #include "platform/geometry/IntSize.h"
35 #include "platform/graphics/GraphicsLayerClient.h" 37 #include "platform/graphics/GraphicsLayerClient.h"
36 #include "platform/scroll/ScrollableArea.h" 38 #include "platform/scroll/ScrollableArea.h"
37 #include "public/platform/WebScrollbar.h" 39 #include "public/platform/WebScrollbar.h"
38 #include "public/platform/WebSize.h" 40 #include "public/platform/WebSize.h"
39 #include "wtf/OwnPtr.h" 41 #include "wtf/OwnPtr.h"
40 #include "wtf/PassOwnPtr.h" 42 #include "wtf/PassOwnPtr.h"
41 43
42 namespace blink { 44 namespace blink {
43 class WebLayerTreeView; 45 class WebLayerTreeView;
44 class WebScrollbarLayer; 46 class WebScrollbarLayer;
45 } 47 }
46 48
47 namespace WebCore { 49 namespace WebCore {
48 50
49 class FrameHost; 51 class FrameHost;
50 class GraphicsContext; 52 class GraphicsContext;
51 class GraphicsLayer; 53 class GraphicsLayer;
52 class GraphicsLayerFactory; 54 class GraphicsLayerFactory;
53 class IntRect; 55 class IntRect;
54 class IntSize; 56 class IntSize;
57 class LocalFrame;
55 58
59 // Represents the pinch-to-zoom viewport the user is currently seeing the page t hrough. This
60 // 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 // 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.
56 class PinchViewport FINAL : public GraphicsLayerClient, public ScrollableArea { 64 class PinchViewport FINAL : public GraphicsLayerClient, public ScrollableArea {
57 public: 65 public:
58 PinchViewport(FrameHost&); 66 PinchViewport(FrameHost&);
59 virtual ~PinchViewport(); 67 virtual ~PinchViewport();
60 68
61 void attachToLayerTree(GraphicsLayer*, GraphicsLayerFactory*); 69 void attachToLayerTree(GraphicsLayer*, GraphicsLayerFactory*);
62 GraphicsLayer* rootGraphicsLayer() 70 GraphicsLayer* rootGraphicsLayer()
63 { 71 {
64 return m_innerViewportContainerLayer.get(); 72 return m_innerViewportContainerLayer.get();
65 } 73 }
66 74
67 void setLocation(const IntPoint&); 75 void setLocation(const FloatPoint&);
68 void setSize(const IntSize&); 76 void mainFrameDidChangeSize();
77
78 void setScale(float);
79 float scale() const { return m_scale; }
69 80
70 void registerLayersWithTreeView(blink::WebLayerTreeView*) const; 81 void registerLayersWithTreeView(blink::WebLayerTreeView*) const;
71 void clearLayersForTreeView(blink::WebLayerTreeView*) const; 82 void clearLayersForTreeView(blink::WebLayerTreeView*) const;
72 83
73 IntRect visibleRect() const { return m_visibleRect; } 84 // The portion of the unzoomed frame visible in the inner "pinch" viewport, in partial CSS pixels.
85 FloatRect visibleRect() const;
74 private: 86 private:
75 // ScrollableArea implementation 87 // ScrollableArea implementation
76 virtual bool isActive() const OVERRIDE { return false; } 88 virtual bool isActive() const OVERRIDE { return false; }
77 virtual int scrollSize(ScrollbarOrientation) const OVERRIDE; 89 virtual int scrollSize(ScrollbarOrientation) const OVERRIDE;
78 virtual bool isScrollCornerVisible() const OVERRIDE { return false; } 90 virtual bool isScrollCornerVisible() const OVERRIDE { return false; }
79 virtual IntRect scrollCornerRect() const OVERRIDE { return IntRect(); } 91 virtual IntRect scrollCornerRect() const OVERRIDE { return IntRect(); }
80 virtual IntPoint scrollPosition() const OVERRIDE { return visibleRect().loca tion(); } 92 virtual IntPoint scrollPosition() const OVERRIDE { return flooredIntPoint(m_ offset); }
81 virtual IntPoint minimumScrollPosition() const OVERRIDE; 93 virtual IntPoint minimumScrollPosition() const OVERRIDE;
82 virtual IntPoint maximumScrollPosition() const OVERRIDE; 94 virtual IntPoint maximumScrollPosition() const OVERRIDE;
83 virtual int visibleHeight() const OVERRIDE { return visibleRect().height(); }; 95 virtual int visibleHeight() const OVERRIDE { return visibleRect().height(); };
84 virtual int visibleWidth() const OVERRIDE { return visibleRect().width(); }; 96 virtual int visibleWidth() const OVERRIDE { return visibleRect().width(); };
85 virtual IntSize contentsSize() const OVERRIDE; 97 virtual IntSize contentsSize() const OVERRIDE;
86 virtual bool scrollbarsCanBeActive() const OVERRIDE { return false; } 98 virtual bool scrollbarsCanBeActive() const OVERRIDE { return false; }
87 virtual IntRect scrollableAreaBoundingBox() const OVERRIDE; 99 virtual IntRect scrollableAreaBoundingBox() const OVERRIDE;
88 virtual bool userInputScrollable(ScrollbarOrientation) const OVERRIDE { retu rn true; } 100 virtual bool userInputScrollable(ScrollbarOrientation) const OVERRIDE { retu rn true; }
89 virtual bool shouldPlaceVerticalScrollbarOnLeft() const OVERRIDE { return fa lse; } 101 virtual bool shouldPlaceVerticalScrollbarOnLeft() const OVERRIDE { return fa lse; }
90 virtual void invalidateScrollbarRect(Scrollbar*, const IntRect&) OVERRIDE; 102 virtual void invalidateScrollbarRect(Scrollbar*, const IntRect&) OVERRIDE;
91 virtual void invalidateScrollCornerRect(const IntRect&) OVERRIDE { } 103 virtual void invalidateScrollCornerRect(const IntRect&) OVERRIDE { }
92 virtual void setScrollOffset(const IntPoint&) OVERRIDE; 104 virtual void setScrollOffset(const IntPoint&) OVERRIDE;
93 virtual GraphicsLayer* layerForContainer() const OVERRIDE; 105 virtual GraphicsLayer* layerForContainer() const OVERRIDE;
94 virtual GraphicsLayer* layerForScrolling() const OVERRIDE; 106 virtual GraphicsLayer* layerForScrolling() const OVERRIDE;
95 virtual GraphicsLayer* layerForHorizontalScrollbar() const OVERRIDE; 107 virtual GraphicsLayer* layerForHorizontalScrollbar() const OVERRIDE;
96 virtual GraphicsLayer* layerForVerticalScrollbar() const OVERRIDE; 108 virtual GraphicsLayer* layerForVerticalScrollbar() const OVERRIDE;
97 109
98 // GraphicsLayerClient implementation. 110 // GraphicsLayerClient implementation.
99 virtual void notifyAnimationStarted(const GraphicsLayer*, double monotonicTi me) OVERRIDE; 111 virtual void notifyAnimationStarted(const GraphicsLayer*, double monotonicTi me) OVERRIDE;
100 virtual void paintContents(const GraphicsLayer*, GraphicsContext&, GraphicsL ayerPaintingPhase, const IntRect& inClip) OVERRIDE; 112 virtual void paintContents(const GraphicsLayer*, GraphicsContext&, GraphicsL ayerPaintingPhase, const IntRect& inClip) OVERRIDE;
101 virtual String debugName(const GraphicsLayer*) OVERRIDE; 113 virtual String debugName(const GraphicsLayer*) OVERRIDE;
102 114
103 void setupScrollbar(blink::WebScrollbar::Orientation); 115 void setupScrollbar(blink::WebScrollbar::Orientation);
116 FloatPoint clampOffsetToBoundaries(const FloatPoint&);
117
118 LocalFrame* mainFrame() const;
104 119
105 FrameHost& m_frameHost; 120 FrameHost& m_frameHost;
106 OwnPtr<GraphicsLayer> m_innerViewportContainerLayer; 121 OwnPtr<GraphicsLayer> m_innerViewportContainerLayer;
107 OwnPtr<GraphicsLayer> m_pageScaleLayer; 122 OwnPtr<GraphicsLayer> m_pageScaleLayer;
108 OwnPtr<GraphicsLayer> m_innerViewportScrollLayer; 123 OwnPtr<GraphicsLayer> m_innerViewportScrollLayer;
109 OwnPtr<GraphicsLayer> m_overlayScrollbarHorizontal; 124 OwnPtr<GraphicsLayer> m_overlayScrollbarHorizontal;
110 OwnPtr<GraphicsLayer> m_overlayScrollbarVertical; 125 OwnPtr<GraphicsLayer> m_overlayScrollbarVertical;
111 OwnPtr<blink::WebScrollbarLayer> m_webOverlayScrollbarHorizontal; 126 OwnPtr<blink::WebScrollbarLayer> m_webOverlayScrollbarHorizontal;
112 OwnPtr<blink::WebScrollbarLayer> m_webOverlayScrollbarVertical; 127 OwnPtr<blink::WebScrollbarLayer> m_webOverlayScrollbarVertical;
113 128
114 IntRect m_visibleRect; 129 // Offset of the pinch viewport from the main frame's origin, in CSS pixels.
130 FloatPoint m_offset;
131 float m_scale;
115 }; 132 };
116 133
117 } // namespace WebCore 134 } // namespace WebCore
118 135
119 #endif // PinchViewport_h 136 #endif // PinchViewport_h
OLDNEW
« no previous file with comments | « Source/core/frame/FrameView.cpp ('k') | Source/core/frame/PinchViewport.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698