| 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 20 matching lines...) Expand all Loading... |
| 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 for the | 37 // Indicates that the next save() should compute a new anchor for the |
| 38 // containing scroller and all ancestor scrollers. | 38 // containing scroller and all ancestor scrollers. |
| 39 void clear(); | 39 void clear(); |
| 40 | 40 |
| 41 // Indicates that the next save() should compute a new anchor for the |
| 42 // containing scroller. |
| 43 void clearSelf(); |
| 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. | 65 // Notifies us that an object will be removed from the layout tree. |
| 62 void notifyRemoved(LayoutObject*); | 66 void notifyRemoved(LayoutObject*); |
| 63 | 67 |
| 64 DEFINE_INLINE_TRACE() { visitor->trace(m_scroller); } | 68 DEFINE_INLINE_TRACE() { visitor->trace(m_scroller); } |
| 65 | 69 |
| 66 private: | 70 private: |
| 67 // Indicates that the next save() should compute a new anchor for the | 71 // Releases the anchor and conditionally clears the IsScrollAnchorObject bit |
| 68 // containing scroller. | 72 // on the LayoutObject. |
| 69 void clearSelf(bool unconditionally = false); | 73 void clearSelf(bool unconditionally); |
| 70 | 74 |
| 71 void findAnchor(); | 75 void findAnchor(); |
| 72 bool computeScrollAnchorDisablingStyleChanged(); | 76 bool computeScrollAnchorDisablingStyleChanged(); |
| 73 | 77 |
| 74 enum WalkStatus { Skip = 0, Constrain, Continue, Return }; | 78 enum WalkStatus { Skip = 0, Constrain, Continue, Return }; |
| 75 struct ExamineResult { | 79 struct ExamineResult { |
| 76 ExamineResult(WalkStatus s) | 80 ExamineResult(WalkStatus s) |
| 77 : status(s), viable(false), corner(Corner::TopLeft) {} | 81 : status(s), viable(false), corner(Corner::TopLeft) {} |
| 78 | 82 |
| 79 ExamineResult(WalkStatus s, Corner c) | 83 ExamineResult(WalkStatus s, Corner c) |
| (...skipping 30 matching lines...) Expand all Loading... |
| 110 // the call to save. In this state, additional calls to save are ignored, | 114 // the call to save. In this state, additional calls to save are ignored, |
| 111 // to make things easier for multi-pass layout modes such as flexbox. | 115 // to make things easier for multi-pass layout modes such as flexbox. |
| 112 // TODO(skobes): explore anchoring at frame boundaries instead of layouts, | 116 // TODO(skobes): explore anchoring at frame boundaries instead of layouts, |
| 113 // which would allow this field to be removed. | 117 // which would allow this field to be removed. |
| 114 bool m_saved; | 118 bool m_saved; |
| 115 }; | 119 }; |
| 116 | 120 |
| 117 } // namespace blink | 121 } // namespace blink |
| 118 | 122 |
| 119 #endif // ScrollAnchor_h | 123 #endif // ScrollAnchor_h |
| OLD | NEW |