| OLD | NEW |
| 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 Loading... |
| 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. |
| 39 void clear(); | 39 void clear(); |
| 40 | 40 |
| 41 // Records the anchor's location in relation to the scroller. Should be | 41 // Records the anchor's location in relation to the scroller. Should be |
| 42 // called when the scroller is about to be laid out. | 42 // called when the scroller is about to be laid out. |
| 43 void save(); | 43 void save(); |
| 44 | 44 |
| 45 // Scrolls to compensate for any change in the anchor's relative location | 45 // 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 | 46 // since the most recent call to save(). Should be called immediately after |
| 47 // the scroller has been laid out. | 47 // the scroller has been laid out. |
| 48 void restore(); | 48 void restore(); |
| 49 | 49 |
| 50 enum class Corner { | 50 enum class Corner { |
| 51 TopLeft = 0, | 51 TopLeft = 0, |
| 52 TopRight, | 52 TopRight, |
| 53 }; | 53 }; |
| 54 // Which corner of the anchor object we are currently anchored to. | 54 // Which corner of the anchor object we are currently anchored to. |
| 55 // Only meaningful if anchorObject() is non-null. | 55 // Only meaningful if anchorObject() is non-null. |
| 56 Corner corner() const { return m_corner; } | 56 Corner corner() const { return m_corner; } |
| 57 | 57 |
| 58 // Checks if we hold any references to the specified object. | 58 // Checks if we hold any references to the specified object. |
| 59 bool refersTo(const LayoutObject*) const; | 59 bool refersTo(const LayoutObject*) const; |
| 60 | 60 |
| 61 // Notifies us that an object will be removed from the layout tree. | 61 // Notifies us that an object will be removed from the layout tree. |
| 62 void notifyRemoved(LayoutObject*); | 62 void notifyRemoved(LayoutObject*); |
| 63 | 63 |
| 64 DEFINE_INLINE_TRACE() { visitor->trace(m_scroller); } | 64 DEFINE_INLINE_TRACE() { visitor->trace(m_scroller); } |
| 65 | 65 |
| 66 private: | 66 private: |
| 67 // Indicates that the next save() should compute a new anchor for the |
| 68 // containing scroller. |
| 69 void clearSelf(bool unconditionally = false); |
| 70 |
| 67 void findAnchor(); | 71 void findAnchor(); |
| 68 bool computeScrollAnchorDisablingStyleChanged(); | 72 bool computeScrollAnchorDisablingStyleChanged(); |
| 69 | 73 |
| 70 enum WalkStatus { Skip = 0, Constrain, Continue, Return }; | 74 enum WalkStatus { Skip = 0, Constrain, Continue, Return }; |
| 71 struct ExamineResult { | 75 struct ExamineResult { |
| 72 ExamineResult(WalkStatus s) | 76 ExamineResult(WalkStatus s) |
| 73 : status(s), viable(false), corner(Corner::TopLeft) {} | 77 : status(s), viable(false), corner(Corner::TopLeft) {} |
| 74 | 78 |
| 75 ExamineResult(WalkStatus s, Corner c) | 79 ExamineResult(WalkStatus s, Corner c) |
| 76 : status(s), viable(true), corner(c) {} | 80 : status(s), viable(true), corner(c) {} |
| (...skipping 29 matching lines...) Expand all Loading... |
| 106 // the call to save. In this state, additional calls to save are ignored, | 110 // 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. | 111 // to make things easier for multi-pass layout modes such as flexbox. |
| 108 // TODO(skobes): explore anchoring at frame boundaries instead of layouts, | 112 // TODO(skobes): explore anchoring at frame boundaries instead of layouts, |
| 109 // which would allow this field to be removed. | 113 // which would allow this field to be removed. |
| 110 bool m_saved; | 114 bool m_saved; |
| 111 }; | 115 }; |
| 112 | 116 |
| 113 } // namespace blink | 117 } // namespace blink |
| 114 | 118 |
| 115 #endif // ScrollAnchor_h | 119 #endif // ScrollAnchor_h |
| OLD | NEW |