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

Side by Side Diff: third_party/WebKit/Source/web/RotationViewportAnchor.cpp

Issue 2387883002: Use float for scroll offset. (Closed)
Patch Set: Fix README.md Created 4 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
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
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 116 // Save the absolute location in case we won't find the anchor node, we'll
118 // fall back to that. 117 // fall back to that.
119 m_visualViewportInDocument = 118 m_visualViewportInDocument =
120 FloatPoint(rootFrameViewport->visibleContentRectDouble().location()); 119 FloatPoint(rootFrameViewport->visibleContentRect().location());
121 120
122 m_anchorNode.clear(); 121 m_anchorNode.clear();
123 m_anchorNodeBounds = LayoutRect(); 122 m_anchorNodeBounds = LayoutRect();
124 m_anchorInNodeCoords = FloatSize(); 123 m_anchorInNodeCoords = FloatSize();
125 m_normalizedVisualViewportOffset = FloatSize(); 124 m_normalizedVisualViewportOffset = FloatSize();
126 125
127 if (innerViewRect.isEmpty()) 126 if (innerViewRect.isEmpty())
128 return; 127 return;
129 128
130 // Preserve origins at the absolute screen origin 129 // Preserve origins at the absolute screen origin
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 newPageScaleFactor); 173 newPageScaleFactor);
175 174
176 FloatSize visualViewportSize(m_visualViewport->size()); 175 FloatSize visualViewportSize(m_visualViewport->size());
177 visualViewportSize.scale(1 / newPageScaleFactor); 176 visualViewportSize.scale(1 / newPageScaleFactor);
178 177
179 IntPoint mainFrameOrigin; 178 IntPoint mainFrameOrigin;
180 FloatPoint visualViewportOrigin; 179 FloatPoint visualViewportOrigin;
181 180
182 computeOrigins(visualViewportSize, mainFrameOrigin, visualViewportOrigin); 181 computeOrigins(visualViewportSize, mainFrameOrigin, visualViewportOrigin);
183 182
184 layoutViewport().setScrollPosition(mainFrameOrigin, ProgrammaticScroll); 183 layoutViewport().setScrollOffset(toScrollOffset(mainFrameOrigin),
184 ProgrammaticScroll);
185 185
186 // Set scale before location, since location can be clamped on setting scale. 186 // Set scale before location, since location can be clamped on setting scale.
187 m_visualViewport->setScale(newPageScaleFactor); 187 m_visualViewport->setScale(newPageScaleFactor);
188 m_visualViewport->setLocation(visualViewportOrigin); 188 m_visualViewport->setLocation(visualViewportOrigin);
189 } 189 }
190 190
191 ScrollableArea& RotationViewportAnchor::layoutViewport() const { 191 ScrollableArea& RotationViewportAnchor::layoutViewport() const {
192 RootFrameViewport* rootFrameViewport = 192 RootFrameViewport* rootFrameViewport =
193 m_rootFrameView->getRootFrameViewport(); 193 m_rootFrameView->getRootFrameViewport();
194 DCHECK(rootFrameViewport); 194 DCHECK(rootFrameViewport);
(...skipping 11 matching lines...) Expand all
206 absVisualViewportOffset.scale(outerSize.width(), outerSize.height()); 206 absVisualViewportOffset.scale(outerSize.width(), outerSize.height());
207 207
208 FloatPoint innerOrigin = getInnerOrigin(innerSize); 208 FloatPoint innerOrigin = getInnerOrigin(innerSize);
209 FloatPoint outerOrigin = innerOrigin - absVisualViewportOffset; 209 FloatPoint outerOrigin = innerOrigin - absVisualViewportOffset;
210 210
211 IntRect outerRect = IntRect(flooredIntPoint(outerOrigin), outerSize); 211 IntRect outerRect = IntRect(flooredIntPoint(outerOrigin), outerSize);
212 FloatRect innerRect = FloatRect(innerOrigin, innerSize); 212 FloatRect innerRect = FloatRect(innerOrigin, innerSize);
213 213
214 moveToEncloseRect(outerRect, innerRect); 214 moveToEncloseRect(outerRect, innerRect);
215 215
216 outerRect.setLocation( 216 outerRect.setLocation(IntPoint(
217 layoutViewport().clampScrollPosition(outerRect.location())); 217 layoutViewport().clampScrollOffset(toIntSize(outerRect.location()))));
218 218
219 moveIntoRect(innerRect, outerRect); 219 moveIntoRect(innerRect, outerRect);
220 220
221 mainFrameOffset = outerRect.location(); 221 mainFrameOffset = outerRect.location();
222 visualViewportOffset = 222 visualViewportOffset =
223 FloatPoint(innerRect.location() - outerRect.location()); 223 FloatPoint(innerRect.location() - outerRect.location());
224 } 224 }
225 225
226 FloatPoint RotationViewportAnchor::getInnerOrigin( 226 FloatPoint RotationViewportAnchor::getInnerOrigin(
227 const FloatSize& innerSize) const { 227 const FloatSize& innerSize) const {
(...skipping 19 matching lines...) Expand all
247 anchorOffsetFromNode; 247 anchorOffsetFromNode;
248 248
249 // Compute the new origin point relative to the new anchor point 249 // Compute the new origin point relative to the new anchor point
250 FloatSize anchorOffsetFromOrigin = innerSize; 250 FloatSize anchorOffsetFromOrigin = innerSize;
251 anchorOffsetFromOrigin.scale(m_anchorInInnerViewCoords.width(), 251 anchorOffsetFromOrigin.scale(m_anchorInInnerViewCoords.width(),
252 m_anchorInInnerViewCoords.height()); 252 m_anchorInInnerViewCoords.height());
253 return anchorPoint - anchorOffsetFromOrigin; 253 return anchorPoint - anchorOffsetFromOrigin;
254 } 254 }
255 255
256 } // namespace blink 256 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/web/ResizeViewportAnchor.cpp ('k') | third_party/WebKit/Source/web/WebHistoryItem.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698