Diff
Modified: trunk/Source/WebCore/ChangeLog (250032 => 250033)
--- trunk/Source/WebCore/ChangeLog 2019-09-18 14:31:12 UTC (rev 250032)
+++ trunk/Source/WebCore/ChangeLog 2019-09-18 15:38:17 UTC (rev 250033)
@@ -1,3 +1,21 @@
+2019-09-18 Zalan Bujtas <[email protected]>
+
+ [LFC] Shrink-to-fit-width needs the available width constraint value only
+ https://bugs.webkit.org/show_bug.cgi?id=201896
+ <rdar://problem/55465382>
+
+ Reviewed by Antti Koivisto.
+
+ * layout/FormattingContext.h:
+ * layout/FormattingContextGeometry.cpp:
+ (WebCore::Layout::FormattingContext::Geometry::shrinkToFitWidth):
+ (WebCore::Layout::FormattingContext::Geometry::outOfFlowNonReplacedHorizontalGeometry):
+ (WebCore::Layout::FormattingContext::Geometry::floatingNonReplacedWidthAndMargin):
+ * layout/blockformatting/BlockFormattingContextGeometry.cpp:
+ (WebCore::Layout::BlockFormattingContext::Geometry::inFlowWidthAndMargin):
+ * layout/inlineformatting/InlineFormattingContextGeometry.cpp:
+ (WebCore::Layout::InlineFormattingContext::Geometry::inlineBlockWidthAndMargin):
+
2019-09-18 David Kilzer <[email protected]>
REGRESSION (r247566): Leak of UICTFontDescriptor in WebCore::FontDatabase::InstalledFont::InstalledFont()
Modified: trunk/Source/WebCore/layout/FormattingContext.h (250032 => 250033)
--- trunk/Source/WebCore/layout/FormattingContext.h 2019-09-18 14:31:12 UTC (rev 250032)
+++ trunk/Source/WebCore/layout/FormattingContext.h 2019-09-18 15:38:17 UTC (rev 250033)
@@ -105,7 +105,7 @@
LayoutSize inFlowPositionedPositionOffset(const Box&, UsedHorizontalValues) const;
HeightAndMargin complicatedCases(const Box&, UsedHorizontalValues, UsedVerticalValues) const;
- LayoutUnit shrinkToFitWidth(const Box&, UsedHorizontalValues);
+ LayoutUnit shrinkToFitWidth(const Box&, LayoutUnit availableWidth);
Edges computedBorder(const Box&) const;
Optional<Edges> computedPadding(const Box&, UsedHorizontalValues) const;
Modified: trunk/Source/WebCore/layout/FormattingContextGeometry.cpp (250032 => 250033)
--- trunk/Source/WebCore/layout/FormattingContextGeometry.cpp 2019-09-18 14:31:12 UTC (rev 250032)
+++ trunk/Source/WebCore/layout/FormattingContextGeometry.cpp 2019-09-18 15:38:17 UTC (rev 250033)
@@ -245,7 +245,7 @@
return left - paddingBoxLeft;
}
-LayoutUnit FormattingContext::Geometry::shrinkToFitWidth(const Box& formattingRoot, UsedHorizontalValues usedHorizontalValues)
+LayoutUnit FormattingContext::Geometry::shrinkToFitWidth(const Box& formattingRoot, LayoutUnit availableWidth)
{
LOG_WITH_STREAM(FormattingContextLayout, stream << "[Width] -> shrink to fit -> unsupported -> width(" << LayoutUnit { } << "px) layoutBox: " << &formattingRoot << ")");
ASSERT(formattingRoot.establishesFormattingContext());
@@ -267,7 +267,6 @@
else
intrinsicWidthConstraints = *precomputedIntrinsicWidthConstraints;
}
- auto availableWidth = usedHorizontalValues.containingBlockWidth;
return std::min(std::max(intrinsicWidthConstraints.minimum, availableWidth), intrinsicWidthConstraints.maximum);
}
@@ -498,7 +497,7 @@
// Calculate the available width by solving for 'width' after setting 'left' (in case 1) to 0
left = LayoutUnit { 0 };
auto availableWidth = containingBlockWidth - (*left + usedHorizontalMargin.start + borderLeft + paddingLeft + paddingRight + borderRight + usedHorizontalMargin.end + *right);
- width = shrinkToFitWidth(layoutBox, UsedHorizontalValues { availableWidth, usedHorizontalValues.width, usedHorizontalValues.margin });
+ width = shrinkToFitWidth(layoutBox, availableWidth);
left = containingBlockWidth - (usedHorizontalMargin.start + borderLeft + paddingLeft + *width + paddingRight + borderRight + usedHorizontalMargin.end + *right);
} else if (!left && !right && width) {
// #2
@@ -515,7 +514,7 @@
// Calculate the available width by solving for 'width' after setting 'right' (in case 3) to 0
right = LayoutUnit { 0 };
auto availableWidth = containingBlockWidth - (*left + usedHorizontalMargin.start + borderLeft + paddingLeft + paddingRight + borderRight + usedHorizontalMargin.end + *right);
- width = shrinkToFitWidth(layoutBox, UsedHorizontalValues { availableWidth, usedHorizontalValues.width, usedHorizontalValues.margin });
+ width = shrinkToFitWidth(layoutBox, availableWidth);
right = containingBlockWidth - (*left + usedHorizontalMargin.start + borderLeft + paddingLeft + *width + paddingRight + borderRight + usedHorizontalMargin.end);
} else if (!left && width && right) {
// #4
@@ -775,7 +774,7 @@
// #2
auto width = computedValueIfNotAuto(usedHorizontalValues.width ? Length { usedHorizontalValues.width.value(), Fixed } : layoutBox.style().logicalWidth(), usedHorizontalValues.containingBlockWidth);
if (!width)
- width = shrinkToFitWidth(layoutBox, usedHorizontalValues);
+ width = shrinkToFitWidth(layoutBox, usedHorizontalValues.containingBlockWidth);
LOG_WITH_STREAM(FormattingContextLayout, stream << "[Width][Margin] -> floating non-replaced -> width(" << *width << "px) margin(" << usedHorizontallMargin.start << "px, " << usedHorizontallMargin.end << "px) -> layoutBox(" << &layoutBox << ")");
return WidthAndMargin { *width, usedHorizontallMargin, computedHorizontalMargin };
Modified: trunk/Source/WebCore/layout/blockformatting/BlockFormattingContextGeometry.cpp (250032 => 250033)
--- trunk/Source/WebCore/layout/blockformatting/BlockFormattingContextGeometry.cpp 2019-09-18 14:31:12 UTC (rev 250032)
+++ trunk/Source/WebCore/layout/blockformatting/BlockFormattingContextGeometry.cpp 2019-09-18 15:38:17 UTC (rev 250033)
@@ -286,7 +286,7 @@
if (layoutBox.establishesTableFormattingContext()) {
// This is a special table "fit-content size" behavior handling. Not in the spec though.
// Table returns its final width as min/max. Use this final width value to computed horizontal margins etc.
- usedValues.width = shrinkToFitWidth(layoutBox, usedValues);
+ usedValues.width = shrinkToFitWidth(layoutBox, usedValues.containingBlockWidth);
}
return inFlowNonReplacedWidthAndMargin(layoutBox, usedValues);
}
Modified: trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContextGeometry.cpp (250032 => 250033)
--- trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContextGeometry.cpp 2019-09-18 14:31:12 UTC (rev 250032)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContextGeometry.cpp 2019-09-18 15:38:17 UTC (rev 250033)
@@ -38,7 +38,7 @@
namespace WebCore {
namespace Layout {
-WidthAndMargin InlineFormattingContext::Geometry::inlineBlockWidthAndMargin(const Box& formattingContextRoot, UsedHorizontalValues usedValues)
+WidthAndMargin InlineFormattingContext::Geometry::inlineBlockWidthAndMargin(const Box& formattingContextRoot, UsedHorizontalValues usedHorizontalValues)
{
ASSERT(formattingContextRoot.isInFlow());
@@ -46,7 +46,7 @@
// Exactly as inline replaced elements.
if (formattingContextRoot.replaced())
- return inlineReplacedWidthAndMargin(formattingContextRoot, usedValues);
+ return inlineReplacedWidthAndMargin(formattingContextRoot, usedHorizontalValues);
// 10.3.9 'Inline-block', non-replaced elements in normal flow
@@ -53,12 +53,12 @@
// If 'width' is 'auto', the used value is the shrink-to-fit width as for floating elements.
// A computed value of 'auto' for 'margin-left' or 'margin-right' becomes a used value of '0'.
// #1
- auto width = computedValueIfNotAuto(formattingContextRoot.style().logicalWidth(), usedValues.containingBlockWidth);
+ auto width = computedValueIfNotAuto(formattingContextRoot.style().logicalWidth(), usedHorizontalValues.containingBlockWidth);
if (!width)
- width = shrinkToFitWidth(formattingContextRoot, usedValues);
+ width = shrinkToFitWidth(formattingContextRoot, usedHorizontalValues.containingBlockWidth);
// #2
- auto computedHorizontalMargin = Geometry::computedHorizontalMargin(formattingContextRoot, usedValues);
+ auto computedHorizontalMargin = Geometry::computedHorizontalMargin(formattingContextRoot, usedHorizontalValues);
return WidthAndMargin { *width, { computedHorizontalMargin.start.valueOr(0_lu), computedHorizontalMargin.end.valueOr(0_lu) }, computedHorizontalMargin };
}