diff --git a/Source/Test/HtmlRenderer.IntegrationTest/BoxModel/WidthIntegrationTests.cs b/Source/Test/HtmlRenderer.IntegrationTest/BoxModel/WidthIntegrationTests.cs index 55fd0b995..926afff84 100644 --- a/Source/Test/HtmlRenderer.IntegrationTest/BoxModel/WidthIntegrationTests.cs +++ b/Source/Test/HtmlRenderer.IntegrationTest/BoxModel/WidthIntegrationTests.cs @@ -209,6 +209,29 @@ public void AutoWidthFloat_ShrinksToFitItsContent() Assert.AreEqual(words[0].Top, words[^1].Top, Delta); } + [TestMethod] + [Spec("css21", "visudet.html#float-width")] + public void AutoWidthFloat_IsSizedByTheFirstLayout() + { + var (root, container) = LayoutHarness.Layout(LayoutHarness.Wrap( + "
"), maxWidth: 400); + var f = Box(root, "f"); + var words = LayoutHarness.Descendants(f).SelectMany(b => b.Words).ToList(); + var size = container.ActualSize; + + Assert.AreEqual(words[^1].Right - words[0].Left, f.Size.Width, 1); + Assert.AreEqual(1, f.Location.X, Delta); + Assert.AreEqual(f.ActualRight + 24, FirstWord(Box(root, "p"))!.Left, 1); + + // Another layout pass must not change anything + LayoutHarness.PerformLayout(container); + + Assert.AreEqual(size.Width, container.ActualSize.Width, Delta); + Assert.AreEqual(size.Height, container.ActualSize.Height, Delta); + } + [TestMethod] [Spec("css21", "visudet.html#float-replaced-width")] public void FloatedImage_KeepsItsIntrinsicWidth() diff --git a/Source/Test/HtmlRenderer.IntegrationTest/TestSupport/LayoutHarness.cs b/Source/Test/HtmlRenderer.IntegrationTest/TestSupport/LayoutHarness.cs index 5abfbf5ed..d7fb43373 100644 --- a/Source/Test/HtmlRenderer.IntegrationTest/TestSupport/LayoutHarness.cs +++ b/Source/Test/HtmlRenderer.IntegrationTest/TestSupport/LayoutHarness.cs @@ -58,23 +58,38 @@ internal static (CssBox Root, HtmlContainerInt Container) Layout( prepare(container.Root!); } + PerformLayout(container); + + Assert.IsNotNull(container.Root); + + return (container.Root!, container); + } + + ///