OLD | NEW |
---|---|
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 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
239 { | 239 { |
240 updateScrollAnimator(); | 240 updateScrollAnimator(); |
241 | 241 |
242 ScrollbarOrientation orientation; | 242 ScrollbarOrientation orientation; |
243 | 243 |
244 if (direction == ScrollUp || direction == ScrollDown) | 244 if (direction == ScrollUp || direction == ScrollDown) |
245 orientation = VerticalScrollbar; | 245 orientation = VerticalScrollbar; |
246 else | 246 else |
247 orientation = HorizontalScrollbar; | 247 orientation = HorizontalScrollbar; |
248 | 248 |
249 if (layoutViewport().userInputScrollable(orientation) && visualViewport().us erInputScrollable(orientation)) | 249 if (layoutViewport().userInputScrollable(orientation) && visualViewport().us erInputScrollable(orientation)) { |
250 return ScrollableArea::userScroll(direction, granularity, delta); | 250 // Distribute the scroll between the visual and layout viewport. |
251 ScrollbarOrientation orientation = scrollbarOrientationFromDirection(dir ection); | |
252 float step = scrollStep(granularity, orientation); | |
253 | |
254 if (direction == ScrollUp || direction == ScrollLeft) | |
255 delta = -delta; | |
256 | |
257 // This is the total amount we need to scroll. Instead of passing step | |
258 // to the scroll animator and letting it compute the total delta, we | |
259 // simply give it the total delta so that the unused delta it reports | |
260 // back can be applied to the secondary viewport. | |
261 delta *= step; | |
bokan
2015/12/04 19:39:02
I don't think you need to do this. I believe the f
ymalik
2015/12/04 20:11:01
So the current flow is as follows
delta -> delta *
bokan
2015/12/04 20:42:52
Ok, just had a look at ScrollAnimatorMac and it se
ymalik
2015/12/07 17:53:14
Hmm, so the ScrollAnimator::userScroll returns 0 f
| |
262 | |
263 cancelProgrammaticScrollAnimation(); | |
264 | |
265 ScrollableArea& primary = !m_invertScrollOrder ? layoutViewport() : visu alViewport(); | |
bokan
2015/12/04 20:42:52
Replace primary with visual and secondary with lay
ymalik
2015/12/07 17:53:14
Done.
| |
266 ScrollableArea& secondary = !m_invertScrollOrder ? visualViewport() : la youtViewport(); | |
267 | |
268 ScrollResultOneDimensional pResult = primary.scrollAnimator()->userScrol l( | |
269 orientation, granularity, /* step */ 1, delta); | |
270 | |
271 // Scroll the secondary viewport if all of the scroll was not applied to the | |
272 // primary viewport. | |
273 if (pResult.unusedScrollDelta == 0) | |
bokan
2015/12/04 19:39:02
Use ScrollResultOneDimensional::didScroll for this
ymalik
2015/12/04 20:13:54
didScroll can be true while we still want to distr
bokan
2015/12/04 20:42:52
Right, right, my bad.
| |
274 return pResult; | |
275 | |
276 ScrollResultOneDimensional sResult = secondary.scrollAnimator()->userScr oll( | |
277 orientation, granularity, /* step */ 1, pResult.unusedScrollDelta); | |
278 | |
279 if (!pResult.didScroll && !sResult.didScroll) | |
280 return ScrollResultOneDimensional(false, pResult.unusedScrollDelta / step); | |
281 | |
282 return ScrollResultOneDimensional(true, sResult.unusedScrollDelta / step ); | |
bokan
2015/12/04 19:39:02
You can merge the last two returns together in the
bokan
2015/12/04 20:42:52
You can still merge these two together (in fact, y
ymalik
2015/12/07 17:53:14
Merged. layoutResult.unusedScrollDelta is the amou
| |
283 } | |
251 | 284 |
252 if (visualViewport().userInputScrollable(orientation)) | 285 if (visualViewport().userInputScrollable(orientation)) |
253 return visualViewport().userScroll(direction, granularity, delta); | 286 return visualViewport().userScroll(direction, granularity, delta); |
254 | 287 |
255 if (layoutViewport().userInputScrollable(orientation)) | 288 if (layoutViewport().userInputScrollable(orientation)) |
256 return layoutViewport().userScroll(direction, granularity, delta); | 289 return layoutViewport().userScroll(direction, granularity, delta); |
257 | 290 |
258 return ScrollResultOneDimensional(false, delta); | 291 return ScrollResultOneDimensional(false, delta); |
259 } | 292 } |
260 | 293 |
(...skipping 14 matching lines...) Expand all Loading... | |
275 visualViewport().serviceScrollAnimations(monotonicTime); | 308 visualViewport().serviceScrollAnimations(monotonicTime); |
276 } | 309 } |
277 | 310 |
278 void RootFrameViewport::updateCompositorScrollAnimations() | 311 void RootFrameViewport::updateCompositorScrollAnimations() |
279 { | 312 { |
280 ScrollableArea::updateCompositorScrollAnimations(); | 313 ScrollableArea::updateCompositorScrollAnimations(); |
281 layoutViewport().updateCompositorScrollAnimations(); | 314 layoutViewport().updateCompositorScrollAnimations(); |
282 visualViewport().updateCompositorScrollAnimations(); | 315 visualViewport().updateCompositorScrollAnimations(); |
283 } | 316 } |
284 | 317 |
318 void RootFrameViewport::cancelProgrammaticScrollAnimation() | |
319 { | |
320 ScrollableArea::cancelProgrammaticScrollAnimation(); | |
321 layoutViewport().cancelProgrammaticScrollAnimation(); | |
322 visualViewport().cancelProgrammaticScrollAnimation(); | |
323 } | |
324 | |
285 DEFINE_TRACE(RootFrameViewport) | 325 DEFINE_TRACE(RootFrameViewport) |
286 { | 326 { |
287 visitor->trace(m_visualViewport); | 327 visitor->trace(m_visualViewport); |
288 visitor->trace(m_layoutViewport); | 328 visitor->trace(m_layoutViewport); |
289 ScrollableArea::trace(visitor); | 329 ScrollableArea::trace(visitor); |
290 } | 330 } |
291 | 331 |
292 } // namespace blink | 332 } // namespace blink |
OLD | NEW |