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

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

Issue 2394053004: Clear scroll anchor on all parent scrollers from ScrollAnchor::clear (Closed)
Patch Set: rebase and fix merge Created 4 years, 2 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/LayoutPoint.h" 9 #include "platform/geometry/LayoutPoint.h"
10 #include "platform/heap/Handle.h" 10 #include "platform/heap/Handle.h"
(...skipping 16 matching lines...) Expand all
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 // save() 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. (In certain 37 // Indicates that the next save() should compute a new anchor for the
38 // cases the previous anchor will be reused; see comments in restore.) 38 // containing scroller and all ancestor scrollers (In certain cases the
skobes 2016/10/10 21:34:35 You can delete the sentence in parentheses, it's a
39 // previous anchor will be reused; see comments in restore.)
39 void clear(); 40 void clear();
40 41
42 // Sets the anchor object to null.
43 void releaseAnchor();
44
41 // 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
42 // called when the scroller is about to be laid out. 46 // called when the scroller is about to be laid out.
43 void save(); 47 void save();
44 48
45 // 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
46 // since the most recent call to save(). Should be called immediately after 50 // since the most recent call to save(). Should be called immediately after
47 // the scroller has been laid out. 51 // the scroller has been laid out.
48 void restore(); 52 void restore();
49 53
50 enum class Corner { 54 enum class Corner {
51 TopLeft = 0, 55 TopLeft = 0,
52 TopRight, 56 TopRight,
53 }; 57 };
54 // Which corner of the anchor object we are currently anchored to. 58 // Which corner of the anchor object we are currently anchored to.
55 // Only meaningful if anchorObject() is non-null. 59 // Only meaningful if anchorObject() is non-null.
56 Corner corner() const { return m_corner; } 60 Corner corner() const { return m_corner; }
57 61
58 // Checks if we hold any references to the specified object. 62 // Checks if we hold any references to the specified object.
59 bool refersTo(const LayoutObject*) const; 63 bool refersTo(const LayoutObject*) const;
60 64
61 // Notifies us that an object will be removed from the layout tree.
62 void notifyRemoved(LayoutObject*);
63
64 DEFINE_INLINE_TRACE() { visitor->trace(m_scroller); } 65 DEFINE_INLINE_TRACE() { visitor->trace(m_scroller); }
65 66
66 private: 67 private:
68 // Indicates that the next save() should compute a new anchor just for the
69 // containing scroller.
70 void clearForContainingScroller();
71
67 void findAnchor(); 72 void findAnchor();
68 bool computeScrollAnchorDisablingStyleChanged(); 73 bool computeScrollAnchorDisablingStyleChanged();
69 74
70 enum WalkStatus { Skip = 0, Constrain, Continue, Return }; 75 enum WalkStatus { Skip = 0, Constrain, Continue, Return };
71 struct ExamineResult { 76 struct ExamineResult {
72 ExamineResult(WalkStatus s) 77 ExamineResult(WalkStatus s)
73 : status(s), viable(false), corner(Corner::TopLeft) {} 78 : status(s), viable(false), corner(Corner::TopLeft) {}
74 79
75 ExamineResult(WalkStatus s, Corner c) 80 ExamineResult(WalkStatus s, Corner c)
76 : status(s), viable(true), corner(c) {} 81 : status(s), viable(true), corner(c) {}
(...skipping 29 matching lines...) Expand all
106 // the call to save. In this state, additional calls to save are ignored, 111 // the call to save. In this state, additional calls to save are ignored,
107 // to make things easier for multi-pass layout modes such as flexbox. 112 // to make things easier for multi-pass layout modes such as flexbox.
108 // TODO(skobes): explore anchoring at frame boundaries instead of layouts, 113 // TODO(skobes): explore anchoring at frame boundaries instead of layouts,
109 // which would allow this field to be removed. 114 // which would allow this field to be removed.
110 bool m_saved; 115 bool m_saved;
111 }; 116 };
112 117
113 } // namespace blink 118 } // namespace blink
114 119
115 #endif // ScrollAnchor_h 120 #endif // ScrollAnchor_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698