| 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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 return Corner::TopLeft; | 57 return Corner::TopLeft; |
| 58 } | 58 } |
| 59 | 59 |
| 60 static LayoutPoint cornerPointOfRect(LayoutRect rect, Corner whichCorner) { | 60 static LayoutPoint cornerPointOfRect(LayoutRect rect, Corner whichCorner) { |
| 61 switch (whichCorner) { | 61 switch (whichCorner) { |
| 62 case Corner::TopLeft: | 62 case Corner::TopLeft: |
| 63 return rect.minXMinYCorner(); | 63 return rect.minXMinYCorner(); |
| 64 case Corner::TopRight: | 64 case Corner::TopRight: |
| 65 return rect.maxXMinYCorner(); | 65 return rect.maxXMinYCorner(); |
| 66 } | 66 } |
| 67 ASSERT_NOT_REACHED(); | 67 NOTREACHED(); |
| 68 return LayoutPoint(); | 68 return LayoutPoint(); |
| 69 } | 69 } |
| 70 | 70 |
| 71 // Bounds of the LayoutObject relative to the scroller's visible content rect. | 71 // Bounds of the LayoutObject relative to the scroller's visible content rect. |
| 72 static LayoutRect relativeBounds(const LayoutObject* layoutObject, | 72 static LayoutRect relativeBounds(const LayoutObject* layoutObject, |
| 73 const ScrollableArea* scroller) { | 73 const ScrollableArea* scroller) { |
| 74 LayoutRect localBounds; | 74 LayoutRect localBounds; |
| 75 if (layoutObject->isBox()) { | 75 if (layoutObject->isBox()) { |
| 76 localBounds = toLayoutBox(layoutObject)->borderBoxRect(); | 76 localBounds = toLayoutBox(layoutObject)->borderBoxRect(); |
| 77 if (!layoutObject->hasOverflowClip()) { | 77 if (!layoutObject->hasOverflowClip()) { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 88 } | 88 } |
| 89 localBounds.shiftMaxYEdgeTo(maxY); | 89 localBounds.shiftMaxYEdgeTo(maxY); |
| 90 } | 90 } |
| 91 } else if (layoutObject->isText()) { | 91 } else if (layoutObject->isText()) { |
| 92 // TODO(skobes): Use first and last InlineTextBox only? | 92 // TODO(skobes): Use first and last InlineTextBox only? |
| 93 for (InlineTextBox* box = toLayoutText(layoutObject)->firstTextBox(); box; | 93 for (InlineTextBox* box = toLayoutText(layoutObject)->firstTextBox(); box; |
| 94 box = box->nextTextBox()) | 94 box = box->nextTextBox()) |
| 95 localBounds.unite(box->frameRect()); | 95 localBounds.unite(box->frameRect()); |
| 96 } else { | 96 } else { |
| 97 // Only LayoutBox and LayoutText are supported. | 97 // Only LayoutBox and LayoutText are supported. |
| 98 ASSERT_NOT_REACHED(); | 98 NOTREACHED(); |
| 99 } | 99 } |
| 100 | 100 |
| 101 LayoutRect relativeBounds = LayoutRect( | 101 LayoutRect relativeBounds = LayoutRect( |
| 102 scroller->localToVisibleContentQuad(FloatRect(localBounds), layoutObject) | 102 scroller->localToVisibleContentQuad(FloatRect(localBounds), layoutObject) |
| 103 .boundingBox()); | 103 .boundingBox()); |
| 104 | 104 |
| 105 return relativeBounds; | 105 return relativeBounds; |
| 106 } | 106 } |
| 107 | 107 |
| 108 static LayoutPoint computeRelativeOffset(const LayoutObject* layoutObject, | 108 static LayoutPoint computeRelativeOffset(const LayoutObject* layoutObject, |
| (...skipping 241 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 |