Commit 78ed3d53 authored by Morten Stenshorne's avatar Morten Stenshorne Committed by Commit Bot

Use the correct out-of-flow containing block in continuations.

We cannot just use the innermost inline, without checking if it's a
valid containing block for absolutely positioned descendants. Find the
right ancestor.

The idea of using the *next* inline in the continuation chain may not be
ideal, but it's not obvious that using the previous one would be much
better (it's more work to find that one anyway), so leaving it as it is.
The spec says that if the relatively positioned inline occurs on
multiple lines, CSS 2 doesn't define exact behavior. Therefore, in the
test, put the same amount of stuff on the line preceding the
interrupting block-level element as on the line following it, to be sure
that the abspos descendant is sized the way we want it to be.

Bug: 897535
Change-Id: Ie9bc4e83400bc283b9c95aafef821000f2303d12
Reviewed-on: https://chromium-review.googlesource.com/c/1301457
Commit-Queue: Morten Stenshorne <mstensho@chromium.org>
Reviewed-by: default avatarEmil A Eklund <eae@chromium.org>
Reviewed-by: default avatarvmpstr <vmpstr@chromium.org>
Reviewed-by: default avatarMason Freed <masonfreed@chromium.org>
Cr-Commit-Position: refs/heads/master@{#603466}
parent 791e8d73
...@@ -74,6 +74,7 @@ crbug.com/591099 compositing/video-frame-size-change.html [ Pass ] ...@@ -74,6 +74,7 @@ crbug.com/591099 compositing/video-frame-size-change.html [ Pass ]
crbug.com/591099 css3/filters/composited-layer-child-bounds-after-composited-to-sw-shadow-change.html [ Failure ] crbug.com/591099 css3/filters/composited-layer-child-bounds-after-composited-to-sw-shadow-change.html [ Failure ]
crbug.com/591099 editing/selection/paint-hyphen.html [ Pass ] crbug.com/591099 editing/selection/paint-hyphen.html [ Pass ]
crbug.com/591099 external/wpt/content-security-policy/generic/only-valid-whitespaces-are-allowed.html [ Pass ] crbug.com/591099 external/wpt/content-security-policy/generic/only-valid-whitespaces-are-allowed.html [ Pass ]
crbug.com/591099 external/wpt/css/CSS2/abspos/abspos-in-block-in-inline-in-relpos-inline.html [ Failure ]
crbug.com/591099 external/wpt/css/CSS2/floats/float-nowrap-3.html [ Pass ] crbug.com/591099 external/wpt/css/CSS2/floats/float-nowrap-3.html [ Pass ]
crbug.com/591099 external/wpt/css/CSS2/floats/floats-line-wrap-shifted-001.html [ Pass ] crbug.com/591099 external/wpt/css/CSS2/floats/floats-line-wrap-shifted-001.html [ Pass ]
crbug.com/591099 external/wpt/css/CSS2/normal-flow/block-in-inline-empty-001.xht [ Pass ] crbug.com/591099 external/wpt/css/CSS2/normal-flow/block-in-inline-empty-001.xht [ Pass ]
......
...@@ -670,6 +670,9 @@ crbug.com/591099 external/wpt/css/cssom-view/offsetTopLeftInline.html [ Failure ...@@ -670,6 +670,9 @@ crbug.com/591099 external/wpt/css/cssom-view/offsetTopLeftInline.html [ Failure
crbug.com/591099 external/wpt/css/css-writing-modes/inline-box-border-vlr-001.html [ Failure ] crbug.com/591099 external/wpt/css/css-writing-modes/inline-box-border-vlr-001.html [ Failure ]
crbug.com/591099 tables/mozilla/bugs/bug14159-1.html [ Failure ] crbug.com/591099 tables/mozilla/bugs/bug14159-1.html [ Failure ]
### virtual/layout_ng/external/wpt/css/CSS2/abspos
crbug.com/591099 virtual/layout_ng/external/wpt/css/CSS2/abspos/abspos-in-block-in-inline-in-relpos-inline.html [ Failure ]
### virtual/layout_ng/external/wpt/css/CSS2/floats ### virtual/layout_ng/external/wpt/css/CSS2/floats
crbug.com/711704 virtual/layout_ng/external/wpt/css/CSS2/floats/floats-rule3-outside-left-002.xht [ Failure ] crbug.com/711704 virtual/layout_ng/external/wpt/css/CSS2/floats/floats-rule3-outside-left-002.xht [ Failure ]
crbug.com/711704 virtual/layout_ng/external/wpt/css/CSS2/floats/floats-rule3-outside-right-002.xht [ Failure ] crbug.com/711704 virtual/layout_ng/external/wpt/css/CSS2/floats/floats-rule3-outside-right-002.xht [ Failure ]
......
<!DOCTYPE html>
<link rel="author" title="Morten Stenshorne" href="mstensho@chromium.org">
<link rel="help" href="https://www.w3.org/TR/CSS22/visudet.html#containing-block-details">
<link rel="help" href="https://www.w3.org/TR/CSS22/visuren.html#anonymous-block-level">
<style>
.rel { position:relative; }
.inline-block { display:inline-block; width:100px; height:1px; }
.inline-block.large { width:200px; }
#target { position:absolute; width:100%; height:100px; background:green; }
</style>
<p>There should be a green square below.</p>
<div style="height:200px;">
<span class="rel" id="notContainingBlockOfTarget">
<div class="large inline-block"></div>
<br>
<span id="containingBlockOfTarget" class="rel">
<div class="inline-block"></div>
<span>
<div>
<div id="target"></div>
</div>
</span>
<div class="inline-block"></div></span><br>
<div class="large inline-block"></div>
</span>
</div>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
test(()=> {
assert_equals(document.getElementById("target").offsetWidth, 100);
}, "Make sure that we're sized by the right ancestor");
</script>
...@@ -3963,12 +3963,20 @@ LayoutUnit LayoutBox::ContainingBlockLogicalWidthForPositioned( ...@@ -3963,12 +3963,20 @@ LayoutUnit LayoutBox::ContainingBlockLogicalWidthForPositioned(
if (HasOverrideContainingBlockContentLogicalWidth()) if (HasOverrideContainingBlockContentLogicalWidth())
return OverrideContainingBlockContentLogicalWidth(); return OverrideContainingBlockContentLogicalWidth();
if (containing_block->IsAnonymousBlock() &&
containing_block->IsRelPositioned()) {
// Ensure we compute our width based on the width of our rel-pos inline // Ensure we compute our width based on the width of our rel-pos inline
// container rather than any anonymous block created to manage a block-flow // container rather than any anonymous block created to manage a block-flow
// ancestor of ours in the rel-pos inline's inline flow. // ancestor of ours in the rel-pos inline's inline flow.
if (containing_block->IsAnonymousBlock() &&
containing_block->IsRelPositioned()) {
containing_block = ToLayoutBox(containing_block)->Continuation(); containing_block = ToLayoutBox(containing_block)->Continuation();
// There may be nested parallel inline continuations. We have now found the
// innermost inline (which may not be relatively positioned). Locate the
// inline that serves as the containing block of this box.
while (!containing_block->CanContainOutOfFlowPositionedElement(
StyleRef().GetPosition())) {
containing_block = ToLayoutBoxModelObject(containing_block->Container());
DCHECK(containing_block->IsLayoutInline());
}
} else if (containing_block->IsBox()) { } else if (containing_block->IsBox()) {
return std::max(LayoutUnit(), return std::max(LayoutUnit(),
ToLayoutBox(containing_block)->ClientLogicalWidth()); ToLayoutBox(containing_block)->ClientLogicalWidth());
......
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