Title: [149929] trunk
Revision
149929
Author
[email protected]
Date
2013-05-11 05:08:57 -0700 (Sat, 11 May 2013)

Log Message

Text flow broken in elements with vertical align top/bottom and inline elements taller than line-height
https://bugs.webkit.org/show_bug.cgi?id=111974

Source/WebCore:

Reviewed by Ryosuke Niwa.

Per http://www.w3.org/TR/CSS2/visudet.html#propdef-vertical-align 'vertical-align' only applies to inline and table-cell
elements.

Test: fast/css/vertical-align-block-elements.html

* rendering/InlineFlowBox.cpp:
(WebCore::isTextInBlockElement):
(WebCore):
(WebCore::InlineFlowBox::adjustMaxAscentAndDescent):
(WebCore::InlineFlowBox::computeLogicalBoxHeights):
(WebCore::InlineFlowBox::placeBoxesInBlockDirection):

LayoutTests:

Reviewed by Ryosuke Niwa.

* editing/execCommand/query-command-state-expected.txt:
* editing/execCommand/script-tests/query-command-state.js: Remove invalid tests, vertical-align does not apply to
  div elements.
(runTests):
* fast/css/vertical-align-block-elements-expected.html: Added.
* fast/css/vertical-align-block-elements.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (149928 => 149929)


--- trunk/LayoutTests/ChangeLog	2013-05-11 08:36:42 UTC (rev 149928)
+++ trunk/LayoutTests/ChangeLog	2013-05-11 12:08:57 UTC (rev 149929)
@@ -1,3 +1,17 @@
+2013-03-17  Robert Hogan  <[email protected]>
+
+        Text flow broken in elements with vertical align top/bottom and inline elements taller than line-height
+        https://bugs.webkit.org/show_bug.cgi?id=111974
+
+        Reviewed by Ryosuke Niwa.
+
+        * editing/execCommand/query-command-state-expected.txt:
+        * editing/execCommand/script-tests/query-command-state.js: Remove invalid tests, vertical-align does not apply to 
+          div elements.
+        (runTests):
+        * fast/css/vertical-align-block-elements-expected.html: Added.
+        * fast/css/vertical-align-block-elements.html: Added.
+
 2013-05-10  Alexey Proskuryakov  <[email protected]>
 
         <rdar://problem/13666412> Clean up some edge cases of URL parsing.

Modified: trunk/LayoutTests/editing/execCommand/query-command-state-expected.txt (149928 => 149929)


--- trunk/LayoutTests/editing/execCommand/query-command-state-expected.txt	2013-05-11 08:36:42 UTC (rev 149928)
+++ trunk/LayoutTests/editing/execCommand/query-command-state-expected.txt	2013-05-11 12:08:57 UTC (rev 149929)
@@ -31,7 +31,6 @@
 PASS queryCommandState("subscript") returns true when selecting all of "<sub>hello</sub>"
 PASS queryCommandState("subscript") returns false when selecting all of "<sub>hello</sub> world"
 PASS queryCommandState("subscript") returns false when selecting all of "hello <sub>world</sub>"
-PASS queryCommandState("subscript") returns true when selecting all of "<div style="vertical-align: sub;">hello world</div>"
 PASS queryCommandState("subscript") returns false when selecting second word of "hello <span style="vertical-align: sub;">world</span> WebKit"
 PASS queryCommandState("superscript") returns false when selecting all of "hello"
 PASS queryCommandState("superscript") returns false when selecting all of "<sub>hello</sub>"
@@ -89,7 +88,6 @@
 PASS queryCommandState("subscript") returns true when selecting all of "<sub>hello</sub>"
 PASS queryCommandState("subscript") returns true when selecting all of "<sub>hello</sub> world"
 PASS queryCommandState("subscript") returns false when selecting all of "hello <sub>world</sub>"
-PASS queryCommandState("subscript") returns true when selecting all of "<div style="vertical-align: sub;">hello world</div>"
 PASS queryCommandState("subscript") returns true when selecting second word of "hello <span style="vertical-align: sub;">world</span> WebKit"
 PASS queryCommandState("superscript") returns false when selecting all of "hello"
 PASS queryCommandState("superscript") returns false when selecting all of "<sub>hello</sub>"

Modified: trunk/LayoutTests/editing/execCommand/script-tests/query-command-state.js (149928 => 149929)


--- trunk/LayoutTests/editing/execCommand/script-tests/query-command-state.js	2013-05-11 08:36:42 UTC (rev 149928)
+++ trunk/LayoutTests/editing/execCommand/script-tests/query-command-state.js	2013-05-11 12:08:57 UTC (rev 149929)
@@ -75,7 +75,6 @@
     testQueryCommandState("subscript", '<sub>hello</sub>', selectAll, {'mac': true, 'win': true}[editingBehavior]);
     testQueryCommandState("subscript", '<sub>hello</sub> world', selectAll, {'mac': true, 'win': false}[editingBehavior]);
     testQueryCommandState("subscript", 'hello <sub>world</sub>', selectAll, {'mac': false, 'win': false}[editingBehavior]);
-    testQueryCommandState("subscript", '<div style="vertical-align: sub;">hello world</div>', selectAll, {'mac': true, 'win': true}[editingBehavior]);
     testQueryCommandState("subscript", 'hello <span style="vertical-align: sub;">world</span> WebKit', selectSecondWord, {'mac': true, 'win': false}[editingBehavior]);
 
     testQueryCommandState("superscript", 'hello', selectAll, {'mac': false, 'win': false}[editingBehavior]);

Added: trunk/LayoutTests/fast/css/vertical-align-block-elements-expected.html (0 => 149929)


--- trunk/LayoutTests/fast/css/vertical-align-block-elements-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/css/vertical-align-block-elements-expected.html	2013-05-11 12:08:57 UTC (rev 149929)
@@ -0,0 +1,23 @@
+<!DOCTYPE html>
+<html>
+<head>
+<style>
+    div {
+        line-height: 30px;
+        font-size: 14px;
+    }
+    button {
+        height: 30px;
+    }
+</style>
+</script>
+</head>
+<body>
+    <p>Bug: webkit.org/b/111974 - vertical-align only applies to inline-level elements and table-cells. The text below should be aligned horiontally.
+    <div>
+        <button>All </button> This <span>text</span> is <a href=""
+    </div>
+</body>
+</html>
+
+
Property changes on: trunk/LayoutTests/fast/css/vertical-align-block-elements-expected.html
___________________________________________________________________

Added: svn:eol-style

Added: trunk/LayoutTests/fast/css/vertical-align-block-elements.html (0 => 149929)


--- trunk/LayoutTests/fast/css/vertical-align-block-elements.html	                        (rev 0)
+++ trunk/LayoutTests/fast/css/vertical-align-block-elements.html	2013-05-11 12:08:57 UTC (rev 149929)
@@ -0,0 +1,25 @@
+<!DOCTYPE html>
+<html>
+<head>
+<style>
+    div {
+        vertical-align: top;
+        line-height: 20px;
+        height: 20px;
+        font-size: 14px;
+    }
+    button {
+        height: 30px;
+    }
+</style>
+</script>
+</head>
+<body>
+    <p>Bug: webkit.org/b/111974 - vertical-align only applies to inline-level elements and table-cells. The text below should be aligned horiontally.
+    <div>
+        <button>All </button> This <span>text</span> is <a href=""
+    </div>
+</body>
+</html>
+
+
Property changes on: trunk/LayoutTests/fast/css/vertical-align-block-elements.html
___________________________________________________________________

Added: svn:eol-style

Modified: trunk/Source/WebCore/ChangeLog (149928 => 149929)


--- trunk/Source/WebCore/ChangeLog	2013-05-11 08:36:42 UTC (rev 149928)
+++ trunk/Source/WebCore/ChangeLog	2013-05-11 12:08:57 UTC (rev 149929)
@@ -1,3 +1,22 @@
+2013-03-17  Robert Hogan  <[email protected]>
+
+        Text flow broken in elements with vertical align top/bottom and inline elements taller than line-height
+        https://bugs.webkit.org/show_bug.cgi?id=111974
+
+        Reviewed by Ryosuke Niwa.
+        
+        Per http://www.w3.org/TR/CSS2/visudet.html#propdef-vertical-align 'vertical-align' only applies to inline and table-cell
+        elements.
+
+        Test: fast/css/vertical-align-block-elements.html
+
+        * rendering/InlineFlowBox.cpp:
+        (WebCore::isTextInBlockElement):
+        (WebCore):
+        (WebCore::InlineFlowBox::adjustMaxAscentAndDescent):
+        (WebCore::InlineFlowBox::computeLogicalBoxHeights):
+        (WebCore::InlineFlowBox::placeBoxesInBlockDirection):
+
 2013-05-11  Benjamin Poulain  <[email protected]>
 
         Make CanvasStyle a plain object instead of an RefCounted object

Modified: trunk/Source/WebCore/rendering/InlineFlowBox.cpp (149928 => 149929)


--- trunk/Source/WebCore/rendering/InlineFlowBox.cpp	2013-05-11 08:36:42 UTC (rev 149928)
+++ trunk/Source/WebCore/rendering/InlineFlowBox.cpp	2013-05-11 12:08:57 UTC (rev 149929)
@@ -480,6 +480,14 @@
     return false;
 }
 
+static bool verticalAlignApplies(RenderObject* curr)
+{
+    // The vertical-align property only applies to inline elements and table cells.
+    if (curr->isRenderBlock() && !curr->isInline())
+        printf("block-flow block\n");
+    return !curr->isText() || curr->parent()->isInline() || curr->parent()->isTableCell();
+}
+
 void InlineFlowBox::adjustMaxAscentAndDescent(int& maxAscent, int& maxDescent, int maxPositionTop, int maxPositionBottom)
 {
     for (InlineBox* curr = firstChild(); curr; curr = curr->nextOnLine()) {
@@ -487,7 +495,8 @@
         // positioned elements
         if (curr->renderer()->isOutOfFlowPositioned())
             continue; // Positioned placeholders don't affect calculations.
-        if (curr->verticalAlign() == TOP || curr->verticalAlign() == BOTTOM) {
+
+        if ((curr->verticalAlign() == TOP || curr->verticalAlign() == BOTTOM) && verticalAlignApplies(curr->renderer())) {
             int lineHeight = curr->lineHeight();
             if (curr->verticalAlign() == TOP) {
                 if (maxAscent + maxDescent < lineHeight)
@@ -570,10 +579,10 @@
         rootBox->ascentAndDescentForBox(curr, textBoxDataMap, ascent, descent, affectsAscent, affectsDescent);
 
         LayoutUnit boxHeight = ascent + descent;
-        if (curr->verticalAlign() == TOP) {
+        if (curr->verticalAlign() == TOP && verticalAlignApplies(curr->renderer())) {
             if (maxPositionTop < boxHeight)
                 maxPositionTop = boxHeight;
-        } else if (curr->verticalAlign() == BOTTOM) {
+        } else if (curr->verticalAlign() == BOTTOM && verticalAlignApplies(curr->renderer())) {
             if (maxPositionBottom < boxHeight)
                 maxPositionBottom = boxHeight;
         } else if (!inlineFlowBox || strictMode || inlineFlowBox->hasTextChildren() || (inlineFlowBox->descendantsHaveSameLineHeightAndBaseline() && inlineFlowBox->hasTextDescendants())
@@ -633,9 +642,10 @@
 
         InlineFlowBox* inlineFlowBox = curr->isInlineFlowBox() ? toInlineFlowBox(curr) : 0;
         bool childAffectsTopBottomPos = true;
-        if (curr->verticalAlign() == TOP)
+
+        if (curr->verticalAlign() == TOP && verticalAlignApplies(curr->renderer()))
             curr->setLogicalTop(top);
-        else if (curr->verticalAlign() == BOTTOM)
+        else if (curr->verticalAlign() == BOTTOM && verticalAlignApplies(curr->renderer()))
             curr->setLogicalTop(top + maxHeight - curr->lineHeight());
         else {
             if (!strictMode && inlineFlowBox && !inlineFlowBox->hasTextChildren() && !curr->boxModelObject()->hasInlineDirectionBordersOrPadding()
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to