Modified: trunk/Source/WebCore/ChangeLog (231893 => 231894)
--- trunk/Source/WebCore/ChangeLog 2018-05-17 11:30:04 UTC (rev 231893)
+++ trunk/Source/WebCore/ChangeLog 2018-05-17 14:07:49 UTC (rev 231894)
@@ -1,3 +1,18 @@
+2018-05-17 Zalan Bujtas <[email protected]>
+
+ [LFC] Implement width computation for replaced out if flow elements.
+ https://bugs.webkit.org/show_bug.cgi?id=185701
+
+ Reviewed by Antti Koivisto.
+
+ The used value of 'width' is determined as for inline replaced elements.
+
+ * layout/FormattingContext.cpp:
+ (WebCore::Layout::FormattingContext::computeOutOfFlowNonReplacedHeight const):
+ (WebCore::Layout::FormattingContext::computeOutOfFlowNonReplacedWidth const):
+ (WebCore::Layout::FormattingContext::computeOutOfFlowReplacedWidth const):
+ * layout/FormattingContext.h:
+
2018-05-17 Thibault Saunier <[email protected]>
[GStreamer]: Consider GstStream(Collection) as if if was not a GInitiallyUnowned
Modified: trunk/Source/WebCore/layout/FormattingContext.cpp (231893 => 231894)
--- trunk/Source/WebCore/layout/FormattingContext.cpp 2018-05-17 11:30:04 UTC (rev 231893)
+++ trunk/Source/WebCore/layout/FormattingContext.cpp 2018-05-17 14:07:49 UTC (rev 231894)
@@ -93,7 +93,7 @@
ASSERT_NOT_REACHED();
return;
}
- computeInFlowReplacedWidth(layoutContext, layoutBox, displayBox);
+ computeReplacedWidth(layoutContext, layoutBox, displayBox);
}
void FormattingContext::computeOutOfFlowHeight(LayoutContext& layoutContext, const Box& layoutBox, Display::Box& displayBox) const
@@ -154,6 +154,10 @@
void FormattingContext::computeOutOfFlowNonReplacedHeight(LayoutContext& layoutContext, const Box& layoutBox, Display::Box& displayBox) const
{
+ ASSERT(layoutBox.isOutOfFlowPositioned() && !layoutBox.isReplaced());
+
+ // 10.6.4 Absolutely positioned, non-replaced elements
+ //
// For absolutely positioned elements, the used values of the vertical dimensions must satisfy this constraint:
// 'top' + 'margin-top' + 'border-top-width' + 'padding-top' + 'height' + 'padding-bottom' + 'border-bottom-width' + 'margin-bottom' + 'bottom'
// = height of containing block
@@ -208,11 +212,14 @@
displayBox.setHeight(computedHeightValue);
}
-void FormattingContext::computeInFlowReplacedWidth(LayoutContext&, const Box& layoutBox, Display::Box& displayBox) const
+void FormattingContext::computeReplacedWidth(LayoutContext&, const Box& layoutBox, Display::Box& displayBox) const
{
- // 10.3.4 Block-level, replaced elements in normal flow: The used value of 'width' is determined as for inline replaced elements
- // 10.3.6 Floating, replaced elements: The used value of 'width' is determined as for inline replaced elements.
+ ASSERT((layoutBox.isOutOfFlowPositioned() || layoutBox.isFloatingPositioned() || layoutBox.isInFlow()) && layoutBox.isReplaced());
+ // 10.3.4 Block-level, replaced elements in normal flow: The used value of 'width' is determined as for inline replaced elements.
+ // 10.3.6 Floating, replaced elements: The used value of 'width' is determined as for inline replaced elements.
+ // 10.3.8 Absolutely positioned, replaced elements: The used value of 'width' is determined as for inline replaced elements.
+
// 10.3.2 Inline, replaced elements
//
// 1. If 'height' and 'width' both have computed values of 'auto' and the element also has an intrinsic width, then that intrinsic width is the used value of 'width'.
@@ -260,6 +267,7 @@
LayoutUnit FormattingContext::contentHeightForFormattingContextRoot(LayoutContext& layoutContext, const Box& layoutBox) const
{
ASSERT(layoutBox.style().logicalHeight().isAuto());
+
if (!is<Container>(layoutBox) || !downcast<Container>(layoutBox).hasInFlowOrFloatingChild())
return 0;
@@ -287,6 +295,10 @@
void FormattingContext::computeOutOfFlowNonReplacedWidth(LayoutContext& layoutContext, const Box& layoutBox, Display::Box& displayBox) const
{
+ ASSERT(layoutBox.isOutOfFlowPositioned() && !layoutBox.isReplaced());
+
+ // 10.3.7 Absolutely positioned, non-replaced elements
+ //
// 'left' + 'margin-left' + 'border-left-width' + 'padding-left' + 'width' + 'padding-right' + 'border-right-width' + 'margin-right' + 'right'
// = width of containing block
@@ -335,6 +347,15 @@
displayBox.setWidth(computedWidthValue);
}
+void FormattingContext::computeOutOfFlowReplacedWidth(LayoutContext& layoutContext, const Box& layoutBox, Display::Box& displayBox) const
+{
+ ASSERT(layoutBox.isOutOfFlowPositioned() && layoutBox.isReplaced());
+ // 10.3.8 Absolutely positioned, replaced elements
+ //
+ // The used value of 'width' is determined as for inline replaced elements.
+ computeReplacedWidth(layoutContext, layoutBox, displayBox);
+}
+
LayoutUnit FormattingContext::shrinkToFitWidth(LayoutContext&, const Box&) const
{
return 0;
Modified: trunk/Source/WebCore/layout/FormattingContext.h (231893 => 231894)
--- trunk/Source/WebCore/layout/FormattingContext.h 2018-05-17 11:30:04 UTC (rev 231893)
+++ trunk/Source/WebCore/layout/FormattingContext.h 2018-05-17 14:07:49 UTC (rev 231894)
@@ -87,11 +87,12 @@
void placeInFlowPositionedChildren(const Container&) const;
void layoutOutOfFlowDescendants(LayoutContext&s) const;
- void computeInFlowReplacedWidth(LayoutContext&, const Box&, Display::Box&) const;
+ void computeReplacedWidth(LayoutContext&, const Box&, Display::Box&) const;
private:
void computeOutOfFlowNonReplacedHeight(LayoutContext&, const Box&, Display::Box&) const;
void computeOutOfFlowNonReplacedWidth(LayoutContext&, const Box&, Display::Box&) const;
+ void computeOutOfFlowReplacedWidth(LayoutContext&, const Box&, Display::Box&) const;
LayoutUnit contentHeightForFormattingContextRoot(LayoutContext&, const Box&) const;
LayoutUnit shrinkToFitWidth(LayoutContext&, const Box&) const;
Modified: trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp (231893 => 231894)
--- trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp 2018-05-17 11:30:04 UTC (rev 231893)
+++ trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp 2018-05-17 14:07:49 UTC (rev 231894)
@@ -149,11 +149,13 @@
computeInFlowNonReplacedWidth(layoutContext, layoutBox, displayBox);
return;
}
- computeInFlowReplacedWidth(layoutContext, layoutBox, displayBox);
+ computeReplacedWidth(layoutContext, layoutBox, displayBox);
}
void BlockFormattingContext::computeInFlowNonReplacedWidth(LayoutContext& layoutContext, const Box& layoutBox, Display::Box& displayBox) const
{
+ ASSERT(layoutBox.isInFlow() && !layoutBox.isReplaced());
+
// 10.3.3 Block-level, non-replaced elements in normal flow
// The following constraints must hold among the used values of the other properties:
// 'margin-left' + 'border-left-width' + 'padding-left' + 'width' + 'padding-right' + 'border-right-width' + 'margin-right' = width of containing block
@@ -202,6 +204,8 @@
void BlockFormattingContext::computeInFlowNonReplacedHeight(LayoutContext& layoutContext, const Box& layoutBox, Display::Box& displayBox) const
{
+ ASSERT(layoutBox.isInFlow() && !layoutBox.isReplaced());
+
// https://www.w3.org/TR/CSS22/visudet.html
// If 'height' is 'auto', the height depends on whether the element has any block-level children and whether it has padding or borders:
// The element's height is the distance from its top content edge to the first applicable of the following: