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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
84 return; | 84 return; |
85 | 85 |
86 DoublePoint clampedPosition = clampScrollPosition(position); | 86 DoublePoint clampedPosition = clampScrollPosition(position); |
87 scrollToOffsetWithoutAnimation(toFloatPoint(clampedPosition)); | 87 scrollToOffsetWithoutAnimation(toFloatPoint(clampedPosition)); |
88 } | 88 } |
89 | 89 |
90 ScrollResult RootFrameViewport::handleWheel(const PlatformWheelEvent& event) | 90 ScrollResult RootFrameViewport::handleWheel(const PlatformWheelEvent& event) |
91 { | 91 { |
92 updateScrollAnimator(); | 92 updateScrollAnimator(); |
93 | 93 |
94 ScrollResult viewScrollResult(false); | 94 ScrollResult viewScrollResult; |
95 if (layoutViewport().isScrollable()) | 95 if (layoutViewport().isScrollable()) |
96 viewScrollResult = layoutViewport().handleWheel(event); | 96 viewScrollResult = layoutViewport().handleWheel(event); |
97 | 97 |
98 // The visual viewport will only accept pixel scrolls. | 98 // The visual viewport will only accept pixel scrolls. |
99 if (!event.canScroll() || event.granularity() == ScrollByPageWheelEvent) | 99 if (!event.canScroll() || event.granularity() == ScrollByPageWheelEvent) |
100 return viewScrollResult; | 100 return viewScrollResult; |
101 | 101 |
102 // Move the location by the negative of the remaining scroll delta. | 102 // Move the location by the negative of the remaining scroll delta. |
103 DoublePoint oldOffset = visualViewport().scrollPositionDouble(); | 103 DoublePoint oldOffset = visualViewport().scrollPositionDouble(); |
104 DoublePoint locationDelta; | 104 DoublePoint locationDelta; |
105 if (viewScrollResult.didScroll) { | 105 if (viewScrollResult.didScroll()) { |
106 locationDelta = -DoublePoint(viewScrollResult.unusedScrollDeltaX, viewSc rollResult.unusedScrollDeltaY); | 106 locationDelta = -DoublePoint(viewScrollResult.unusedScrollDeltaX, viewSc rollResult.unusedScrollDeltaY); |
107 } else { | 107 } else { |
108 if (event.railsMode() != PlatformEvent::RailsModeVertical) | 108 if (event.railsMode() != PlatformEvent::RailsModeVertical) |
109 locationDelta.setX(-event.deltaX()); | 109 locationDelta.setX(-event.deltaX()); |
110 if (event.railsMode() != PlatformEvent::RailsModeHorizontal) | 110 if (event.railsMode() != PlatformEvent::RailsModeHorizontal) |
111 locationDelta.setY(-event.deltaY()); | 111 locationDelta.setY(-event.deltaY()); |
112 } | 112 } |
113 | 113 |
114 DoublePoint targetPosition = visualViewport().adjustScrollPositionWithinRang e( | 114 DoublePoint targetPosition = visualViewport().adjustScrollPositionWithinRang e( |
115 visualViewport().scrollPositionDouble() + toDoubleSize(locationDelta)); | 115 visualViewport().scrollPositionDouble() + toDoubleSize(locationDelta)); |
116 visualViewport().scrollToOffsetWithoutAnimation(FloatPoint(targetPosition)); | 116 visualViewport().scrollToOffsetWithoutAnimation(FloatPoint(targetPosition)); |
117 | 117 |
118 DoublePoint usedLocationDelta(visualViewport().scrollPositionDouble() - oldO ffset); | 118 DoublePoint usedLocationDelta(visualViewport().scrollPositionDouble() - oldO ffset); |
119 if (!viewScrollResult.didScroll && usedLocationDelta == DoublePoint::zero()) | 119 if (!viewScrollResult.didScroll() && usedLocationDelta == DoublePoint::zero( )) |
120 return ScrollResult(false); | 120 return ScrollResult(); |
121 | 121 |
122 DoubleSize unusedLocationDelta(locationDelta - usedLocationDelta); | 122 DoubleSize unusedLocationDelta(locationDelta - usedLocationDelta); |
123 return ScrollResult(true, -unusedLocationDelta.width(), -unusedLocationDelta .height()); | 123 return ScrollResult(locationDelta.x()-usedLocationDelta.x(), locationDelta.y ()-usedLocationDelta.y(), -unusedLocationDelta.width(), -unusedLocationDelta.hei ght()); |
MuVen
2015/06/02 09:04:00
This shall return didScrollX and didScrollY scroll
majidvp
2015/06/02 17:00:31
Yes but I don't think the calculation is incorrect
MuVen
2015/06/03 09:32:18
Done.
| |
124 } | 124 } |
125 | 125 |
126 LayoutRect RootFrameViewport::scrollIntoView(const LayoutRect& rectInContent, co nst ScrollAlignment& alignX, const ScrollAlignment& alignY) | 126 LayoutRect RootFrameViewport::scrollIntoView(const LayoutRect& rectInContent, co nst ScrollAlignment& alignX, const ScrollAlignment& alignY) |
127 { | 127 { |
128 // We want to move the rect into the viewport that excludes the scrollbars s o we intersect | 128 // We want to move the rect into the viewport that excludes the scrollbars s o we intersect |
129 // the pinch viewport with the scrollbar-excluded frameView content rect. Ho wever, we don't | 129 // the pinch viewport with the scrollbar-excluded frameView content rect. Ho wever, we don't |
130 // use visibleContentRect directly since it floors the scroll position. Inst ead, we use | 130 // use visibleContentRect directly since it floors the scroll position. Inst ead, we use |
131 // FrameView::scrollPositionDouble and construct a LayoutRect from that (the FrameView size | 131 // FrameView::scrollPositionDouble and construct a LayoutRect from that (the FrameView size |
132 // is always integer sized. | 132 // is always integer sized. |
133 | 133 |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
269 GraphicsLayer* RootFrameViewport::layerForHorizontalScrollbar() const | 269 GraphicsLayer* RootFrameViewport::layerForHorizontalScrollbar() const |
270 { | 270 { |
271 return layoutViewport().layerForHorizontalScrollbar(); | 271 return layoutViewport().layerForHorizontalScrollbar(); |
272 } | 272 } |
273 | 273 |
274 GraphicsLayer* RootFrameViewport::layerForVerticalScrollbar() const | 274 GraphicsLayer* RootFrameViewport::layerForVerticalScrollbar() const |
275 { | 275 { |
276 return layoutViewport().layerForVerticalScrollbar(); | 276 return layoutViewport().layerForVerticalScrollbar(); |
277 } | 277 } |
278 | 278 |
279 bool RootFrameViewport::scroll(ScrollDirectionPhysical direction, ScrollGranular ity granularity, float delta) | 279 ScrollResultOneDimensional RootFrameViewport::scroll(ScrollDirectionPhysical dir ection, ScrollGranularity granularity, float delta) |
280 { | 280 { |
281 updateScrollAnimator(); | 281 updateScrollAnimator(); |
282 | 282 |
283 ScrollbarOrientation orientation; | 283 ScrollbarOrientation orientation; |
284 | 284 |
285 if (direction == ScrollUp || direction == ScrollDown) | 285 if (direction == ScrollUp || direction == ScrollDown) |
286 orientation = VerticalScrollbar; | 286 orientation = VerticalScrollbar; |
287 else | 287 else |
288 orientation = HorizontalScrollbar; | 288 orientation = HorizontalScrollbar; |
289 | 289 |
290 if (layoutViewport().userInputScrollable(orientation) && visualViewport().us erInputScrollable(orientation)) | 290 if (layoutViewport().userInputScrollable(orientation) && visualViewport().us erInputScrollable(orientation)) |
291 return ScrollableArea::scroll(direction, granularity, delta); | 291 return ScrollableArea::scroll(direction, granularity, delta); |
292 | 292 |
293 if (visualViewport().userInputScrollable(orientation)) | 293 if (visualViewport().userInputScrollable(orientation)) |
294 return visualViewport().scroll(direction, granularity, delta); | 294 return visualViewport().scroll(direction, granularity, delta); |
295 | 295 |
296 if (layoutViewport().userInputScrollable(orientation)) | 296 if (layoutViewport().userInputScrollable(orientation)) |
297 return layoutViewport().scroll(direction, granularity, delta); | 297 return layoutViewport().scroll(direction, granularity, delta); |
298 | 298 |
299 return false; | 299 return ScrollResultOneDimensional(false); |
300 } | 300 } |
301 | 301 |
302 } // namespace blink | 302 } // namespace blink |
OLD | NEW |