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

Side by Side Diff: third_party/WebKit/Source/core/layout/ScrollAnchor.h

Issue 1647793002: Use ScrollAnchor in FrameView and PaintLayerScrollableArea. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@anchor-skeleton
Patch Set: move save/restore from LayoutBlockFlow into LayoutBlock Created 4 years, 10 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 ScrollAnchor_h 5 #ifndef ScrollAnchor_h
6 #define ScrollAnchor_h 6 #define ScrollAnchor_h
7 7
8 #include "core/CoreExport.h" 8 #include "core/CoreExport.h"
9 #include "platform/geometry/DoublePoint.h" 9 #include "platform/geometry/DoublePoint.h"
10 #include "platform/heap/Handle.h" 10 #include "platform/heap/Handle.h"
11 11
12 namespace blink { 12 namespace blink {
13 13
14 class LayoutObject; 14 class LayoutObject;
15 class ScrollableArea; 15 class ScrollableArea;
16 16
17 // Scrolls to compensate for layout movements (bit.ly/scroll-anchoring). 17 // Scrolls to compensate for layout movements (bit.ly/scroll-anchoring).
18 class CORE_EXPORT ScrollAnchor final { 18 class CORE_EXPORT ScrollAnchor final {
19 DISALLOW_NEW(); 19 DISALLOW_NEW();
20 20
21 public: 21 public:
22 ScrollAnchor(ScrollableArea*); 22 ScrollAnchor(ScrollableArea*);
23 ~ScrollAnchor(); 23 ~ScrollAnchor();
24 24
25 // The LayoutObject we are currently anchored to. Lazily computed during 25 // The LayoutObject we are currently anchored to. Lazily computed during
26 // save() and cached until the next call to clear(). 26 // save() and cached until the next call to clear().
27 const LayoutObject* anchorObject() const { return m_anchorObject; } 27 LayoutObject* anchorObject() const { return m_anchorObject; }
28 28
29 // Invalidates the anchor. 29 // Invalidates the anchor.
30 void clear() { m_anchorObject = nullptr; } 30 void clear();
31 31
32 // Records the anchor's location in relation to the scroller. Should be 32 // Records the anchor's location in relation to the scroller. Should be
33 // called when the scroller is about to be laid out. 33 // called when the scroller is about to be laid out.
34 void save(); 34 void save();
35 35
36 // Scrolls to compensate for any change in the anchor's relative location 36 // Scrolls to compensate for any change in the anchor's relative location
37 // since the most recent call to save(). Should be called immediately after 37 // since the most recent call to save(). Should be called immediately after
38 // the scroller has been laid out. 38 // the scroller has been laid out.
39 void restore(); 39 void restore();
40 40
41 DEFINE_INLINE_TRACE() { visitor->trace(m_scroller); } 41 DEFINE_INLINE_TRACE() { visitor->trace(m_scroller); }
42 42
43 private: 43 private:
44 // The scroller that owns and is adjusted by this ScrollAnchor. 44 // The scroller that owns and is adjusted by this ScrollAnchor.
45 RawPtrWillBeMember<ScrollableArea> m_scroller; 45 RawPtrWillBeMember<ScrollableArea> m_scroller;
46 46
47 // The LayoutObject we should anchor to. Lazily computed. 47 // The LayoutObject we should anchor to. Lazily computed.
48 const LayoutObject* m_anchorObject; 48 LayoutObject* m_anchorObject;
49 49
50 // Location of m_layoutObject relative to scroller at time of save(). 50 // Location of m_layoutObject relative to scroller at time of save().
51 DoublePoint m_savedRelativeOffset; 51 DoublePoint m_savedRelativeOffset;
52 }; 52 };
53 53
54 } // namespace blink 54 } // namespace blink
55 55
56 #endif // ScrollAnchor_h 56 #endif // ScrollAnchor_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698