| 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 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 ScrollAlignment::getRectToExpose(viewRectInContent, rectInContent, align
X, alignY); | 154 ScrollAlignment::getRectToExpose(viewRectInContent, rectInContent, align
X, alignY); |
| 155 | 155 |
| 156 // visualViewport.scrollIntoView will attempt to center the given rect withi
n the viewport | 156 // visualViewport.scrollIntoView will attempt to center the given rect withi
n the viewport |
| 157 // so to prevent it from adjusting r's coordinates the rect must match the v
iewport's size | 157 // so to prevent it from adjusting r's coordinates the rect must match the v
iewport's size |
| 158 // i.e. add the subtracted scrollbars from above back in. | 158 // i.e. add the subtracted scrollbars from above back in. |
| 159 // FIXME: This is hacky and required because getRectToExpose doesn't natural
ly account | 159 // FIXME: This is hacky and required because getRectToExpose doesn't natural
ly account |
| 160 // for the two viewports. crbug.com/449340. | 160 // for the two viewports. crbug.com/449340. |
| 161 targetViewport.setSize(LayoutSize(visualViewport().visibleContentRect().size
())); | 161 targetViewport.setSize(LayoutSize(visualViewport().visibleContentRect().size
())); |
| 162 | 162 |
| 163 // Snap the visible rect to layout units to match the calculated target view
port rect. | 163 // Snap the visible rect to layout units to match the calculated target view
port rect. |
| 164 FloatRect visible = | 164 FloatRect visible(LayoutRect(visualViewport().scrollPositionDouble(), visual
Viewport().visibleContentRect().size())); |
| 165 LayoutRect(visualViewport().scrollPositionDouble(), visualViewport().vis
ibleContentRect().size()); | |
| 166 | 165 |
| 167 float centeringOffsetX = (visible.width() - targetViewport.width()) / 2; | 166 float centeringOffsetX = (visible.width() - targetViewport.width()) / 2; |
| 168 float centeringOffsetY = (visible.height() - targetViewport.height()) / 2; | 167 float centeringOffsetY = (visible.height() - targetViewport.height()) / 2; |
| 169 | 168 |
| 170 DoublePoint targetOffset( | 169 DoublePoint targetOffset( |
| 171 targetViewport.x() - centeringOffsetX, | 170 targetViewport.x() - centeringOffsetX, |
| 172 targetViewport.y() - centeringOffsetY); | 171 targetViewport.y() - centeringOffsetY); |
| 173 | 172 |
| 174 setScrollPosition(targetOffset, ProgrammaticScroll); | 173 setScrollPosition(targetOffset, ProgrammaticScroll); |
| 175 | 174 |
| (...skipping 160 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 |