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

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

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

Powered by Google App Engine
This is Rietveld 408576698