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

Side by Side Diff: third_party/WebKit/Source/core/frame/RootFrameViewport.cpp

Issue 1435233002: Remove invert viewport scroll order setting from Blink (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Build fix after rebase Created 4 years, 11 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 "core/frame/RootFrameViewport.h" 5 #include "core/frame/RootFrameViewport.h"
6 6
7 #include "core/frame/FrameView.h" 7 #include "core/frame/FrameView.h"
8 #include "core/layout/ScrollAlignment.h" 8 #include "core/layout/ScrollAlignment.h"
9 #include "platform/geometry/DoubleRect.h" 9 #include "platform/geometry/DoubleRect.h"
10 #include "platform/geometry/FloatRect.h" 10 #include "platform/geometry/FloatRect.h"
11 #include "platform/geometry/LayoutRect.h" 11 #include "platform/geometry/LayoutRect.h"
12 12
13 namespace blink { 13 namespace blink {
14 14
15 RootFrameViewport::RootFrameViewport(ScrollableArea& visualViewport, ScrollableA rea& layoutViewport, bool invertScrollOrder) 15 RootFrameViewport::RootFrameViewport(ScrollableArea& visualViewport, ScrollableA rea& layoutViewport)
16 : m_visualViewport(visualViewport) 16 : m_visualViewport(visualViewport)
17 , m_layoutViewport(layoutViewport) 17 , m_layoutViewport(layoutViewport)
18 , m_invertScrollOrder(invertScrollOrder)
19 { 18 {
20 } 19 }
21 20
22 void RootFrameViewport::updateScrollAnimator() 21 void RootFrameViewport::updateScrollAnimator()
23 { 22 {
24 scrollAnimator().setCurrentPosition(toFloatPoint(scrollOffsetFromScrollAnima tors())); 23 scrollAnimator().setCurrentPosition(toFloatPoint(scrollOffsetFromScrollAnima tors()));
25 } 24 }
26 25
27 DoublePoint RootFrameViewport::scrollOffsetFromScrollAnimators() const 26 DoublePoint RootFrameViewport::scrollOffsetFromScrollAnimators() const
28 { 27 {
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 { 132 {
134 // Make sure we use the scroll positions as reported by each viewport's Scro llAnimatorBase, since its 133 // Make sure we use the scroll positions as reported by each viewport's Scro llAnimatorBase, since its
135 // ScrollableArea's position may have the fractional part truncated off. 134 // ScrollableArea's position may have the fractional part truncated off.
136 DoublePoint oldPosition = scrollOffsetFromScrollAnimators(); 135 DoublePoint oldPosition = scrollOffsetFromScrollAnimators();
137 136
138 DoubleSize delta = offset - oldPosition; 137 DoubleSize delta = offset - oldPosition;
139 138
140 if (delta.isZero()) 139 if (delta.isZero())
141 return; 140 return;
142 141
143 ScrollableArea& primary = !m_invertScrollOrder ? layoutViewport() : visualVi ewport(); 142 DoublePoint targetPosition = visualViewport().clampScrollPosition(
144 ScrollableArea& secondary = !m_invertScrollOrder ? visualViewport() : layout Viewport(); 143 visualViewport().scrollAnimator().currentPosition() + delta);
145 144
146 DoublePoint targetPosition = primary.clampScrollPosition(primary.scrollAnima tor().currentPosition() + delta); 145 visualViewport().setScrollPosition(targetPosition, scrollType, behavior);
147 primary.setScrollPosition(targetPosition, scrollType, behavior);
148 146
149 // Scroll the secondary viewport if all of the scroll was not applied to the 147 // Scroll the secondary viewport if all of the scroll was not applied to the
150 // primary viewport. 148 // primary viewport.
151 DoublePoint updatedPosition = secondary.scrollAnimator().currentPosition() + FloatPoint(targetPosition); 149 DoublePoint updatedPosition = layoutViewport().scrollAnimator().currentPosit ion() + FloatPoint(targetPosition);
152 DoubleSize applied = updatedPosition - oldPosition; 150 DoubleSize applied = updatedPosition - oldPosition;
153 delta -= applied; 151 delta -= applied;
154 152
155 if (delta.isZero()) 153 if (delta.isZero())
156 return; 154 return;
157 155
158 targetPosition = secondary.clampScrollPosition(secondary.scrollAnimator().cu rrentPosition() + delta); 156 targetPosition = layoutViewport().clampScrollPosition(layoutViewport().scrol lAnimator().currentPosition() + delta);
159 secondary.setScrollPosition(targetPosition, scrollType, behavior); 157 layoutViewport().setScrollPosition(targetPosition, scrollType, behavior);
160 } 158 }
161 159
162 IntPoint RootFrameViewport::scrollPosition() const 160 IntPoint RootFrameViewport::scrollPosition() const
163 { 161 {
164 return flooredIntPoint(scrollPositionDouble()); 162 return flooredIntPoint(scrollPositionDouble());
165 } 163 }
166 164
167 DoublePoint RootFrameViewport::scrollPositionDouble() const 165 DoublePoint RootFrameViewport::scrollPositionDouble() const
168 { 166 {
169 return layoutViewport().scrollPositionDouble() + toDoubleSize(visualViewport ().scrollPositionDouble()); 167 return layoutViewport().scrollPositionDouble() + toDoubleSize(visualViewport ().scrollPositionDouble());
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 } 317 }
320 318
321 DEFINE_TRACE(RootFrameViewport) 319 DEFINE_TRACE(RootFrameViewport)
322 { 320 {
323 visitor->trace(m_visualViewport); 321 visitor->trace(m_visualViewport);
324 visitor->trace(m_layoutViewport); 322 visitor->trace(m_layoutViewport);
325 ScrollableArea::trace(visitor); 323 ScrollableArea::trace(visitor);
326 } 324 }
327 325
328 } // namespace blink 326 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698