| 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 "core/frame/RootFrameViewport.h" | 5 #include "core/frame/RootFrameViewport.h" |
| 6 | 6 |
| 7 #include "core/frame/FrameView.h" | 7 #include "core/frame/FrameView.h" |
| 8 #include "core/layout/ScrollAlignment.h" | 8 #include "core/layout/ScrollAlignment.h" |
| 9 #include "platform/geometry/DoubleRect.h" | 9 #include "platform/geometry/DoubleRect.h" |
| 10 #include "platform/geometry/FloatRect.h" | 10 #include "platform/geometry/FloatRect.h" |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 layoutViewport().scrollAnimator().currentPosition(), | 102 layoutViewport().scrollAnimator().currentPosition(), |
| 103 layoutViewport().visibleContentRect().size()); | 103 layoutViewport().visibleContentRect().size()); |
| 104 LayoutRect visualRectInContent = LayoutRect( | 104 LayoutRect visualRectInContent = LayoutRect( |
| 105 scrollOffsetFromScrollAnimators(), | 105 scrollOffsetFromScrollAnimators(), |
| 106 visualViewport().visibleContentRect().size()); | 106 visualViewport().visibleContentRect().size()); |
| 107 | 107 |
| 108 // Intersect layout and visual rects to exclude the scrollbar from the view
rect. | 108 // Intersect layout and visual rects to exclude the scrollbar from the view
rect. |
| 109 LayoutRect viewRectInContent = intersection(visualRectInContent, frameRectIn
Content); | 109 LayoutRect viewRectInContent = intersection(visualRectInContent, frameRectIn
Content); |
| 110 LayoutRect targetViewport = | 110 LayoutRect targetViewport = |
| 111 ScrollAlignment::getRectToExpose(viewRectInContent, rectInContent, align
X, alignY); | 111 ScrollAlignment::getRectToExpose(viewRectInContent, rectInContent, align
X, alignY); |
| 112 DoublePoint targetOffset(targetViewport.x(), targetViewport.y()); | 112 if (targetViewport != viewRectInContent) |
| 113 | 113 setScrollPosition(DoublePoint(targetViewport.x(), targetViewport.y()), s
crollType); |
| 114 setScrollPosition(targetOffset, scrollType, ScrollBehaviorInstant); | |
| 115 | 114 |
| 116 // RootFrameViewport only changes the viewport relative to the document so w
e can't change the input | 115 // RootFrameViewport only changes the viewport relative to the document so w
e can't change the input |
| 117 // rect's location relative to the document origin. | 116 // rect's location relative to the document origin. |
| 118 return rectInContent; | 117 return rectInContent; |
| 119 } | 118 } |
| 120 | 119 |
| 121 void RootFrameViewport::setScrollOffset(const DoublePoint& offset, ScrollType sc
rollType) | 120 void RootFrameViewport::setScrollOffset(const DoublePoint& offset, ScrollType sc
rollType) |
| 122 { | 121 { |
| 123 distributeScrollBetweenViewports(DoublePoint(offset), scrollType, ScrollBeha
viorInstant); | 122 distributeScrollBetweenViewports(DoublePoint(offset), scrollType, ScrollBeha
viorInstant); |
| 124 } | 123 } |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 336 } | 335 } |
| 337 | 336 |
| 338 DEFINE_TRACE(RootFrameViewport) | 337 DEFINE_TRACE(RootFrameViewport) |
| 339 { | 338 { |
| 340 visitor->trace(m_visualViewport); | 339 visitor->trace(m_visualViewport); |
| 341 visitor->trace(m_layoutViewport); | 340 visitor->trace(m_layoutViewport); |
| 342 ScrollableArea::trace(visitor); | 341 ScrollableArea::trace(visitor); |
| 343 } | 342 } |
| 344 | 343 |
| 345 } // namespace blink | 344 } // namespace blink |
| OLD | NEW |