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 // FrameView::scrollPositionDouble and construct a LayoutRect from that (the
FrameView size | 101 // FrameView::scrollPositionDouble and construct a LayoutRect from that (the
FrameView size |
102 // is always integer sized. | 102 // is always integer sized. |
103 | 103 |
104 LayoutRect frameRectInContent = LayoutRect( | 104 LayoutRect frameRectInContent = LayoutRect( |
105 layoutViewport().scrollAnimator()->currentPosition(), | 105 layoutViewport().scrollAnimator()->currentPosition(), |
106 layoutViewport().visibleContentRect().size()); | 106 layoutViewport().visibleContentRect().size()); |
(...skipping 15 matching lines...) Expand all Loading... |
122 // Snap the visible rect to layout units to match the calculated target view
port rect. | 122 // Snap the visible rect to layout units to match the calculated target view
port rect. |
123 FloatRect visible(LayoutRect(visualViewport().scrollPositionDouble(), visual
Viewport().visibleContentRect().size())); | 123 FloatRect visible(LayoutRect(visualViewport().scrollPositionDouble(), visual
Viewport().visibleContentRect().size())); |
124 | 124 |
125 float centeringOffsetX = (visible.width() - targetViewport.width()) / 2; | 125 float centeringOffsetX = (visible.width() - targetViewport.width()) / 2; |
126 float centeringOffsetY = (visible.height() - targetViewport.height()) / 2; | 126 float centeringOffsetY = (visible.height() - targetViewport.height()) / 2; |
127 | 127 |
128 DoublePoint targetOffset( | 128 DoublePoint targetOffset( |
129 targetViewport.x() - centeringOffsetX, | 129 targetViewport.x() - centeringOffsetX, |
130 targetViewport.y() - centeringOffsetY); | 130 targetViewport.y() - centeringOffsetY); |
131 | 131 |
132 setScrollPosition(targetOffset, ProgrammaticScroll); | 132 setScrollPosition(targetOffset, scrollType, ScrollBehaviorInstant); |
133 | 133 |
134 // RootFrameViewport only changes the viewport relative to the document so w
e can't change the input | 134 // RootFrameViewport only changes the viewport relative to the document so w
e can't change the input |
135 // rect's location relative to the document origin. | 135 // rect's location relative to the document origin. |
136 return rectInContent; | 136 return rectInContent; |
137 } | 137 } |
138 | 138 |
139 void RootFrameViewport::setScrollOffset(const IntPoint& offset, ScrollType scrol
lType) | 139 void RootFrameViewport::setScrollOffset(const IntPoint& offset, ScrollType scrol
lType) |
140 { | 140 { |
141 setScrollOffset(DoublePoint(offset), scrollType); | 141 setScrollOffset(DoublePoint(offset), scrollType); |
142 } | 142 } |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
304 } | 304 } |
305 | 305 |
306 DEFINE_TRACE(RootFrameViewport) | 306 DEFINE_TRACE(RootFrameViewport) |
307 { | 307 { |
308 visitor->trace(m_visualViewport); | 308 visitor->trace(m_visualViewport); |
309 visitor->trace(m_layoutViewport); | 309 visitor->trace(m_layoutViewport); |
310 ScrollableArea::trace(visitor); | 310 ScrollableArea::trace(visitor); |
311 } | 311 } |
312 | 312 |
313 } // namespace blink | 313 } // namespace blink |
OLD | NEW |