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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 class GraphicsLayerFactory; | 54 class GraphicsLayerFactory; |
55 class IntRect; | 55 class IntRect; |
56 class IntSize; | 56 class IntSize; |
57 class LocalFrame; | 57 class LocalFrame; |
58 | 58 |
59 // Represents the pinch-to-zoom viewport the user is currently seeing the page t
hrough. This | 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 | 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 | 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 | 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. | 63 // in the outer viewport and can pan within it. |
64 class PinchViewport final : public GraphicsLayerClient, public ScrollableArea { | 64 class PinchViewport final : public NoBaseWillBeGarbageCollectedFinalized<PinchVi
ewport>, public GraphicsLayerClient, public ScrollableArea { |
65 public: | 65 public: |
66 explicit PinchViewport(FrameHost&); | 66 static PassOwnPtrWillBeRawPtr<PinchViewport> create(FrameHost& host) |
| 67 { |
| 68 return adoptPtrWillBeNoop(new PinchViewport(host)); |
| 69 } |
67 virtual ~PinchViewport(); | 70 virtual ~PinchViewport(); |
| 71 virtual void trace(Visitor*); |
68 | 72 |
69 void attachToLayerTree(GraphicsLayer*, GraphicsLayerFactory*); | 73 void attachToLayerTree(GraphicsLayer*, GraphicsLayerFactory*); |
70 GraphicsLayer* rootGraphicsLayer() | 74 GraphicsLayer* rootGraphicsLayer() |
71 { | 75 { |
72 return m_rootTransformLayer.get(); | 76 return m_rootTransformLayer.get(); |
73 } | 77 } |
74 GraphicsLayer* containerLayer() | 78 GraphicsLayer* containerLayer() |
75 { | 79 { |
76 return m_innerViewportContainerLayer.get(); | 80 return m_innerViewportContainerLayer.get(); |
77 } | 81 } |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 // Scroll the main frame and pinch viewport so that the given rect in the | 116 // Scroll the main frame and pinch viewport so that the given rect in the |
113 // top-level document is centered in the viewport. This method will avoid | 117 // top-level document is centered in the viewport. This method will avoid |
114 // scrolling the pinch viewport unless necessary. | 118 // scrolling the pinch viewport unless necessary. |
115 void scrollIntoView(const FloatRect&); | 119 void scrollIntoView(const FloatRect&); |
116 | 120 |
117 // Clamp the given point, in document coordinates, to the maximum/minimum | 121 // Clamp the given point, in document coordinates, to the maximum/minimum |
118 // scroll extents of the viewport within the document. | 122 // scroll extents of the viewport within the document. |
119 IntPoint clampDocumentOffsetAtScale(const IntPoint& offset, float scale); | 123 IntPoint clampDocumentOffsetAtScale(const IntPoint& offset, float scale); |
120 | 124 |
121 private: | 125 private: |
| 126 explicit PinchViewport(FrameHost&); |
| 127 |
122 // ScrollableArea implementation | 128 // ScrollableArea implementation |
123 virtual bool isActive() const override { return false; } | 129 virtual bool isActive() const override { return false; } |
124 virtual int scrollSize(ScrollbarOrientation) const override; | 130 virtual int scrollSize(ScrollbarOrientation) const override; |
125 virtual bool isScrollCornerVisible() const override { return false; } | 131 virtual bool isScrollCornerVisible() const override { return false; } |
126 virtual IntRect scrollCornerRect() const override { return IntRect(); } | 132 virtual IntRect scrollCornerRect() const override { return IntRect(); } |
127 virtual IntPoint scrollPosition() const override { return flooredIntPoint(m_
offset); } | 133 virtual IntPoint scrollPosition() const override { return flooredIntPoint(m_
offset); } |
128 virtual IntPoint minimumScrollPosition() const override; | 134 virtual IntPoint minimumScrollPosition() const override; |
129 virtual IntPoint maximumScrollPosition() const override; | 135 virtual IntPoint maximumScrollPosition() const override; |
130 virtual int visibleHeight() const override { return visibleRect().height();
}; | 136 virtual int visibleHeight() const override { return visibleRect().height();
}; |
131 virtual int visibleWidth() const override { return visibleRect().width(); }; | 137 virtual int visibleWidth() const override { return visibleRect().width(); }; |
(...skipping 14 matching lines...) Expand all Loading... |
146 virtual void notifyAnimationStarted(const GraphicsLayer*, double monotonicTi
me) override; | 152 virtual void notifyAnimationStarted(const GraphicsLayer*, double monotonicTi
me) override; |
147 virtual void paintContents(const GraphicsLayer*, GraphicsContext&, GraphicsL
ayerPaintingPhase, const IntRect& inClip) override; | 153 virtual void paintContents(const GraphicsLayer*, GraphicsContext&, GraphicsL
ayerPaintingPhase, const IntRect& inClip) override; |
148 virtual String debugName(const GraphicsLayer*) override; | 154 virtual String debugName(const GraphicsLayer*) override; |
149 | 155 |
150 void setupScrollbar(blink::WebScrollbar::Orientation); | 156 void setupScrollbar(blink::WebScrollbar::Orientation); |
151 FloatPoint clampOffsetToBoundaries(const FloatPoint&); | 157 FloatPoint clampOffsetToBoundaries(const FloatPoint&); |
152 void clampToBoundaries(); | 158 void clampToBoundaries(); |
153 | 159 |
154 LocalFrame* mainFrame() const; | 160 LocalFrame* mainFrame() const; |
155 | 161 |
156 FrameHost& m_frameHost; | 162 FrameHost& frameHost() const |
| 163 { |
| 164 ASSERT(m_frameHost); |
| 165 return *m_frameHost; |
| 166 } |
| 167 |
| 168 RawPtrWillBeMember<FrameHost> m_frameHost; |
157 OwnPtr<GraphicsLayer> m_rootTransformLayer; | 169 OwnPtr<GraphicsLayer> m_rootTransformLayer; |
158 OwnPtr<GraphicsLayer> m_innerViewportContainerLayer; | 170 OwnPtr<GraphicsLayer> m_innerViewportContainerLayer; |
159 OwnPtr<GraphicsLayer> m_pageScaleLayer; | 171 OwnPtr<GraphicsLayer> m_pageScaleLayer; |
160 OwnPtr<GraphicsLayer> m_innerViewportScrollLayer; | 172 OwnPtr<GraphicsLayer> m_innerViewportScrollLayer; |
161 OwnPtr<GraphicsLayer> m_overlayScrollbarHorizontal; | 173 OwnPtr<GraphicsLayer> m_overlayScrollbarHorizontal; |
162 OwnPtr<GraphicsLayer> m_overlayScrollbarVertical; | 174 OwnPtr<GraphicsLayer> m_overlayScrollbarVertical; |
163 OwnPtr<blink::WebScrollbarLayer> m_webOverlayScrollbarHorizontal; | 175 OwnPtr<blink::WebScrollbarLayer> m_webOverlayScrollbarHorizontal; |
164 OwnPtr<blink::WebScrollbarLayer> m_webOverlayScrollbarVertical; | 176 OwnPtr<blink::WebScrollbarLayer> m_webOverlayScrollbarVertical; |
165 | 177 |
166 // Offset of the pinch viewport from the main frame's origin, in CSS pixels. | 178 // Offset of the pinch viewport from the main frame's origin, in CSS pixels. |
167 FloatPoint m_offset; | 179 FloatPoint m_offset; |
168 float m_scale; | 180 float m_scale; |
169 IntSize m_size; | 181 IntSize m_size; |
170 }; | 182 }; |
171 | 183 |
172 } // namespace blink | 184 } // namespace blink |
173 | 185 |
174 #endif // PinchViewport_h | 186 #endif // PinchViewport_h |
OLD | NEW |