Inline block children do not have correct baselines if their children are also block...
authormmaxfield@apple.com <mmaxfield@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 11 Mar 2015 14:41:01 +0000 (14:41 +0000)
committermmaxfield@apple.com <mmaxfield@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 11 Mar 2015 14:41:01 +0000 (14:41 +0000)
https://bugs.webkit.org/show_bug.cgi?id=142559

Patch by Myles C. Maxfield <mmaxfield@apple.com> on 2015-03-11
Reviewed by Darin Adler.

Source/WebCore:

Perform the same computation on child block elements as child inline elements.

Test: fast/text/baseline-inline-block-block-children.html

* rendering/RenderBlockFlow.cpp:
(WebCore::RenderBlockFlow::inlineBlockBaseline):

LayoutTests:

* fast/text/baseline-inline-block-block-children-expected.html: Added.
* fast/text/baseline-inline-block-block-children.html: Added.

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

LayoutTests/ChangeLog
LayoutTests/fast/text/baseline-inline-block-block-children-expected.html [new file with mode: 0644]
LayoutTests/fast/text/baseline-inline-block-block-children.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/rendering/RenderBlockFlow.cpp

index 641ba3a61edd0e7ebed21c72b9ad9db7c9ab7473..1bce10336b682332c6f0b362821fe3fca8146b3a 100644 (file)
@@ -1,3 +1,13 @@
+2015-03-11  Myles C. Maxfield  <mmaxfield@apple.com>
+
+        Inline block children do not have correct baselines if their children are also block elements
+        https://bugs.webkit.org/show_bug.cgi?id=142559
+
+        Reviewed by Darin Adler.
+
+        * fast/text/baseline-inline-block-block-children-expected.html: Added.
+        * fast/text/baseline-inline-block-block-children.html: Added.
+
 2015-03-10  Joseph Pecoraro  <pecoraro@apple.com>
 
         Web Inspector: CSS parser errors in the console should include column numbers
diff --git a/LayoutTests/fast/text/baseline-inline-block-block-children-expected.html b/LayoutTests/fast/text/baseline-inline-block-block-children-expected.html
new file mode 100644 (file)
index 0000000..2e47897
--- /dev/null
@@ -0,0 +1,7 @@
+This tests that block children of overflow: scroll have the correct baseline calculated.<br>
+<div style="display: inline-block; background: green;">
+    <div style="height: 150px; width: 200px; overflow: scroll;">
+        Overflow with<br>overflow: scroll<br>M<br>M<br>M<br>M<br>M<br>M<br>M<br>M<br>M<br>M<br>M
+    </div>
+</div>
+Baseline
diff --git a/LayoutTests/fast/text/baseline-inline-block-block-children.html b/LayoutTests/fast/text/baseline-inline-block-block-children.html
new file mode 100644 (file)
index 0000000..0ee980a
--- /dev/null
@@ -0,0 +1,7 @@
+This tests that block children of overflow: scroll have the correct baseline calculated.<br>
+<div style="display: inline-block; background: green;">
+    <div style="height: 150px; width: 200px; overflow: scroll;">
+        <div>Overflow with<br>overflow: scroll</div>M<br>M<br>M<br>M<br>M<br>M<br>M<br>M<br>M<br>M<br>M
+    </div>
+</div>
+Baseline
index b531c650979fab08a3e05d49dca0081571dc631c..2ef31fdd8836299e838f2f086d3afc515463815c 100644 (file)
@@ -1,3 +1,17 @@
+2015-03-11  Myles C. Maxfield  <mmaxfield@apple.com>
+
+        Inline block children do not have correct baselines if their children are also block elements
+        https://bugs.webkit.org/show_bug.cgi?id=142559
+
+        Reviewed by Darin Adler.
+
+        Perform the same computation on child block elements as child inline elements.
+
+        Test: fast/text/baseline-inline-block-block-children.html
+
+        * rendering/RenderBlockFlow.cpp:
+        (WebCore::RenderBlockFlow::inlineBlockBaseline):
+
 2015-03-11  Carlos Alberto Lopez Perez  <clopez@igalia.com>
 
         [CMake][GStreamer] Building EFL or GTK with ENABLE_VIDEO and without ENABLE_WEB_AUDIO is broken.
index e53243823016c97dcf6129f0a601415e7ae4e105..075a050bc20abb878f00bd569b9942cb3d5a0017 100644 (file)
@@ -3011,27 +3011,28 @@ int RenderBlockFlow::inlineBlockBaseline(LineDirectionMode lineDirection) const
     if (isWritingModeRoot() && !isRubyRun())
         return -1;
 
-    if (!childrenInline())
-        return RenderBlock::inlineBlockBaseline(lineDirection);
-
-    if (!hasLines()) {
-        if (!hasLineIfEmpty())
-            return -1;
-        const FontMetrics& fontMetrics = firstLineStyle().fontMetrics();
-        return fontMetrics.ascent()
-             + (lineHeight(true, lineDirection, PositionOfInteriorLineBoxes) - fontMetrics.height()) / 2
-             + (lineDirection == HorizontalLine ? borderTop() + paddingTop() : borderRight() + paddingRight());
-    }
-
     // Note that here we only take the left and bottom into consideration. Our caller takes the right and top into consideration.
     float boxHeight = lineDirection == HorizontalLine ? height() + m_marginBox.bottom() : width() + m_marginBox.left();
     float lastBaseline;
-    if (auto simpleLineLayout = this->simpleLineLayout())
-        lastBaseline = SimpleLineLayout::computeFlowLastLineBaseline(*this, *simpleLineLayout);
+    if (!childrenInline())
+        lastBaseline = RenderBlock::inlineBlockBaseline(lineDirection);
     else {
-        bool isFirstLine = lastRootBox() == firstRootBox();
-        const RenderStyle& style = isFirstLine ? firstLineStyle() : this->style();
-        lastBaseline = lastRootBox()->logicalTop() + style.fontMetrics().ascent(lastRootBox()->baselineType());
+        if (!hasLines()) {
+            if (!hasLineIfEmpty())
+                return -1;
+            const auto& fontMetrics = firstLineStyle().fontMetrics();
+            return fontMetrics.ascent()
+                + (lineHeight(true, lineDirection, PositionOfInteriorLineBoxes) - fontMetrics.height()) / 2
+                + (lineDirection == HorizontalLine ? borderTop() + paddingTop() : borderRight() + paddingRight());
+        }
+
+        if (auto simpleLineLayout = this->simpleLineLayout())
+            lastBaseline = SimpleLineLayout::computeFlowLastLineBaseline(*this, *simpleLineLayout);
+        else {
+            bool isFirstLine = lastRootBox() == firstRootBox();
+            const auto& style = isFirstLine ? firstLineStyle() : this->style();
+            lastBaseline = lastRootBox()->logicalTop() + style.fontMetrics().ascent(lastRootBox()->baselineType());
+        }
     }
     // According to the CSS spec http://www.w3.org/TR/CSS21/visudet.html, we shouldn't be performing this min, but should
     // instead be returning boxHeight directly. However, we feel that a min here is better behavior (and is consistent