Title: [241195] trunk/Source/WebCore
Revision
241195
Author
[email protected]
Date
2019-02-08 06:46:36 -0800 (Fri, 08 Feb 2019)

Log Message

[LFC] The used containing block width value is optional
https://bugs.webkit.org/show_bug.cgi?id=194428

Reviewed by Antti Koivisto.

The preferred width codepath cannot provide a valid used containing block width value.

"The percentage is calculated with respect to the width of the generated box's containing block.
If the containing block's width depends on this element's width, then the resulting layout is undefined in CSS 2.2."

Let's use 0 as used value for now.

* layout/FormattingContextGeometry.cpp:
(WebCore::Layout::FormattingContext::Geometry::shrinkToFitWidth):
(WebCore::Layout::FormattingContext::Geometry::outOfFlowNonReplacedHorizontalGeometry):
(WebCore::Layout::FormattingContext::Geometry::outOfFlowReplacedHorizontalGeometry):
(WebCore::Layout::FormattingContext::Geometry::floatingNonReplacedWidthAndMargin):
(WebCore::Layout::FormattingContext::Geometry::floatingReplacedWidthAndMargin):
(WebCore::Layout::FormattingContext::Geometry::inlineReplacedWidthAndMargin):
(WebCore::Layout::FormattingContext::Geometry::computedPadding):
(WebCore::Layout::FormattingContext::Geometry::computedHorizontalMargin):
* layout/LayoutUnits.h:
(WebCore::Layout::UsedHorizontalValues::UsedHorizontalValues):
* layout/blockformatting/BlockFormattingContextGeometry.cpp:
(WebCore::Layout::BlockFormattingContext::Geometry::inFlowNonReplacedWidthAndMargin):
* layout/inlineformatting/InlineFormattingContextGeometry.cpp:
(WebCore::Layout::InlineFormattingContext::Geometry::inlineBlockWidthAndMargin):
* page/FrameViewLayoutContext.cpp:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (241194 => 241195)


--- trunk/Source/WebCore/ChangeLog	2019-02-08 13:57:09 UTC (rev 241194)
+++ trunk/Source/WebCore/ChangeLog	2019-02-08 14:46:36 UTC (rev 241195)
@@ -1,5 +1,36 @@
 2019-02-08  Zalan Bujtas  <[email protected]>
 
+        [LFC] The used containing block width value is optional
+        https://bugs.webkit.org/show_bug.cgi?id=194428
+
+        Reviewed by Antti Koivisto.
+
+        The preferred width codepath cannot provide a valid used containing block width value.
+
+        "The percentage is calculated with respect to the width of the generated box's containing block.
+        If the containing block's width depends on this element's width, then the resulting layout is undefined in CSS 2.2."
+
+        Let's use 0 as used value for now.
+
+        * layout/FormattingContextGeometry.cpp:
+        (WebCore::Layout::FormattingContext::Geometry::shrinkToFitWidth):
+        (WebCore::Layout::FormattingContext::Geometry::outOfFlowNonReplacedHorizontalGeometry):
+        (WebCore::Layout::FormattingContext::Geometry::outOfFlowReplacedHorizontalGeometry):
+        (WebCore::Layout::FormattingContext::Geometry::floatingNonReplacedWidthAndMargin):
+        (WebCore::Layout::FormattingContext::Geometry::floatingReplacedWidthAndMargin):
+        (WebCore::Layout::FormattingContext::Geometry::inlineReplacedWidthAndMargin):
+        (WebCore::Layout::FormattingContext::Geometry::computedPadding):
+        (WebCore::Layout::FormattingContext::Geometry::computedHorizontalMargin):
+        * layout/LayoutUnits.h:
+        (WebCore::Layout::UsedHorizontalValues::UsedHorizontalValues):
+        * layout/blockformatting/BlockFormattingContextGeometry.cpp:
+        (WebCore::Layout::BlockFormattingContext::Geometry::inFlowNonReplacedWidthAndMargin):
+        * layout/inlineformatting/InlineFormattingContextGeometry.cpp:
+        (WebCore::Layout::InlineFormattingContext::Geometry::inlineBlockWidthAndMargin):
+        * page/FrameViewLayoutContext.cpp:
+
+2019-02-08  Zalan Bujtas  <[email protected]>
+
         [LFC] Horizontal geometry compute functions should take the containing block's width as a used value
         https://bugs.webkit.org/show_bug.cgi?id=194424
 

Modified: trunk/Source/WebCore/layout/FormattingContextGeometry.cpp (241194 => 241195)


--- trunk/Source/WebCore/layout/FormattingContextGeometry.cpp	2019-02-08 13:57:09 UTC (rev 241194)
+++ trunk/Source/WebCore/layout/FormattingContextGeometry.cpp	2019-02-08 14:46:36 UTC (rev 241195)
@@ -246,7 +246,8 @@
     // 'padding-left', 'padding-right', 'border-right-width', 'margin-right', and the widths of any relevant scroll bars.
 
     // Then the shrink-to-fit width is: min(max(preferred minimum width, available width), preferred width).
-    auto availableWidth = usedValues.containingBlockWidth;
+    ASSERT(usedValues.containingBlockWidth.hasValue());
+    auto availableWidth = *usedValues.containingBlockWidth;
     auto instrinsicWidthConstraints = layoutState.createFormattingContext(formattingRoot)->instrinsicWidthConstraints();
     return std::min(std::max(instrinsicWidthConstraints.minimum, availableWidth), instrinsicWidthConstraints.maximum);
 }
@@ -410,7 +411,7 @@
     auto& displayBox = layoutState.displayBoxForLayoutBox(layoutBox);
     auto& containingBlock = *layoutBox.containingBlock();
     auto& containingBlockDisplayBox = layoutState.displayBoxForLayoutBox(containingBlock);
-    auto containingBlockWidth = usedValues.containingBlockWidth;
+    auto containingBlockWidth = usedValues.containingBlockWidth.valueOr(0);
     auto isLeftToRightDirection = containingBlock.style().isLeftToRightDirection();
     
     auto left = computedValueIfNotAuto(style.logicalLeft(), containingBlockWidth);
@@ -635,7 +636,7 @@
     auto& style = layoutBox.style();
     auto& displayBox = layoutState.displayBoxForLayoutBox(layoutBox);
     auto& containingBlock = *layoutBox.containingBlock();
-    auto containingBlockWidth = usedValues.containingBlockWidth;
+    auto containingBlockWidth = usedValues.containingBlockWidth.valueOr(0);
     auto isLeftToRightDirection = containingBlock.style().isLeftToRightDirection();
 
     auto left = computedValueIfNotAuto(style.logicalLeft(), containingBlockWidth);
@@ -766,7 +767,7 @@
     // #1
     auto usedHorizontallMargin = UsedHorizontalMargin { computedHorizontalMargin.start.valueOr(0), computedHorizontalMargin.end.valueOr(0) };
     // #2
-    auto width = computedValueIfNotAuto(usedValues.width ? Length { usedValues.width.value(), Fixed } : layoutBox.style().logicalWidth(), usedValues.containingBlockWidth);
+    auto width = computedValueIfNotAuto(usedValues.width ? Length { usedValues.width.value(), Fixed } : layoutBox.style().logicalWidth(), usedValues.containingBlockWidth.valueOr(0));
     if (!width)
         width = shrinkToFitWidth(layoutState, layoutBox, usedValues);
 
@@ -795,7 +796,8 @@
     auto computedHorizontalMargin = Geometry::computedHorizontalMargin(layoutBox, usedValues);
 
     LOG_WITH_STREAM(FormattingContextLayout, stream << "[Height][Margin] -> floating replaced -> redirected to inline replaced");
-    return inlineReplacedWidthAndMargin(layoutState, layoutBox, UsedHorizontalValues { usedValues.containingBlockWidth, usedValues.width, UsedHorizontalMargin { computedHorizontalMargin.start.valueOr(0), computedHorizontalMargin.end.valueOr(0) } });
+    return inlineReplacedWidthAndMargin(layoutState, layoutBox, UsedHorizontalValues { usedValues.containingBlockWidth.valueOr(0),
+        usedValues.width, UsedHorizontalMargin { computedHorizontalMargin.start.valueOr(0), computedHorizontalMargin.end.valueOr(0) } });
 }
 
 VerticalGeometry FormattingContext::Geometry::outOfFlowVerticalGeometry(const LayoutState& layoutState, const Box& layoutBox, UsedVerticalValues usedValues)
@@ -903,7 +905,7 @@
     //    If 300px is too wide to fit the device, UAs should use the width of the largest rectangle that has a 2:1 ratio and fits the device instead.
 
     auto& style = layoutBox.style();
-    auto containingBlockWidth = usedValues.containingBlockWidth;
+    auto containingBlockWidth = usedValues.containingBlockWidth.valueOr(0);
     auto computedHorizontalMargin = Geometry::computedHorizontalMargin(layoutBox, usedValues);
 
     auto usedMarginStart = [&] {
@@ -1042,10 +1044,11 @@
         return WTF::nullopt;
 
     auto& style = layoutBox.style();
+    auto containingBlockWidth = usedValues.containingBlockWidth.valueOr(0);
     LOG_WITH_STREAM(FormattingContextLayout, stream << "[Padding] -> layoutBox: " << &layoutBox);
     return Edges {
-        { valueForLength(style.paddingLeft(), usedValues.containingBlockWidth), valueForLength(style.paddingRight(), usedValues.containingBlockWidth) },
-        { valueForLength(style.paddingTop(), usedValues.containingBlockWidth), valueForLength(style.paddingBottom(), usedValues.containingBlockWidth) }
+        { valueForLength(style.paddingLeft(), containingBlockWidth), valueForLength(style.paddingRight(), containingBlockWidth) },
+        { valueForLength(style.paddingTop(), containingBlockWidth), valueForLength(style.paddingBottom(), containingBlockWidth) }
     };
 }
 
@@ -1052,7 +1055,8 @@
 ComputedHorizontalMargin FormattingContext::Geometry::computedHorizontalMargin(const Box& layoutBox, UsedHorizontalValues usedValues)
 {
     auto& style = layoutBox.style();
-    return { computedValueIfNotAuto(style.marginStart(), usedValues.containingBlockWidth), computedValueIfNotAuto(style.marginEnd(), usedValues.containingBlockWidth) };
+    auto containingBlockWidth = usedValues.containingBlockWidth.valueOr(0);
+    return { computedValueIfNotAuto(style.marginStart(), containingBlockWidth), computedValueIfNotAuto(style.marginEnd(), containingBlockWidth) };
 }
 
 ComputedVerticalMargin FormattingContext::Geometry::computedVerticalMargin(const LayoutState& layoutState, const Box& layoutBox)

Modified: trunk/Source/WebCore/layout/LayoutUnits.h (241194 => 241195)


--- trunk/Source/WebCore/layout/LayoutUnits.h	2019-02-08 13:57:09 UTC (rev 241194)
+++ trunk/Source/WebCore/layout/LayoutUnits.h	2019-02-08 14:46:36 UTC (rev 241195)
@@ -125,7 +125,7 @@
 };
 
 struct UsedHorizontalValues {
-    explicit UsedHorizontalValues(LayoutUnit containingBlockWidth, Optional<LayoutUnit> width, Optional<UsedHorizontalMargin> margin)
+    explicit UsedHorizontalValues(Optional<LayoutUnit> containingBlockWidth, Optional<LayoutUnit> width, Optional<UsedHorizontalMargin> margin)
         : containingBlockWidth(containingBlockWidth)
         , width(width)
         , margin(margin)
@@ -132,7 +132,7 @@
         {
         }
 
-    LayoutUnit containingBlockWidth;
+    Optional<LayoutUnit> containingBlockWidth;
     Optional<LayoutUnit> width;
     Optional<UsedHorizontalMargin> margin;
 };

Modified: trunk/Source/WebCore/layout/blockformatting/BlockFormattingContextGeometry.cpp (241194 => 241195)


--- trunk/Source/WebCore/layout/blockformatting/BlockFormattingContextGeometry.cpp	2019-02-08 13:57:09 UTC (rev 241194)
+++ trunk/Source/WebCore/layout/blockformatting/BlockFormattingContextGeometry.cpp	2019-02-08 14:46:36 UTC (rev 241195)
@@ -136,7 +136,7 @@
 
         auto& style = layoutBox.style();
         auto* containingBlock = layoutBox.containingBlock();
-        auto containingBlockWidth = usedValues.containingBlockWidth;
+        auto containingBlockWidth = usedValues.containingBlockWidth.valueOr(0);
         auto& displayBox = layoutState.displayBoxForLayoutBox(layoutBox);
 
         auto width = computedValueIfNotAuto(usedValues.width ? Length { usedValues.width.value(), Fixed } : style.logicalWidth(), containingBlockWidth);

Modified: trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContextGeometry.cpp (241194 => 241195)


--- trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContextGeometry.cpp	2019-02-08 13:57:09 UTC (rev 241194)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContextGeometry.cpp	2019-02-08 14:46:36 UTC (rev 241195)
@@ -53,7 +53,7 @@
     // 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(), usedValues.containingBlockWidth.valueOr(0));
     if (!width)
         width = shrinkToFitWidth(layoutState, formattingContextRoot, usedValues);
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to