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 #include "core/layout/ScrollAnchor.h" | 5 #include "core/layout/ScrollAnchor.h" |
6 | 6 |
7 #include "core/frame/FrameView.h" | 7 #include "core/frame/FrameView.h" |
8 #include "core/frame/UseCounter.h" | 8 #include "core/frame/UseCounter.h" |
9 #include "core/layout/LayoutBlockFlow.h" | 9 #include "core/layout/LayoutBlockFlow.h" |
10 #include "core/layout/api/LayoutBoxItem.h" | 10 #include "core/layout/api/LayoutBoxItem.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 m_scrollAnchorDisablingStyleChanged(false), | 23 m_scrollAnchorDisablingStyleChanged(false), |
24 m_queued(false) {} | 24 m_queued(false) {} |
25 | 25 |
26 ScrollAnchor::ScrollAnchor(ScrollableArea* scroller) : ScrollAnchor() { | 26 ScrollAnchor::ScrollAnchor(ScrollableArea* scroller) : ScrollAnchor() { |
27 setScroller(scroller); | 27 setScroller(scroller); |
28 } | 28 } |
29 | 29 |
30 ScrollAnchor::~ScrollAnchor() {} | 30 ScrollAnchor::~ScrollAnchor() {} |
31 | 31 |
32 void ScrollAnchor::setScroller(ScrollableArea* scroller) { | 32 void ScrollAnchor::setScroller(ScrollableArea* scroller) { |
33 DCHECK(m_scroller != scroller); | 33 DCHECK_NE(m_scroller, scroller); |
34 DCHECK(scroller); | 34 DCHECK(scroller); |
35 DCHECK(scroller->isRootFrameViewport() || scroller->isFrameView() || | 35 DCHECK(scroller->isRootFrameViewport() || scroller->isFrameView() || |
36 scroller->isPaintLayerScrollableArea()); | 36 scroller->isPaintLayerScrollableArea()); |
37 m_scroller = scroller; | 37 m_scroller = scroller; |
38 clearSelf(); | 38 clearSelf(); |
39 } | 39 } |
40 | 40 |
41 // TODO(pilgrim): Replace all instances of scrollerLayoutBox with | 41 // TODO(pilgrim): Replace all instances of scrollerLayoutBox with |
42 // scrollerLayoutBoxItem, https://crbug.com/499321 | 42 // scrollerLayoutBoxItem, https://crbug.com/499321 |
43 static LayoutBox* scrollerLayoutBox(const ScrollableArea* scroller) { | 43 static LayoutBox* scrollerLayoutBox(const ScrollableArea* scroller) { |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 if (findAnchorRecursive(descendant)) | 194 if (findAnchorRecursive(descendant)) |
195 return true; | 195 return true; |
196 } | 196 } |
197 } | 197 } |
198 } | 198 } |
199 } | 199 } |
200 | 200 |
201 if (result.status == Constrain) | 201 if (result.status == Constrain) |
202 return true; | 202 return true; |
203 | 203 |
204 DCHECK(result.status == Continue); | 204 DCHECK_EQ(result.status, Continue); |
205 return false; | 205 return false; |
206 } | 206 } |
207 | 207 |
208 bool ScrollAnchor::computeScrollAnchorDisablingStyleChanged() { | 208 bool ScrollAnchor::computeScrollAnchorDisablingStyleChanged() { |
209 LayoutObject* current = anchorObject(); | 209 LayoutObject* current = anchorObject(); |
210 if (!current) | 210 if (!current) |
211 return false; | 211 return false; |
212 | 212 |
213 LayoutObject* scrollerBox = scrollerLayoutBox(m_scroller); | 213 LayoutObject* scrollerBox = scrollerLayoutBox(m_scroller); |
214 while (true) { | 214 while (true) { |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
350 bool ScrollAnchor::refersTo(const LayoutObject* layoutObject) const { | 350 bool ScrollAnchor::refersTo(const LayoutObject* layoutObject) const { |
351 return m_anchorObject == layoutObject; | 351 return m_anchorObject == layoutObject; |
352 } | 352 } |
353 | 353 |
354 void ScrollAnchor::notifyRemoved(LayoutObject* layoutObject) { | 354 void ScrollAnchor::notifyRemoved(LayoutObject* layoutObject) { |
355 if (m_anchorObject == layoutObject) | 355 if (m_anchorObject == layoutObject) |
356 clearSelf(); | 356 clearSelf(); |
357 } | 357 } |
358 | 358 |
359 } // namespace blink | 359 } // namespace blink |
OLD | NEW |