Title: [152840] trunk
Revision
152840
Author
[email protected]
Date
2013-07-18 02:09:00 -0700 (Thu, 18 Jul 2013)

Log Message

Incorrect calculated width for mspace.
https://bugs.webkit.org/show_bug.cgi?id=118601

Patch by Zalan Bujtas <[email protected]> on 2013-07-18
Reviewed by Chris Fleizach.

Source/WebCore:

Use intrinsic logical widths to size <mspace> properly.
This patch also fixes an assert on isPreferredLogicalHeightDirty() which occurs
while layouting <mspace>. The assert fix is required, so that the sizing can be
fixed.

Test: mathml/presentation/mspace-prefered-width.html

* rendering/mathml/RenderMathMLBlock.cpp:
(WebCore::parseMathMLLength): switch to LayoutUnits.
(WebCore::parseMathMLNamedSpace): switch to LayoutUnits.
* rendering/mathml/RenderMathMLBlock.h:
* rendering/mathml/RenderMathMLFraction.cpp:
(WebCore::RenderMathMLFraction::updateFromElement):
* rendering/mathml/RenderMathMLFraction.h:
* rendering/mathml/RenderMathMLSpace.cpp:
(WebCore::RenderMathMLSpace::computeIntrinsicLogicalWidths):
* rendering/mathml/RenderMathMLSpace.h:

LayoutTests:

Use intrinsic logical widths to size <mspace> properly.
This patch also fixes an assert on isPreferredLogicalHeightDirty(), which occurs
while layouting <mspace>. The assert fix is required, so that the sizing can be
fixed.

* mathml/presentation/mspace-prefered-width-expected.html: Added.
* mathml/presentation/mspace-prefered-width.html: Added.
* platform/mac/mathml/presentation/fractions-expected.png: Rebaseline: float->LayoutUnit.
* platform/mac/mathml/presentation/fractions-expected.txt: Rebaseline: float->LayoutUnit.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (152839 => 152840)


--- trunk/LayoutTests/ChangeLog	2013-07-18 08:45:19 UTC (rev 152839)
+++ trunk/LayoutTests/ChangeLog	2013-07-18 09:09:00 UTC (rev 152840)
@@ -1,3 +1,20 @@
+2013-07-18  Zalan Bujtas  <[email protected]>
+
+        Incorrect calculated width for mspace.
+        https://bugs.webkit.org/show_bug.cgi?id=118601
+
+        Reviewed by Chris Fleizach.
+
+        Use intrinsic logical widths to size <mspace> properly.
+        This patch also fixes an assert on isPreferredLogicalHeightDirty(), which occurs
+        while layouting <mspace>. The assert fix is required, so that the sizing can be
+        fixed.
+
+        * mathml/presentation/mspace-prefered-width-expected.html: Added.
+        * mathml/presentation/mspace-prefered-width.html: Added.
+        * platform/mac/mathml/presentation/fractions-expected.png: Rebaseline: float->LayoutUnit.
+        * platform/mac/mathml/presentation/fractions-expected.txt: Rebaseline: float->LayoutUnit.
+
 2013-07-18  Santosh Mahto  <[email protected]>
 
         ASSERTION FAILED: !listItems().size() || m_activeSelectionAnchorIndex >= 0 in WebCore::HTMLSelectElement::updateListBoxSelection

Added: trunk/LayoutTests/mathml/presentation/mspace-prefered-width-expected.html (0 => 152840)


--- trunk/LayoutTests/mathml/presentation/mspace-prefered-width-expected.html	                        (rev 0)
+++ trunk/LayoutTests/mathml/presentation/mspace-prefered-width-expected.html	2013-07-18 09:09:00 UTC (rev 152840)
@@ -0,0 +1,25 @@
+<!doctype html>
+<html>
+<head>
+  <style type="text/css">
+    td {
+      border: 1px solid black;
+    }
+  </style>
+</head>
+<body>
+<table>
+  <tr>
+    <td>
+	 <span style="display: inline-block; width: 50px; height: 10px; background:green;"></span>
+	</td>
+    <td>
+	 <span style="display: inline-block; width: 50px; height: 10px; background:green; margin-right: 50px;"></span>
+	</td>
+    <td>
+	 <span style="display: inline-block; width: 50px; height: 10px; background:green; margin-right: -40px;"></span>
+	</td>
+  </tr>
+</table>
+</body>
+</html>

Added: trunk/LayoutTests/mathml/presentation/mspace-prefered-width.html (0 => 152840)


--- trunk/LayoutTests/mathml/presentation/mspace-prefered-width.html	                        (rev 0)
+++ trunk/LayoutTests/mathml/presentation/mspace-prefered-width.html	2013-07-18 09:09:00 UTC (rev 152840)
@@ -0,0 +1,35 @@
+<!doctype html>
+<html>
+<head>
+  <style type="text/css">
+    td {
+      border: 1px solid black;
+    }
+
+    math {
+        padding: 0px;
+    }
+  </style>
+</head>
+<body>
+<table>
+  <tr>
+    <td>
+	  <math>
+	    <mspace width="50px" height="10px" mathbackground="green"/>
+	  </math>
+	</td>
+    <td>
+	  <math>
+	    <mspace style="width: 100px;" width="50px" height="10px" mathbackground="green"/>
+	  </math>
+	</td>
+    <td>
+	  <math>
+	    <mspace style="width: 10px;" width="50px" height="10px" mathbackground="green"/>
+	  </math>
+	</td>
+  </tr>
+</table>
+</body>
+</html>

Modified: trunk/LayoutTests/platform/mac/mathml/presentation/fractions-expected.png


(Binary files differ)

Modified: trunk/LayoutTests/platform/mac/mathml/presentation/fractions-expected.txt (152839 => 152840)


--- trunk/LayoutTests/platform/mac/mathml/presentation/fractions-expected.txt	2013-07-18 08:45:19 UTC (rev 152839)
+++ trunk/LayoutTests/platform/mac/mathml/presentation/fractions-expected.txt	2013-07-18 09:09:00 UTC (rev 152840)
@@ -66,7 +66,7 @@
         RenderText {#text} at (0,27) size 173x18
           text run at (0,27) width 173: "line thickness by keyword: "
         RenderMathMLMath {math} at (173,0) size 74x63 [padding: 0 1 0 1]
-          RenderMathMLFraction {mfrac} at (2,4) size 16x58
+          RenderMathMLFraction {mfrac} at (2,5) size 16x58
             RenderMathMLBlock (anonymous, flex) at (0,0) size 16x29
               RenderBlock {mn} at (0,0) size 16x23
                 RenderText {#text} at (0,-12) size 16x49

Modified: trunk/Source/WebCore/ChangeLog (152839 => 152840)


--- trunk/Source/WebCore/ChangeLog	2013-07-18 08:45:19 UTC (rev 152839)
+++ trunk/Source/WebCore/ChangeLog	2013-07-18 09:09:00 UTC (rev 152840)
@@ -1,3 +1,28 @@
+2013-07-18  Zalan Bujtas  <[email protected]>
+
+        Incorrect calculated width for mspace.
+        https://bugs.webkit.org/show_bug.cgi?id=118601
+
+        Reviewed by Chris Fleizach.
+
+        Use intrinsic logical widths to size <mspace> properly.
+        This patch also fixes an assert on isPreferredLogicalHeightDirty() which occurs
+        while layouting <mspace>. The assert fix is required, so that the sizing can be
+        fixed.
+
+        Test: mathml/presentation/mspace-prefered-width.html
+
+        * rendering/mathml/RenderMathMLBlock.cpp:
+        (WebCore::parseMathMLLength): switch to LayoutUnits.
+        (WebCore::parseMathMLNamedSpace): switch to LayoutUnits.
+        * rendering/mathml/RenderMathMLBlock.h:
+        * rendering/mathml/RenderMathMLFraction.cpp:
+        (WebCore::RenderMathMLFraction::updateFromElement):
+        * rendering/mathml/RenderMathMLFraction.h:
+        * rendering/mathml/RenderMathMLSpace.cpp:
+        (WebCore::RenderMathMLSpace::computeIntrinsicLogicalWidths):
+        * rendering/mathml/RenderMathMLSpace.h:
+
 2013-07-18  Ryosuke Niwa  <[email protected]>
 
         willWriteSelectionToPasteboard and willPerformDragSourceAction editing callbacks are not called for drag and drop

Modified: trunk/Source/WebCore/rendering/mathml/RenderMathMLBlock.cpp (152839 => 152840)


--- trunk/Source/WebCore/rendering/mathml/RenderMathMLBlock.cpp	2013-07-18 08:45:19 UTC (rev 152839)
+++ trunk/Source/WebCore/rendering/mathml/RenderMathMLBlock.cpp	2013-07-18 09:09:00 UTC (rev 152840)
@@ -226,7 +226,7 @@
 //   number, representing a terminating decimal number (a type of rational
 //   number)"
 //
-bool parseMathMLLength(const String& string, float& lengthValue, const RenderStyle* style, bool allowNegative)
+bool parseMathMLLength(const String& string, LayoutUnit& lengthValue, const RenderStyle* style, bool allowNegative)
 {
     String s = string.simplifyWhiteSpace();
 
@@ -320,7 +320,7 @@
     return false;
 }
 
-bool parseMathMLNamedSpace(const String& string, float& lengthValue, const RenderStyle* style, bool allowNegative)
+bool parseMathMLNamedSpace(const String& string, LayoutUnit& lengthValue, const RenderStyle* style, bool allowNegative)
 {
     float length = 0;
     // See if it is one of the namedspaces (ranging -7/18em, -6/18, ... 7/18em)

Modified: trunk/Source/WebCore/rendering/mathml/RenderMathMLBlock.h (152839 => 152840)


--- trunk/Source/WebCore/rendering/mathml/RenderMathMLBlock.h	2013-07-18 08:45:19 UTC (rev 152839)
+++ trunk/Source/WebCore/rendering/mathml/RenderMathMLBlock.h	2013-07-18 09:09:00 UTC (rev 152840)
@@ -129,8 +129,8 @@
 };
 
 // Parsing functions for MathML Length values
-bool parseMathMLLength(const String&, float&, const RenderStyle*, bool allowNegative = true);
-bool parseMathMLNamedSpace(const String&, float&, const RenderStyle*, bool allowNegative = true);
+bool parseMathMLLength(const String&, LayoutUnit&, const RenderStyle*, bool allowNegative = true);
+bool parseMathMLNamedSpace(const String&, LayoutUnit&, const RenderStyle*, bool allowNegative = true);
 }
 
 #endif // ENABLE(MATHML)

Modified: trunk/Source/WebCore/rendering/mathml/RenderMathMLFraction.cpp (152839 => 152840)


--- trunk/Source/WebCore/rendering/mathml/RenderMathMLFraction.cpp	2013-07-18 08:45:19 UTC (rev 152839)
+++ trunk/Source/WebCore/rendering/mathml/RenderMathMLFraction.cpp	2013-07-18 09:09:00 UTC (rev 152840)
@@ -78,11 +78,12 @@
         m_lineThickness = gLineMedium;
     else if (equalIgnoringCase(thickness, "thick"))
         m_lineThickness = gLineThick;
-    else
+    else {
         // This function parses the thickness attribute using gLineMedium as
         // the default value. If the parsing fails, m_lineThickness will not be
         // modified i.e. the default value will be used.
         parseMathMLLength(thickness, m_lineThickness, style(), false);
+    }
 
     // Update the style for the padding of the denominator for the line thickness
     lastChild()->style()->setPaddingTop(Length(static_cast<int>(m_lineThickness), Fixed));

Modified: trunk/Source/WebCore/rendering/mathml/RenderMathMLFraction.h (152839 => 152840)


--- trunk/Source/WebCore/rendering/mathml/RenderMathMLFraction.h	2013-07-18 08:45:19 UTC (rev 152839)
+++ trunk/Source/WebCore/rendering/mathml/RenderMathMLFraction.h	2013-07-18 09:09:00 UTC (rev 152840)
@@ -54,7 +54,7 @@
 
     virtual const char* renderName() const { return "RenderMathMLFraction"; }
     
-    float m_lineThickness;
+    LayoutUnit m_lineThickness;
 };
     
 inline RenderMathMLFraction* toRenderMathMLFraction(RenderObject* object)

Modified: trunk/Source/WebCore/rendering/mathml/RenderMathMLSpace.cpp (152839 => 152840)


--- trunk/Source/WebCore/rendering/mathml/RenderMathMLSpace.cpp	2013-07-18 08:45:19 UTC (rev 152839)
+++ trunk/Source/WebCore/rendering/mathml/RenderMathMLSpace.cpp	2013-07-18 09:09:00 UTC (rev 152840)
@@ -44,14 +44,10 @@
 {
 }
 
-void RenderMathMLSpace::computePreferredLogicalWidths()
+void RenderMathMLSpace::computeIntrinsicLogicalWidths(LayoutUnit& minLogicalWidth, LayoutUnit& maxLogicalWidth) const
 {
-    ASSERT(preferredLogicalWidthsDirty());
-
-    m_minPreferredLogicalWidth = m_width;
-    m_maxPreferredLogicalWidth = m_width;
-
-    RenderMathMLBlock::computePreferredLogicalWidths();
+    minLogicalWidth = m_width;
+    maxLogicalWidth = m_width;
 }
 
 void RenderMathMLSpace::updateFromElement()
@@ -89,12 +85,6 @@
     setLogicalHeight(m_height + m_depth);
 }
 
-void RenderMathMLSpace::layout()
-{
-    updateFromElement();
-    RenderMathMLBlock::layout();
-}
-
 void RenderMathMLSpace::styleDidChange(StyleDifference diff, const RenderStyle* oldStyle)
 {
     RenderMathMLBlock::styleDidChange(diff, oldStyle);

Modified: trunk/Source/WebCore/rendering/mathml/RenderMathMLSpace.h (152839 => 152840)


--- trunk/Source/WebCore/rendering/mathml/RenderMathMLSpace.h	2013-07-18 08:45:19 UTC (rev 152839)
+++ trunk/Source/WebCore/rendering/mathml/RenderMathMLSpace.h	2013-07-18 09:09:00 UTC (rev 152840)
@@ -40,9 +40,6 @@
     virtual void updateLogicalWidth() OVERRIDE;
     virtual void updateLogicalHeight() OVERRIDE;
 
-protected:
-    virtual void layout();
-    
 private:
     virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle) OVERRIDE;
     virtual const char* renderName() const OVERRIDE { return isAnonymous() ? "RenderMathMLSpace (anonymous)" : "RenderMathMLSpace"; }
@@ -50,12 +47,13 @@
     virtual bool isRenderMathMLSpace() const OVERRIDE { return true; }
 
     virtual bool isChildAllowed(RenderObject*, RenderStyle*) const OVERRIDE { return false; } 
-    virtual void computePreferredLogicalWidths() OVERRIDE;
+    virtual void computeIntrinsicLogicalWidths(LayoutUnit& minLogicalWidth, LayoutUnit& maxLogicalWidth) const OVERRIDE;
+
     virtual void updateFromElement() OVERRIDE;
 
-    float m_width;
-    float m_height;
-    float m_depth;
+    LayoutUnit m_width;
+    LayoutUnit m_height;
+    LayoutUnit m_depth;
 };
 
 inline RenderMathMLSpace* toRenderMathMLSpace(RenderMathMLBlock* block)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to