| 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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 ASSERT_NOT_REACHED(); | 66 ASSERT_NOT_REACHED(); |
| 67 return LayoutPoint(); | 67 return LayoutPoint(); |
| 68 } | 68 } |
| 69 | 69 |
| 70 // Bounds of the LayoutObject relative to the scroller's visible content rect. | 70 // Bounds of the LayoutObject relative to the scroller's visible content rect. |
| 71 static LayoutRect relativeBounds(const LayoutObject* layoutObject, const Scrolla
bleArea* scroller) | 71 static LayoutRect relativeBounds(const LayoutObject* layoutObject, const Scrolla
bleArea* scroller) |
| 72 { | 72 { |
| 73 LayoutRect localBounds; | 73 LayoutRect localBounds; |
| 74 if (layoutObject->isBox()) { | 74 if (layoutObject->isBox()) { |
| 75 localBounds = toLayoutBox(layoutObject)->borderBoxRect(); | 75 localBounds = toLayoutBox(layoutObject)->borderBoxRect(); |
| 76 // borderBoxRect doesn't include overflow content and floats. |
| 77 LayoutUnit maxHeight = std::max(localBounds.height(), toLayoutBox(layout
Object)->layoutOverflowRect().height()); |
| 78 if (layoutObject->isLayoutBlockFlow() && toLayoutBlockFlow(layoutObject)
->containsFloats()) { |
| 79 // Note that lowestFloatLogicalBottom doesn't include floating |
| 80 // grandchildren. |
| 81 maxHeight = std::max(maxHeight, toLayoutBlockFlow(layoutObject)->low
estFloatLogicalBottom()); |
| 82 } |
| 83 localBounds.setHeight(maxHeight); |
| 76 } else if (layoutObject->isText()) { | 84 } else if (layoutObject->isText()) { |
| 77 // TODO(skobes): Use first and last InlineTextBox only? | 85 // TODO(skobes): Use first and last InlineTextBox only? |
| 78 for (InlineTextBox* box = toLayoutText(layoutObject)->firstTextBox(); bo
x; box = box->nextTextBox()) | 86 for (InlineTextBox* box = toLayoutText(layoutObject)->firstTextBox(); bo
x; box = box->nextTextBox()) |
| 79 localBounds.unite(box->calculateBoundaries()); | 87 localBounds.unite(box->calculateBoundaries()); |
| 80 } else { | 88 } else { |
| 81 // Only LayoutBox and LayoutText are supported. | 89 // Only LayoutBox and LayoutText are supported. |
| 82 ASSERT_NOT_REACHED(); | 90 ASSERT_NOT_REACHED(); |
| 83 } | 91 } |
| 84 LayoutRect relativeBounds = LayoutRect(layoutObject->localToAncestorQuad( | 92 LayoutRect relativeBounds = LayoutRect(layoutObject->localToAncestorQuad( |
| 85 FloatRect(localBounds), scrollerLayoutBox(scroller)).boundingBox()); | 93 FloatRect(localBounds), scrollerLayoutBox(scroller)).boundingBox()); |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 void ScrollAnchor::clear() | 222 void ScrollAnchor::clear() |
| 215 { | 223 { |
| 216 LayoutObject* anchorObject = m_anchorObject; | 224 LayoutObject* anchorObject = m_anchorObject; |
| 217 m_anchorObject = nullptr; | 225 m_anchorObject = nullptr; |
| 218 | 226 |
| 219 if (anchorObject) | 227 if (anchorObject) |
| 220 anchorObject->maybeClearIsScrollAnchorObject(); | 228 anchorObject->maybeClearIsScrollAnchorObject(); |
| 221 } | 229 } |
| 222 | 230 |
| 223 } // namespace blink | 231 } // namespace blink |
| OLD | NEW |