| 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/LayoutView.h" | 9 #include "core/layout/LayoutView.h" |
| 10 #include "core/layout/line/InlineTextBox.h" | 10 #include "core/layout/line/InlineTextBox.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 , m_corner(Corner::TopLeft) | 21 , m_corner(Corner::TopLeft) |
| 22 { | 22 { |
| 23 ASSERT(m_scroller); | 23 ASSERT(m_scroller); |
| 24 ASSERT(m_scroller->isFrameView() || m_scroller->isPaintLayerScrollableArea()
); | 24 ASSERT(m_scroller->isFrameView() || m_scroller->isPaintLayerScrollableArea()
); |
| 25 } | 25 } |
| 26 | 26 |
| 27 ScrollAnchor::~ScrollAnchor() | 27 ScrollAnchor::~ScrollAnchor() |
| 28 { | 28 { |
| 29 } | 29 } |
| 30 | 30 |
| 31 // TODO(pilgrim) replace all instances of scrollerLayoutBox with scrollerLayoutB
oxItem |
| 32 // https://crbug.com/499321 |
| 31 static LayoutBox* scrollerLayoutBox(const ScrollableArea* scroller) | 33 static LayoutBox* scrollerLayoutBox(const ScrollableArea* scroller) |
| 32 { | 34 { |
| 33 LayoutBox* box = scroller->isFrameView() | 35 LayoutBox* box = scroller->isFrameView() |
| 34 ? toFrameView(scroller)->layoutView() | 36 ? toFrameView(scroller)->layoutView() |
| 35 : &toPaintLayerScrollableArea(scroller)->box(); | 37 : &toPaintLayerScrollableArea(scroller)->box(); |
| 36 ASSERT(box); | 38 ASSERT(box); |
| 37 return box; | 39 return box; |
| 38 } | 40 } |
| 39 | 41 |
| 42 static LayoutBoxItem scrollerLayoutBoxItem(const ScrollableArea* scroller) |
| 43 { |
| 44 LayoutBoxItem box = scroller->isFrameView() |
| 45 ? toFrameView(scroller)->layoutViewItem() |
| 46 : LayoutBoxItem(&toPaintLayerScrollableArea(scroller)->box()); |
| 47 ASSERT(!box.isNull()); |
| 48 return box; |
| 49 } |
| 50 |
| 40 static Corner cornerFromCandidateRect(LayoutRect candidateRect, LayoutRect visib
leRect) | 51 static Corner cornerFromCandidateRect(LayoutRect candidateRect, LayoutRect visib
leRect) |
| 41 { | 52 { |
| 42 if (visibleRect.contains(candidateRect.minXMinYCorner())) | 53 if (visibleRect.contains(candidateRect.minXMinYCorner())) |
| 43 return Corner::TopLeft; | 54 return Corner::TopLeft; |
| 44 if (visibleRect.contains(candidateRect.maxXMinYCorner())) | 55 if (visibleRect.contains(candidateRect.maxXMinYCorner())) |
| 45 return Corner::TopRight; | 56 return Corner::TopRight; |
| 46 if (visibleRect.contains(candidateRect.minXMaxYCorner())) | 57 if (visibleRect.contains(candidateRect.minXMaxYCorner())) |
| 47 return Corner::BottomLeft; | 58 return Corner::BottomLeft; |
| 48 if (visibleRect.contains(candidateRect.maxXMaxYCorner())) | 59 if (visibleRect.contains(candidateRect.maxXMaxYCorner())) |
| 49 return Corner::BottomRight; | 60 return Corner::BottomRight; |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 if (candidate->isLayoutInline()) | 114 if (candidate->isLayoutInline()) |
| 104 return ExamineResult(Continue); | 115 return ExamineResult(Continue); |
| 105 | 116 |
| 106 if (!candidate->isText() && !candidate->isBox()) | 117 if (!candidate->isText() && !candidate->isBox()) |
| 107 return ExamineResult(Skip); | 118 return ExamineResult(Skip); |
| 108 | 119 |
| 109 if (!candidateMovesWithScroller(candidate, m_scroller)) | 120 if (!candidateMovesWithScroller(candidate, m_scroller)) |
| 110 return ExamineResult(Skip); | 121 return ExamineResult(Skip); |
| 111 | 122 |
| 112 LayoutRect candidateRect = relativeBounds(candidate, m_scroller); | 123 LayoutRect candidateRect = relativeBounds(candidate, m_scroller); |
| 113 LayoutRect visibleRect = scrollerLayoutBox(m_scroller)->overflowClipRect(Lay
outPoint()); | 124 LayoutRect visibleRect = scrollerLayoutBoxItem(m_scroller).overflowClipRect(
LayoutPoint()); |
| 114 | 125 |
| 115 bool occupiesSpace = candidateRect.width() > 0 && candidateRect.height() > 0
; | 126 bool occupiesSpace = candidateRect.width() > 0 && candidateRect.height() > 0
; |
| 116 if (occupiesSpace && visibleRect.intersects(candidateRect)) { | 127 if (occupiesSpace && visibleRect.intersects(candidateRect)) { |
| 117 return ExamineResult( | 128 return ExamineResult( |
| 118 visibleRect.contains(candidateRect) ? Return : Constrain, | 129 visibleRect.contains(candidateRect) ? Return : Constrain, |
| 119 cornerFromCandidateRect(candidateRect, visibleRect)); | 130 cornerFromCandidateRect(candidateRect, visibleRect)); |
| 120 } else { | 131 } else { |
| 121 return ExamineResult(Skip); | 132 return ExamineResult(Skip); |
| 122 } | 133 } |
| 123 } | 134 } |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 void ScrollAnchor::clear() | 209 void ScrollAnchor::clear() |
| 199 { | 210 { |
| 200 LayoutObject* anchorObject = m_anchorObject; | 211 LayoutObject* anchorObject = m_anchorObject; |
| 201 m_anchorObject = nullptr; | 212 m_anchorObject = nullptr; |
| 202 | 213 |
| 203 if (anchorObject) | 214 if (anchorObject) |
| 204 anchorObject->maybeClearIsScrollAnchorObject(); | 215 anchorObject->maybeClearIsScrollAnchorObject(); |
| 205 } | 216 } |
| 206 | 217 |
| 207 } // namespace blink | 218 } // namespace blink |
| OLD | NEW |