Title: [276358] trunk/Source/WebCore
- Revision
- 276358
- Author
- za...@apple.com
- Date
- 2021-04-21 06:36:58 -0700 (Wed, 21 Apr 2021)
Log Message
[LFC] Take "contain: size" into account when computing the preferred logical width
https://bugs.webkit.org/show_bug.cgi?id=224850
Reviewed by Antti Koivisto.
The intrinsic sizes of the size containment box are determined as if the element had no content,
following the same logic as when sizing as if empty.
* layout/blockformatting/BlockFormattingContextGeometry.cpp:
(WebCore::Layout::BlockFormattingContext::Geometry::intrinsicWidthConstraints):
* layout/inlineformatting/InlineFormattingContext.cpp:
(WebCore::Layout::InlineFormattingContext::computeIntrinsicWidthForFormattingRoot):
* layout/tableformatting/TableFormattingContext.cpp:
(WebCore::Layout::TableFormattingContext::computedIntrinsicWidthConstraints):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (276357 => 276358)
--- trunk/Source/WebCore/ChangeLog 2021-04-21 13:36:34 UTC (rev 276357)
+++ trunk/Source/WebCore/ChangeLog 2021-04-21 13:36:58 UTC (rev 276358)
@@ -1,5 +1,22 @@
2021-04-21 Zalan Bujtas <za...@apple.com>
+ [LFC] Take "contain: size" into account when computing the preferred logical width
+ https://bugs.webkit.org/show_bug.cgi?id=224850
+
+ Reviewed by Antti Koivisto.
+
+ The intrinsic sizes of the size containment box are determined as if the element had no content,
+ following the same logic as when sizing as if empty.
+
+ * layout/blockformatting/BlockFormattingContextGeometry.cpp:
+ (WebCore::Layout::BlockFormattingContext::Geometry::intrinsicWidthConstraints):
+ * layout/inlineformatting/InlineFormattingContext.cpp:
+ (WebCore::Layout::InlineFormattingContext::computeIntrinsicWidthForFormattingRoot):
+ * layout/tableformatting/TableFormattingContext.cpp:
+ (WebCore::Layout::TableFormattingContext::computedIntrinsicWidthConstraints):
+
+2021-04-21 Zalan Bujtas <za...@apple.com>
+
REGRESSION(r256107): Text moves around when selecting at https://www.tokyo-sports.co.jp/entame/news/2834187/
https://bugs.webkit.org/show_bug.cgi?id=224839
<rdar://74958484>
Modified: trunk/Source/WebCore/layout/blockformatting/BlockFormattingContextGeometry.cpp (276357 => 276358)
--- trunk/Source/WebCore/layout/blockformatting/BlockFormattingContextGeometry.cpp 2021-04-21 13:36:34 UTC (rev 276357)
+++ trunk/Source/WebCore/layout/blockformatting/BlockFormattingContextGeometry.cpp 2021-04-21 13:36:58 UTC (rev 276358)
@@ -361,6 +361,12 @@
if (!is<ContainerBox>(layoutBox) || !downcast<ContainerBox>(layoutBox).hasInFlowOrFloatingChild())
return { };
+ if (layoutBox.isSizeContainmentBox()) {
+ // The intrinsic sizes of the size containment box are determined as if the element had no content,
+ // following the same logic as when sizing as if empty.
+ return { };
+ }
+
if (layoutBox.establishesFormattingContext()) {
auto intrinsicWidthConstraints = LayoutContext::createFormattingContext(downcast<ContainerBox>(layoutBox), layoutState())->computedIntrinsicWidthConstraints();
if (logicalWidth.isMinContent())
Modified: trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContext.cpp (276357 => 276358)
--- trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContext.cpp 2021-04-21 13:36:34 UTC (rev 276357)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContext.cpp 2021-04-21 13:36:58 UTC (rev 276358)
@@ -318,8 +318,13 @@
auto constraints = IntrinsicWidthConstraints { };
if (auto fixedWidth = geometry().fixedValue(formattingRoot.style().logicalWidth()))
constraints = { *fixedWidth, *fixedWidth };
- else if (is<ContainerBox>(formattingRoot) && downcast<ContainerBox>(formattingRoot).hasInFlowOrFloatingChild())
- constraints = LayoutContext::createFormattingContext(downcast<ContainerBox>(formattingRoot), layoutState())->computedIntrinsicWidthConstraints();
+ else {
+ auto hasInflowOrFloatingContent = is<ContainerBox>(formattingRoot) && downcast<ContainerBox>(formattingRoot).hasInFlowOrFloatingChild();
+ // The intrinsic sizes of the size containment box are determined as if the element had no content.
+ auto shouldIgnoreChildContent = formattingRoot.isSizeContainmentBox();
+ if (hasInflowOrFloatingContent && !shouldIgnoreChildContent)
+ constraints = LayoutContext::createFormattingContext(downcast<ContainerBox>(formattingRoot), layoutState())->computedIntrinsicWidthConstraints();
+ }
constraints = geometry().constrainByMinMaxWidth(formattingRoot, constraints);
constraints.expand(geometryForBox(formattingRoot).horizontalMarginBorderAndPadding());
formattingState().setIntrinsicWidthConstraintsForBox(formattingRoot, constraints);
Modified: trunk/Source/WebCore/layout/tableformatting/TableFormattingContext.cpp (276357 => 276358)
--- trunk/Source/WebCore/layout/tableformatting/TableFormattingContext.cpp 2021-04-21 13:36:34 UTC (rev 276357)
+++ trunk/Source/WebCore/layout/tableformatting/TableFormattingContext.cpp 2021-04-21 13:36:58 UTC (rev 276358)
@@ -305,6 +305,7 @@
FormattingContext::IntrinsicWidthConstraints TableFormattingContext::computedIntrinsicWidthConstraints()
{
+ ASSERT(!root().isSizeContainmentBox());
// Tables have a slighty different concept of shrink to fit. It's really only different with non-auto "width" values, where
// a generic shrink-to fit block level box like a float box would be just sized to the computed value of "width", tables
// can actually be streched way over.
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes