Modified: trunk/Source/WebCore/layout/FormattingContext.cpp (231952 => 231953)
--- trunk/Source/WebCore/layout/FormattingContext.cpp 2018-05-18 14:30:44 UTC (rev 231952)
+++ trunk/Source/WebCore/layout/FormattingContext.cpp 2018-05-18 14:31:02 UTC (rev 231953)
@@ -74,7 +74,7 @@
if (layoutBox.isOutOfFlowPositioned())
return computeOutOfFlowHeight(layoutContext, layoutBox, displayBox);
if (layoutBox.isFloatingPositioned())
- return computeFloatingHeight(layoutBox, displayBox);
+ return computeFloatingHeight(layoutContext, layoutBox, displayBox);
return computeInFlowHeight(layoutContext, layoutBox, displayBox);
}
@@ -84,7 +84,7 @@
computeOutOfFlowNonReplacedWidth(layoutContext, layoutBox, displayBox);
return;
}
- ASSERT_NOT_IMPLEMENTED_YET();
+ computeOutOfFlowReplacedWidth(layoutContext, layoutBox, displayBox);
}
void FormattingContext::computeFloatingWidth(LayoutContext& layoutContext, const Box& layoutBox, Display::Box& displayBox) const
@@ -102,11 +102,16 @@
computeOutOfFlowNonReplacedHeight(layoutContext, layoutBox, displayBox);
return;
}
- ASSERT_NOT_IMPLEMENTED_YET();
+ computeOutOfFlowReplacedHeight(layoutContext, layoutBox, displayBox);
}
-void FormattingContext::computeFloatingHeight(const Box&, Display::Box&) const
+void FormattingContext::computeFloatingHeight(LayoutContext& layoutContext, const Box& layoutBox, Display::Box& displayBox) const
{
+ if (!layoutBox.replaced()) {
+ ASSERT_NOT_IMPLEMENTED_YET();
+ return;
+ }
+ computeReplacedHeight(layoutContext, layoutBox, displayBox);
}
LayoutUnit FormattingContext::marginTop(const Box&) const
@@ -212,6 +217,50 @@
displayBox.setHeight(computedHeightValue);
}
+void FormattingContext::computeReplacedHeight(LayoutContext&, const Box& layoutBox, Display::Box& displayBox) const
+{
+ ASSERT((layoutBox.isOutOfFlowPositioned() || layoutBox.isFloatingPositioned() || layoutBox.isInFlow()) && layoutBox.replaced());
+ // 10.6.5 Absolutely positioned, replaced elements. The used value of 'height' is determined as for inline replaced elements.
+
+ // 10.6.2 Inline replaced elements, block-level replaced elements in normal flow, 'inline-block' replaced elements in normal flow and floating replaced elements
+ //
+ // 1. If 'height' and 'width' both have computed values of 'auto' and the element also has an intrinsic height, then that intrinsic height is the used value of 'height'.
+ //
+ // 2. Otherwise, if 'height' has a computed value of 'auto', and the element has an intrinsic ratio then the used value of 'height' is:
+ // (used width) / (intrinsic ratio)
+ //
+ // 3. Otherwise, if 'height' has a computed value of 'auto', and the element has an intrinsic height, then that intrinsic height is the used value of 'height'.
+ //
+ // 4. Otherwise, if 'height' has a computed value of 'auto', but none of the conditions above are met, then the used value of 'height' must be set to
+ // the height of the largest rectangle that has a 2:1 ratio, has a height not greater than 150px, and has a width not greater than the device width.
+ auto& style = layoutBox.style();
+ auto width = style.logicalWidth();
+ auto height = style.logicalHeight();
+
+ LayoutUnit computedHeightValue;
+ auto replaced = layoutBox.replaced();
+ ASSERT(replaced);
+
+ if (height.isAuto()) {
+ if (width.isAuto() && replaced->hasIntrinsicHeight()) {
+ // #1
+ computedHeightValue = replaced->intrinsicHeight();
+ } else if (replaced->hasIntrinsicRatio()) {
+ // #2
+ computedHeightValue = width.value() / replaced->intrinsicRatio();
+ } else if (replaced->hasIntrinsicHeight()) {
+ // #3
+ computedHeightValue = replaced->intrinsicHeight();
+ } else {
+ // #4
+ computedHeightValue = 150;
+ }
+ } else
+ computedHeightValue = height.value();
+
+ displayBox.setHeight(computedHeightValue);
+}
+
void FormattingContext::computeReplacedWidth(LayoutContext&, const Box& layoutBox, Display::Box& displayBox) const
{
ASSERT((layoutBox.isOutOfFlowPositioned() || layoutBox.isFloatingPositioned() || layoutBox.isInFlow()) && layoutBox.replaced());
@@ -263,7 +312,7 @@
computedWidthValue = 300;
}
- displayBox.setWidth(computedWidthValue);
+ displayBox.setWidth(computedWidthValue);
}
LayoutUnit FormattingContext::contentHeightForFormattingContextRoot(LayoutContext& layoutContext, const Box& layoutBox) const
@@ -359,6 +408,15 @@
displayBox.setWidth(computedWidthValue);
}
+void FormattingContext::computeOutOfFlowReplacedHeight(LayoutContext& layoutContext, const Box& layoutBox, Display::Box& displayBox) const
+{
+ ASSERT(layoutBox.isOutOfFlowPositioned() && layoutBox.replaced());
+ // 10.6.5 Absolutely positioned, replaced elements
+ //
+ // The used value of 'height' is determined as for inline replaced elements.
+ computeReplacedHeight(layoutContext, layoutBox, displayBox);
+}
+
void FormattingContext::computeOutOfFlowReplacedWidth(LayoutContext& layoutContext, const Box& layoutBox, Display::Box& displayBox) const
{
ASSERT(layoutBox.isOutOfFlowPositioned() && layoutBox.replaced());
Modified: trunk/Source/WebCore/layout/FormattingContext.h (231952 => 231953)
--- trunk/Source/WebCore/layout/FormattingContext.h 2018-05-18 14:30:44 UTC (rev 231952)
+++ trunk/Source/WebCore/layout/FormattingContext.h 2018-05-18 14:31:02 UTC (rev 231953)
@@ -76,7 +76,7 @@
virtual void computeInFlowWidth(LayoutContext&, const Box&, Display::Box&) const = 0;
virtual void computeOutOfFlowHeight(LayoutContext&, const Box&, Display::Box&) const;
- virtual void computeFloatingHeight(const Box&, Display::Box&) const;
+ virtual void computeFloatingHeight(LayoutContext&, const Box&, Display::Box&) const;
virtual void computeInFlowHeight(LayoutContext&, const Box&, Display::Box&) const = 0;
virtual LayoutUnit marginTop(const Box&) const;
@@ -87,11 +87,13 @@
void placeInFlowPositionedChildren(const Container&) const;
void layoutOutOfFlowDescendants(LayoutContext&s) const;
+ void computeReplacedHeight(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 computeOutOfFlowReplacedHeight(LayoutContext&, const Box&, Display::Box&) const;
void computeOutOfFlowReplacedWidth(LayoutContext&, const Box&, Display::Box&) const;
void computeFloatingNonReplacedWidth(LayoutContext&, const Box&, Display::Box&) const;
Modified: trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp (231952 => 231953)
--- trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp 2018-05-18 14:30:44 UTC (rev 231952)
+++ trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp 2018-05-18 14:31:02 UTC (rev 231953)
@@ -189,7 +189,7 @@
computeInFlowNonReplacedHeight(layoutContext, layoutBox, displayBox);
return;
}
- ASSERT_NOT_IMPLEMENTED_YET();
+ computeReplacedHeight(layoutContext, layoutBox, displayBox);
}
LayoutUnit BlockFormattingContext::marginTop(const Box& layoutBox) const