Commit 0956beaf authored by Morten Stenshorne's avatar Morten Stenshorne Committed by Commit Bot

[LayoutNG] Don't resolve unresolvable percentage min-height and max-height.

We cannot use the content size (intrinsic block size) as min-height or
max-height (min-width or max-width, if writing mode is vertical).
Doing so would cause min-height to incorrectly override any specified
height or max-height that is less than the intrinsic block size, and
max-height to override any specified height that's greater than the
intrinsic block size. Do what the spec says [1] instead: max-height
to become 'none', and min-height to become 0.

This fixes the final rendering problem with Acid2 (this was about the
min-height issue). It now renders correctly with LayoutNG!

Since no other tests than Acid2 started to pass with this change, I wrote
a couple.

[1] https://www.w3.org/TR/CSS22/visudet.html#min-max-heights

     XXXXXX
   XX      XX
  X          X
 X   O    O   X
 X            X
X      /\      X
X      \/      X
X              X
 X X        X X
 X  XXXXXXXX  X
  X          X
   XX      XX
     XXXXXX

Cq-Include-Trybots: master.tryserver.chromium.linux:linux_layout_tests_layout_ng
Change-Id: Ic4f2c3c1dbc2bd66956ed4b270b08058999bc351
Reviewed-on: https://chromium-review.googlesource.com/960085Reviewed-by: default avatarIan Kilpatrick <ikilpatrick@chromium.org>
Reviewed-by: default avatarAleks Totic <atotic@chromium.org>
Reviewed-by: default avatarEmil A Eklund <eae@chromium.org>
Commit-Queue: Morten Stenshorne <mstensho@chromium.org>
Cr-Commit-Position: refs/heads/master@{#543018}
parent 25ed8415
......@@ -2945,7 +2945,6 @@ crbug.com/591099 http/tests/loading/preload-picture-sizes.html [ Failure ]
crbug.com/591099 http/tests/loading/simple-subframe.html [ Failure ]
crbug.com/591099 http/tests/local/file-url-sent-as-referer.html [ Failure ]
crbug.com/591099 http/tests/local/fileapi/select-dragged-file-input.html [ Skip ]
crbug.com/591099 http/tests/misc/acid2.html [ Failure ]
crbug.com/591099 http/tests/misc/acid3.html [ Crash ]
crbug.com/591099 http/tests/misc/object-embedding-svg-delayed-size-negotiation.xhtml [ Failure ]
crbug.com/591099 http/tests/origin_trials/sample-api-workers.html [ Pass ]
......
<!DOCTYPE html>
<title>Unresolvable percentage min-height</title>
<link rel="author" title="Morten Stenshorne" href="mstensho@chromium.org">
<link rel="help" href="https://www.w3.org/TR/CSS22/visudet.html#min-max-heights" title="10.7 Minimum and maximum heights: 'min-height' and 'max-height'">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/check-layout-th.js"></script>
<div id="container" style="width:100px; height:30000px; max-height:100%;" data-expected-height="30000">
<div style="height:12345px;"></div>
</div>
<script>
checkLayout("#container");
</script>
<!DOCTYPE html>
<title>Unresolvable percentage min-height</title>
<link rel="author" title="Morten Stenshorne" href="mstensho@chromium.org">
<link rel="help" href="https://www.w3.org/TR/CSS22/visudet.html#min-max-heights" title="10.7 Minimum and maximum heights: 'min-height' and 'max-height'">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/check-layout-th.js"></script>
<p>There should be a blue square below.</p>
<div id="container" style="width:100px; max-height:100px; min-height:100%; background:blue;" data-expected-height="100">
<div style="height:300px;"></div>
</div>
<script>
checkLayout("#container");
</script>
......@@ -139,12 +139,21 @@ LayoutUnit ResolveBlockLength(const NGConstraintSpace& constraint_space,
if (type == LengthResolveType::kMinSize && length.IsAuto())
return LayoutUnit();
// Make sure that indefinite percentages resolve to NGSizeIndefinite, not to
// a random negative number.
if (length.IsPercentOrCalc() &&
constraint_space.PercentageResolutionSize().block_size ==
NGSizeIndefinite)
return content_size;
NGSizeIndefinite) {
// We're unable to resolve this percentage, since there's nothing to resolve
// it against. Height/width becomes 'auto', so we can just return the
// content size. Min-height/min-width becomes 0. Max-height/max-width
// becomes 'none', which means that we shouldn't impose any max limit, so
// return "infinity".
if (type == LengthResolveType::kContentSize)
return content_size;
if (type == LengthResolveType::kMaxSize)
return LayoutUnit::Max();
DCHECK_EQ(type, LengthResolveType::kMinSize);
return LayoutUnit();
}
// We don't need this when we're resolving margin/border/padding; skip
// computing it as an optimization and to simplify the code below.
......
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