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

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

Issue 2404393003: Tie scroll anchoring adjustments to frame lifecycle instead of layout. (Closed)
Patch Set: add DCHECK Created 4 years, 1 month 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/LayoutPoint.h" 9 #include "platform/geometry/LayoutPoint.h"
10 #include "platform/heap/Handle.h" 10 #include "platform/heap/Handle.h"
(...skipping 13 matching lines...) Expand all
24 ~ScrollAnchor(); 24 ~ScrollAnchor();
25 25
26 // The scroller that is scrolled to componsate for layout movements. Note 26 // The scroller that is scrolled to componsate for layout movements. Note
27 // that the scroller can only be initialized once. 27 // that the scroller can only be initialized once.
28 void setScroller(ScrollableArea*); 28 void setScroller(ScrollableArea*);
29 29
30 // Returns true if the underlying scroller is set. 30 // Returns true if the underlying scroller is set.
31 bool hasScroller() const { return m_scroller; } 31 bool hasScroller() const { return m_scroller; }
32 32
33 // The LayoutObject we are currently anchored to. Lazily computed during 33 // The LayoutObject we are currently anchored to. Lazily computed during
34 // save() and cached until the next call to clear(). 34 // notifyBeforeLayout() and cached until the next call to clear().
35 LayoutObject* anchorObject() const { return m_anchorObject; } 35 LayoutObject* anchorObject() const { return m_anchorObject; }
36 36
37 // Indicates that the next save() should compute a new anchor for the 37 // Indicates that this ScrollAnchor, and all ancestor ScrollAnchors, should
38 // containing scroller and all ancestor scrollers. 38 // compute new anchor nodes on their next notifyBeforeLayout().
39 void clear(); 39 void clear();
40 40
41 // Indicates that the next save() should compute a new anchor for the 41 // Indicates that this ScrollAnchor should compute a new anchor node on the
42 // containing scroller. 42 // next call to notifyBeforeLayout().
43 void clearSelf(); 43 void clearSelf();
44 44
45 // Records the anchor's location in relation to the scroller. Should be 45 // Records the anchor's location in relation to the scroller. Should be
46 // called when the scroller is about to be laid out. 46 // called when the scroller is about to be laid out.
47 void save(); 47 void notifyBeforeLayout();
48 48
49 // Scrolls to compensate for any change in the anchor's relative location 49 // Scrolls to compensate for any change in the anchor's relative location.
50 // since the most recent call to save(). Should be called immediately after 50 // Should be called at the end of the animation frame.
51 // the scroller has been laid out. 51 void adjust();
52 void restore();
53 52
54 enum class Corner { 53 enum class Corner {
55 TopLeft = 0, 54 TopLeft = 0,
56 TopRight, 55 TopRight,
57 }; 56 };
58 // Which corner of the anchor object we are currently anchored to. 57 // Which corner of the anchor object we are currently anchored to.
59 // Only meaningful if anchorObject() is non-null. 58 // Only meaningful if anchorObject() is non-null.
60 Corner corner() const { return m_corner; } 59 Corner corner() const { return m_corner; }
61 60
62 // Checks if we hold any references to the specified object. 61 // Checks if we hold any references to the specified object.
(...skipping 21 matching lines...) Expand all
84 : status(s), viable(true), corner(c) {} 83 : status(s), viable(true), corner(c) {}
85 84
86 WalkStatus status; 85 WalkStatus status;
87 bool viable; 86 bool viable;
88 Corner corner; 87 Corner corner;
89 }; 88 };
90 ExamineResult examine(const LayoutObject*) const; 89 ExamineResult examine(const LayoutObject*) const;
91 90
92 IntSize computeAdjustment() const; 91 IntSize computeAdjustment() const;
93 92
94 // The scroller that owns and is adjusted by this ScrollAnchor. 93 // The scroller to be adjusted by this ScrollAnchor. This is also the scroller
94 // that owns us, unless it is the RootFrameViewport in which case we are owned
95 // by the layout viewport.
95 Member<ScrollableArea> m_scroller; 96 Member<ScrollableArea> m_scroller;
96 97
97 // The LayoutObject we should anchor to. 98 // The LayoutObject we should anchor to.
98 LayoutObject* m_anchorObject; 99 LayoutObject* m_anchorObject;
99 100
100 // Which corner of m_anchorObject's bounding box to anchor to. 101 // Which corner of m_anchorObject's bounding box to anchor to.
101 Corner m_corner; 102 Corner m_corner;
102 103
103 // Location of m_layoutObject relative to scroller at time of save(). 104 // Location of m_layoutObject relative to scroller at time of
105 // notifyBeforeLayout().
104 LayoutPoint m_savedRelativeOffset; 106 LayoutPoint m_savedRelativeOffset;
105 107
106 // We suppress scroll anchoring after a style change on the anchor node or 108 // We suppress scroll anchoring after a style change on the anchor node or
107 // one of its ancestors, if that change might have caused the node to move. 109 // one of its ancestors, if that change might have caused the node to move.
108 // This bit tracks whether we have had a scroll-anchor-disabling style 110 // This bit tracks whether we have had a scroll-anchor-disabling style
109 // change since the last layout. It is recomputed in save(), and used to 111 // change since the last layout. It is recomputed in notifyBeforeLayout(),
110 // suppress the adjustment in restore(). More at http://bit.ly/sanaclap. 112 // and used to suppress adjustment in adjust(). See http://bit.ly/sanaclap.
111 bool m_scrollAnchorDisablingStyleChanged; 113 bool m_scrollAnchorDisablingStyleChanged;
112 114
113 // True iff save has been called, and restore has not been called since 115 // True iff an adjustment check has been queued with the FrameView but not yet
114 // the call to save. In this state, additional calls to save are ignored, 116 // performed.
115 // to make things easier for multi-pass layout modes such as flexbox. 117 bool m_queued;
116 // TODO(skobes): explore anchoring at frame boundaries instead of layouts,
117 // which would allow this field to be removed.
118 bool m_saved;
119 }; 118 };
120 119
121 } // namespace blink 120 } // namespace blink
122 121
123 #endif // ScrollAnchor_h 122 #endif // ScrollAnchor_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutBlock.cpp ('k') | third_party/WebKit/Source/core/layout/ScrollAnchor.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698