Commit 7e57fa8c authored by Ian Kilpatrick's avatar Ian Kilpatrick Committed by Commit Bot

[canvas] Fix intrinsic size invalidation for canvas elements.

Previously we cached at the preferred sizes level, this meant that
whenever we called LayoutReplaced::PreferredLogicalWidths the (previous)
PreferredLogicalWidthsDirty bit got cleared.

However we now cache at the IntrinsicLogicalWidths level. The difference
is that LayoutReplaced elements don't clear their
IntrinsicLgoicalWidthsDirty bit.

This meant that the innocent looking:
if (!IntrinsicLogicalWidthsDirty())
  SetIntrinsicLogicalWidthsDirty();

Was incorrect, as we were never invalidating the container chain.
This caused the observed incorrect rendering in the bug.

This patch changes this function to always invalidate the container
chain for intrinsic sizes, and layout invalidations.

Bug: 1086299
Change-Id: I8145a6276d4ec89c0c7acf91c1bf67714c127440
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2216373
Commit-Queue: Ian Kilpatrick <ikilpatrick@chromium.org>
Reviewed-by: default avatarChristian Biesinger <cbiesinger@chromium.org>
Reviewed-by: default avatarMorten Stenshorne <mstensho@chromium.org>
Cr-Commit-Position: refs/heads/master@{#771912}
parent 2421449c
...@@ -61,22 +61,7 @@ void LayoutHTMLCanvas::CanvasSizeChanged() { ...@@ -61,22 +61,7 @@ void LayoutHTMLCanvas::CanvasSizeChanged() {
if (!Parent()) if (!Parent())
return; return;
if (!IntrinsicLogicalWidthsDirty())
SetIntrinsicLogicalWidthsDirty(); SetIntrinsicLogicalWidthsDirty();
LayoutSize old_size = Size();
UpdateLogicalWidth();
UpdateLogicalHeight();
if (old_size == Size() && !HasOverrideLogicalWidth() &&
!HasOverrideLogicalHeight()) {
// If we have an override size, then we're probably a flex item, and the
// check above is insufficient because updateLogical{Width,Height} just
// used the override size. We actually have to mark ourselves as needing
// layout so the flex algorithm can run and compute our size correctly.
return;
}
if (!SelfNeedsLayout())
SetNeedsLayout(layout_invalidation_reason::kSizeChanged); SetNeedsLayout(layout_invalidation_reason::kSizeChanged);
} }
......
<!DOCTYPE html>
<link rel="help" href="https://drafts.csswg.org/css-sizing-3/#intrinsic">
<link rel="match" href="../reference/ref-filled-green-100px-square-only.html">
<meta name="assert" content="This test checks that a dynamic change in the intrinsic size of a canvas element correctly changes the intrinsic size of a parent." />
<body style="position: relative;">
<p>Test passes if there is a filled green square.</p>
<div style="position: absolute; background: green; line-height: 0;">
<canvas id="target"></canvas>
</div>
</body>
<script>
document.body.offsetTop;
const target = document.getElementById('target');
target.width = '100';
target.height = '100';
</script>
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