OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "web/RotationViewportAnchor.h" | 5 #include "web/RotationViewportAnchor.h" |
6 | 6 |
7 #include "core/dom/ContainerNode.h" | 7 #include "core/dom/ContainerNode.h" |
8 #include "core/dom/Node.h" | 8 #include "core/dom/Node.h" |
9 #include "core/frame/FrameView.h" | 9 #include "core/frame/FrameView.h" |
10 #include "core/frame/LocalFrame.h" | 10 #include "core/frame/LocalFrame.h" |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 restoreToAnchor(); | 100 restoreToAnchor(); |
101 } | 101 } |
102 | 102 |
103 void RotationViewportAnchor::setAnchor() { | 103 void RotationViewportAnchor::setAnchor() { |
104 RootFrameViewport* rootFrameViewport = | 104 RootFrameViewport* rootFrameViewport = |
105 m_rootFrameView->getRootFrameViewport(); | 105 m_rootFrameView->getRootFrameViewport(); |
106 DCHECK(rootFrameViewport); | 106 DCHECK(rootFrameViewport); |
107 | 107 |
108 IntRect outerViewRect = | 108 IntRect outerViewRect = |
109 layoutViewport().visibleContentRect(IncludeScrollbars); | 109 layoutViewport().visibleContentRect(IncludeScrollbars); |
110 IntRect innerViewRect = | 110 IntRect innerViewRect = rootFrameViewport->visibleContentRect(); |
111 enclosedIntRect(rootFrameViewport->visibleContentRectDouble()); | |
112 | 111 |
113 m_oldPageScaleFactor = m_visualViewport->scale(); | 112 m_oldPageScaleFactor = m_visualViewport->scale(); |
114 m_oldMinimumPageScaleFactor = | 113 m_oldMinimumPageScaleFactor = |
115 m_pageScaleConstraintsSet.finalConstraints().minimumScale; | 114 m_pageScaleConstraintsSet.finalConstraints().minimumScale; |
116 | 115 |
117 // Save the absolute location in case we won't find the anchor node, we'll fal
l back to that. | 116 // Save the absolute location in case we won't find the anchor node, we'll fal
l back to that. |
118 m_visualViewportInDocument = | 117 m_visualViewportInDocument = |
119 FloatPoint(rootFrameViewport->visibleContentRectDouble().location()); | 118 FloatPoint(rootFrameViewport->visibleContentRect().location()); |
120 | 119 |
121 m_anchorNode.clear(); | 120 m_anchorNode.clear(); |
122 m_anchorNodeBounds = LayoutRect(); | 121 m_anchorNodeBounds = LayoutRect(); |
123 m_anchorInNodeCoords = FloatSize(); | 122 m_anchorInNodeCoords = FloatSize(); |
124 m_normalizedVisualViewportOffset = FloatSize(); | 123 m_normalizedVisualViewportOffset = FloatSize(); |
125 | 124 |
126 if (innerViewRect.isEmpty()) | 125 if (innerViewRect.isEmpty()) |
127 return; | 126 return; |
128 | 127 |
129 // Preserve origins at the absolute screen origin | 128 // Preserve origins at the absolute screen origin |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 newPageScaleFactor); | 172 newPageScaleFactor); |
174 | 173 |
175 FloatSize visualViewportSize(m_visualViewport->size()); | 174 FloatSize visualViewportSize(m_visualViewport->size()); |
176 visualViewportSize.scale(1 / newPageScaleFactor); | 175 visualViewportSize.scale(1 / newPageScaleFactor); |
177 | 176 |
178 IntPoint mainFrameOrigin; | 177 IntPoint mainFrameOrigin; |
179 FloatPoint visualViewportOrigin; | 178 FloatPoint visualViewportOrigin; |
180 | 179 |
181 computeOrigins(visualViewportSize, mainFrameOrigin, visualViewportOrigin); | 180 computeOrigins(visualViewportSize, mainFrameOrigin, visualViewportOrigin); |
182 | 181 |
183 layoutViewport().setScrollPosition(mainFrameOrigin, ProgrammaticScroll); | 182 layoutViewport().setScrollOffset(toScrollOffset(mainFrameOrigin), |
| 183 ProgrammaticScroll); |
184 | 184 |
185 // Set scale before location, since location can be clamped on setting scale. | 185 // Set scale before location, since location can be clamped on setting scale. |
186 m_visualViewport->setScale(newPageScaleFactor); | 186 m_visualViewport->setScale(newPageScaleFactor); |
187 m_visualViewport->setLocation(visualViewportOrigin); | 187 m_visualViewport->setLocation(visualViewportOrigin); |
188 } | 188 } |
189 | 189 |
190 ScrollableArea& RotationViewportAnchor::layoutViewport() const { | 190 ScrollableArea& RotationViewportAnchor::layoutViewport() const { |
191 RootFrameViewport* rootFrameViewport = | 191 RootFrameViewport* rootFrameViewport = |
192 m_rootFrameView->getRootFrameViewport(); | 192 m_rootFrameView->getRootFrameViewport(); |
193 DCHECK(rootFrameViewport); | 193 DCHECK(rootFrameViewport); |
(...skipping 11 matching lines...) Expand all Loading... |
205 absVisualViewportOffset.scale(outerSize.width(), outerSize.height()); | 205 absVisualViewportOffset.scale(outerSize.width(), outerSize.height()); |
206 | 206 |
207 FloatPoint innerOrigin = getInnerOrigin(innerSize); | 207 FloatPoint innerOrigin = getInnerOrigin(innerSize); |
208 FloatPoint outerOrigin = innerOrigin - absVisualViewportOffset; | 208 FloatPoint outerOrigin = innerOrigin - absVisualViewportOffset; |
209 | 209 |
210 IntRect outerRect = IntRect(flooredIntPoint(outerOrigin), outerSize); | 210 IntRect outerRect = IntRect(flooredIntPoint(outerOrigin), outerSize); |
211 FloatRect innerRect = FloatRect(innerOrigin, innerSize); | 211 FloatRect innerRect = FloatRect(innerOrigin, innerSize); |
212 | 212 |
213 moveToEncloseRect(outerRect, innerRect); | 213 moveToEncloseRect(outerRect, innerRect); |
214 | 214 |
215 outerRect.setLocation( | 215 outerRect.setLocation(IntPoint( |
216 layoutViewport().clampScrollPosition(outerRect.location())); | 216 layoutViewport().clampScrollOffset(toIntSize(outerRect.location())))); |
217 | 217 |
218 moveIntoRect(innerRect, outerRect); | 218 moveIntoRect(innerRect, outerRect); |
219 | 219 |
220 mainFrameOffset = outerRect.location(); | 220 mainFrameOffset = outerRect.location(); |
221 visualViewportOffset = | 221 visualViewportOffset = |
222 FloatPoint(innerRect.location() - outerRect.location()); | 222 FloatPoint(innerRect.location() - outerRect.location()); |
223 } | 223 } |
224 | 224 |
225 FloatPoint RotationViewportAnchor::getInnerOrigin( | 225 FloatPoint RotationViewportAnchor::getInnerOrigin( |
226 const FloatSize& innerSize) const { | 226 const FloatSize& innerSize) const { |
(...skipping 19 matching lines...) Expand all Loading... |
246 anchorOffsetFromNode; | 246 anchorOffsetFromNode; |
247 | 247 |
248 // Compute the new origin point relative to the new anchor point | 248 // Compute the new origin point relative to the new anchor point |
249 FloatSize anchorOffsetFromOrigin = innerSize; | 249 FloatSize anchorOffsetFromOrigin = innerSize; |
250 anchorOffsetFromOrigin.scale(m_anchorInInnerViewCoords.width(), | 250 anchorOffsetFromOrigin.scale(m_anchorInInnerViewCoords.width(), |
251 m_anchorInInnerViewCoords.height()); | 251 m_anchorInInnerViewCoords.height()); |
252 return anchorPoint - anchorOffsetFromOrigin; | 252 return anchorPoint - anchorOffsetFromOrigin; |
253 } | 253 } |
254 | 254 |
255 } // namespace blink | 255 } // namespace blink |
OLD | NEW |