Title: [122663] trunk
Revision
122663
Author
[email protected]
Date
2012-07-14 01:57:27 -0700 (Sat, 14 Jul 2012)

Log Message

CSS 2.1 failure: vertical-align-boxes-001 fails
https://bugs.webkit.org/show_bug.cgi?id=90626

Reviewed by Eric Seidel.

Source/WebCore:

Tests: css2.1/20110323/vertical-align-boxes-001.htm

A percentage value vertical-align is always a percentage of the actual line-height rather than
the margin box per http://www.w3.org/TR/CSS21/visudet.html#propdef-vertical-align: 'Percentages:
refer to the 'line-height' of the element itself'.  Confusingly, RenderBox::lineheight() is a
shorthand into the dimensions of the margin box for replaced elements in the other vertical-align
cases, i.e. where it's the margin box that's relevant rather than the 'line-height'. So rather than patch RenderBox's
lineHeight() to somehow consider the percentage cases, just give percentage vertical-align the full computedLineHeight()
rather than lineHeight()'s margin box.

* rendering/RootInlineBox.cpp:
(WebCore::RootInlineBox::verticalPositionForBox):

LayoutTests:

* css2.1/20110323/vertical-align-boxes-001-expected.html: Added.
* css2.1/20110323/vertical-align-boxes-001.htm: Added.
  This patch fixes the 'percentage' case in this test so that it calculates 50% of the
  line-height of 60px rather than 50% of the img's margin-box of -8px.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (122662 => 122663)


--- trunk/LayoutTests/ChangeLog	2012-07-14 08:09:20 UTC (rev 122662)
+++ trunk/LayoutTests/ChangeLog	2012-07-14 08:57:27 UTC (rev 122663)
@@ -1,3 +1,15 @@
+2012-07-05  Robert Hogan  <[email protected]>
+
+        CSS 2.1 failure: vertical-align-boxes-001 fails
+        https://bugs.webkit.org/show_bug.cgi?id=90626
+
+        Reviewed by Eric Seidel.
+
+        * css2.1/20110323/vertical-align-boxes-001-expected.html: Added.
+        * css2.1/20110323/vertical-align-boxes-001.htm: Added.
+          This patch fixes the 'percentage' case in this test so that it calculates 50% of the
+          line-height of 60px rather than 50% of the img's margin-box of -8px.
+
 2012-07-14  Zan Dobersek  <[email protected]>
 
         Unreviewed GTK gardening, marking http/tests/misc/webtiming-origins.html as flaky.

Added: trunk/LayoutTests/css2.1/20110323/vertical-align-boxes-001-expected.html (0 => 122663)


--- trunk/LayoutTests/css2.1/20110323/vertical-align-boxes-001-expected.html	                        (rev 0)
+++ trunk/LayoutTests/css2.1/20110323/vertical-align-boxes-001-expected.html	2012-07-14 08:57:27 UTC (rev 122663)
@@ -0,0 +1,39 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
+<html>
+ <head>
+  <title>CSS Test: Reference Result</title>
+  <style type="text/css">
+    .test {
+        height: 2em;
+        font: 40px/60px Ahem; color: blue;
+    }
+
+    #control {
+      height: 40px;
+      margin-bottom: -18px;
+    }
+    #control2 {
+      height: 40px;
+      width: 15px;
+      margin-bottom: -18px;
+    }
+
+    img {
+      background: blue;
+    }
+  </style>
+ </head>
+ <body>
+  <p>There should be a single blue rectangle with perfectly straight sides below.</p>
+  <div class="test">
+    <img id="control" src="" alt="FAIL"><!--
+ --><img id="control2" src="" alt="FAIL"><!--
+ --><img id="control2" src="" alt="FAIL"><!--
+ --><img id="control2" src="" alt="FAIL"><!--
+ --><img id="control2" src="" alt="FAIL"><!--
+ --><img id="control2" src="" alt="FAIL"><!--
+ --><img id="control2" src="" alt="FAIL">
+  </div>
+
+ </body>
+</html>
\ No newline at end of file
Property changes on: trunk/LayoutTests/css2.1/20110323/vertical-align-boxes-001-expected.html
___________________________________________________________________

Added: svn:eol-style

Added: trunk/LayoutTests/css2.1/20110323/vertical-align-boxes-001.htm (0 => 122663)


--- trunk/LayoutTests/css2.1/20110323/vertical-align-boxes-001.htm	                        (rev 0)
+++ trunk/LayoutTests/css2.1/20110323/vertical-align-boxes-001.htm	2012-07-14 08:57:27 UTC (rev 122663)
@@ -0,0 +1,74 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
+<html>
+ <head>
+  <title>CSS Test: Vertical Alignment boxes: replaced elements</title>
+  <link rel="author" title="Elika J. Etemad" href=""
+  <link rel="help" href=""
+  <meta name="flags" content="ahem image">
+  <meta name="assert" content="Vertical alignment aligns the margin box of inline replaced elements.">
+  <style type="text/css">
+    .test {
+        height: 2em;
+        font: 40px/60px Ahem; color: blue;
+    }
+
+    #control {
+      height: 40px;
+      margin-bottom: -18px;
+    }
+    #length {
+      vertical-align: -28px;
+      padding-top: 15px;
+      border-top: 10px solid;
+      margin: 10px 0;
+    }
+    #percent {
+      vertical-align: 50%;
+      padding-bottom: 15px;
+      border-bottom: 10px solid;
+      margin-bottom: -48px;
+    }
+    #text-bottom {
+      vertical-align: text-bottom;
+      padding-bottom: 10px;
+      border-bottom: 15px solid;
+      margin-bottom: -10px;
+    }
+    #text-top {
+      vertical-align: text-top;
+      padding-top: 15px;
+      border-top: 10px solid;
+      margin-top: 10px;
+    }
+    #middle {
+      vertical-align: middle;
+      padding-top: 15px;
+      border-top: 10px solid;
+      margin-bottom: -28px;
+    }
+    #baseline {
+      vertical-align: baseline;
+      padding-bottom: 10px;
+      border-bottom: 15px solid;
+      margin-bottom: -18px;
+    }
+
+    img {
+      background: blue;
+    }
+  </style>
+ </head>
+ <body>
+  <p>There should be a single blue rectangle with perfectly straight sides below.</p>
+  <div class="test">
+    <img id="control" src="" alt="FAIL"><!--
+ --><img id="baseline" src="" alt="FAIL"><!--
+ --><img id="middle" src="" alt="FAIL"><!--
+ --><img id="text-top" src="" alt="FAIL"><!--
+ --><img id="text-bottom" src="" alt="FAIL"><!--
+ --><img id="percent" src="" alt="FAIL"><!--
+ --><img id="length" src="" alt="FAIL">
+  </div>
+
+ </body>
+</html>
\ No newline at end of file
Property changes on: trunk/LayoutTests/css2.1/20110323/vertical-align-boxes-001.htm
___________________________________________________________________

Added: svn:eol-style

Modified: trunk/Source/WebCore/ChangeLog (122662 => 122663)


--- trunk/Source/WebCore/ChangeLog	2012-07-14 08:09:20 UTC (rev 122662)
+++ trunk/Source/WebCore/ChangeLog	2012-07-14 08:57:27 UTC (rev 122663)
@@ -1,3 +1,23 @@
+2012-07-05  Robert Hogan  <[email protected]>
+
+        CSS 2.1 failure: vertical-align-boxes-001 fails
+        https://bugs.webkit.org/show_bug.cgi?id=90626
+
+        Reviewed by Eric Seidel.
+
+        Tests: css2.1/20110323/vertical-align-boxes-001.htm
+
+        A percentage value vertical-align is always a percentage of the actual line-height rather than
+        the margin box per http://www.w3.org/TR/CSS21/visudet.html#propdef-vertical-align: 'Percentages: 
+        refer to the 'line-height' of the element itself'.  Confusingly, RenderBox::lineheight() is a
+        shorthand into the dimensions of the margin box for replaced elements in the other vertical-align
+        cases, i.e. where it's the margin box that's relevant rather than the 'line-height'. So rather than patch RenderBox's
+        lineHeight() to somehow consider the percentage cases, just give percentage vertical-align the full computedLineHeight()
+        rather than lineHeight()'s margin box.
+
+        * rendering/RootInlineBox.cpp:
+        (WebCore::RootInlineBox::verticalPositionForBox):
+
 2012-07-13  Ryosuke Niwa  <[email protected]>
 
         Iterating backwards over HTMLCollection is O(n^2)

Modified: trunk/Source/WebCore/rendering/RootInlineBox.cpp (122662 => 122663)


--- trunk/Source/WebCore/rendering/RootInlineBox.cpp	2012-07-14 08:09:20 UTC (rev 122662)
+++ trunk/Source/WebCore/rendering/RootInlineBox.cpp	2012-07-14 08:57:27 UTC (rev 122663)
@@ -883,8 +883,15 @@
                 verticalPosition -= (renderer->lineHeight(firstLine, lineDirection) - renderer->baselinePosition(baselineType(), firstLine, lineDirection));
         } else if (verticalAlign == BASELINE_MIDDLE)
             verticalPosition += -renderer->lineHeight(firstLine, lineDirection) / 2 + renderer->baselinePosition(baselineType(), firstLine, lineDirection);
-        else if (verticalAlign == LENGTH)
-            verticalPosition -= valueForLength(renderer->style()->verticalAlignLength(), renderer->lineHeight(firstLine, lineDirection), renderer->view());
+        else if (verticalAlign == LENGTH) {
+            LayoutUnit lineHeight;
+            //Per http://www.w3.org/TR/CSS21/visudet.html#propdef-vertical-align: 'Percentages: refer to the 'line-height' of the element itself'.
+            if (renderer->style()->verticalAlignLength().isPercent())
+                lineHeight = renderer->style()->computedLineHeight();
+            else
+                lineHeight = renderer->lineHeight(firstLine, lineDirection);
+            verticalPosition -= valueForLength(renderer->style()->verticalAlignLength(), lineHeight, renderer->view());
+        }
     }
 
     // Store the cached value.
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to