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

Side by Side Diff: sky/engine/core/frame/PinchViewport.h

Issue 681583002: Remove pinch viewports. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: upload synced patch Created 6 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
(Empty)
1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above
11 * copyright notice, this list of conditions and the following disclaimer
12 * in the documentation and/or other materials provided with the
13 * distribution.
14 * * Neither the name of Google Inc. nor the names of its
15 * contributors may be used to endorse or promote products derived from
16 * this software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
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.
29 */
30
31 #ifndef PinchViewport_h
32 #define PinchViewport_h
33
34 #include "platform/geometry/FloatPoint.h"
35 #include "platform/geometry/FloatRect.h"
36 #include "platform/geometry/IntSize.h"
37 #include "platform/graphics/GraphicsLayerClient.h"
38 #include "platform/scroll/ScrollableArea.h"
39 #include "public/platform/WebScrollbar.h"
40 #include "public/platform/WebSize.h"
41 #include "wtf/OwnPtr.h"
42 #include "wtf/PassOwnPtr.h"
43
44 namespace blink {
45 class WebLayerTreeView;
46 class WebScrollbarLayer;
47 }
48
49 namespace blink {
50
51 class FrameHost;
52 class GraphicsContext;
53 class GraphicsLayer;
54 class GraphicsLayerFactory;
55 class IntRect;
56 class IntSize;
57 class LocalFrame;
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.
64 class PinchViewport final : public GraphicsLayerClient, public ScrollableArea {
65 public:
66 explicit PinchViewport(FrameHost&);
67 virtual ~PinchViewport();
68
69 void attachToLayerTree(GraphicsLayer*, GraphicsLayerFactory*);
70 GraphicsLayer* rootGraphicsLayer()
71 {
72 return m_rootTransformLayer.get();
73 }
74 GraphicsLayer* containerLayer()
75 {
76 return m_innerViewportContainerLayer.get();
77 }
78
79 // Sets the location of the inner viewport relative to the outer viewport. T he
80 // coordinates are in partial CSS pixels.
81 void setLocation(const FloatPoint&);
82 void move(const FloatPoint&);
83
84 // Sets the size of the inner viewport when unscaled in CSS pixels.
85 // This will be clamped to the size of the outer viewport (the main frame).
86 void setSize(const IntSize&);
87 IntSize size() const { return m_size; }
88
89 // Resets the viewport to initial state.
90 void reset();
91
92 // Let the viewport know that the main frame changed size (either through sc reen
93 // rotation on Android or window resize elsewhere).
94 void mainFrameDidChangeSize();
95
96 void setScale(float);
97 float scale() const { return m_scale; }
98
99 void registerLayersWithTreeView(blink::WebLayerTreeView*) const;
100 void clearLayersForTreeView(blink::WebLayerTreeView*) const;
101
102 // The portion of the unzoomed frame visible in the inner "pinch" viewport,
103 // in partial CSS pixels. Relative to the main frame.
104 FloatRect visibleRect() const;
105
106 // The viewport rect relative to the document origin, in partial CSS pixels.
107 FloatRect visibleRectInDocument() const;
108
109 // Scroll the main frame and pinch viewport so that the given rect in the
110 // top-level document is centered in the viewport. This method will avoid
111 // scrolling the pinch viewport unless necessary.
112 void scrollIntoView(const FloatRect&);
113 private:
114 // ScrollableArea implementation
115 virtual bool isActive() const override { return false; }
116 virtual int scrollSize(ScrollbarOrientation) const override;
117 virtual bool isScrollCornerVisible() const override { return false; }
118 virtual IntRect scrollCornerRect() const override { return IntRect(); }
119 virtual IntPoint scrollPosition() const override { return flooredIntPoint(m_ offset); }
120 virtual IntPoint minimumScrollPosition() const override;
121 virtual IntPoint maximumScrollPosition() const override;
122 virtual int visibleHeight() const override { return visibleRect().height(); };
123 virtual int visibleWidth() const override { return visibleRect().width(); };
124 virtual IntSize contentsSize() const override;
125 virtual bool scrollbarsCanBeActive() const override { return false; }
126 virtual IntRect scrollableAreaBoundingBox() const override;
127 virtual bool userInputScrollable(ScrollbarOrientation) const override { retu rn true; }
128 virtual bool shouldPlaceVerticalScrollbarOnLeft() const override { return fa lse; }
129 virtual void invalidateScrollbarRect(Scrollbar*, const IntRect&) override;
130 virtual void invalidateScrollCornerRect(const IntRect&) override { }
131 virtual void setScrollOffset(const IntPoint&) override;
132 virtual GraphicsLayer* layerForContainer() const override;
133 virtual GraphicsLayer* layerForScrolling() const override;
134 virtual GraphicsLayer* layerForHorizontalScrollbar() const override;
135 virtual GraphicsLayer* layerForVerticalScrollbar() const override;
136
137 // GraphicsLayerClient implementation.
138 virtual void notifyAnimationStarted(const GraphicsLayer*, double monotonicTi me) override;
139 virtual void paintContents(const GraphicsLayer*, GraphicsContext&, GraphicsL ayerPaintingPhase, const IntRect& inClip) override;
140 virtual String debugName(const GraphicsLayer*) override;
141
142 void setupScrollbar(blink::WebScrollbar::Orientation);
143 FloatPoint clampOffsetToBoundaries(const FloatPoint&);
144
145 LocalFrame* mainFrame() const;
146
147 FrameHost& m_frameHost;
148 OwnPtr<GraphicsLayer> m_rootTransformLayer;
149 OwnPtr<GraphicsLayer> m_innerViewportContainerLayer;
150 OwnPtr<GraphicsLayer> m_pageScaleLayer;
151 OwnPtr<GraphicsLayer> m_innerViewportScrollLayer;
152 OwnPtr<GraphicsLayer> m_overlayScrollbarHorizontal;
153 OwnPtr<GraphicsLayer> m_overlayScrollbarVertical;
154 OwnPtr<blink::WebScrollbarLayer> m_webOverlayScrollbarHorizontal;
155 OwnPtr<blink::WebScrollbarLayer> m_webOverlayScrollbarVertical;
156
157 // Offset of the pinch viewport from the main frame's origin, in CSS pixels.
158 FloatPoint m_offset;
159 float m_scale;
160 IntSize m_size;
161 };
162
163 } // namespace blink
164
165 #endif // PinchViewport_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698