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

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

Issue 1496693005: Update RootFrameViewport::userScroll to distribute scrolls between viewports. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: addressed remaining review comments 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"
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 232
233 GraphicsLayer* RootFrameViewport::layerForVerticalScrollbar() const 233 GraphicsLayer* RootFrameViewport::layerForVerticalScrollbar() const
234 { 234 {
235 return layoutViewport().layerForVerticalScrollbar(); 235 return layoutViewport().layerForVerticalScrollbar();
236 } 236 }
237 237
238 ScrollResultOneDimensional RootFrameViewport::userScroll(ScrollDirectionPhysical direction, ScrollGranularity granularity, float delta) 238 ScrollResultOneDimensional RootFrameViewport::userScroll(ScrollDirectionPhysical direction, ScrollGranularity granularity, float delta)
239 { 239 {
240 updateScrollAnimator(); 240 updateScrollAnimator();
241 241
242 ScrollbarOrientation orientation; 242 ScrollbarOrientation orientation = scrollbarOrientationFromDirection(directi on);
243 243
244 if (direction == ScrollUp || direction == ScrollDown) 244 if (layoutViewport().userInputScrollable(orientation) && visualViewport().us erInputScrollable(orientation)) {
245 orientation = VerticalScrollbar; 245 // Distribute the scroll between the visual and layout viewport.
246 else 246 float step = scrollStep(granularity, orientation);
247 orientation = HorizontalScrollbar;
248 247
249 if (layoutViewport().userInputScrollable(orientation) && visualViewport().us erInputScrollable(orientation)) 248 if (direction == ScrollUp || direction == ScrollLeft)
250 return ScrollableArea::userScroll(direction, granularity, delta); 249 delta = -delta;
250
251 // This is the total amount we need to scroll. Instead of passing step
252 // to the scroll animator and letting it compute the total delta, we
253 // give it the delta it should scroll. This way we can apply the
254 // unused delta from the visual viewport to the layout viewport.
255 // TODO(ymalik): ScrollAnimator should return unused delta in pixles
256 // rather than in terms of steps.
257 delta *= step;
258
259 cancelProgrammaticScrollAnimation();
260
261 float visualUsedDelta = visualViewport().scrollAnimator()->usedScrollDel ta(
262 orientation, delta);
263
264 ScrollResultOneDimensional visualResult = visualViewport().scrollAnimato r()->userScroll(
265 orientation, granularity, 1 /* step */, visualUsedDelta);
266
267 // Scroll the layout viewport if all of the scroll was not applied to th e
268 // visual viewport.
269 if (visualUsedDelta == delta)
270 return visualResult;
271
272 ScrollResultOneDimensional layoutResult = layoutViewport().scrollAnimato r()->userScroll(
273 orientation, granularity, 1 /* step */, delta - visualUsedDelta);
274
275 return ScrollResultOneDimensional(visualResult.didScroll || layoutResult .didScroll,
276 layoutResult.unusedScrollDelta / step);
277 }
251 278
252 if (visualViewport().userInputScrollable(orientation)) 279 if (visualViewport().userInputScrollable(orientation))
253 return visualViewport().userScroll(direction, granularity, delta); 280 return visualViewport().userScroll(direction, granularity, delta);
254 281
255 if (layoutViewport().userInputScrollable(orientation)) 282 if (layoutViewport().userInputScrollable(orientation))
256 return layoutViewport().userScroll(direction, granularity, delta); 283 return layoutViewport().userScroll(direction, granularity, delta);
257 284
258 return ScrollResultOneDimensional(false, delta); 285 return ScrollResultOneDimensional(false, delta);
259 } 286 }
260 287
(...skipping 14 matching lines...) Expand all
275 visualViewport().serviceScrollAnimations(monotonicTime); 302 visualViewport().serviceScrollAnimations(monotonicTime);
276 } 303 }
277 304
278 void RootFrameViewport::updateCompositorScrollAnimations() 305 void RootFrameViewport::updateCompositorScrollAnimations()
279 { 306 {
280 ScrollableArea::updateCompositorScrollAnimations(); 307 ScrollableArea::updateCompositorScrollAnimations();
281 layoutViewport().updateCompositorScrollAnimations(); 308 layoutViewport().updateCompositorScrollAnimations();
282 visualViewport().updateCompositorScrollAnimations(); 309 visualViewport().updateCompositorScrollAnimations();
283 } 310 }
284 311
312 void RootFrameViewport::cancelProgrammaticScrollAnimation()
313 {
314 ScrollableArea::cancelProgrammaticScrollAnimation();
315 layoutViewport().cancelProgrammaticScrollAnimation();
316 visualViewport().cancelProgrammaticScrollAnimation();
317 }
318
285 DEFINE_TRACE(RootFrameViewport) 319 DEFINE_TRACE(RootFrameViewport)
286 { 320 {
287 visitor->trace(m_visualViewport); 321 visitor->trace(m_visualViewport);
288 visitor->trace(m_layoutViewport); 322 visitor->trace(m_layoutViewport);
289 ScrollableArea::trace(visitor); 323 ScrollableArea::trace(visitor);
290 } 324 }
291 325
292 } // namespace blink 326 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698