Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(92)

Side by Side Diff: third_party/WebKit/Source/web/ResizeViewportAnchor.cpp

Issue 2837503002: Move (Resize|Rotation)ViewportAnchor.* from web/ to core/frame/. (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "web/ResizeViewportAnchor.h"
6
7 #include "core/frame/FrameView.h"
8 #include "core/frame/RootFrameViewport.h"
9 #include "core/frame/VisualViewport.h"
10 #include "core/page/Page.h"
11 #include "platform/geometry/DoubleRect.h"
12 #include "platform/geometry/FloatSize.h"
13
14 namespace blink {
15
16 void ResizeViewportAnchor::ResizeFrameView(IntSize size) {
17 FrameView* frame_view = RootFrameView();
18 DCHECK(frame_view);
19
20 ScrollableArea* root_viewport = frame_view->GetScrollableArea();
21 ScrollOffset offset = root_viewport->GetScrollOffset();
22
23 frame_view->Resize(size);
24 drift_ += root_viewport->GetScrollOffset() - offset;
25 }
26
27 void ResizeViewportAnchor::EndScope() {
28 if (--scope_count_ > 0)
29 return;
30
31 FrameView* frame_view = RootFrameView();
32 if (!frame_view)
33 return;
34
35 ScrollOffset visual_viewport_in_document =
36 frame_view->GetScrollableArea()->GetScrollOffset() - drift_;
37
38 // TODO(bokan): Don't use RootFrameViewport::setScrollPosition since it
39 // assumes we can just set a sub-pixel precision offset on the FrameView.
40 // While we "can" do this, the offset that will be shipped to CC will be the
41 // truncated number and this class is used to handle TopControl movement
42 // which needs the two threads to match exactly pixel-for-pixel. We can
43 // replace this with RFV::setScrollPosition once Blink is sub-pixel scroll
44 // offset aware. crbug.com/414283.
45 DCHECK(frame_view->GetRootFrameViewport());
46 frame_view->GetRootFrameViewport()->RestoreToAnchor(
47 visual_viewport_in_document);
48
49 drift_ = ScrollOffset();
50 }
51
52 FrameView* ResizeViewportAnchor::RootFrameView() {
53 if (Frame* frame = page_->MainFrame()) {
54 if (frame->IsLocalFrame())
55 return ToLocalFrame(frame)->View();
56 }
57 return nullptr;
58 }
59
60 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/web/ResizeViewportAnchor.h ('k') | third_party/WebKit/Source/web/RotationViewportAnchor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698