Title: [181387] trunk
Revision
181387
Author
mmaxfi...@apple.com
Date
2015-03-11 07:41:01 -0700 (Wed, 11 Mar 2015)

Log Message

Inline block children do not have correct baselines if their children are also block elements
https://bugs.webkit.org/show_bug.cgi?id=142559

Patch by Myles C. Maxfield <mmaxfi...@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.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (181386 => 181387)


--- trunk/LayoutTests/ChangeLog	2015-03-11 14:09:29 UTC (rev 181386)
+++ trunk/LayoutTests/ChangeLog	2015-03-11 14:41:01 UTC (rev 181387)
@@ -1,3 +1,13 @@
+2015-03-11  Myles C. Maxfield  <mmaxfi...@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  <pecor...@apple.com>
 
         Web Inspector: CSS parser errors in the console should include column numbers

Added: trunk/LayoutTests/fast/text/baseline-inline-block-block-children-expected.html (0 => 181387)


--- trunk/LayoutTests/fast/text/baseline-inline-block-block-children-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/text/baseline-inline-block-block-children-expected.html	2015-03-11 14:41:01 UTC (rev 181387)
@@ -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

Added: trunk/LayoutTests/fast/text/baseline-inline-block-block-children.html (0 => 181387)


--- trunk/LayoutTests/fast/text/baseline-inline-block-block-children.html	                        (rev 0)
+++ trunk/LayoutTests/fast/text/baseline-inline-block-block-children.html	2015-03-11 14:41:01 UTC (rev 181387)
@@ -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

Modified: trunk/Source/WebCore/ChangeLog (181386 => 181387)


--- trunk/Source/WebCore/ChangeLog	2015-03-11 14:09:29 UTC (rev 181386)
+++ trunk/Source/WebCore/ChangeLog	2015-03-11 14:41:01 UTC (rev 181387)
@@ -1,3 +1,17 @@
+2015-03-11  Myles C. Maxfield  <mmaxfi...@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  <clo...@igalia.com>
 
         [CMake][GStreamer] Building EFL or GTK with ENABLE_VIDEO and without ENABLE_WEB_AUDIO is broken.

Modified: trunk/Source/WebCore/rendering/RenderBlockFlow.cpp (181386 => 181387)


--- trunk/Source/WebCore/rendering/RenderBlockFlow.cpp	2015-03-11 14:09:29 UTC (rev 181386)
+++ trunk/Source/WebCore/rendering/RenderBlockFlow.cpp	2015-03-11 14:41:01 UTC (rev 181387)
@@ -3011,27 +3011,28 @@
     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
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to