Commit 5e75268d authored by Morten Stenshorne's avatar Morten Stenshorne Committed by Commit Bot

[LayoutNG] Allow zero-width layout opportunities.

Zero-width floats or in-flow block-level objects that establish a new formatting
context may fit beside preceding floats even if there's zero inline space left.

With this change, a couple of tests start passing, but coverage seems a
bit low, so I added a few new ones.

Had to rebaseline fast/text/word-break.html because a zero-width line
may now fit beside a float that takes up all available inline
space. There was a <br clear=all> in the test that used to insert the
line below such a float. We're now compatible with the others (and our
old selves).

Cq-Include-Trybots: master.tryserver.chromium.linux:linux_layout_tests_layout_ng
Change-Id: Iaf394b7039545eea235b2841457f1662e5890ba9
Reviewed-on: https://chromium-review.googlesource.com/916262
Commit-Queue: Morten Stenshorne <mstensho@chromium.org>
Reviewed-by: default avatarIan Kilpatrick <ikilpatrick@chromium.org>
Reviewed-by: default avatarKoji Ishii <kojii@chromium.org>
Cr-Commit-Position: refs/heads/master@{#537000}
parent 8f4afda5
......@@ -2367,7 +2367,6 @@ crbug.com/810335 fast/block/float/003.html [ Failure ]
crbug.com/591099 fast/block/float/br-with-clear-2.html [ Failure ]
crbug.com/591099 fast/block/float/element-clears-float-without-clearance.html [ Failure ]
crbug.com/591099 fast/block/float/float-avoidance.html [ Failure ]
crbug.com/591099 fast/block/float/float-forced-below-other-floats.html [ Failure ]
crbug.com/591099 fast/block/float/float-in-float-hit-testing.html [ Failure ]
crbug.com/591099 fast/block/float/float-in-float-painting.html [ Failure ]
crbug.com/591099 fast/block/float/float-should-dirty-line-when-adjacent-to-line-breaks-2.html [ Failure ]
......@@ -2381,7 +2380,6 @@ crbug.com/591099 fast/block/float/nopaint-after-layer-destruction2.html [ Failur
crbug.com/810370 fast/block/float/overhanging-float-remove-from-fixed-position-block.html [ Failure ]
crbug.com/810370 fast/block/float/overhanging-float-remove-from-fixed-position-block2.html [ Failure ]
crbug.com/591099 fast/block/float/overlapping-floats-paint-hittest-order-1.html [ Failure ]
crbug.com/591099 fast/block/float/overlapping-floats-paint-hittest-order-2.html [ Failure ]
crbug.com/591099 fast/block/line-layout/floats-do-not-fit-on-line.html [ Failure ]
crbug.com/591099 fast/block/line-layout/line-break-removal-near-textarea-crash.html [ Failure ]
crbug.com/591099 fast/block/margin-collapse/clear-nested-float-more-than-one-previous-sibling-away.html [ Failure ]
......@@ -2628,7 +2626,6 @@ crbug.com/591099 fast/css-grid-layout/minmax-min-content-column-resolution-colum
crbug.com/591099 fast/css-grid-layout/minmax-min-content-column-resolution-rows.html [ Failure ]
crbug.com/591099 fast/css-grid-layout/minmax-spanning-resolution-columns.html [ Failure ]
crbug.com/591099 fast/css-grid-layout/minmax-spanning-resolution-rows.html [ Failure ]
crbug.com/591099 fast/css-grid-layout/mozilla/grid-repeat-auto-fill-fit-005-part-1.html [ Failure ]
crbug.com/591099 fast/css-grid-layout/named-grid-line-get-set.html [ Pass Timeout ]
crbug.com/591099 fast/css-grid-layout/named-grid-lines-with-named-grid-areas-dynamic-get-set.html [ Failure ]
crbug.com/591099 fast/css-grid-layout/named-grid-lines-with-named-grid-areas-resolution.html [ Failure ]
......@@ -6407,7 +6404,6 @@ crbug.com/714962 svg/transforms/text-with-mask-with-svg-transform.svg [ Failure
crbug.com/591099 svg/transforms/text-with-pattern-inside-transformed-html.xhtml [ Failure ]
crbug.com/714962 svg/transforms/text-with-pattern-with-svg-transform.svg [ Failure ]
crbug.com/591099 svg/transforms/transformed-text-fill-pattern.html [ Failure ]
crbug.com/591099 svg/wicd/rightsizing-grid.html [ Failure ]
crbug.com/591099 svg/wicd/test-rightsizing-a.xhtml [ Failure ]
crbug.com/591099 svg/wicd/test-rightsizing-b.xhtml [ Failure ]
crbug.com/591099 svg/wicd/test-scalable-background-image1.xhtml [ Crash ]
......
......@@ -311,7 +311,6 @@ crbug.com/635619 virtual/layout_ng/fast/block/float/float-at-start-of-clean-line
crbug.com/635619 [ Mac ] virtual/layout_ng/fast/block/float/floats-and-text-indent.html [ Failure ]
crbug.com/635619 virtual/layout_ng/fast/block/float/float-at-start-of-clean-lines-that-are-subsequently-dirtied.html [ Failure ]
crbug.com/635619 virtual/layout_ng/fast/block/float/float-avoidance.html [ Failure ]
crbug.com/635619 virtual/layout_ng/fast/block/float/float-forced-below-other-floats.html [ Failure ]
crbug.com/635619 virtual/layout_ng/fast/block/float/float-in-float-hit-testing.html [ Failure ]
crbug.com/635619 virtual/layout_ng/fast/block/float/float-in-float-painting.html [ Failure ]
crbug.com/635619 virtual/layout_ng/fast/block/float/float-inserted-into-clean-line.html [ Failure ]
......@@ -330,7 +329,6 @@ crbug.com/635619 virtual/layout_ng/fast/block/float/nopaint-after-layer-destruct
crbug.com/810370 virtual/layout_ng/fast/block/float/overhanging-float-remove-from-fixed-position-block.html [ Failure ]
crbug.com/810370 virtual/layout_ng/fast/block/float/overhanging-float-remove-from-fixed-position-block2.html [ Failure ]
crbug.com/635619 virtual/layout_ng/fast/block/float/overlapping-floats-paint-hittest-order-1.html [ Failure ]
crbug.com/635619 virtual/layout_ng/fast/block/float/overlapping-floats-paint-hittest-order-2.html [ Failure ]
crbug.com/635619 [ Mac ] virtual/layout_ng/fast/block/float/overhanging-tall-block.html [ Failure ]
crbug.com/635619 virtual/layout_ng/fast/block/float/rubybase-children-moved-crash.html [ Crash Pass ]
crbug.com/635619 [ Mac ] virtual/layout_ng/fast/block/float/width-update-after-clear.html [ Failure ]
......
<!DOCTYPE html>
<title>A zero-width new formatting context should fit in a zero-width layout opportunity between floats</title>
<link rel="author" title="Morten Stenshorne" href="mstensho@chromium.org">
<link rel="help" href="https://www.w3.org/TR/CSS22/visuren.html#float-position" title="9.5.1 Positioning the float: the 'float' property">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/check-layout-th.js"></script>
<div id="container" style="position:relative; width:200px;">
<div style="float:left; width:100px; height:200px;"></div>
<div style="float:right; width:100px; height:200px;"></div>
<div data-offset-x="100" data-offset-y="0" style="overflow:hidden; width:0; height:200px;"></div>
</div>
<script>
checkLayout("#container");
</script>
<!DOCTYPE html>
<title>A zero-width new formatting context should fit in a zero-width layout opportunity between floats, above a 100% wide float</title>
<link rel="author" title="Morten Stenshorne" href="mstensho@chromium.org">
<link rel="help" href="https://www.w3.org/TR/CSS22/visuren.html#float-position" title="9.5.1 Positioning the float: the 'float' property">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/check-layout-th.js"></script>
<div id="container" style="position:relative; width:200px;">
<div style="float:left; width:100px; height:200px;"></div>
<div style="float:right; width:100px; height:200px;"></div>
<div style="float:right; width:100%; height:10px;"></div>
<div data-offset-x="100" data-offset-y="0" style="overflow:hidden; width:0; height:200px;"></div>
</div>
<script>
checkLayout("#container");
</script>
<!DOCTYPE html>
<title>Zero-width new formatting context with clearance</title>
<link rel="author" title="Morten Stenshorne" href="mstensho@chromium.org">
<link rel="help" href="https://www.w3.org/TR/CSS22/visuren.html#float-position" title="9.5.1 Positioning the float: the 'float' property">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/check-layout-th.js"></script>
<div id="container" style="position:relative; width:200px;">
<div style="float:left; width:100px; height:100px;"></div>
<div style="float:right; width:100px; height:100px;"></div>
<div style="float:right; width:100%; height:100px;"></div>
<div data-offset-x="0" data-offset-y="100" style="overflow:hidden; clear:left; width:0;"></div>
</div>
<script>
checkLayout("#container");
</script>
<!DOCTYPE html>
<title>Zero-width new formatting context with clearance</title>
<link rel="author" title="Morten Stenshorne" href="mstensho@chromium.org">
<link rel="help" href="https://www.w3.org/TR/CSS22/visuren.html#float-position" title="9.5.1 Positioning the float: the 'float' property">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/check-layout-th.js"></script>
<div id="container" style="position:relative; width:200px;">
<div style="float:left; width:100px; height:100px;"></div>
<div style="float:right; width:100px; height:100px;"></div>
<div style="float:right; width:100%; height:100px;"></div>
<div data-offset-x="0" data-offset-y="200" style="overflow:hidden; clear:right; width:0;"></div>
</div>
<script>
checkLayout("#container");
</script>
......@@ -102,9 +102,9 @@ bool Intersects(const NGExclusionSpace::NGShelf& shelf,
const NGBfcOffset& offset,
const LayoutUnit inline_size) {
return (shelf.line_right == LayoutUnit::Max() ||
shelf.line_right > offset.line_offset) &&
shelf.line_right >= offset.line_offset) &&
(shelf.line_left == LayoutUnit::Min() ||
shelf.line_left < offset.line_offset + inline_size);
shelf.line_left <= offset.line_offset + inline_size);
}
// Creates a new layout opportunity. The given layout opportunity *must*
......@@ -346,10 +346,11 @@ void NGExclusionSpace::Add(scoped_refptr<const NGExclusion> exclusion) {
(i > 0) && shelf.line_left == shelves_[i - 1].line_left &&
shelf.line_right == shelves_[i - 1].line_right;
// The shelf also may now be non-existent.
bool shelf_has_zero_size = shelf.line_right <= shelf.line_left;
// The shelf also may now be non-existent. Note that zero inline size is
// allowed, since subsequent zero-size content may still fit there.
bool shelf_disappearing = shelf.line_right < shelf.line_left;
if (is_same_as_previous || shelf_has_zero_size) {
if (is_same_as_previous || shelf_disappearing) {
shelves_.EraseAt(i);
removed_shelf = true;
}
......@@ -458,7 +459,7 @@ Vector<NGLayoutOpportunity> NGExclusionSpace::AllLayoutOpportunities(
continue;
}
// We always perfer the closed-off opportunity, instead of the shelf
// We always prefer the closed-off opportunity, instead of the shelf
// opportunity if they exist at the some offset.
if (opportunity.rect.BlockStartOffset() <= shelf.block_offset) {
opportunities.push_back(CreateLayoutOpportunity(opportunity, offset,
......
......@@ -83,17 +83,31 @@ TEST(NGExclusionSpaceTest, SingleExclusion) {
NGBfcOffset(LayoutUnit(-10), LayoutUnit(90)),
NGBfcOffset(LayoutUnit(90), LayoutUnit::Max()));
// This will still produce three opportunities, with a zero-width RHS
// opportunity.
opportunites = exclusion_space.AllLayoutOpportunities(
/* offset */ {LayoutUnit(10), LayoutUnit(10)},
/* available_size */ LayoutUnit(50));
EXPECT_EQ(3u, opportunites.size());
TEST_OPPORTUNITY(opportunites[0], NGBfcOffset(LayoutUnit(10), LayoutUnit(10)),
NGBfcOffset(LayoutUnit(60), LayoutUnit(20)));
TEST_OPPORTUNITY(opportunites[1], NGBfcOffset(LayoutUnit(60), LayoutUnit(10)),
NGBfcOffset(LayoutUnit(60), LayoutUnit::Max()));
TEST_OPPORTUNITY(opportunites[2], NGBfcOffset(LayoutUnit(10), LayoutUnit(90)),
NGBfcOffset(LayoutUnit(60), LayoutUnit::Max()));
// This will only produce two opportunities, as the RHS opportunity will be
// outside the search area.
opportunites = exclusion_space.AllLayoutOpportunities(
/* offset */ {LayoutUnit(10), LayoutUnit(10)},
/* available_size */ LayoutUnit(50));
/* available_size */ LayoutUnit(49));
EXPECT_EQ(2u, opportunites.size());
TEST_OPPORTUNITY(opportunites[0], NGBfcOffset(LayoutUnit(10), LayoutUnit(10)),
NGBfcOffset(LayoutUnit(60), LayoutUnit(20)));
NGBfcOffset(LayoutUnit(59), LayoutUnit(20)));
TEST_OPPORTUNITY(opportunites[1], NGBfcOffset(LayoutUnit(10), LayoutUnit(90)),
NGBfcOffset(LayoutUnit(60), LayoutUnit::Max()));
NGBfcOffset(LayoutUnit(59), LayoutUnit::Max()));
}
TEST(NGExclusionSpaceTest, TwoExclusions) {
......
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