Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(785)

Side by Side Diff: third_party/WebKit/Source/core/layout/ScrollAnchor.cpp

Issue 2136323002: Properly calculate the localBounds for elements with overflow clipped (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: review nit Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/layout/ScrollAnchorTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/layout/ScrollAnchorTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698