Commit f7a9136e authored by robhogan@gmail.com's avatar robhogan@gmail.com

Ensure floats get added to floating objects list even if they don't have a linebox

In https://codereview.chromium.org/1132103007 the problem with the trailing float
in fast/block/float/trailing-float.html is that it doesn't have a linebox, so 
when line layout is run on a selection of dirty lineboxes on the parent it is
not re-added to the floating objects list and so doesn't get a paint. So the correct
fix is to ensure any floats not added to the floating objects list during line
layout are added, rather than to attempt to dirty more lines in the hope that
line layout will hit the float, add it to the floats list 
and so ensure it gets a paint.

BUG=510703

Review URL: https://codereview.chromium.org/1298603004

git-svn-id: svn://svn.chromium.org/blink/trunk@200915 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 19dde480
PASS
crbug.com/517030: Ensure trailing float gets a layout.
<!DOCTYPE html>
<object>
<span style="display: inline-block;"><span id="float" style="float: left; width: 1px; height: 150px" data-expected-height=0></span></span>
<div style="padding-top: 55%"></div>
</object>
<p>crbug.com/517030: Ensure trailing float gets a layout.</p>
<script src="../../../resources/check-layout.js"></script>
<script>
checkLayout('#float');
</script>
......@@ -529,7 +529,7 @@ private:
void layoutRunsAndFloatsInRange(LineLayoutState&, InlineBidiResolver&,
const InlineIterator& cleanLineStart, const BidiStatus& cleanLineBidiStatus);
void linkToEndLineIfNeeded(LineLayoutState&);
static void markDirtyFloatsForPaintInvalidation(Vector<FloatWithRect>& floats);
void markDirtyFloatsForPaintInvalidation(Vector<FloatWithRect>& floats);
RootInlineBox* determineStartPosition(LineLayoutState&, InlineBidiResolver&);
void determineEndPosition(LineLayoutState&, RootInlineBox* startBox, InlineIterator& cleanLineStart, BidiStatus& cleanLineBidiStatus);
bool lineBoxHasBRWithClearance(RootInlineBox*);
......
......@@ -1042,12 +1042,14 @@ void LayoutBlockFlow::markDirtyFloatsForPaintInvalidation(Vector<FloatWithRect>&
// painted by now if they had moved, but if they stayed at (0, 0), they still need to be
// painted.
for (size_t i = 0; i < floatCount; ++i) {
LayoutBox* f = floats[i].object;
if (!floats[i].everHadLayout) {
LayoutBox* f = floats[i].object;
if (!f->location().x() && !f->location().y())
f->setShouldDoFullPaintInvalidation();
}
insertFloatingObject(*f);
}
positionNewFloats();
}
struct InlineMinMaxIterator {
......@@ -1530,7 +1532,6 @@ void LayoutBlockFlow::layoutInlineChildren(bool relayoutChildren, LayoutUnit& pa
// deleted and only dirtied. In that case, we can layout the replaced
// elements at the same time.
Vector<LayoutBox*> replacedChildren;
LayoutObject* lastChild = nullptr;
for (InlineWalker walker(this); !walker.atEnd(); walker.advance()) {
LayoutObject* o = walker.current();
......@@ -1565,13 +1566,7 @@ void LayoutBlockFlow::layoutInlineChildren(bool relayoutChildren, LayoutUnit& pa
dirtyLineBoxesForObject(o, layoutState.isFullLayout());
o->clearNeedsLayout();
}
if (!o->isText() || !toLayoutText(o)->isAllCollapsibleWhitespace())
lastChild = o;
}
// If there is a trailing float on the line that will possibly occur after a natural line break
// then dirty its adjacent lineboxes to ensure it gets placed.
if (lastChild && lastChild->isFloating())
dirtyLinesFromChangedChild(lastChild);
for (size_t i = 0; i < replacedChildren.size(); i++)
replacedChildren[i]->layoutIfNeeded();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment