Commit a83d1dd4 authored by Koji Ishii's avatar Koji Ishii Committed by Commit Bot

[LayoutNG] Make floats push line boxes down if no break opportunities can fit

When no break opportunities can fit in a line that has floats and/or
exclusions, such line box should be pushed down to avoid them.

A simple example is "float: left; width: 100%". This patch supports both
100% case and other cases in slightly different code paths since
NGLayoutOpportunityIterator handles 100% case differently.

Rewind() has been used for next lines, but this is the first case where
NGLineBreaker rewinds and process the current line again. Initializing
states is moved to NextLine() from BreakLine() to make this possible.

This patch also includes fix to avoid processing the same floats twice.
This should have been an issue when Rewind() is used, but it was not
handled properly before. The fix isn't very clean though, this should be
revisited.

Moved from a Reitveld CL[1].

[1] https://codereview.chromium.org/2955843002

Bug: 636993
Cq-Include-Trybots: master.tryserver.chromium.linux:linux_layout_tests_layout_ng
Change-Id: Ideae5ae00374c500f858bb992d5d3203772829a2
Reviewed-on: https://chromium-review.googlesource.com/582249
Commit-Queue: Koji Ishii <kojii@chromium.org>
Reviewed-by: default avatarIan Kilpatrick <ikilpatrick@chromium.org>
Cr-Commit-Position: refs/heads/master@{#492019}
parent df40dcca
...@@ -3441,6 +3441,9 @@ crbug.com/591099 external/wpt/css/css-shapes-1/shape-outside/shape-box/shape-out ...@@ -3441,6 +3441,9 @@ crbug.com/591099 external/wpt/css/css-shapes-1/shape-outside/shape-box/shape-out
crbug.com/591099 external/wpt/css/css-shapes-1/shape-outside/shape-box/shape-outside-box-007.html [ Failure ] crbug.com/591099 external/wpt/css/css-shapes-1/shape-outside/shape-box/shape-outside-box-007.html [ Failure ]
crbug.com/591099 external/wpt/css/css-shapes-1/shape-outside/shape-box/shape-outside-box-008.html [ Failure ] crbug.com/591099 external/wpt/css/css-shapes-1/shape-outside/shape-box/shape-outside-box-008.html [ Failure ]
crbug.com/591099 external/wpt/css/css-shapes-1/shape-outside/shape-image/gradients/shape-outside-linear-gradient-001.html [ Failure ] crbug.com/591099 external/wpt/css/css-shapes-1/shape-outside/shape-image/gradients/shape-outside-linear-gradient-001.html [ Failure ]
crbug.com/591099 external/wpt/css/css-shapes-1/shape-outside/shape-image/gradients/shape-outside-linear-gradient-002.html [ Failure ]
crbug.com/591099 external/wpt/css/css-shapes-1/shape-outside/shape-image/gradients/shape-outside-linear-gradient-003.html [ Failure ]
crbug.com/591099 external/wpt/css/css-shapes-1/shape-outside/shape-image/gradients/shape-outside-linear-gradient-004.html [ Failure ]
crbug.com/591099 external/wpt/css/css-shapes-1/shape-outside/shape-image/gradients/shape-outside-radial-gradient-001.html [ Failure ] crbug.com/591099 external/wpt/css/css-shapes-1/shape-outside/shape-image/gradients/shape-outside-radial-gradient-001.html [ Failure ]
crbug.com/591099 external/wpt/css/css-shapes-1/shape-outside/shape-image/gradients/shape-outside-radial-gradient-002.html [ Failure ] crbug.com/591099 external/wpt/css/css-shapes-1/shape-outside/shape-image/gradients/shape-outside-radial-gradient-002.html [ Failure ]
crbug.com/591099 external/wpt/css/css-shapes-1/shape-outside/shape-image/gradients/shape-outside-radial-gradient-003.html [ Failure ] crbug.com/591099 external/wpt/css/css-shapes-1/shape-outside/shape-image/gradients/shape-outside-radial-gradient-003.html [ Failure ]
...@@ -3459,6 +3462,9 @@ crbug.com/591099 external/wpt/css/css-shapes-1/shape-outside/shape-image/shape-i ...@@ -3459,6 +3462,9 @@ crbug.com/591099 external/wpt/css/css-shapes-1/shape-outside/shape-image/shape-i
crbug.com/591099 external/wpt/css/css-shapes-1/shape-outside/shape-image/shape-image-012.html [ Failure ] crbug.com/591099 external/wpt/css/css-shapes-1/shape-outside/shape-image/shape-image-012.html [ Failure ]
crbug.com/591099 external/wpt/css/css-shapes-1/shape-outside/shape-image/shape-image-013.html [ Failure ] crbug.com/591099 external/wpt/css/css-shapes-1/shape-outside/shape-image/shape-image-013.html [ Failure ]
crbug.com/591099 external/wpt/css/css-shapes-1/shape-outside/shape-image/shape-image-014.html [ Failure ] crbug.com/591099 external/wpt/css/css-shapes-1/shape-outside/shape-image/shape-image-014.html [ Failure ]
crbug.com/591099 external/wpt/css/css-shapes-1/shape-outside/shape-image/shape-image-015.html [ Failure ]
crbug.com/591099 external/wpt/css/css-shapes-1/shape-outside/shape-image/shape-image-016.html [ Failure ]
crbug.com/591099 external/wpt/css/css-shapes-1/shape-outside/shape-image/shape-image-017.html [ Failure ]
crbug.com/591099 external/wpt/css/css-shapes-1/shape-outside/shape-image/shape-image-018.html [ Failure ] crbug.com/591099 external/wpt/css/css-shapes-1/shape-outside/shape-image/shape-image-018.html [ Failure ]
crbug.com/591099 external/wpt/css/css-shapes-1/shape-outside/shape-image/shape-image-019.html [ Failure ] crbug.com/591099 external/wpt/css/css-shapes-1/shape-outside/shape-image/shape-image-019.html [ Failure ]
crbug.com/591099 external/wpt/css/css-shapes-1/shape-outside/shape-image/shape-image-020.html [ Failure ] crbug.com/591099 external/wpt/css/css-shapes-1/shape-outside/shape-image/shape-image-020.html [ Failure ]
...@@ -3510,6 +3516,8 @@ crbug.com/591099 external/wpt/css/css-shapes-1/shape-outside/supported-shapes/po ...@@ -3510,6 +3516,8 @@ crbug.com/591099 external/wpt/css/css-shapes-1/shape-outside/supported-shapes/po
crbug.com/591099 external/wpt/css/css-shapes-1/shape-outside/supported-shapes/polygon/shape-outside-polygon-009.html [ Failure ] crbug.com/591099 external/wpt/css/css-shapes-1/shape-outside/supported-shapes/polygon/shape-outside-polygon-009.html [ Failure ]
crbug.com/591099 external/wpt/css/css-shapes-1/shape-outside/supported-shapes/polygon/shape-outside-polygon-010.html [ Failure ] crbug.com/591099 external/wpt/css/css-shapes-1/shape-outside/supported-shapes/polygon/shape-outside-polygon-010.html [ Failure ]
crbug.com/591099 external/wpt/css/css-shapes-1/shape-outside/supported-shapes/polygon/shape-outside-polygon-011.html [ Failure ] crbug.com/591099 external/wpt/css/css-shapes-1/shape-outside/supported-shapes/polygon/shape-outside-polygon-011.html [ Failure ]
crbug.com/591099 external/wpt/css/css-shapes-1/shape-outside/supported-shapes/polygon/shape-outside-polygon-012.html [ Failure ]
crbug.com/591099 external/wpt/css/css-shapes-1/shape-outside/supported-shapes/polygon/shape-outside-polygon-013.html [ Failure ]
crbug.com/591099 external/wpt/css/css-shapes-1/shape-outside/supported-shapes/polygon/shape-outside-polygon-014.html [ Failure ] crbug.com/591099 external/wpt/css/css-shapes-1/shape-outside/supported-shapes/polygon/shape-outside-polygon-014.html [ Failure ]
crbug.com/591099 external/wpt/css/css-shapes-1/shape-outside/supported-shapes/polygon/shape-outside-polygon-015.html [ Failure ] crbug.com/591099 external/wpt/css/css-shapes-1/shape-outside/supported-shapes/polygon/shape-outside-polygon-015.html [ Failure ]
crbug.com/591099 external/wpt/css/css-shapes-1/shape-outside/supported-shapes/polygon/shape-outside-polygon-016.html [ Failure ] crbug.com/591099 external/wpt/css/css-shapes-1/shape-outside/supported-shapes/polygon/shape-outside-polygon-016.html [ Failure ]
...@@ -10360,12 +10368,16 @@ crbug.com/591099 fast/shapes/shape-outside-floats/shape-outside-floats-inset-rou ...@@ -10360,12 +10368,16 @@ crbug.com/591099 fast/shapes/shape-outside-floats/shape-outside-floats-inset-rou
crbug.com/591099 fast/shapes/shape-outside-floats/shape-outside-floats-inset-rounded-top-left.html [ Failure ] crbug.com/591099 fast/shapes/shape-outside-floats/shape-outside-floats-inset-rounded-top-left.html [ Failure ]
crbug.com/591099 fast/shapes/shape-outside-floats/shape-outside-floats-inset-rounded-top-right.html [ Failure ] crbug.com/591099 fast/shapes/shape-outside-floats/shape-outside-floats-inset-rounded-top-right.html [ Failure ]
crbug.com/591099 fast/shapes/shape-outside-floats/shape-outside-floats-inset.html [ Failure ] crbug.com/591099 fast/shapes/shape-outside-floats/shape-outside-floats-inset.html [ Failure ]
crbug.com/591099 fast/shapes/shape-outside-floats/shape-outside-floats-linetop-adjustment.html [ Failure ]
crbug.com/591099 fast/shapes/shape-outside-floats/shape-outside-floats-margin-crash.html [ Failure ] crbug.com/591099 fast/shapes/shape-outside-floats/shape-outside-floats-margin-crash.html [ Failure ]
crbug.com/591099 fast/shapes/shape-outside-floats/shape-outside-floats-not-a-layer.html [ Failure ] crbug.com/591099 fast/shapes/shape-outside-floats/shape-outside-floats-not-a-layer.html [ Failure ]
crbug.com/591099 fast/shapes/shape-outside-floats/shape-outside-floats-outermost.html [ Failure ] crbug.com/591099 fast/shapes/shape-outside-floats/shape-outside-floats-outermost.html [ Failure ]
crbug.com/591099 fast/shapes/shape-outside-floats/shape-outside-floats-polygon-000.html [ Crash Failure ] crbug.com/591099 fast/shapes/shape-outside-floats/shape-outside-floats-polygon-000.html [ Crash Failure ]
crbug.com/591099 fast/shapes/shape-outside-floats/shape-outside-floats-polygon-001.html [ Failure ]
crbug.com/591099 fast/shapes/shape-outside-floats/shape-outside-floats-polygon-002.html [ Failure ] crbug.com/591099 fast/shapes/shape-outside-floats/shape-outside-floats-polygon-002.html [ Failure ]
crbug.com/591099 fast/shapes/shape-outside-floats/shape-outside-floats-shape-margin-percent.html [ Failure ] crbug.com/591099 fast/shapes/shape-outside-floats/shape-outside-floats-shape-margin-percent.html [ Failure ]
crbug.com/591099 fast/shapes/shape-outside-floats/shape-outside-floats-stacked-000.html [ Failure ]
crbug.com/591099 fast/shapes/shape-outside-floats/shape-outside-floats-stacked-001.html [ Failure ]
crbug.com/591099 fast/shapes/shape-outside-floats/shape-outside-floats-stacked-002.html [ Crash Failure ] crbug.com/591099 fast/shapes/shape-outside-floats/shape-outside-floats-stacked-002.html [ Crash Failure ]
crbug.com/591099 fast/shapes/shape-outside-floats/shape-outside-image-fit-001.html [ Failure ] crbug.com/591099 fast/shapes/shape-outside-floats/shape-outside-image-fit-001.html [ Failure ]
crbug.com/591099 fast/shapes/shape-outside-floats/shape-outside-image-fit-002.html [ Failure ] crbug.com/591099 fast/shapes/shape-outside-floats/shape-outside-image-fit-002.html [ Failure ]
...@@ -10379,12 +10391,15 @@ crbug.com/591099 fast/shapes/shape-outside-floats/shape-outside-line-height-cras ...@@ -10379,12 +10391,15 @@ crbug.com/591099 fast/shapes/shape-outside-floats/shape-outside-line-height-cras
crbug.com/591099 fast/shapes/shape-outside-floats/shape-outside-line-height-crash2.html [ Crash Failure ] crbug.com/591099 fast/shapes/shape-outside-floats/shape-outside-line-height-crash2.html [ Crash Failure ]
crbug.com/591099 fast/shapes/shape-outside-floats/shape-outside-linear-gradient.html [ Failure ] crbug.com/591099 fast/shapes/shape-outside-floats/shape-outside-linear-gradient.html [ Failure ]
crbug.com/591099 fast/shapes/shape-outside-floats/shape-outside-negative-height-crash.html [ Crash Failure ] crbug.com/591099 fast/shapes/shape-outside-floats/shape-outside-negative-height-crash.html [ Crash Failure ]
crbug.com/591099 fast/shapes/shape-outside-floats/shape-outside-polygon-012.html [ Failure ]
crbug.com/591099 fast/shapes/shape-outside-floats/shape-outside-polygon-013.html [ Failure ]
crbug.com/591099 fast/shapes/shape-outside-floats/shape-outside-polygon-014.html [ Failure ] crbug.com/591099 fast/shapes/shape-outside-floats/shape-outside-polygon-014.html [ Failure ]
crbug.com/591099 fast/shapes/shape-outside-floats/shape-outside-polygon-015.html [ Failure ] crbug.com/591099 fast/shapes/shape-outside-floats/shape-outside-polygon-015.html [ Failure ]
crbug.com/591099 fast/shapes/shape-outside-floats/shape-outside-polygon-zero-vertex.html [ Failure Pass ] crbug.com/591099 fast/shapes/shape-outside-floats/shape-outside-polygon-zero-vertex.html [ Failure Pass ]
crbug.com/591099 fast/shapes/shape-outside-floats/shape-outside-relative-size-svg.html [ Failure ] crbug.com/591099 fast/shapes/shape-outside-floats/shape-outside-relative-size-svg.html [ Failure ]
crbug.com/591099 fast/shapes/shape-outside-floats/shape-outside-rounded-boxes-001.html [ Failure ] crbug.com/591099 fast/shapes/shape-outside-floats/shape-outside-rounded-boxes-001.html [ Failure ]
crbug.com/591099 fast/shapes/shape-outside-floats/shape-outside-rounded-boxes-002.html [ Failure ] crbug.com/591099 fast/shapes/shape-outside-floats/shape-outside-rounded-boxes-002.html [ Failure ]
crbug.com/591099 fast/shapes/shape-outside-floats/shape-outside-rounded-inset.html [ Failure ]
crbug.com/591099 fast/spatial-navigation/snav-aligned-not-aligned.html [ Failure ] crbug.com/591099 fast/spatial-navigation/snav-aligned-not-aligned.html [ Failure ]
crbug.com/591099 fast/spatial-navigation/snav-clipped-overflowed-content.html [ Failure ] crbug.com/591099 fast/spatial-navigation/snav-clipped-overflowed-content.html [ Failure ]
crbug.com/591099 fast/spatial-navigation/snav-container-white-space.html [ Failure ] crbug.com/591099 fast/spatial-navigation/snav-container-white-space.html [ Failure ]
...@@ -10435,6 +10450,7 @@ crbug.com/591099 fast/sub-pixel/float-list-inside.html [ Crash Failure Pass ] ...@@ -10435,6 +10450,7 @@ crbug.com/591099 fast/sub-pixel/float-list-inside.html [ Crash Failure Pass ]
crbug.com/591099 fast/sub-pixel/float-percentage-widths.html [ Failure ] crbug.com/591099 fast/sub-pixel/float-percentage-widths.html [ Failure ]
crbug.com/591099 fast/sub-pixel/float-with-margin-in-container.html [ Failure ] crbug.com/591099 fast/sub-pixel/float-with-margin-in-container.html [ Failure ]
crbug.com/591099 fast/sub-pixel/float-with-right-margin-zoom.html [ Failure ] crbug.com/591099 fast/sub-pixel/float-with-right-margin-zoom.html [ Failure ]
crbug.com/591099 fast/sub-pixel/float-wrap-zoom.html [ Failure ]
crbug.com/591099 fast/sub-pixel/inline-block-with-padding.html [ Failure ] crbug.com/591099 fast/sub-pixel/inline-block-with-padding.html [ Failure ]
crbug.com/591099 fast/sub-pixel/repaint-subpixel-layer-in-subpixel-composited-layer.html [ Failure Pass ] crbug.com/591099 fast/sub-pixel/repaint-subpixel-layer-in-subpixel-composited-layer.html [ Failure Pass ]
crbug.com/591099 fast/sub-pixel/shadows-computed-style.html [ Failure ] crbug.com/591099 fast/sub-pixel/shadows-computed-style.html [ Failure ]
...@@ -10946,6 +10962,7 @@ crbug.com/591099 fast/text/whitespace/whitespace-in-pre.html [ Failure ] ...@@ -10946,6 +10962,7 @@ crbug.com/591099 fast/text/whitespace/whitespace-in-pre.html [ Failure ]
crbug.com/591099 fast/text/wide-preformatted.html [ Failure ] crbug.com/591099 fast/text/wide-preformatted.html [ Failure ]
crbug.com/591099 fast/text/word-break-run-rounding.html [ Failure ] crbug.com/591099 fast/text/word-break-run-rounding.html [ Failure ]
crbug.com/591099 fast/text/word-break-soft-hyphen.html [ Failure ] crbug.com/591099 fast/text/word-break-soft-hyphen.html [ Failure ]
crbug.com/591099 fast/text/word-break.html [ Failure ]
crbug.com/591099 fast/text/word-space-between-inlines.html [ Failure ] crbug.com/591099 fast/text/word-space-between-inlines.html [ Failure ]
crbug.com/591099 fast/text/word-space.html [ Failure ] crbug.com/591099 fast/text/word-space.html [ Failure ]
crbug.com/591099 fast/text/writing-root-with-overflow-clip-baseline.html [ Crash Failure Pass ] crbug.com/591099 fast/text/writing-root-with-overflow-clip-baseline.html [ Crash Failure Pass ]
...@@ -15992,6 +16009,7 @@ crbug.com/591099 svg/transforms/svg-css-transforms.xhtml [ Failure ] ...@@ -15992,6 +16009,7 @@ crbug.com/591099 svg/transforms/svg-css-transforms.xhtml [ Failure ]
crbug.com/591099 svg/transforms/text-with-pattern-inside-transformed-html.xhtml [ Failure ] crbug.com/591099 svg/transforms/text-with-pattern-inside-transformed-html.xhtml [ Failure ]
crbug.com/591099 svg/transforms/transform-origin-presentation-attribute.xhtml [ Failure ] crbug.com/591099 svg/transforms/transform-origin-presentation-attribute.xhtml [ Failure ]
crbug.com/591099 svg/transforms/transformed-text-fill-pattern.html [ 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-a.xhtml [ Failure ]
crbug.com/591099 svg/wicd/test-rightsizing-b.xhtml [ Failure ] crbug.com/591099 svg/wicd/test-rightsizing-b.xhtml [ Failure ]
crbug.com/591099 svg/wicd/test-scalable-background-image1.xhtml [ Failure ] crbug.com/591099 svg/wicd/test-scalable-background-image1.xhtml [ Failure ]
...@@ -308,7 +308,6 @@ crbug.com/635619 virtual/layout_ng/external/wpt/css/CSS2/floats-clear/floats-128 ...@@ -308,7 +308,6 @@ crbug.com/635619 virtual/layout_ng/external/wpt/css/CSS2/floats-clear/floats-128
crbug.com/635619 virtual/layout_ng/external/wpt/css/CSS2/floats-clear/floats-129.xht [ Skip ] crbug.com/635619 virtual/layout_ng/external/wpt/css/CSS2/floats-clear/floats-129.xht [ Skip ]
crbug.com/635619 virtual/layout_ng/external/wpt/css/CSS2/floats-clear/floats-130.xht [ Skip ] crbug.com/635619 virtual/layout_ng/external/wpt/css/CSS2/floats-clear/floats-130.xht [ Skip ]
crbug.com/635619 virtual/layout_ng/external/wpt/css/CSS2/floats-clear/floats-131.xht [ Skip ] crbug.com/635619 virtual/layout_ng/external/wpt/css/CSS2/floats-clear/floats-131.xht [ Skip ]
crbug.com/635619 virtual/layout_ng/external/wpt/css/CSS2/floats-clear/floats-132.xht [ Failure ]
crbug.com/635619 virtual/layout_ng/external/wpt/css/CSS2/floats-clear/floats-137.xht [ Skip ] crbug.com/635619 virtual/layout_ng/external/wpt/css/CSS2/floats-clear/floats-137.xht [ Skip ]
crbug.com/635619 virtual/layout_ng/external/wpt/css/CSS2/floats-clear/floats-143.xht [ Failure ] crbug.com/635619 virtual/layout_ng/external/wpt/css/CSS2/floats-clear/floats-143.xht [ Failure ]
crbug.com/635619 virtual/layout_ng/external/wpt/css/CSS2/floats-clear/margin-collapse-018.xht [ Failure ] crbug.com/635619 virtual/layout_ng/external/wpt/css/CSS2/floats-clear/margin-collapse-018.xht [ Failure ]
...@@ -362,10 +361,7 @@ crbug.com/635619 virtual/layout_ng/external/wpt/css/CSS2/normal-flow/block-in-in ...@@ -362,10 +361,7 @@ crbug.com/635619 virtual/layout_ng/external/wpt/css/CSS2/normal-flow/block-in-in
crbug.com/635619 virtual/layout_ng/external/wpt/css/CSS2/normal-flow/block-in-inline-remove-004.xht [ Failure Pass ] crbug.com/635619 virtual/layout_ng/external/wpt/css/CSS2/normal-flow/block-in-inline-remove-004.xht [ Failure Pass ]
crbug.com/635619 virtual/layout_ng/external/wpt/css/CSS2/normal-flow/block-in-inline-remove-005.xht [ Failure Pass ] crbug.com/635619 virtual/layout_ng/external/wpt/css/CSS2/normal-flow/block-in-inline-remove-005.xht [ Failure Pass ]
# Inline: misc. # Block: margin collapsing.
crbug.com/635619 virtual/layout_ng/external/wpt/css/CSS2/normal-flow/inline-replaced-width-012.xht [ Failure ]
crbug.com/635619 virtual/layout_ng/external/wpt/css/CSS2/normal-flow/inline-replaced-width-013.xht [ Failure ]
crbug.com/635619 virtual/layout_ng/external/wpt/css/CSS2/normal-flow/inline-replaced-width-015.xht [ Failure ]
crbug.com/635619 virtual/layout_ng/external/wpt/css/CSS2/normal-flow/root-box-001.xht [ Failure ] crbug.com/635619 virtual/layout_ng/external/wpt/css/CSS2/normal-flow/root-box-001.xht [ Failure ]
# Missing refs, these are also skipped for existing layout. # Missing refs, these are also skipped for existing layout.
...@@ -463,7 +459,6 @@ crbug.com/635619 virtual/layout_ng/fast/block/basic/018.html [ Failure ] ...@@ -463,7 +459,6 @@ crbug.com/635619 virtual/layout_ng/fast/block/basic/018.html [ Failure ]
crbug.com/635619 virtual/layout_ng/fast/block/basic/020.html [ Failure ] crbug.com/635619 virtual/layout_ng/fast/block/basic/020.html [ Failure ]
crbug.com/635619 virtual/layout_ng/fast/block/basic/adding-near-anonymous-block.html [ Failure ] crbug.com/635619 virtual/layout_ng/fast/block/basic/adding-near-anonymous-block.html [ Failure ]
crbug.com/635619 virtual/layout_ng/fast/block/basic/fieldset-stretch-to-legend.html [ Failure Crash ] crbug.com/635619 virtual/layout_ng/fast/block/basic/fieldset-stretch-to-legend.html [ Failure Crash ]
crbug.com/635619 virtual/layout_ng/fast/block/basic/min-pref-width-nowrap-floats.html [ Failure ]
crbug.com/635619 virtual/layout_ng/fast/block/basic/quirk-height.html [ Failure ] crbug.com/635619 virtual/layout_ng/fast/block/basic/quirk-height.html [ Failure ]
crbug.com/635619 virtual/layout_ng/fast/block/basic/quirk-percent-height-grandchild.html [ Failure ] crbug.com/635619 virtual/layout_ng/fast/block/basic/quirk-percent-height-grandchild.html [ Failure ]
crbug.com/635619 virtual/layout_ng/fast/block/basic/text-indent-rtl.html [ Failure ] crbug.com/635619 virtual/layout_ng/fast/block/basic/text-indent-rtl.html [ Failure ]
...@@ -479,7 +474,6 @@ crbug.com/635619 virtual/layout_ng/fast/block/float/014.html [ Failure Crash ] ...@@ -479,7 +474,6 @@ crbug.com/635619 virtual/layout_ng/fast/block/float/014.html [ Failure Crash ]
crbug.com/635619 virtual/layout_ng/fast/block/float/015.html [ Failure ] crbug.com/635619 virtual/layout_ng/fast/block/float/015.html [ Failure ]
crbug.com/635619 virtual/layout_ng/fast/block/float/017.html [ Failure ] crbug.com/635619 virtual/layout_ng/fast/block/float/017.html [ Failure ]
crbug.com/635619 virtual/layout_ng/fast/block/float/018.html [ Failure ] crbug.com/635619 virtual/layout_ng/fast/block/float/018.html [ Failure ]
crbug.com/635619 virtual/layout_ng/fast/block/float/019.html [ Failure ]
crbug.com/635619 virtual/layout_ng/fast/block/float/020.html [ Failure ] crbug.com/635619 virtual/layout_ng/fast/block/float/020.html [ Failure ]
crbug.com/635619 virtual/layout_ng/fast/block/float/022.html [ Failure ] crbug.com/635619 virtual/layout_ng/fast/block/float/022.html [ Failure ]
crbug.com/635619 virtual/layout_ng/fast/block/float/023.html [ Failure ] crbug.com/635619 virtual/layout_ng/fast/block/float/023.html [ Failure ]
...@@ -511,7 +505,6 @@ crbug.com/635619 virtual/layout_ng/fast/block/float/crash-on-absolute-positionin ...@@ -511,7 +505,6 @@ crbug.com/635619 virtual/layout_ng/fast/block/float/crash-on-absolute-positionin
crbug.com/635619 virtual/layout_ng/fast/block/float/crash-replaced-display-block.html [ Failure ] crbug.com/635619 virtual/layout_ng/fast/block/float/crash-replaced-display-block.html [ Failure ]
crbug.com/635619 virtual/layout_ng/fast/block/float/editable-text-overlapping-float.html [ Failure ] crbug.com/635619 virtual/layout_ng/fast/block/float/editable-text-overlapping-float.html [ Failure ]
crbug.com/635619 virtual/layout_ng/fast/block/float/element-clears-float-without-clearance.html [ Failure ] crbug.com/635619 virtual/layout_ng/fast/block/float/element-clears-float-without-clearance.html [ Failure ]
crbug.com/635619 virtual/layout_ng/fast/block/float/fit_line_below_floats.html [ Failure ]
crbug.com/635619 virtual/layout_ng/fast/block/float/float-at-start-of-clean-lines-that-are-subsequently-dirtied-vertical-rl.html [ Failure ] crbug.com/635619 virtual/layout_ng/fast/block/float/float-at-start-of-clean-lines-that-are-subsequently-dirtied-vertical-rl.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-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-avoidance.html [ Failure ]
...@@ -545,8 +538,6 @@ crbug.com/635619 virtual/layout_ng/fast/block/float/floats-wrap-inside-inline-00 ...@@ -545,8 +538,6 @@ crbug.com/635619 virtual/layout_ng/fast/block/float/floats-wrap-inside-inline-00
crbug.com/635619 virtual/layout_ng/fast/block/float/floats-wrap-inside-inline-007.html [ Failure ] crbug.com/635619 virtual/layout_ng/fast/block/float/floats-wrap-inside-inline-007.html [ Failure ]
crbug.com/635619 virtual/layout_ng/fast/block/float/formatting-context-changes.html [ Failure Crash ] crbug.com/635619 virtual/layout_ng/fast/block/float/formatting-context-changes.html [ Failure Crash ]
crbug.com/635619 virtual/layout_ng/fast/block/float/independent-align-positioning.html [ Failure ] crbug.com/635619 virtual/layout_ng/fast/block/float/independent-align-positioning.html [ Failure ]
crbug.com/635619 virtual/layout_ng/fast/block/float/intruding-float-add-in-sibling-block-on-static-position.html [ Failure ]
crbug.com/635619 virtual/layout_ng/fast/block/float/intruding-float-add-in-sibling-block-on-static-position2.html [ Failure ]
crbug.com/635619 virtual/layout_ng/fast/block/float/intruding-painted-twice.html [ Failure ] crbug.com/635619 virtual/layout_ng/fast/block/float/intruding-painted-twice.html [ Failure ]
crbug.com/635619 virtual/layout_ng/fast/block/float/logical-bottom-exceeds-layoutunit-max.html [ Failure ] crbug.com/635619 virtual/layout_ng/fast/block/float/logical-bottom-exceeds-layoutunit-max.html [ Failure ]
crbug.com/635619 virtual/layout_ng/fast/block/float/marquee-shrink-to-avoid-floats.html [ Failure ] crbug.com/635619 virtual/layout_ng/fast/block/float/marquee-shrink-to-avoid-floats.html [ Failure ]
...@@ -555,8 +546,6 @@ crbug.com/635619 virtual/layout_ng/fast/block/float/negative-margin-on-element-a ...@@ -555,8 +546,6 @@ crbug.com/635619 virtual/layout_ng/fast/block/float/negative-margin-on-element-a
crbug.com/635619 virtual/layout_ng/fast/block/float/nested-clearance.html [ Failure ] crbug.com/635619 virtual/layout_ng/fast/block/float/nested-clearance.html [ Failure ]
crbug.com/635619 virtual/layout_ng/fast/block/float/nopaint-after-layer-destruction.html [ Failure ] crbug.com/635619 virtual/layout_ng/fast/block/float/nopaint-after-layer-destruction.html [ Failure ]
crbug.com/635619 virtual/layout_ng/fast/block/float/nopaint-after-layer-destruction2.html [ Failure ] crbug.com/635619 virtual/layout_ng/fast/block/float/nopaint-after-layer-destruction2.html [ Failure ]
crbug.com/635619 virtual/layout_ng/fast/block/float/overhanging-float-add-in-static-position-block.html [ Failure Crash ]
crbug.com/635619 virtual/layout_ng/fast/block/float/overhanging-float-add-in-static-position-block2.html [ Failure Crash ]
crbug.com/635619 virtual/layout_ng/fast/block/float/overhanging-float-remove-from-fixed-position-block.html [ Failure ] crbug.com/635619 virtual/layout_ng/fast/block/float/overhanging-float-remove-from-fixed-position-block.html [ Failure ]
crbug.com/635619 virtual/layout_ng/fast/block/float/overhanging-float-remove-from-fixed-position-block2.html [ Failure ] crbug.com/635619 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-1.html [ Failure ]
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#include "core/layout/ng/ng_fragment_builder.h" #include "core/layout/ng/ng_fragment_builder.h"
#include "core/layout/ng/ng_layout_opportunity_iterator.h" #include "core/layout/ng/ng_layout_opportunity_iterator.h"
#include "core/layout/ng/ng_length_utils.h" #include "core/layout/ng/ng_length_utils.h"
#include "core/layout/ng/ng_space_utils.h"
#include "core/style/ComputedStyle.h" #include "core/style/ComputedStyle.h"
#include "platform/fonts/shaping/ShapingLineBreaker.h" #include "platform/fonts/shaping/ShapingLineBreaker.h"
...@@ -111,7 +112,7 @@ void NGLineBreaker::PrepareNextLine(NGLineInfo* line_info) { ...@@ -111,7 +112,7 @@ void NGLineBreaker::PrepareNextLine(NGLineInfo* line_info) {
// We are only able to calculate our available_width if our container has // We are only able to calculate our available_width if our container has
// been positioned in the BFC coordinate space yet. // been positioned in the BFC coordinate space yet.
if (container_builder_->BfcOffset()) if (container_builder_->BfcOffset())
UpdateAvailableWidth(); FindNextLayoutOpportunity();
else else
line_.opportunity.reset(); line_.opportunity.reset();
} }
...@@ -201,15 +202,54 @@ void NGLineBreaker::BreakLine(NGLineInfo* line_info) { ...@@ -201,15 +202,54 @@ void NGLineBreaker::BreakLine(NGLineInfo* line_info) {
line_info->SetIsLastLine(true); line_info->SetIsLastLine(true);
} }
// @return if there are floats that affect current line.
// This is different from the clearance offset in that floats outside of the
// current layout opportunities, such as floats in margin/padding, or floats
// below such floats, are not included.
bool NGLineBreaker::HasFloatsAffectingCurrentLine() const {
return line_.opportunity->InlineSize() !=
constraint_space_->AvailableSize().inline_size;
}
// Update the inline size of the first layout opportunity from the given // Update the inline size of the first layout opportunity from the given
// content_offset. // content_offset.
void NGLineBreaker::UpdateAvailableWidth() { void NGLineBreaker::FindNextLayoutOpportunity() {
NGLogicalOffset offset = container_builder_->BfcOffset().value(); const NGLogicalOffset& bfc_offset = container_builder_->BfcOffset().value();
offset += content_offset_;
NGLayoutOpportunityIterator iter(constraint_space_->Exclusions().get(), NGLayoutOpportunityIterator iter(constraint_space_->Exclusions().get(),
constraint_space_->AvailableSize(), offset); constraint_space_->AvailableSize(),
bfc_offset + content_offset_);
line_.opportunity = iter.Next(); line_.opportunity = iter.Next();
// When floats/exclusions occupies the entire line (e.g., float: left; width:
// 100%), zero-inline-size opportunities are not included in the iterator.
// Instead, the block offset of the first opportunity is pushed down to avoid
// such floats/exclusions. Set the line box location to it.
content_offset_.block_offset =
line_.opportunity.value().BlockStartOffset() - bfc_offset.block_offset;
}
// Finds a layout opportunity that has the given minimum inline size, or the one
// without floats/exclusions (and that there will not be wider oppotunities than
// that,) and moves |content_offset_.block_offset| down to it.
//
// Used to move lines down when no break opportunities can fit in a line that
// has floats.
void NGLineBreaker::FindNextLayoutOpportunityWithMinimumInlineSize(
LayoutUnit min_inline_size) {
const NGLogicalOffset& bfc_offset = container_builder_->BfcOffset().value();
NGLayoutOpportunityIterator iter(constraint_space_->Exclusions().get(),
constraint_space_->AvailableSize(),
bfc_offset + content_offset_);
while (true) {
line_.opportunity = iter.Next();
if (iter.IsAtEnd() ||
line_.opportunity.value().InlineSize() >= min_inline_size) {
content_offset_.block_offset =
line_.opportunity.value().BlockStartOffset() -
bfc_offset.block_offset;
return;
}
}
} }
void NGLineBreaker::ComputeLineLocation(NGLineInfo* line_info) const { void NGLineBreaker::ComputeLineLocation(NGLineInfo* line_info) const {
...@@ -453,6 +493,19 @@ NGLineBreaker::LineBreakState NGLineBreaker::HandleAtomicInline( ...@@ -453,6 +493,19 @@ NGLineBreaker::LineBreakState NGLineBreaker::HandleAtomicInline(
NGLineBreaker::LineBreakState NGLineBreaker::HandleFloat( NGLineBreaker::LineBreakState NGLineBreaker::HandleFloat(
const NGInlineItem& item, const NGInlineItem& item,
NGInlineItemResult* item_result) { NGInlineItemResult* item_result) {
// When rewind occurs, an item may be handled multiple times.
// Since floats are put into a separate list, avoid handling same floats
// twice.
// Ideally rewind can take floats out of floats list, but the difference is
// sutble compared to the complexity.
// TODO(kojii): Keep a list of floats in a separate vector, then "commit" them
// inside NGLineLayoutAlgorithm.
if (item_index_ < handled_floats_end_item_index_) {
MoveToNextOf(item);
return ComputeIsBreakableAfter(item_result);
}
handled_floats_end_item_index_ = item_index_ + 1;
NGBlockNode node(ToLayoutBox(item.GetLayoutObject())); NGBlockNode node(ToLayoutBox(item.GetLayoutObject()));
const ComputedStyle& float_style = node.Style(); const ComputedStyle& float_style = node.Style();
...@@ -501,7 +554,7 @@ NGLineBreaker::LineBreakState NGLineBreaker::HandleFloat( ...@@ -501,7 +554,7 @@ NGLineBreaker::LineBreakState NGLineBreaker::HandleFloat(
// We need to recalculate the available_width as the float probably // We need to recalculate the available_width as the float probably
// consumed space on the line. // consumed space on the line.
if (container_builder_->BfcOffset()) if (container_builder_->BfcOffset())
UpdateAvailableWidth(); FindNextLayoutOpportunity();
} }
MoveToNextOf(item); MoveToNextOf(item);
...@@ -638,7 +691,25 @@ void NGLineBreaker::HandleOverflow(NGLineInfo* line_info) { ...@@ -638,7 +691,25 @@ void NGLineBreaker::HandleOverflow(NGLineInfo* line_info) {
width_to_rewind = next_width_to_rewind; width_to_rewind = next_width_to_rewind;
} }
// The rewind point did not found, let this line overflow. // Reaching here means that the rewind point was not found.
// When the first break opportunity overflows and if the current line has
// floats or intruding floats, we need to find the next layout opportunity
// which will fit the first break opportunity.
// Doing so will move the line down to where there are narrower floats (and
// thus wider available width,) or no floats.
if (HasFloatsAffectingCurrentLine()) {
FindNextLayoutOpportunityWithMinimumInlineSize(line_.position);
// Moving the line down widened the available width. Need to rewind items
// that depend on old available width, but it's not trivial to rewind all
// the states. For the simplicity, rewind to the beginning of the line.
Rewind(line_info, 0);
line_.position = line_info->TextIndent();
BreakLine(line_info);
return;
}
// Let this line overflow.
// If there was a break opporunity, the overflow should stop there. // If there was a break opporunity, the overflow should stop there.
if (break_before) if (break_before)
return Rewind(line_info, break_before); return Rewind(line_info, break_before);
...@@ -648,14 +719,25 @@ void NGLineBreaker::HandleOverflow(NGLineInfo* line_info) { ...@@ -648,14 +719,25 @@ void NGLineBreaker::HandleOverflow(NGLineInfo* line_info) {
void NGLineBreaker::Rewind(NGLineInfo* line_info, unsigned new_end) { void NGLineBreaker::Rewind(NGLineInfo* line_info, unsigned new_end) {
NGInlineItemResults* item_results = &line_info->Results(); NGInlineItemResults* item_results = &line_info->Results();
DCHECK_LT(new_end, item_results->size());
if (new_end) {
// Use |results[new_end - 1].end_offset| because it may have been truncated
// and may not be equal to |results[new_end].start_offset|.
MoveToNextOf((*item_results)[new_end - 1]);
} else {
// When rewinding all items, use |results[0].start_offset|.
const NGInlineItemResult& first_remove = (*item_results)[new_end];
item_index_ = first_remove.item_index;
offset_ = first_remove.start_offset;
}
// TODO(kojii): Should we keep results for the next line? We don't need to // TODO(kojii): Should we keep results for the next line? We don't need to
// re-layout atomic inlines. // re-layout atomic inlines.
// TODO(kojii): Removing processed floats is likely a problematic. Keep // TODO(kojii): Removing processed floats is likely a problematic. Keep
// floats in this line, or keep it for the next line. // floats in this line, or keep it for the next line.
item_results->Shrink(new_end); item_results->Shrink(new_end);
MoveToNextOf(item_results->back());
DCHECK_LT(item_index_, node_.Items().size());
line_info->SetIsLastLine(false); line_info->SetIsLastLine(false);
} }
......
...@@ -79,7 +79,9 @@ class CORE_EXPORT NGLineBreaker { ...@@ -79,7 +79,9 @@ class CORE_EXPORT NGLineBreaker {
void PrepareNextLine(NGLineInfo*); void PrepareNextLine(NGLineInfo*);
void UpdateAvailableWidth(); bool HasFloatsAffectingCurrentLine() const;
void FindNextLayoutOpportunity();
void FindNextLayoutOpportunityWithMinimumInlineSize(LayoutUnit);
void ComputeLineLocation(NGLineInfo*) const; void ComputeLineLocation(NGLineInfo*) const;
...@@ -135,6 +137,9 @@ class CORE_EXPORT NGLineBreaker { ...@@ -135,6 +137,9 @@ class CORE_EXPORT NGLineBreaker {
HarfBuzzShaper shaper_; HarfBuzzShaper shaper_;
ShapeResultSpacing<String> spacing_; ShapeResultSpacing<String> spacing_;
// Keep track of handled float items. See HandleFloat().
unsigned handled_floats_end_item_index_ = 0;
// True when current box allows line wrapping. // True when current box allows line wrapping.
bool auto_wrap_ = false; bool auto_wrap_ = false;
......
...@@ -38,6 +38,12 @@ class CORE_EXPORT NGLayoutOpportunityIterator final { ...@@ -38,6 +38,12 @@ class CORE_EXPORT NGLayoutOpportunityIterator final {
const NGLogicalSize& available_size, const NGLogicalSize& available_size,
const NGLogicalOffset& offset); const NGLogicalOffset& offset);
// @return If there is no more opportunities to iterate.
// This also means that the last returned opportunity does not have
// exclusions, because the iterator adds an opportunity of the
// initial available size at the end.
bool IsAtEnd() const { return opportunity_iter_ == opportunities_.end(); }
// Gets the next Layout Opportunity or empty one if the search is exhausted. // Gets the next Layout Opportunity or empty one if the search is exhausted.
// TODO(chrome-layout-team): Refactor with using C++ <iterator> library. // TODO(chrome-layout-team): Refactor with using C++ <iterator> library.
// TODO(glebl): Refactor the iterator to return unique_ptr here. // TODO(glebl): Refactor the iterator to return unique_ptr here.
......
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