Title: [110769] trunk
Revision
110769
Author
[email protected]
Date
2012-03-14 15:24:38 -0700 (Wed, 14 Mar 2012)

Log Message

Incorrect handling of sizes in "em" when first-line changes font size
https://bugs.webkit.org/show_bug.cgi?id=79526

Patch by Grace Ku <[email protected]> on 2012-03-14
Reviewed by Eric Seidel.

Source/WebCore:

When a first-line pseudo class changes the font size, the "em" unit is handled incorrectly.
It uses the paragraph's original font size (the size of the rest of the paragraph) rather than
the font-size of the first-line of the paragraph.

This was corrected by checking if the InlineFlowBox was the first line using the existing
InlineFlowBox::isFirstLineStyle() function. The corrected behaviour matches Gecko and Presto.
Trident seems to get it half-wrong in the use case we are testing, painting the correct width for
the border but leaving the wrong amount of space.

The CSS specification doc at the time of this patch specifies that ':first-line' should only support
certain properties, though UAs may choose to apply more properties. Furthermore, the spec does not
define the exact rendering of all cases of ':first-line'. It notes that a more precise definition
may appear in future revisions.

Test: fast/css/pseudo-first-line-border-width.html

* rendering/InlineFlowBox.cpp:
(WebCore::InlineFlowBox::paintBoxDecorations):
* rendering/InlineFlowBox.h:
(WebCore::InlineFlowBox::borderLogicalLeft):
(WebCore::InlineFlowBox::borderLogicalRight):
* rendering/RenderBoxModelObject.cpp:
(WebCore::RenderBoxModelObject::paintBorder):
(WebCore::RenderBoxModelObject::getBorderEdgeInfo):
(WebCore::RenderBoxModelObject::borderObscuresBackgroundEdge):
(WebCore::RenderBoxModelObject::borderObscuresBackground):
* rendering/RenderBoxModelObject.h:
(RenderBoxModelObject):

LayoutTests:

Checks that the width of the left-border of the span is the desired 10px
rather than 100px. The expect file is somewhat misleading since the computed
border width is still printed as 100px. The true test is in the position of the
RenderText box beside the left-border.

* fast/css/pseudo-first-line-border-width.html: Added.
* fast/css/pseudo-first-line-border-width-expected.txt: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (110768 => 110769)


--- trunk/LayoutTests/ChangeLog	2012-03-14 22:17:36 UTC (rev 110768)
+++ trunk/LayoutTests/ChangeLog	2012-03-14 22:24:38 UTC (rev 110769)
@@ -1,3 +1,18 @@
+2012-03-14  Grace Ku  <[email protected]> 
+
+        Incorrect handling of sizes in "em" when first-line changes font size
+        https://bugs.webkit.org/show_bug.cgi?id=79526
+
+        Reviewed by Eric Seidel.
+
+        Checks that the width of the left-border of the span is the desired 10px
+        rather than 100px. The expect file is somewhat misleading since the computed
+        border width is still printed as 100px. The true test is in the position of the
+        RenderText box beside the left-border.
+
+        * fast/css/pseudo-first-line-border-width.html: Added.
+        * fast/css/pseudo-first-line-border-width-expected.txt: Added.
+
 2012-03-14  Adam Barth  <[email protected]>
 
         Update some compositing baselines.  These look correct.  They just differ in scrollbars, etc.

Added: trunk/LayoutTests/fast/css/pseudo-first-line-border-width-expected.txt (0 => 110769)


--- trunk/LayoutTests/fast/css/pseudo-first-line-border-width-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/css/pseudo-first-line-border-width-expected.txt	2012-03-14 22:24:38 UTC (rev 110769)
@@ -0,0 +1,22 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 800x452
+  RenderBlock {HTML} at (0,0) size 800x452
+    RenderBody {BODY} at (8,8) size 784x344
+      RenderBlock {DIV} at (0,0) size 784x34
+        RenderText {#text} at (0,0) size 144x17
+          text run at (0,0) width 144: "Test for "
+        RenderInline {A} at (0,0) size 736x34 [color=#0000EE]
+          RenderText {#text} at (144,0) size 736x34
+            text run at (144,0) width 592: "https://bugs.webkit.org/show_bug.cgi?"
+            text run at (0,17) width 128: "id=79526"
+      RenderBlock {P} at (0,134) size 784x210
+        RenderText {#text} at (0,0) size 350x10
+          text run at (0,0) width 350: "A green 10px border on the left of "
+        RenderInline {SPAN} at (0,0) size 500x210 [border: (100px solid #008000)]
+          RenderText {#text} at (360,0) size 50x10
+            text run at (360,0) width 50: "this,"
+          RenderBR {BR} at (410,0) size 0x10
+          RenderText {#text} at (0,10) size 500x200
+            text run at (0,10) width 400: "is a"
+            text run at (0,110) width 500: "pass."

Added: trunk/LayoutTests/fast/css/pseudo-first-line-border-width.html (0 => 110769)


--- trunk/LayoutTests/fast/css/pseudo-first-line-border-width.html	                        (rev 0)
+++ trunk/LayoutTests/fast/css/pseudo-first-line-border-width.html	2012-03-14 22:24:38 UTC (rev 110769)
@@ -0,0 +1,25 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
+    <style>
+        body {
+            font-family: ahem;
+        }
+        p {
+            font-size: 100px;
+        }
+        p:first-line {
+            font-size: 10px;
+        }
+        span {
+            border-left: solid 1em green;
+        }
+    </style>
+</head>
+    <body>
+        <div>Test for <a href=""
+        <p>A green 10px border on the left of <span>this,<br>
+        is a pass.</span></p>
+    </body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (110768 => 110769)


--- trunk/Source/WebCore/ChangeLog	2012-03-14 22:17:36 UTC (rev 110768)
+++ trunk/Source/WebCore/ChangeLog	2012-03-14 22:24:38 UTC (rev 110769)
@@ -1,3 +1,39 @@
+2012-03-14  Grace Ku  <[email protected]>
+
+        Incorrect handling of sizes in "em" when first-line changes font size
+        https://bugs.webkit.org/show_bug.cgi?id=79526
+
+        Reviewed by Eric Seidel.
+
+        When a first-line pseudo class changes the font size, the "em" unit is handled incorrectly.
+        It uses the paragraph's original font size (the size of the rest of the paragraph) rather than
+        the font-size of the first-line of the paragraph.
+
+        This was corrected by checking if the InlineFlowBox was the first line using the existing
+        InlineFlowBox::isFirstLineStyle() function. The corrected behaviour matches Gecko and Presto.
+        Trident seems to get it half-wrong in the use case we are testing, painting the correct width for
+        the border but leaving the wrong amount of space.
+
+        The CSS specification doc at the time of this patch specifies that ':first-line' should only support
+        certain properties, though UAs may choose to apply more properties. Furthermore, the spec does not
+        define the exact rendering of all cases of ':first-line'. It notes that a more precise definition
+        may appear in future revisions.
+
+        Test: fast/css/pseudo-first-line-border-width.html
+
+        * rendering/InlineFlowBox.cpp:
+        (WebCore::InlineFlowBox::paintBoxDecorations):
+        * rendering/InlineFlowBox.h:
+        (WebCore::InlineFlowBox::borderLogicalLeft):
+        (WebCore::InlineFlowBox::borderLogicalRight):
+        * rendering/RenderBoxModelObject.cpp:
+        (WebCore::RenderBoxModelObject::paintBorder):
+        (WebCore::RenderBoxModelObject::getBorderEdgeInfo):
+        (WebCore::RenderBoxModelObject::borderObscuresBackgroundEdge):
+        (WebCore::RenderBoxModelObject::borderObscuresBackground):
+        * rendering/RenderBoxModelObject.h:
+        (RenderBoxModelObject):
+
 2012-03-14  Martin Robinson  <[email protected]>
 
         Fix the TextureMapper build for GTK+.

Modified: trunk/Source/WebCore/rendering/InlineFlowBox.cpp (110768 => 110769)


--- trunk/Source/WebCore/rendering/InlineFlowBox.cpp	2012-03-14 22:17:36 UTC (rev 110768)
+++ trunk/Source/WebCore/rendering/InlineFlowBox.cpp	2012-03-14 22:24:38 UTC (rev 110769)
@@ -1231,7 +1231,7 @@
             // The simple case is where we either have no border image or we are the only box for this object.  In those
             // cases only a single call to draw is required.
             if (!hasBorderImage || (!prevLineBox() && !nextLineBox()))
-                boxModelObject()->paintBorder(paintInfo, paintRect, renderer()->style(), BackgroundBleedNone, includeLogicalLeftEdge(), includeLogicalRightEdge());
+                boxModelObject()->paintBorder(paintInfo, paintRect, renderer()->style(isFirstLineStyle()), BackgroundBleedNone, includeLogicalLeftEdge(), includeLogicalRightEdge());
             else {
                 // We have a border image that spans multiple lines.
                 // We need to adjust tx and ty by the width of all previous lines.
@@ -1255,7 +1255,7 @@
                 LayoutRect clipRect = clipRectForNinePieceImageStrip(this, borderImage, paintRect);
                 GraphicsContextStateSaver stateSaver(*context);
                 context->clip(clipRect);
-                boxModelObject()->paintBorder(paintInfo, LayoutRect(stripX, stripY, stripWidth, stripHeight), renderer()->style());
+                boxModelObject()->paintBorder(paintInfo, LayoutRect(stripX, stripY, stripWidth, stripHeight), renderer()->style(isFirstLineStyle()));
             }
         }
     }

Modified: trunk/Source/WebCore/rendering/InlineFlowBox.h (110768 => 110769)


--- trunk/Source/WebCore/rendering/InlineFlowBox.h	2012-03-14 22:17:36 UTC (rev 110768)
+++ trunk/Source/WebCore/rendering/InlineFlowBox.h	2012-03-14 22:24:38 UTC (rev 110769)
@@ -137,13 +137,13 @@
     {
         if (!includeLogicalLeftEdge())
             return 0;
-        return isHorizontal() ? renderer()->style()->borderLeftWidth() : renderer()->style()->borderTopWidth();
+        return isHorizontal() ? renderer()->style(isFirstLineStyle())->borderLeftWidth() : renderer()->style(isFirstLineStyle())->borderTopWidth();
     }
     int borderLogicalRight() const
     {
         if (!includeLogicalRightEdge())
             return 0;
-        return isHorizontal() ? renderer()->style()->borderRightWidth() : renderer()->style()->borderBottomWidth();
+        return isHorizontal() ? renderer()->style(isFirstLineStyle())->borderRightWidth() : renderer()->style(isFirstLineStyle())->borderBottomWidth();
     }
     int paddingLogicalLeft() const
     {

Modified: trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp (110768 => 110769)


--- trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp	2012-03-14 22:17:36 UTC (rev 110768)
+++ trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp	2012-03-14 22:24:38 UTC (rev 110769)
@@ -1755,7 +1755,7 @@
         return;
 
     BorderEdge edges[4];
-    getBorderEdgeInfo(edges, includeLogicalLeftEdge, includeLogicalRightEdge);
+    getBorderEdgeInfo(edges, style, includeLogicalLeftEdge, includeLogicalRightEdge);
 
     RoundedRect outerBorder = style->getRoundedBorderFor(rect, includeLogicalLeftEdge, includeLogicalRightEdge);
     RoundedRect innerBorder = style->getRoundedInnerBorderFor(rect, includeLogicalLeftEdge, includeLogicalRightEdge);
@@ -2560,9 +2560,8 @@
     graphicsContext->clipOutRoundedRect(calculateAdjustedInnerBorder(innerBorder, side));
 }
 
-void RenderBoxModelObject::getBorderEdgeInfo(BorderEdge edges[], bool includeLogicalLeftEdge, bool includeLogicalRightEdge) const
+void RenderBoxModelObject::getBorderEdgeInfo(BorderEdge edges[], const RenderStyle* style, bool includeLogicalLeftEdge, bool includeLogicalRightEdge) const
 {
-    const RenderStyle* style = this->style();
     bool horizontal = style->isHorizontalWritingMode();
 
     edges[BSTop] = BorderEdge(style->borderTopWidth(),
@@ -2593,7 +2592,7 @@
 bool RenderBoxModelObject::borderObscuresBackgroundEdge(const FloatSize& contextScale) const
 {
     BorderEdge edges[4];
-    getBorderEdgeInfo(edges);
+    getBorderEdgeInfo(edges, style());
 
     for (int i = BSTop; i <= BSLeft; ++i) {
         const BorderEdge& currEdge = edges[i];
@@ -2616,7 +2615,7 @@
         return false;
 
     BorderEdge edges[4];
-    getBorderEdgeInfo(edges);
+    getBorderEdgeInfo(edges, style());
 
     for (int i = BSTop; i <= BSLeft; ++i) {
         const BorderEdge& currEdge = edges[i];

Modified: trunk/Source/WebCore/rendering/RenderBoxModelObject.h (110768 => 110769)


--- trunk/Source/WebCore/rendering/RenderBoxModelObject.h	2012-03-14 22:17:36 UTC (rev 110768)
+++ trunk/Source/WebCore/rendering/RenderBoxModelObject.h	2012-03-14 22:24:38 UTC (rev 110769)
@@ -195,7 +195,7 @@
     };
 
     void calculateBackgroundImageGeometry(const FillLayer*, const LayoutRect& paintRect, BackgroundImageGeometry&);
-    void getBorderEdgeInfo(class BorderEdge[], bool includeLogicalLeftEdge = true, bool includeLogicalRightEdge = true) const;
+    void getBorderEdgeInfo(class BorderEdge[], const RenderStyle*, bool includeLogicalLeftEdge = true, bool includeLogicalRightEdge = true) const;
     bool borderObscuresBackgroundEdge(const FloatSize& contextScale) const;
     bool borderObscuresBackground() const;
 
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to