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

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

Issue 1738243002: Removed main-thread one dimensional scrolling paths. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@removeStepFromUserScroll
Patch Set: Removed TODO that was already fixed Created 4 years, 10 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"
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 GraphicsLayer* RootFrameViewport::layerForHorizontalScrollbar() const 225 GraphicsLayer* RootFrameViewport::layerForHorizontalScrollbar() const
226 { 226 {
227 return layoutViewport().layerForHorizontalScrollbar(); 227 return layoutViewport().layerForHorizontalScrollbar();
228 } 228 }
229 229
230 GraphicsLayer* RootFrameViewport::layerForVerticalScrollbar() const 230 GraphicsLayer* RootFrameViewport::layerForVerticalScrollbar() const
231 { 231 {
232 return layoutViewport().layerForVerticalScrollbar(); 232 return layoutViewport().layerForVerticalScrollbar();
233 } 233 }
234 234
235 ScrollResultOneDimensional RootFrameViewport::userScroll(ScrollDirectionPhysical direction, ScrollGranularity granularity, float delta) 235 ScrollResult RootFrameViewport::userScroll(ScrollGranularity granularity, const FloatSize& delta)
236 { 236 {
237 // TODO(bokan/ymalik): This method specialization can likely go away as a
238 // result of the smooth scrolling work.
tdresser 2016/02/29 14:53:43 I may just be lacking context, but it isn't clear
bokan 2016/03/01 05:56:24 I think it should be clearer now.
239
237 updateScrollAnimator(); 240 updateScrollAnimator();
238 241
239 ScrollbarOrientation orientation = scrollbarOrientationFromDirection(directi on); 242 // Distribute the scroll between the visual and layout viewport.
240 243
241 if (layoutViewport().userInputScrollable(orientation) && visualViewport().us erInputScrollable(orientation)) { 244 float stepX = scrollStep(granularity, HorizontalScrollbar);
242 // Distribute the scroll between the visual and layout viewport. 245 float stepY = scrollStep(granularity, VerticalScrollbar);
243 float step = scrollStep(granularity, orientation);
244 246
245 if (direction == ScrollUp || direction == ScrollLeft) 247 FloatSize pixelDelta(delta);
246 delta = -delta; 248 pixelDelta.scale(stepX, stepY);
247 249
248 // This is the total amount we need to scroll. Instead of passing step 250 if (!layoutViewport().userInputScrollable(HorizontalScrollbar))
249 // to the scroll animator and letting it compute the total delta, we 251 pixelDelta.setWidth(0);
tdresser 2016/02/29 14:53:43 Can we avoid calling scrollStep in cases where we'
bokan 2016/03/01 05:56:24 Actually, we'll still want to call scrollStep so w
250 // give it the delta it should scroll. This way we can apply the 252 if (!layoutViewport().userInputScrollable(VerticalScrollbar))
251 // unused delta from the visual viewport to the layout viewport. 253 pixelDelta.setHeight(0);
252 delta *= step;
253 254
254 cancelProgrammaticScrollAnimation(); 255 // If the layoutViewport isn't scrollable, just let the visual viewport
256 // handle the scroll since it's always userInputScrollable.
257 if (pixelDelta.isZero())
258 return visualViewport().userScroll(granularity, delta);
tdresser 2016/02/29 14:53:43 If one axis didn't scroll, but the other did, this
bokan 2016/03/01 05:56:24 I'm not sure I understand. If pixelDelta.isZero()
255 259
256 float visualUsedDelta = visualViewport().scrollAnimator().computeDeltaTo Consume(orientation, delta); 260 cancelProgrammaticScrollAnimation();
257 ScrollResultOneDimensional visualResult = visualViewport().scrollAnimato r().userScroll(
258 orientation, granularity, visualUsedDelta);
259 261
260 // Scroll the layout viewport if all of the scroll was not applied to th e 262 // TODO(bokan): Why do we call userScroll on the animators directly and
261 // visual viewport. 263 // not through the ScrollableAreas?
262 if (visualUsedDelta == delta)
263 return visualResult;
264 264
265 ScrollResultOneDimensional layoutResult = layoutViewport().scrollAnimato r().userScroll( 265 // Precompute the amount of possible scrolling since, when animated,
266 orientation, granularity, delta - visualUsedDelta); 266 // ScrollAnimator::userScroll will consume the total scroll delta even
267 // beyond the scrolling bounds.
268 FloatSize visualUsedDelta = visualViewport().scrollAnimator().computeDeltaTo Consume(pixelDelta);
269 ScrollResult visualResult = visualViewport().scrollAnimator().userScroll(gra nularity, visualUsedDelta);
267 270
268 return ScrollResultOneDimensional(visualResult.didScroll || layoutResult .didScroll, 271 // Scroll the layout viewport if all of the scroll was not applied to the
269 layoutResult.unusedScrollDelta); 272 // visual viewport.
270 } 273 if (visualUsedDelta == pixelDelta)
274 return visualResult;
271 275
272 if (visualViewport().userInputScrollable(orientation)) 276 ScrollResult layoutResult = layoutViewport().scrollAnimator().userScroll(gra nularity, pixelDelta - visualUsedDelta);
tdresser 2016/02/29 14:53:43 I'm a bit confused about how this works. If I unde
bokan 2016/03/01 05:56:24 It's actually: 1. Try to scroll the visual viewpo
273 return visualViewport().userScroll(direction, granularity, delta);
274 277
275 if (layoutViewport().userInputScrollable(orientation)) 278 return ScrollResult(
276 return layoutViewport().userScroll(direction, granularity, delta); 279 visualResult.didScrollX || layoutResult.didScrollX,
277 280 visualResult.didScrollY || layoutResult.didScrollY,
278 return ScrollResultOneDimensional(false, delta); 281 layoutResult.unusedScrollDeltaX,
282 layoutResult.unusedScrollDeltaY);
279 } 283 }
280 284
281 bool RootFrameViewport::scrollAnimatorEnabled() const 285 bool RootFrameViewport::scrollAnimatorEnabled() const
282 { 286 {
283 return layoutViewport().scrollAnimatorEnabled(); 287 return layoutViewport().scrollAnimatorEnabled();
284 } 288 }
285 289
286 HostWindow* RootFrameViewport::hostWindow() const 290 HostWindow* RootFrameViewport::hostWindow() const
287 { 291 {
288 return layoutViewport().hostWindow(); 292 return layoutViewport().hostWindow();
(...skipping 26 matching lines...) Expand all
315 } 319 }
316 320
317 DEFINE_TRACE(RootFrameViewport) 321 DEFINE_TRACE(RootFrameViewport)
318 { 322 {
319 visitor->trace(m_visualViewport); 323 visitor->trace(m_visualViewport);
320 visitor->trace(m_layoutViewport); 324 visitor->trace(m_layoutViewport);
321 ScrollableArea::trace(visitor); 325 ScrollableArea::trace(visitor);
322 } 326 }
323 327
324 } // namespace blink 328 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698