Chromium Code Reviews| 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 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 89 | 89 |
| 90 ScrollBehavior RootFrameViewport::scrollBehaviorStyle() const | 90 ScrollBehavior RootFrameViewport::scrollBehaviorStyle() const |
| 91 { | 91 { |
| 92 return layoutViewport().scrollBehaviorStyle(); | 92 return layoutViewport().scrollBehaviorStyle(); |
| 93 } | 93 } |
| 94 | 94 |
| 95 ScrollResult RootFrameViewport::handleWheel(const PlatformWheelEvent& event) | 95 ScrollResult RootFrameViewport::handleWheel(const PlatformWheelEvent& event) |
| 96 { | 96 { |
| 97 updateScrollAnimator(); | 97 updateScrollAnimator(); |
| 98 | 98 |
| 99 ScrollResult viewScrollResult; | 99 ScrollResult viewScrollResult = layoutViewport().handleWheel(event); |
|
MuVen
2015/06/25 12:55:51
bokan@, handleWheel should be triggered, irrespect
bokan
2015/06/25 14:54:35
Sounds fine to me - it's actually an improvement -
MuVen
2015/06/25 17:05:36
Done.
| |
| 100 if (layoutViewport().isScrollable()) | |
| 101 viewScrollResult = layoutViewport().handleWheel(event); | |
| 102 | 100 |
| 103 // The visual viewport will only accept pixel scrolls. | 101 // The visual viewport will only accept pixel scrolls. |
| 104 if (!event.canScroll() || event.granularity() == ScrollByPageWheelEvent) | 102 if (!event.canScroll() || event.granularity() == ScrollByPageWheelEvent) |
| 105 return viewScrollResult; | 103 return viewScrollResult; |
| 106 | 104 |
| 107 // Move the location by the negative of the remaining scroll delta. | 105 // Move the location by the negative of the remaining scroll delta. |
| 108 DoublePoint oldOffset = visualViewport().scrollPositionDouble(); | 106 DoublePoint oldOffset = visualViewport().scrollPositionDouble(); |
| 109 DoublePoint locationDelta; | 107 DoublePoint locationDelta; |
| 110 if (viewScrollResult.didScroll()) { | 108 if (viewScrollResult.didScroll()) { |
| 111 locationDelta = -DoublePoint(viewScrollResult.unusedScrollDeltaX, viewSc rollResult.unusedScrollDeltaY); | 109 locationDelta = -DoublePoint(viewScrollResult.unusedScrollDeltaX, viewSc rollResult.unusedScrollDeltaY); |
| 112 } else { | 110 } else { |
| 113 if (event.railsMode() != PlatformEvent::RailsModeVertical) | 111 if (event.railsMode() != PlatformEvent::RailsModeVertical) |
| 114 locationDelta.setX(-event.deltaX()); | 112 locationDelta.setX(-event.deltaX()); |
| 115 if (event.railsMode() != PlatformEvent::RailsModeHorizontal) | 113 if (event.railsMode() != PlatformEvent::RailsModeHorizontal) |
| 116 locationDelta.setY(-event.deltaY()); | 114 locationDelta.setY(-event.deltaY()); |
| 117 } | 115 } |
| 118 | 116 |
| 119 DoublePoint targetPosition = visualViewport().adjustScrollPositionWithinRang e( | 117 DoublePoint targetPosition = visualViewport().adjustScrollPositionWithinRang e( |
| 120 visualViewport().scrollPositionDouble() + toDoubleSize(locationDelta)); | 118 visualViewport().scrollPositionDouble() + toDoubleSize(locationDelta)); |
| 121 visualViewport().setScrollPosition(targetPosition, UserScroll); | 119 visualViewport().setScrollPosition(targetPosition, UserScroll); |
| 122 | 120 |
| 123 DoublePoint usedLocationDelta(visualViewport().scrollPositionDouble() - oldO ffset); | 121 DoublePoint usedLocationDelta(visualViewport().scrollPositionDouble() - oldO ffset); |
| 124 if (!viewScrollResult.didScroll() && usedLocationDelta == DoublePoint::zero( )) | 122 if (!viewScrollResult.didScroll() && usedLocationDelta == DoublePoint::zero( )) |
| 125 return ScrollResult(); | 123 return ScrollResult(false, false, viewScrollResult.unusedScrollDeltaX - usedLocationDelta.x(), viewScrollResult.unusedScrollDeltaY - usedLocationDelta.y ()); |
|
bokan
2015/06/25 14:54:35
This still looks wrong to me, I think you have the
MuVen
2015/06/25 17:05:36
Done. filed bug @ crbug.com/504389.
| |
| 126 | 124 |
| 127 DoubleSize unusedLocationDelta(locationDelta - usedLocationDelta); | 125 DoubleSize unusedLocationDelta(locationDelta - usedLocationDelta); |
| 128 bool didScrollX = viewScrollResult.didScrollX || unusedLocationDelta.width() ; | 126 bool didScrollX = viewScrollResult.didScrollX || unusedLocationDelta.width() ; |
| 129 bool didScrollY = viewScrollResult.didScrollY || unusedLocationDelta.height( ); | 127 bool didScrollY = viewScrollResult.didScrollY || unusedLocationDelta.height( ); |
| 130 return ScrollResult(didScrollX, didScrollY, -unusedLocationDelta.width(), -u nusedLocationDelta.height()); | 128 return ScrollResult(didScrollX, didScrollY, -unusedLocationDelta.width(), -u nusedLocationDelta.height()); |
| 131 } | 129 } |
| 132 | 130 |
| 133 LayoutRect RootFrameViewport::scrollIntoView(const LayoutRect& rectInContent, co nst ScrollAlignment& alignX, const ScrollAlignment& alignY) | 131 LayoutRect RootFrameViewport::scrollIntoView(const LayoutRect& rectInContent, co nst ScrollAlignment& alignX, const ScrollAlignment& alignY) |
| 134 { | 132 { |
| 135 // We want to move the rect into the viewport that excludes the scrollbars s o we intersect | 133 // We want to move the rect into the viewport that excludes the scrollbars s o we intersect |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 323 } | 321 } |
| 324 | 322 |
| 325 void RootFrameViewport::updateCompositorScrollAnimations() | 323 void RootFrameViewport::updateCompositorScrollAnimations() |
| 326 { | 324 { |
| 327 ScrollableArea::updateCompositorScrollAnimations(); | 325 ScrollableArea::updateCompositorScrollAnimations(); |
| 328 layoutViewport().updateCompositorScrollAnimations(); | 326 layoutViewport().updateCompositorScrollAnimations(); |
| 329 } | 327 } |
| 330 | 328 |
| 331 | 329 |
| 332 } // namespace blink | 330 } // namespace blink |
| OLD | NEW |