| 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/line/InlineTextBox.h" | 9 #include "core/layout/line/InlineTextBox.h" |
| 10 #include "core/paint/PaintLayerScrollableArea.h" | 10 #include "core/paint/PaintLayerScrollableArea.h" |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 ASSERT_NOT_REACHED(); | 72 ASSERT_NOT_REACHED(); |
| 73 return LayoutPoint(); | 73 return LayoutPoint(); |
| 74 } | 74 } |
| 75 | 75 |
| 76 // Bounds of the LayoutObject relative to the scroller's visible content rect. | 76 // Bounds of the LayoutObject relative to the scroller's visible content rect. |
| 77 static LayoutRect relativeBounds(const LayoutObject* layoutObject, const Scrolla
bleArea* scroller) | 77 static LayoutRect relativeBounds(const LayoutObject* layoutObject, const Scrolla
bleArea* scroller) |
| 78 { | 78 { |
| 79 LayoutRect localBounds; | 79 LayoutRect localBounds; |
| 80 if (layoutObject->isBox()) { | 80 if (layoutObject->isBox()) { |
| 81 localBounds = toLayoutBox(layoutObject)->borderBoxRect(); | 81 localBounds = toLayoutBox(layoutObject)->borderBoxRect(); |
| 82 // borderBoxRect doesn't include overflow content and floats. | 82 if (!layoutObject->hasOverflowClip()) { |
| 83 LayoutUnit maxHeight = std::max(localBounds.height(), toLayoutBox(layout
Object)->layoutOverflowRect().height()); | 83 // borderBoxRect doesn't include overflow content and floats. |
| 84 if (layoutObject->isLayoutBlockFlow() && toLayoutBlockFlow(layoutObject)
->containsFloats()) { | 84 LayoutUnit maxHeight = std::max(localBounds.height(), toLayoutBox(la
youtObject)->layoutOverflowRect().height()); |
| 85 // Note that lowestFloatLogicalBottom doesn't include floating | 85 if (layoutObject->isLayoutBlockFlow() && toLayoutBlockFlow(layoutObj
ect)->containsFloats()) { |
| 86 // grandchildren. | 86 // Note that lowestFloatLogicalBottom doesn't include floating |
| 87 maxHeight = std::max(maxHeight, toLayoutBlockFlow(layoutObject)->low
estFloatLogicalBottom()); | 87 // grandchildren. |
| 88 maxHeight = std::max(maxHeight, toLayoutBlockFlow(layoutObject)-
>lowestFloatLogicalBottom()); |
| 89 } |
| 90 localBounds.setHeight(maxHeight); |
| 88 } | 91 } |
| 89 localBounds.setHeight(maxHeight); | |
| 90 } else if (layoutObject->isText()) { | 92 } else if (layoutObject->isText()) { |
| 91 // TODO(skobes): Use first and last InlineTextBox only? | 93 // TODO(skobes): Use first and last InlineTextBox only? |
| 92 for (InlineTextBox* box = toLayoutText(layoutObject)->firstTextBox(); bo
x; box = box->nextTextBox()) | 94 for (InlineTextBox* box = toLayoutText(layoutObject)->firstTextBox(); bo
x; box = box->nextTextBox()) |
| 93 localBounds.unite(box->calculateBoundaries()); | 95 localBounds.unite(box->calculateBoundaries()); |
| 94 } else { | 96 } else { |
| 95 // Only LayoutBox and LayoutText are supported. | 97 // Only LayoutBox and LayoutText are supported. |
| 96 ASSERT_NOT_REACHED(); | 98 ASSERT_NOT_REACHED(); |
| 97 } | 99 } |
| 98 LayoutRect relativeBounds = LayoutRect(layoutObject->localToAncestorQuad( | 100 LayoutRect relativeBounds = LayoutRect(layoutObject->localToAncestorQuad( |
| 99 FloatRect(localBounds), scrollerLayoutBox(scroller)).boundingBox()); | 101 FloatRect(localBounds), scrollerLayoutBox(scroller)).boundingBox()); |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 308 | 310 |
| 309 void ScrollAnchor::notifyRemoved(LayoutObject* layoutObject) | 311 void ScrollAnchor::notifyRemoved(LayoutObject* layoutObject) |
| 310 { | 312 { |
| 311 if (m_current.m_anchorObject == layoutObject) | 313 if (m_current.m_anchorObject == layoutObject) |
| 312 m_current.clear(); | 314 m_current.clear(); |
| 313 if (m_lastAdjusted.m_anchorObject == layoutObject) | 315 if (m_lastAdjusted.m_anchorObject == layoutObject) |
| 314 m_lastAdjusted.clear(); | 316 m_lastAdjusted.clear(); |
| 315 } | 317 } |
| 316 | 318 |
| 317 } // namespace blink | 319 } // namespace blink |
| OLD | NEW |