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

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

Issue 2184333002: Fix scroll anchoring during viewport resize. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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
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 #ifndef ResizeViewportAnchor_h 5 #ifndef ResizeViewportAnchor_h
6 #define ResizeViewportAnchor_h 6 #define ResizeViewportAnchor_h
7 7
8 #include "platform/geometry/DoublePoint.h" 8 #include "core/page/Page.h"
9 #include "platform/heap/Handle.h" 9 #include "platform/heap/Handle.h"
10 #include "web/ViewportAnchor.h"
11 10
12 namespace blink { 11 namespace blink {
13 12
14 class FrameView; 13 class FrameView;
15 class VisualViewport;
16 14
17 // The resize anchor saves the current scroll offset of the visual viewport and 15 // This class scrolls the viewports to compensate for bounds clamping caused by
18 // restores to that scroll offset so that document location appears exactly 16 // viewport size changes.
19 // unchanged to the user. 17 //
20 class ResizeViewportAnchor : public ViewportAnchor { 18 // It is needed when the layout viewport grows (causing its own scroll position
21 STACK_ALLOCATED(); 19 // to be clamped) and also when it shrinks (causing the visual viewport's scroll
20 // position to be clamped).
21 class ResizeViewportAnchor : public GarbageCollectedFinalized<ResizeViewportAnch or> {
22 WTF_MAKE_NONCOPYABLE(ResizeViewportAnchor);
22 public: 23 public:
23 ResizeViewportAnchor(FrameView& rootFrameView, VisualViewport&); 24 ResizeViewportAnchor(Page& page)
24 ~ResizeViewportAnchor(); 25 : m_page(page)
26 , m_scopeCount(0)
27 {
28 }
29
30 class ResizeScope {
31 STACK_ALLOCATED();
32 public:
33 explicit ResizeScope(ResizeViewportAnchor& anchor)
34 : m_anchor(anchor)
35 {
36 m_anchor->beginScope();
37 }
38 ~ResizeScope()
39 {
40 m_anchor->endScope();
41 }
42 private:
43 Member<ResizeViewportAnchor> m_anchor;
44 };
45
46 void resizeFrameView(IntSize);
47
48 DEFINE_INLINE_TRACE()
49 {
50 visitor->trace(m_page);
51 }
25 52
26 private: 53 private:
27 // Inner viewport origin in the reference frame of the root document, in CSS 54 void beginScope() { m_scopeCount++; }
28 // pixels. 55 void endScope();
29 DoublePoint m_visualViewportInDocument; 56 FrameView* rootFrameView();
57
58 DoubleSize m_drift;
bokan 2016/07/28 14:55:55 Could you add a comment describing this member? I'
skobes 2016/07/28 15:45:50 The opposite actually :) Comment added.
59 Member<Page> m_page;
60 int m_scopeCount;
30 }; 61 };
31 62
32 } // namespace blink 63 } // namespace blink
33 64
34 #endif // ResizeViewportAnchor_h 65 #endif // ResizeViewportAnchor_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698