Prevent break between cloned box decoration and 1st child fragment.
This would cause an infinite loop, due to a last-resort break being
inserted before a tall and unbreakable first-child-fragment over and
over again. Last-resort breaks are questionable in general, but in the
case of cloned box decorations, there's really no question: They must be
avoided! Avoid this by adjusting the fragmentainer block-offset more
consistently when cloned decorations are used. We previously did this
for child constraint spaces, but the fragment builder (the parent of
such constraint spaces) that establishes cloned decorations really also
needs to do this.
Add blink::FragmentationOffset() that takes a builder argument, rather
than using ConstraintSpace::FragmentainerOffset() directly, so that we
can pay attention to cloned block-start decorations. Also add a
FragmentationOffsetForChildren() convenience function to
LayoutAlgorithm.
This is all pretty simple, except when it comes from floats, which has
no access to the parent fragment builder (they don't even know if it's
an inline or block layout algorithm - and they really don't want to
know, either). UnpositionedFloat now needs to know the fragmentainer
offset (it already knew the fragmentainer block size). The fragmentainer
offset is meaningless unless inside block fragmentation, and there even
used to be a DCHECK in ConstraintSpace::FragmentainerOffset() for it.
Just remove it, rather than worrying about this at every call site.
Also flip is_for_children to false in call to FragmentainerSpaceLeft()
in SetupFragmentBuilderForFragmentation(). This is correct, although it
doesn't matter much with the way the code is right now, since we haven't
yet told the builder whether block-end decorations should be cloned at
this point. There are tests for this situation (when the remainder of
the node fits in the current fragmentainer, and block-end decorations
should therefore not be cloned, but behave as regular block-end
decorations), such as css/css-break/box-decoration-break-clone-002.html
Bug: 40415661
Change-Id: I2f1d596fa638435b5f6f66dd5ae234fb48e26475
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5713911
Reviewed-by: Ian Kilpatrick ikilpatrick@chromium.org
Commit-Queue: Morten Stenshorne mstensho@chromium.org
Cr-Commit-Position: refs/heads/main@{#1328733}