| 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 IntPoint& offset, ScrollType scrol
lType) | 120 void RootFrameViewport::setScrollOffset(const IntPoint& offset, ScrollType scrol
lType) |
| 122 { | 121 { |
| 123 setScrollOffset(DoublePoint(offset), scrollType); | 122 setScrollOffset(DoublePoint(offset), scrollType); |
| 124 } | 123 } |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 317 } | 316 } |
| 318 | 317 |
| 319 DEFINE_TRACE(RootFrameViewport) | 318 DEFINE_TRACE(RootFrameViewport) |
| 320 { | 319 { |
| 321 visitor->trace(m_visualViewport); | 320 visitor->trace(m_visualViewport); |
| 322 visitor->trace(m_layoutViewport); | 321 visitor->trace(m_layoutViewport); |
| 323 ScrollableArea::trace(visitor); | 322 ScrollableArea::trace(visitor); |
| 324 } | 323 } |
| 325 | 324 |
| 326 } // namespace blink | 325 } // namespace blink |
| OLD | NEW |