[LFC] Inline replaced height calculation should use "used value"
authorzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 7 Sep 2018 04:24:38 +0000 (04:24 +0000)
committerzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 7 Sep 2018 04:24:38 +0000 (04:24 +0000)
https://bugs.webkit.org/show_bug.cgi?id=189395

Reviewed by Antti Koivisto.

Use the already assigned width value (aka used value) instead of the computed value when computing the inline's height.
see https://www.w3.org/TR/CSS22/cascade.html#value-stages for "used" and "computed" value.

* layout/FormattingContextGeometry.cpp:
(WebCore::Layout::FormattingContext::Geometry::inlineReplacedHeightAndMargin):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@235777 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/layout/FormattingContextGeometry.cpp

index c34c8f5..9d292b6 100644 (file)
@@ -1,3 +1,16 @@
+2018-09-06  Zalan Bujtas  <zalan@apple.com>
+
+        [LFC] Inline replaced height calculation should use "used value"
+        https://bugs.webkit.org/show_bug.cgi?id=189395
+
+        Reviewed by Antti Koivisto.
+
+        Use the already assigned width value (aka used value) instead of the computed value when computing the inline's height.
+        see https://www.w3.org/TR/CSS22/cascade.html#value-stages for "used" and "computed" value.
+
+        * layout/FormattingContextGeometry.cpp:
+        (WebCore::Layout::FormattingContext::Geometry::inlineReplacedHeightAndMargin):
+
 2018-09-06  Wenson Hsieh  <wenson_hsieh@apple.com>
 
         Refactor WebCore::EditAction to be an 8-bit enum class
index 81634d0..dc836fa 100644 (file)
@@ -788,22 +788,21 @@ HeightAndMargin FormattingContext::Geometry::inlineReplacedHeightAndMargin(const
 
     auto& style = layoutBox.style();
     auto replaced = layoutBox.replaced();
-    auto& containingBlockDisplayBox = layoutContext.displayBoxForLayoutBox(*layoutBox.containingBlock());
-    auto containingBlockWidth = containingBlockDisplayBox.width();
 
     auto height = fixedValue(precomputedHeight ? Length { precomputedHeight.value(), Fixed } : style.logicalHeight());
-    auto heightIsAuto = style.logicalHeight().isAuto();
-    auto width = computedValueIfNotAuto(style.logicalWidth(), containingBlockWidth);
+    auto heightIsAuto = !precomputedHeight && style.logicalHeight().isAuto();
+    auto widthIsAuto = style.logicalWidth().isAuto();
 
     if (!height && !heightIsAuto)
         ASSERT_NOT_IMPLEMENTED_YET();
 
-    if (heightIsAuto && !width && replaced->hasIntrinsicHeight()) {
+    if (heightIsAuto && widthIsAuto && replaced->hasIntrinsicHeight()) {
         // #2
         height = replaced->intrinsicHeight();
     } else if (heightIsAuto && replaced->hasIntrinsicRatio()) {
         // #3
-        height = *width / replaced->intrinsicRatio();
+        auto usedWidth = layoutContext.displayBoxForLayoutBox(layoutBox).width();
+        height = usedWidth / replaced->intrinsicRatio();
     } else if (heightIsAuto && replaced->hasIntrinsicHeight()) {
         // #4
         height = replaced->intrinsicHeight();