Title: [254933] trunk/Source/WebCore
Revision
254933
Author
[email protected]
Date
2020-01-22 11:45:59 -0800 (Wed, 22 Jan 2020)

Log Message

[LFC] Do not create a FormattingContext to compute intrinsic width unless there's some content.
https://bugs.webkit.org/show_bug.cgi?id=206581
<rdar://problem/58798593>

Reviewed by Antti Koivisto.

We should only construct a formatting context when it has some content.

* layout/FormattingContext.cpp:
(WebCore::Layout::FormattingContext::FormattingContext):
* layout/FormattingContextGeometry.cpp:
(WebCore::Layout::FormattingContext::Geometry::shrinkToFitWidth):
* layout/blockformatting/BlockFormattingContextGeometry.cpp:
(WebCore::Layout::BlockFormattingContext::Geometry::intrinsicWidthConstraints):
* layout/inlineformatting/InlineFormattingContext.cpp:
(WebCore::Layout::InlineFormattingContext::computeIntrinsicWidthForFormattingRoot):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (254932 => 254933)


--- trunk/Source/WebCore/ChangeLog	2020-01-22 19:45:23 UTC (rev 254932)
+++ trunk/Source/WebCore/ChangeLog	2020-01-22 19:45:59 UTC (rev 254933)
@@ -1,3 +1,22 @@
+2020-01-22  Zalan Bujtas  <[email protected]>
+
+        [LFC] Do not create a FormattingContext to compute intrinsic width unless there's some content.
+        https://bugs.webkit.org/show_bug.cgi?id=206581
+        <rdar://problem/58798593>
+
+        Reviewed by Antti Koivisto.
+
+        We should only construct a formatting context when it has some content.
+
+        * layout/FormattingContext.cpp:
+        (WebCore::Layout::FormattingContext::FormattingContext):
+        * layout/FormattingContextGeometry.cpp:
+        (WebCore::Layout::FormattingContext::Geometry::shrinkToFitWidth):
+        * layout/blockformatting/BlockFormattingContextGeometry.cpp:
+        (WebCore::Layout::BlockFormattingContext::Geometry::intrinsicWidthConstraints):
+        * layout/inlineformatting/InlineFormattingContext.cpp:
+        (WebCore::Layout::InlineFormattingContext::computeIntrinsicWidthForFormattingRoot):
+
 2020-01-22  Chris Dumez  <[email protected]>
 
         Frequent NetworkConnectionToWebProcess::CookiesEnabled sync IPC when browsing reddit.com

Modified: trunk/Source/WebCore/layout/FormattingContext.cpp (254932 => 254933)


--- trunk/Source/WebCore/layout/FormattingContext.cpp	2020-01-22 19:45:23 UTC (rev 254932)
+++ trunk/Source/WebCore/layout/FormattingContext.cpp	2020-01-22 19:45:59 UTC (rev 254933)
@@ -49,6 +49,7 @@
     : m_root(makeWeakPtr(formattingContextRoot))
     , m_formattingState(formattingState)
 {
+    ASSERT(formattingContextRoot.hasChild());
 #ifndef NDEBUG
     layoutState().registerFormattingContext(*this);
 #endif

Modified: trunk/Source/WebCore/layout/FormattingContextGeometry.cpp (254932 => 254933)


--- trunk/Source/WebCore/layout/FormattingContextGeometry.cpp	2020-01-22 19:45:23 UTC (rev 254932)
+++ trunk/Source/WebCore/layout/FormattingContextGeometry.cpp	2020-01-22 19:45:59 UTC (rev 254933)
@@ -285,7 +285,7 @@
 
     // Then the shrink-to-fit width is: min(max(preferred minimum width, available width), preferred width).
     auto intrinsicWidthConstraints = IntrinsicWidthConstraints { };
-    if (is<Container>(formattingRoot)) {
+    if (is<Container>(formattingRoot) && downcast<Container>(formattingRoot).hasInFlowOrFloatingChild()) {
         auto& root = downcast<Container>(formattingRoot);
         auto& formattingStateForRoot = layoutState().ensureFormattingState(root);
         auto precomputedIntrinsicWidthConstraints = formattingStateForRoot.intrinsicWidthConstraints();

Modified: trunk/Source/WebCore/layout/blockformatting/BlockFormattingContextGeometry.cpp (254932 => 254933)


--- trunk/Source/WebCore/layout/blockformatting/BlockFormattingContextGeometry.cpp	2020-01-22 19:45:23 UTC (rev 254932)
+++ trunk/Source/WebCore/layout/blockformatting/BlockFormattingContextGeometry.cpp	2020-01-22 19:45:59 UTC (rev 254933)
@@ -318,12 +318,12 @@
             return { };
         }
 
-        if (layoutBox.establishesFormattingContext() && is<Container>(layoutBox))
-            return LayoutContext::createFormattingContext(downcast<Container>(layoutBox), layoutState())->computedIntrinsicWidthConstraints();
-
         if (!is<Container>(layoutBox) || !downcast<Container>(layoutBox).hasInFlowOrFloatingChild())
             return { };
 
+        if (layoutBox.establishesFormattingContext())
+            return LayoutContext::createFormattingContext(downcast<Container>(layoutBox), layoutState())->computedIntrinsicWidthConstraints();
+
         auto intrinsicWidthConstraints = IntrinsicWidthConstraints { };
         auto& formattingState = layoutState().formattingStateForBox(layoutBox);
         for (auto& child : childrenOfType<Box>(downcast<Container>(layoutBox))) {

Modified: trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContext.cpp (254932 => 254933)


--- trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContext.cpp	2020-01-22 19:45:23 UTC (rev 254932)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContext.cpp	2020-01-22 19:45:59 UTC (rev 254933)
@@ -264,7 +264,7 @@
     auto constraints = IntrinsicWidthConstraints { };
     if (auto fixedWidth = geometry().fixedValue(formattingRoot.style().logicalWidth()))
         constraints = { *fixedWidth, *fixedWidth };
-    else if (is<Container>(formattingRoot))
+    else if (is<Container>(formattingRoot) && downcast<Container>(formattingRoot).hasInFlowOrFloatingChild())
         constraints = LayoutContext::createFormattingContext(downcast<Container>(formattingRoot), layoutState())->computedIntrinsicWidthConstraints();
     constraints = geometry().constrainByMinMaxWidth(formattingRoot, constraints);
     constraints.expand(geometryForBox(formattingRoot).horizontalMarginBorderAndPadding());
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to