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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 | 86 |
87 DoublePoint clampedPosition = clampScrollPosition(position); | 87 DoublePoint clampedPosition = clampScrollPosition(position); |
88 ScrollableArea::setScrollPosition(clampedPosition, scrollType, scrollBehavio
r); | 88 ScrollableArea::setScrollPosition(clampedPosition, scrollType, scrollBehavio
r); |
89 } | 89 } |
90 | 90 |
91 ScrollBehavior RootFrameViewport::scrollBehaviorStyle() const | 91 ScrollBehavior RootFrameViewport::scrollBehaviorStyle() const |
92 { | 92 { |
93 return layoutViewport().scrollBehaviorStyle(); | 93 return layoutViewport().scrollBehaviorStyle(); |
94 } | 94 } |
95 | 95 |
96 LayoutRect RootFrameViewport::scrollIntoView(const LayoutRect& rectInContent, co
nst ScrollAlignment& alignX, const ScrollAlignment& alignY) | 96 LayoutRect RootFrameViewport::scrollIntoView(const LayoutRect& rectInContent, co
nst ScrollAlignment& alignX, const ScrollAlignment& alignY, ScrollType scrollTyp
e) |
97 { | 97 { |
98 // We want to move the rect into the viewport that excludes the scrollbars s
o we intersect | 98 // We want to move the rect into the viewport that excludes the scrollbars s
o we intersect |
99 // the visual viewport with the scrollbar-excluded frameView content rect. H
owever, we don't | 99 // the visual viewport with the scrollbar-excluded frameView content rect. H
owever, we don't |
100 // use visibleContentRect directly since it floors the scroll position. Inst
ead, we use | 100 // use visibleContentRect directly since it floors the scroll position. Inst
ead, we use |
101 // ScrollAnimator::currentPosition and construct a LayoutRect from that. | 101 // ScrollAnimator::currentPosition and construct a LayoutRect from that. |
102 | 102 |
103 LayoutRect frameRectInContent = LayoutRect( | 103 LayoutRect frameRectInContent = LayoutRect( |
104 layoutViewport().scrollAnimator()->currentPosition(), | 104 layoutViewport().scrollAnimator()->currentPosition(), |
105 layoutViewport().visibleContentRect().size()); | 105 layoutViewport().visibleContentRect().size()); |
106 LayoutRect visualRectInContent = LayoutRect( | 106 LayoutRect visualRectInContent = LayoutRect( |
107 scrollOffsetFromScrollAnimators(), | 107 scrollOffsetFromScrollAnimators(), |
108 visualViewport().visibleContentRect().size()); | 108 visualViewport().visibleContentRect().size()); |
109 | 109 |
110 // Intersect layout and visual rects to exclude the scrollbar from the view
rect. | 110 // Intersect layout and visual rects to exclude the scrollbar from the view
rect. |
111 LayoutRect viewRectInContent = intersection(visualRectInContent, frameRectIn
Content); | 111 LayoutRect viewRectInContent = intersection(visualRectInContent, frameRectIn
Content); |
112 LayoutRect targetViewport = | 112 LayoutRect targetViewport = |
113 ScrollAlignment::getRectToExpose(viewRectInContent, rectInContent, align
X, alignY); | 113 ScrollAlignment::getRectToExpose(viewRectInContent, rectInContent, align
X, alignY); |
114 DoublePoint targetOffset(targetViewport.x(), targetViewport.y()); | 114 DoublePoint targetOffset(targetViewport.x(), targetViewport.y()); |
115 | 115 |
116 setScrollPosition(targetOffset, ProgrammaticScroll); | 116 setScrollPosition(targetOffset, scrollType, ScrollBehaviorInstant); |
117 | 117 |
118 // RootFrameViewport only changes the viewport relative to the document so w
e can't change the input | 118 // RootFrameViewport only changes the viewport relative to the document so w
e can't change the input |
119 // rect's location relative to the document origin. | 119 // rect's location relative to the document origin. |
120 return rectInContent; | 120 return rectInContent; |
121 } | 121 } |
122 | 122 |
123 void RootFrameViewport::setScrollOffset(const IntPoint& offset, ScrollType scrol
lType) | 123 void RootFrameViewport::setScrollOffset(const IntPoint& offset, ScrollType scrol
lType) |
124 { | 124 { |
125 setScrollOffset(DoublePoint(offset), scrollType); | 125 setScrollOffset(DoublePoint(offset), scrollType); |
126 } | 126 } |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
288 } | 288 } |
289 | 289 |
290 DEFINE_TRACE(RootFrameViewport) | 290 DEFINE_TRACE(RootFrameViewport) |
291 { | 291 { |
292 visitor->trace(m_visualViewport); | 292 visitor->trace(m_visualViewport); |
293 visitor->trace(m_layoutViewport); | 293 visitor->trace(m_layoutViewport); |
294 ScrollableArea::trace(visitor); | 294 ScrollableArea::trace(visitor); |
295 } | 295 } |
296 | 296 |
297 } // namespace blink | 297 } // namespace blink |
OLD | NEW |