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 "web/ResizeViewportAnchor.h" | 5 #include "web/ResizeViewportAnchor.h" |
6 | 6 |
7 #include "core/frame/FrameHost.h" | 7 #include "core/frame/FrameHost.h" |
8 #include "core/frame/FrameView.h" | 8 #include "core/frame/FrameView.h" |
9 #include "core/frame/RootFrameViewport.h" | 9 #include "core/frame/RootFrameViewport.h" |
10 #include "core/frame/VisualViewport.h" | 10 #include "core/frame/VisualViewport.h" |
11 #include "core/page/Page.h" | 11 #include "core/page/Page.h" |
12 #include "platform/geometry/DoubleRect.h" | 12 #include "platform/geometry/DoubleRect.h" |
13 #include "platform/geometry/FloatSize.h" | 13 #include "platform/geometry/FloatSize.h" |
14 | 14 |
15 namespace blink { | 15 namespace blink { |
16 | 16 |
17 void ResizeViewportAnchor::resizeFrameView(IntSize size) { | 17 void ResizeViewportAnchor::resizeFrameView(IntSize size) { |
18 FrameView* frameView = rootFrameView(); | 18 FrameView* frameView = rootFrameView(); |
19 DCHECK(frameView); | 19 DCHECK(frameView); |
20 | 20 |
21 ScrollableArea* rootViewport = frameView->getScrollableArea(); | 21 ScrollableArea* rootViewport = frameView->getScrollableArea(); |
22 DoublePoint position = rootViewport->scrollPositionDouble(); | 22 ScrollOffset offset = rootViewport->scrollOffset(); |
23 | 23 |
24 frameView->resize(size); | 24 frameView->resize(size); |
25 m_drift += rootViewport->scrollPositionDouble() - position; | 25 m_drift += rootViewport->scrollOffset() - offset; |
26 } | 26 } |
27 | 27 |
28 void ResizeViewportAnchor::endScope() { | 28 void ResizeViewportAnchor::endScope() { |
29 if (--m_scopeCount > 0) | 29 if (--m_scopeCount > 0) |
30 return; | 30 return; |
31 | 31 |
32 FrameView* frameView = rootFrameView(); | 32 FrameView* frameView = rootFrameView(); |
33 if (!frameView) | 33 if (!frameView) |
34 return; | 34 return; |
35 | 35 |
36 DoublePoint visualViewportInDocument = | 36 ScrollOffset visualViewportInDocument = |
37 frameView->getScrollableArea()->scrollPositionDouble() - m_drift; | 37 frameView->getScrollableArea()->scrollOffset() - m_drift; |
38 | 38 |
39 // TODO(bokan): Don't use RootFrameViewport::setScrollPosition since it | 39 // TODO(bokan): Don't use RootFrameViewport::setScrollPosition since it |
40 // assumes we can just set a sub-pixel precision offset on the FrameView. | 40 // assumes we can just set a sub-pixel precision offset on the FrameView. |
41 // While we "can" do this, the offset that will be shipped to CC will be the | 41 // While we "can" do this, the offset that will be shipped to CC will be the |
42 // truncated number and this class is used to handle TopControl movement | 42 // truncated number and this class is used to handle TopControl movement |
43 // which needs the two threads to match exactly pixel-for-pixel. We can | 43 // which needs the two threads to match exactly pixel-for-pixel. We can |
44 // replace this with RFV::setScrollPosition once Blink is sub-pixel scroll | 44 // replace this with RFV::setScrollPosition once Blink is sub-pixel scroll |
45 // offset aware. crbug.com/414283. | 45 // offset aware. crbug.com/414283. |
46 DCHECK(frameView->getRootFrameViewport()); | 46 DCHECK(frameView->getRootFrameViewport()); |
47 frameView->getRootFrameViewport()->restoreToAnchor(visualViewportInDocument); | 47 frameView->getRootFrameViewport()->restoreToAnchor(visualViewportInDocument); |
48 | 48 |
49 m_drift = DoubleSize(); | 49 m_drift = ScrollOffset(); |
50 } | 50 } |
51 | 51 |
52 FrameView* ResizeViewportAnchor::rootFrameView() { | 52 FrameView* ResizeViewportAnchor::rootFrameView() { |
53 if (Frame* frame = m_page->mainFrame()) { | 53 if (Frame* frame = m_page->mainFrame()) { |
54 if (frame->isLocalFrame()) | 54 if (frame->isLocalFrame()) |
55 return toLocalFrame(frame)->view(); | 55 return toLocalFrame(frame)->view(); |
56 } | 56 } |
57 return nullptr; | 57 return nullptr; |
58 } | 58 } |
59 | 59 |
60 } // namespace blink | 60 } // namespace blink |
OLD | NEW |