| 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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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()) { |
| 78 // borderBoxRect doesn't include overflow content and floats. | 78 // borderBoxRect doesn't include overflow content and floats. |
| 79 LayoutUnit maxHeight = | 79 LayoutUnit maxY = |
| 80 std::max(localBounds.height(), | 80 std::max(localBounds.maxY(), |
| 81 toLayoutBox(layoutObject)->layoutOverflowRect().height()); | 81 toLayoutBox(layoutObject)->layoutOverflowRect().maxY()); |
| 82 if (layoutObject->isLayoutBlockFlow() && | 82 if (layoutObject->isLayoutBlockFlow() && |
| 83 toLayoutBlockFlow(layoutObject)->containsFloats()) { | 83 toLayoutBlockFlow(layoutObject)->containsFloats()) { |
| 84 // Note that lowestFloatLogicalBottom doesn't include floating | 84 // Note that lowestFloatLogicalBottom doesn't include floating |
| 85 // grandchildren. | 85 // grandchildren. |
| 86 maxHeight = std::max( | 86 maxY = std::max( |
| 87 maxHeight, | 87 maxY, toLayoutBlockFlow(layoutObject)->lowestFloatLogicalBottom()); |
| 88 toLayoutBlockFlow(layoutObject)->lowestFloatLogicalBottom()); | |
| 89 } | 88 } |
| 90 localBounds.setHeight(maxHeight); | 89 localBounds.shiftMaxYEdgeTo(maxY); |
| 91 } | 90 } |
| 92 } else if (layoutObject->isText()) { | 91 } else if (layoutObject->isText()) { |
| 93 // TODO(skobes): Use first and last InlineTextBox only? | 92 // TODO(skobes): Use first and last InlineTextBox only? |
| 94 for (InlineTextBox* box = toLayoutText(layoutObject)->firstTextBox(); box; | 93 for (InlineTextBox* box = toLayoutText(layoutObject)->firstTextBox(); box; |
| 95 box = box->nextTextBox()) | 94 box = box->nextTextBox()) |
| 96 localBounds.unite(box->frameRect()); | 95 localBounds.unite(box->frameRect()); |
| 97 } else { | 96 } else { |
| 98 // Only LayoutBox and LayoutText are supported. | 97 // Only LayoutBox and LayoutText are supported. |
| 99 ASSERT_NOT_REACHED(); | 98 ASSERT_NOT_REACHED(); |
| 100 } | 99 } |
| (...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 330 bool ScrollAnchor::refersTo(const LayoutObject* layoutObject) const { | 329 bool ScrollAnchor::refersTo(const LayoutObject* layoutObject) const { |
| 331 return m_anchorObject == layoutObject; | 330 return m_anchorObject == layoutObject; |
| 332 } | 331 } |
| 333 | 332 |
| 334 void ScrollAnchor::notifyRemoved(LayoutObject* layoutObject) { | 333 void ScrollAnchor::notifyRemoved(LayoutObject* layoutObject) { |
| 335 if (m_anchorObject == layoutObject) | 334 if (m_anchorObject == layoutObject) |
| 336 clearSelf(); | 335 clearSelf(); |
| 337 } | 336 } |
| 338 | 337 |
| 339 } // namespace blink | 338 } // namespace blink |
| OLD | NEW |