Title: [114012] trunk
Revision
114012
Author
[email protected]
Date
2012-04-12 12:07:07 -0700 (Thu, 12 Apr 2012)

Log Message

Don't modify shared style objects in RenderMathMLRoot.cpp
https://bugs.webkit.org/show_bug.cgi?id=83736

Patch by David Barton <[email protected]> on 2012-04-12
Reviewed by Julien Chaffraix.

Source/WebCore:

To leave room for the radical sign and absolutely positioned "index", we switch to using
intrinsic padding. RenderMathMLRoot.cpp is also cleaned up and prepared for merging with
RenderMathMLSquareRoot.cpp. The base and index are no longer wrapped in extra renderers,
and the child renderers are now in the same order as in the DOM. Some padding/placement
terms are unified and debugged.

Tested by existing tests in roots.xhtml.

* css/mathml.css:
(mroot):
(mroot > * + *):
(mroot > * + mrow, mroot > * + mfenced):
* rendering/mathml/RenderMathMLRoot.cpp:
(WebCore):
(WebCore::RenderMathMLRoot::index):
(WebCore::RenderMathMLRoot::paint):
(WebCore::RenderMathMLRoot::layout):
* rendering/mathml/RenderMathMLRoot.h:
(RenderMathMLRoot):
* rendering/mathml/RenderMathMLSquareRoot.cpp:
(WebCore):
(WebCore::RenderMathMLSquareRoot::paint):

LayoutTests:

* platform/mac/mathml/presentation/roots-expected.png:
* platform/mac/mathml/presentation/roots-expected.txt:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (114011 => 114012)


--- trunk/LayoutTests/ChangeLog	2012-04-12 19:03:38 UTC (rev 114011)
+++ trunk/LayoutTests/ChangeLog	2012-04-12 19:07:07 UTC (rev 114012)
@@ -1,3 +1,13 @@
+2012-04-12  David Barton  <[email protected]>
+
+        Don't modify shared style objects in RenderMathMLRoot.cpp
+        https://bugs.webkit.org/show_bug.cgi?id=83736
+
+        Reviewed by Julien Chaffraix.
+
+        * platform/mac/mathml/presentation/roots-expected.png:
+        * platform/mac/mathml/presentation/roots-expected.txt:
+
 2012-04-12  Tom Sepez  <[email protected]>
 
         Typos in LayoutTests/http/tests/security/xssAuditor/script-tag-inside-svg-tag*.html

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


(Binary files differ)

Modified: trunk/LayoutTests/platform/mac/mathml/presentation/roots-expected.txt (114011 => 114012)


--- trunk/LayoutTests/platform/mac/mathml/presentation/roots-expected.txt	2012-04-12 19:03:38 UTC (rev 114011)
+++ trunk/LayoutTests/platform/mac/mathml/presentation/roots-expected.txt	2012-04-12 19:07:07 UTC (rev 114012)
@@ -90,9 +90,9 @@
           text run at (0,3) width 75: "long index: "
         RenderMathMLMath {math} at (75,0) size 47x22
       RenderBlock {p} at (0,238) size 784x40
-        RenderText {#text} at (0,10) size 185x18
-          text run at (0,10) width 185: "long index w/ complex base: "
-        RenderMathMLMath {math} at (185,0) size 73x40
+        RenderText {#text} at (0,9) size 185x18
+          text run at (0,9) width 185: "long index w/ complex base: "
+        RenderMathMLMath {math} at (185,0) size 72x40
       RenderBlock {p} at (0,294) size 784x48
         RenderText {#text} at (0,29) size 75x18
           text run at (0,29) width 75: "high index: "
@@ -179,26 +179,22 @@
       RenderBlock {p} at (0,429) size 784x76
         RenderText {#text} at (0,36) size 110x18
           text run at (0,36) width 110: "Imbricated roots: "
-        RenderMathMLMath {math} at (110,0) size 328x76
+        RenderMathMLMath {math} at (110,0) size 285x76
         RenderText {#text} at (0,0) size 0x0
 layer at (182,180) size 20x20
   RenderMathMLRoot {mroot} at (1,0) size 20x20
-    RenderMathMLBlock {mroot} at (12,15) size 0x0
-    RenderMathMLBlock {mroot} at (12,4) size 8x16
-      RenderInline {mn} at (0,0) size 8x16
-        RenderText {#text} at (0,0) size 8x16
-          text run at (0,0) width 8: "2"
+    RenderInline {mn} at (0,0) size 8x16
+      RenderText {#text} at (12,4) size 8x16
+        text run at (12,4) width 8: "2"
 layer at (182,180) size 12x14
   RenderBlock (positioned) {mn} at (0,0) size 12x14
     RenderText {#text} at (2,0) size 6x12
       text run at (2,0) width 6: "3"
 layer at (84,216) size 45x22
   RenderMathMLRoot {mroot} at (1,0) size 45x22
-    RenderMathMLBlock {mroot} at (37,17) size 0x0
-    RenderMathMLBlock {mroot} at (37,6) size 8x16
-      RenderInline {mn} at (0,0) size 8x16
-        RenderText {#text} at (0,0) size 8x16
-          text run at (0,0) width 8: "2"
+    RenderInline {mn} at (0,0) size 8x16
+      RenderText {#text} at (37,6) size 8x16
+        text run at (37,6) width 8: "2"
 layer at (84,216) size 37x16
   RenderMathMLRow {mrow} at (0,0) size 37x16
     RenderInline {mi} at (0,0) size 5x12
@@ -218,37 +214,35 @@
     RenderInline {mi} at (0,0) size 5x12
       RenderText {#text} at (28,0) size 5x12
         text run at (28,0) width 5: "z"
-layer at (194,254) size 71x40
-  RenderMathMLRoot {mroot} at (1,0) size 71x40
-    RenderMathMLBlock {mroot} at (39,24) size 0x0
-    RenderMathMLBlock {mroot} at (39,3) size 32x34
-      RenderMathMLFraction {mfrac} at (1,0) size 31x34
-        RenderMathMLBlock {mfrac} at (0,0) size 31x16
-          RenderMathMLRow {mrow} at (3,0) size 25x16
-            RenderInline {mi} at (0,0) size 7x16
-              RenderText {#text} at (0,0) size 7x16
-                text run at (0,0) width 7: "x"
-            RenderMathMLOperator {mo} at (7,0) size 10x16
-              RenderMathMLBlock {mo} at (0,0) size 9x16
-                RenderText {mo} at (0,0) size 9x16
-                  text run at (0,0) width 9: "+"
-            RenderInline {mn} at (0,0) size 8x16
-              RenderText {#text} at (17,0) size 8x16
-                text run at (17,0) width 8: "1"
-        RenderMathMLBlock {mfrac} at (0,16) size 31x18
-          RenderMathMLRow {mrow} at (3,2) size 25x16
-            RenderInline {mi} at (0,0) size 7x16
-              RenderText {#text} at (0,0) size 7x16
-                text run at (0,0) width 7: "x"
-            RenderMathMLOperator {mo} at (7,0) size 10x16
-              RenderMathMLBlock {mo} at (0,0) size 9x16
-                RenderText {mo} at (0,0) size 9x16
-                  text run at (0,0) width 9: "+"
-            RenderInline {mn} at (0,0) size 8x16
-              RenderText {#text} at (17,0) size 8x16
-                text run at (17,0) width 8: "2"
-layer at (194,263) size 37x16
-  RenderMathMLRow {mrow} at (0,9) size 37x16
+layer at (194,254) size 70x40
+  RenderMathMLRoot {mroot} at (1,0) size 70x40
+    RenderMathMLFraction {mfrac} at (39,3) size 31x34
+      RenderMathMLBlock {mfrac} at (0,0) size 31x16
+        RenderMathMLRow {mrow} at (3,0) size 25x16
+          RenderInline {mi} at (0,0) size 7x16
+            RenderText {#text} at (0,0) size 7x16
+              text run at (0,0) width 7: "x"
+          RenderMathMLOperator {mo} at (7,0) size 10x16
+            RenderMathMLBlock {mo} at (0,0) size 9x16
+              RenderText {mo} at (0,0) size 9x16
+                text run at (0,0) width 9: "+"
+          RenderInline {mn} at (0,0) size 8x16
+            RenderText {#text} at (17,0) size 8x16
+              text run at (17,0) width 8: "1"
+      RenderMathMLBlock {mfrac} at (0,16) size 31x18
+        RenderMathMLRow {mrow} at (3,2) size 25x16
+          RenderInline {mi} at (0,0) size 7x16
+            RenderText {#text} at (0,0) size 7x16
+              text run at (0,0) width 7: "x"
+          RenderMathMLOperator {mo} at (7,0) size 10x16
+            RenderMathMLBlock {mo} at (0,0) size 9x16
+              RenderText {mo} at (0,0) size 9x16
+                text run at (0,0) width 9: "+"
+          RenderInline {mn} at (0,0) size 8x16
+            RenderText {#text} at (17,0) size 8x16
+              text run at (17,0) width 8: "2"
+layer at (194,262) size 37x16
+  RenderMathMLRow {mrow} at (0,8) size 37x16
     RenderInline {mi} at (0,0) size 5x12
       RenderText {#text} at (2,0) size 5x12
         text run at (2,0) width 5: "x"
@@ -268,11 +262,9 @@
         text run at (28,0) width 5: "z"
 layer at (84,310) size 27x48
   RenderMathMLRoot {mroot} at (1,0) size 27x48
-    RenderMathMLBlock {mroot} at (19,43) size 0x0
-    RenderMathMLBlock {mroot} at (19,32) size 8x16
-      RenderInline {mn} at (0,0) size 8x16
-        RenderText {#text} at (0,0) size 8x16
-          text run at (0,0) width 8: "2"
+    RenderInline {mn} at (0,0) size 8x16
+      RenderText {#text} at (19,32) size 8x16
+        text run at (19,32) width 8: "2"
 layer at (84,310) size 19x42
   RenderMathMLFraction {mfrac} at (0,0) size 19x42
     RenderMathMLBlock {mfrac} at (2,0) size 13x26
@@ -289,126 +281,82 @@
       RenderInline {mi} at (0,0) size 5x12
         RenderText {#text} at (4,2) size 5x12
           text run at (4,2) width 5: "z"
-layer at (119,445) size 326x76
-  RenderMathMLRoot {mroot} at (1,0) size 326x76
-    RenderMathMLBlock {mroot} at (18,50) size 0x0
-    RenderMathMLBlock {mroot} at (18,3) size 308x70
-      RenderMathMLRow {mrow} at (11,0) size 297x70
-        RenderInline {mn} at (0,0) size 8x16
-          RenderText {#text} at (0,36) size 8x16
-            text run at (0,36) width 8: "1"
-        RenderMathMLOperator {mo} at (8,36) size 10x16
-          RenderMathMLBlock {mo} at (0,0) size 9x16
-            RenderText {mo} at (0,0) size 9x16
-              text run at (0,0) width 9: "+"
-layer at (119,478) size 12x14
-  RenderBlock (positioned) {mn} at (0,33) size 12x14
-    RenderText {#text} at (2,0) size 6x12
-      text run at (2,0) width 6: "3"
-layer at (166,448) size 279x70
-  RenderMathMLRoot {mroot} at (18,0) size 279x70
-    RenderMathMLBlock {mroot} at (18,47) size 0x0
-    RenderMathMLBlock {mroot} at (18,3) size 261x64
-      RenderMathMLRow {mrow} at (9,0) size 252x64
-        RenderInline {mn} at (0,0) size 8x16
-          RenderText {#text} at (0,33) size 8x16
-            text run at (0,33) width 8: "2"
-        RenderMathMLOperator {mo} at (8,33) size 10x16
-          RenderMathMLBlock {mo} at (0,0) size 9x16
-            RenderText {mo} at (0,0) size 9x16
-              text run at (0,0) width 9: "+"
-layer at (166,477) size 12x14
-  RenderBlock (positioned) {mn} at (0,29) size 12x14
-    RenderText {#text} at (2,0) size 6x12
-      text run at (2,0) width 6: "4"
-layer at (211,451) size 234x64
-  RenderMathMLRoot {mroot} at (18,0) size 234x64
-    RenderMathMLBlock {mroot} at (18,44) size 0x0
-    RenderMathMLBlock {mroot} at (18,3) size 216x58
-      RenderMathMLRow {mrow} at (8,0) size 208x58
-        RenderInline {mn} at (0,0) size 8x16
-          RenderText {#text} at (0,30) size 8x16
-            text run at (0,30) width 8: "3"
-        RenderMathMLOperator {mo} at (8,30) size 10x16
-          RenderMathMLBlock {mo} at (0,0) size 9x16
-            RenderText {mo} at (0,0) size 9x16
-              text run at (0,0) width 9: "+"
-layer at (211,477) size 12x14
-  RenderBlock (positioned) {mn} at (0,26) size 12x14
-    RenderText {#text} at (2,0) size 6x12
-      text run at (2,0) width 6: "5"
-layer at (255,454) size 190x58
-  RenderMathMLRoot {mroot} at (18,0) size 190x58
-    RenderMathMLBlock {mroot} at (18,41) size 0x0
-    RenderMathMLBlock {mroot} at (18,3) size 172x52
-      RenderMathMLRow {mrow} at (6,0) size 166x52
-        RenderInline {mn} at (0,0) size 8x16
-          RenderText {#text} at (0,27) size 8x16
-            text run at (0,27) width 8: "4"
-        RenderMathMLOperator {mo} at (8,27) size 10x16
-          RenderMathMLBlock {mo} at (0,0) size 9x16
-            RenderText {mo} at (0,0) size 9x16
-              text run at (0,0) width 9: "+"
-layer at (255,476) size 12x14
-  RenderBlock (positioned) {mn} at (0,22) size 12x14
-    RenderText {#text} at (2,0) size 6x12
-      text run at (2,0) width 6: "6"
-layer at (297,457) size 148x52
-  RenderMathMLRoot {mroot} at (18,0) size 148x52
-    RenderMathMLBlock {mroot} at (17,38) size 0x0
-    RenderMathMLBlock {mroot} at (17,3) size 131x46
-      RenderMathMLRow {mrow} at (4,0) size 127x46
-        RenderInline {mn} at (0,0) size 8x16
-          RenderText {#text} at (0,24) size 8x16
-            text run at (0,24) width 8: "5"
-        RenderMathMLOperator {mo} at (8,24) size 10x16
-          RenderMathMLBlock {mo} at (0,0) size 9x16
-            RenderText {mo} at (0,0) size 9x16
-              text run at (0,0) width 9: "+"
-layer at (297,475) size 12x14
-  RenderBlock (positioned) {mn} at (0,18) size 12x14
-    RenderText {#text} at (2,0) size 6x12
-      text run at (2,0) width 6: "7"
-layer at (336,460) size 109x46
-  RenderMathMLRoot {mroot} at (18,0) size 109x46
-    RenderMathMLBlock {mroot} at (16,35) size 0x0
-    RenderMathMLBlock {mroot} at (16,3) size 93x40
-      RenderMathMLRow {mrow} at (3,0) size 90x40
-        RenderInline {mn} at (0,0) size 8x16
-          RenderText {#text} at (0,21) size 8x16
-            text run at (0,21) width 8: "6"
-        RenderMathMLOperator {mo} at (8,21) size 10x16
-          RenderMathMLBlock {mo} at (0,0) size 9x16
-            RenderText {mo} at (0,0) size 9x16
-              text run at (0,0) width 9: "+"
-layer at (336,474) size 12x14
-  RenderBlock (positioned) {mn} at (0,14) size 12x14
-    RenderText {#text} at (2,0) size 6x12
-      text run at (2,0) width 6: "8"
-layer at (373,463) size 72x40
-  RenderMathMLRoot {mroot} at (18,0) size 72x40
-    RenderMathMLBlock {mroot} at (14,32) size 0x0
-    RenderMathMLBlock {mroot} at (14,3) size 58x34
-      RenderMathMLRow {mrow} at (2,0) size 56x34
-        RenderInline {mn} at (0,0) size 8x16
-          RenderText {#text} at (0,18) size 8x16
-            text run at (0,18) width 8: "7"
-        RenderMathMLOperator {mo} at (8,18) size 10x16
-          RenderMathMLBlock {mo} at (0,0) size 9x16
-            RenderText {mo} at (0,0) size 9x16
-              text run at (0,0) width 9: "+"
-layer at (373,474) size 12x14
-  RenderBlock (positioned) {mn} at (0,11) size 12x14
-    RenderText {#text} at (2,0) size 6x12
-      text run at (2,0) width 6: "9"
-layer at (407,466) size 38x34
+layer at (119,445) size 283x76
+  RenderMathMLRoot {mroot} at (1,0) size 283x76
+    RenderMathMLRow {mrow} at (18,3) size 265x70
+      RenderInline {mn} at (0,0) size 8x16
+        RenderText {#text} at (0,36) size 8x16
+          text run at (0,36) width 8: "1"
+      RenderMathMLOperator {mo} at (8,36) size 10x16
+        RenderMathMLBlock {mo} at (0,0) size 9x16
+          RenderText {mo} at (0,0) size 9x16
+            text run at (0,0) width 9: "+"
+layer at (155,448) size 247x70
+  RenderMathMLRoot {mroot} at (18,0) size 247x70
+    RenderMathMLRow {mrow} at (18,3) size 229x64
+      RenderInline {mn} at (0,0) size 8x16
+        RenderText {#text} at (0,33) size 8x16
+          text run at (0,33) width 8: "2"
+      RenderMathMLOperator {mo} at (8,33) size 10x16
+        RenderMathMLBlock {mo} at (0,0) size 9x16
+          RenderText {mo} at (0,0) size 9x16
+            text run at (0,0) width 9: "+"
+layer at (191,451) size 211x64
+  RenderMathMLRoot {mroot} at (18,0) size 211x64
+    RenderMathMLRow {mrow} at (18,3) size 193x58
+      RenderInline {mn} at (0,0) size 8x16
+        RenderText {#text} at (0,30) size 8x16
+          text run at (0,30) width 8: "3"
+      RenderMathMLOperator {mo} at (8,30) size 10x16
+        RenderMathMLBlock {mo} at (0,0) size 9x16
+          RenderText {mo} at (0,0) size 9x16
+            text run at (0,0) width 9: "+"
+layer at (227,454) size 175x58
+  RenderMathMLRoot {mroot} at (18,0) size 175x58
+    RenderMathMLRow {mrow} at (18,3) size 157x52
+      RenderInline {mn} at (0,0) size 8x16
+        RenderText {#text} at (0,27) size 8x16
+          text run at (0,27) width 8: "4"
+      RenderMathMLOperator {mo} at (8,27) size 10x16
+        RenderMathMLBlock {mo} at (0,0) size 9x16
+          RenderText {mo} at (0,0) size 9x16
+            text run at (0,0) width 9: "+"
+layer at (263,457) size 139x52
+  RenderMathMLRoot {mroot} at (18,0) size 139x52
+    RenderMathMLRow {mrow} at (17,3) size 122x46
+      RenderInline {mn} at (0,0) size 8x16
+        RenderText {#text} at (0,24) size 8x16
+          text run at (0,24) width 8: "5"
+      RenderMathMLOperator {mo} at (8,24) size 10x16
+        RenderMathMLBlock {mo} at (0,0) size 9x16
+          RenderText {mo} at (0,0) size 9x16
+            text run at (0,0) width 9: "+"
+layer at (298,460) size 104x46
+  RenderMathMLRoot {mroot} at (18,0) size 104x46
+    RenderMathMLRow {mrow} at (16,3) size 88x40
+      RenderInline {mn} at (0,0) size 8x16
+        RenderText {#text} at (0,21) size 8x16
+          text run at (0,21) width 8: "6"
+      RenderMathMLOperator {mo} at (8,21) size 10x16
+        RenderMathMLBlock {mo} at (0,0) size 9x16
+          RenderText {mo} at (0,0) size 9x16
+            text run at (0,0) width 9: "+"
+layer at (332,463) size 70x40
+  RenderMathMLRoot {mroot} at (18,0) size 70x40
+    RenderMathMLRow {mrow} at (14,3) size 56x34
+      RenderInline {mn} at (0,0) size 8x16
+        RenderText {#text} at (0,18) size 8x16
+          text run at (0,18) width 8: "7"
+      RenderMathMLOperator {mo} at (8,18) size 10x16
+        RenderMathMLBlock {mo} at (0,0) size 9x16
+          RenderText {mo} at (0,0) size 9x16
+            text run at (0,0) width 9: "+"
+layer at (364,466) size 38x34
   RenderMathMLRoot {mroot} at (18,0) size 38x34
-    RenderMathMLBlock {mroot} at (28,29) size 0x0
-    RenderMathMLBlock {mroot} at (28,18) size 10x16
-      RenderInline {mi} at (0,0) size 10x16
-        RenderText {#text} at (0,0) size 10x16
-          text run at (0,0) width 10: "A"
-layer at (407,466) size 28x28
+    RenderInline {mi} at (0,0) size 10x16
+      RenderText {#text} at (28,18) size 10x16
+        text run at (28,18) width 10: "A"
+layer at (364,466) size 28x28
   RenderMathMLFraction {mfrac} at (0,0) size 28x28
     RenderMathMLBlock {mfrac} at (2,0) size 22x12
       RenderMathMLRow {mrow} at (2,0) size 18x12
@@ -426,3 +374,31 @@
       RenderInline {mi} at (0,0) size 6x12
         RenderText {#text} at (8,2) size 6x12
           text run at (8,2) width 6: "z"
+layer at (332,473) size 12x14
+  RenderBlock (positioned) {mn} at (0,10) size 12x14
+    RenderText {#text} at (2,0) size 6x12
+      text run at (2,0) width 6: "9"
+layer at (298,474) size 12x14
+  RenderBlock (positioned) {mn} at (0,14) size 12x14
+    RenderText {#text} at (2,0) size 6x12
+      text run at (2,0) width 6: "8"
+layer at (263,475) size 12x14
+  RenderBlock (positioned) {mn} at (0,18) size 12x14
+    RenderText {#text} at (2,0) size 6x12
+      text run at (2,0) width 6: "7"
+layer at (227,475) size 12x14
+  RenderBlock (positioned) {mn} at (0,21) size 12x14
+    RenderText {#text} at (2,0) size 6x12
+      text run at (2,0) width 6: "6"
+layer at (191,476) size 12x14
+  RenderBlock (positioned) {mn} at (0,25) size 12x14
+    RenderText {#text} at (2,0) size 6x12
+      text run at (2,0) width 6: "5"
+layer at (155,477) size 12x14
+  RenderBlock (positioned) {mn} at (0,29) size 12x14
+    RenderText {#text} at (2,0) size 6x12
+      text run at (2,0) width 6: "4"
+layer at (119,478) size 12x14
+  RenderBlock (positioned) {mn} at (0,33) size 12x14
+    RenderText {#text} at (2,0) size 6x12
+      text run at (2,0) width 6: "3"

Modified: trunk/Source/WebCore/ChangeLog (114011 => 114012)


--- trunk/Source/WebCore/ChangeLog	2012-04-12 19:03:38 UTC (rev 114011)
+++ trunk/Source/WebCore/ChangeLog	2012-04-12 19:07:07 UTC (rev 114012)
@@ -1,3 +1,33 @@
+2012-04-12  David Barton  <[email protected]>
+
+        Don't modify shared style objects in RenderMathMLRoot.cpp
+        https://bugs.webkit.org/show_bug.cgi?id=83736
+
+        Reviewed by Julien Chaffraix.
+
+        To leave room for the radical sign and absolutely positioned "index", we switch to using
+        intrinsic padding. RenderMathMLRoot.cpp is also cleaned up and prepared for merging with
+        RenderMathMLSquareRoot.cpp. The base and index are no longer wrapped in extra renderers,
+        and the child renderers are now in the same order as in the DOM. Some padding/placement
+        terms are unified and debugged.
+
+        Tested by existing tests in roots.xhtml.
+
+        * css/mathml.css:
+        (mroot):
+        (mroot > * + *):
+        (mroot > * + mrow, mroot > * + mfenced):
+        * rendering/mathml/RenderMathMLRoot.cpp:
+        (WebCore):
+        (WebCore::RenderMathMLRoot::index):
+        (WebCore::RenderMathMLRoot::paint):
+        (WebCore::RenderMathMLRoot::layout):
+        * rendering/mathml/RenderMathMLRoot.h:
+        (RenderMathMLRoot):
+        * rendering/mathml/RenderMathMLSquareRoot.cpp:
+        (WebCore):
+        (WebCore::RenderMathMLSquareRoot::paint):
+
 2012-04-12  Anders Carlsson  <[email protected]>
 
         Build fix.

Modified: trunk/Source/WebCore/css/mathml.css (114011 => 114012)


--- trunk/Source/WebCore/css/mathml.css	2012-04-12 19:03:38 UTC (rev 114011)
+++ trunk/Source/WebCore/css/mathml.css	2012-04-12 19:07:07 UTC (rev 114012)
@@ -151,21 +151,19 @@
 mroot {
     display: inline-block;
     position: relative;
-    padding-top: 0.2em;
-    padding-left: 0.2em;
 }
 
 mroot > * + * {
     font-size: 0.75em;
-    vertical-align: bottom;
     position: absolute;
-    left: 0px;
+    left: 0;
+    top: 0;
     padding-right: 0.4em;
     padding-left: 0.2em;
-    padding-bottom: 0.2em;
+    padding-bottom: 0.2em; /* FIXME: change to 0.25em */
 }
 
-mroot > * + mrow, mroot > * + mfenced {
+mroot > * + mrow, mroot > * + mfenced { /* FIXME: eliminate */
     padding-bottom: 0.4em;
 }
 

Modified: trunk/Source/WebCore/rendering/mathml/RenderMathMLRoot.cpp (114011 => 114012)


--- trunk/Source/WebCore/rendering/mathml/RenderMathMLRoot.cpp	2012-04-12 19:03:38 UTC (rev 114011)
+++ trunk/Source/WebCore/rendering/mathml/RenderMathMLRoot.cpp	2012-04-12 19:07:07 UTC (rev 114012)
@@ -34,28 +34,30 @@
 #include "MathMLNames.h"
 #include "PaintInfo.h"
 
+using namespace std;
+
 namespace WebCore {
     
 using namespace MathMLNames;
 
-// Extra space on the left for the radical sign (px)
-const int gRadicalLeftExtra = 3;
-// Lower the radical sign's bottom point (px)
-const int gRadicalBottomPointLower = 3;
+// FIXME: This whole file should be changed to work with various writing modes. See https://bugs.webkit.org/show_bug.cgi?id=48951.
+
 // Threshold above which the radical shape is modified to look nice with big bases (em)
 const float gThresholdBaseHeightEms = 1.5f;
-// Front width (em)
+// Normal width of the front of the radical sign, before the base & overbar (em)
 const float gFrontWidthEms = 0.75f;
+// Gap between the base and overbar (em)
+const float gSpaceAboveEms = 0.2f;
 // Horizontal position of the bottom point of the radical (* frontWidth)
 const float gRadicalBottomPointXFront = 0.5f;
+// Lower the radical sign's bottom point (px)
+const int gRadicalBottomPointLower = 3;
 // Horizontal position of the top left point of the radical "dip" (* frontWidth)
 const float gRadicalDipLeftPointXFront = 0.8f;
 // Vertical position of the top left point of the radical "dip" (* baseHeight)
 const float gRadicalDipLeftPointYPos = 0.625f; 
 // Vertical shift of the left end point of the radical (em)
 const float gRadicalLeftEndYShiftEms = 0.05f;
-// Root padding around the base (em) (mroot padding-top/left from mathml.css)
-const float gRootPaddingEms = 0.2f;
 // Additional bottom root padding if baseHeight > threshold (em)
 const float gBigRootBottomPaddingEms = 0.2f;
 
@@ -69,25 +71,16 @@
 {
 }
 
-void RenderMathMLRoot::addChild(RenderObject* child, RenderObject* )
+RenderBoxModelObject* RenderMathMLRoot::index() const
 {
-    if (isEmpty()) {
-        // Add a block for the index
-        RenderBlock* indexWrapper = createAlmostAnonymousBlock(INLINE_BLOCK);
-        RenderBlock::addChild(indexWrapper);
-        
-        // FIXME: the wrapping does not seem to be needed anymore.
-        // this is the base, so wrap it so we can pad it
-        RenderBlock* baseWrapper = createAlmostAnonymousBlock(INLINE_BLOCK);
-        baseWrapper->style()->setPaddingLeft(Length(5 * gFrontWidthEms, Percent));
-        RenderBlock::addChild(baseWrapper);
-        baseWrapper->addChild(child);
-    } else {
-        // always add to the index
-        firstChild()->addChild(child);
-    }
+    if (!firstChild())
+        return 0;
+    RenderObject* index = firstChild()->nextSibling();
+    if (!index || !index->isBoxModelObject())
+        return 0;
+    return toRenderBoxModelObject(index);
 }
-    
+
 void RenderMathMLRoot::paint(PaintInfo& info, const LayoutPoint& paintOffset)
 {
     RenderMathMLBlock::paint(info, paintOffset);
@@ -95,48 +88,22 @@
     if (info.context->paintingDisabled())
         return;
     
-    if (!firstChild() || !lastChild())
+    if (!index())
         return;
     
-    IntPoint adjustedPaintOffset = roundedIntPoint(paintOffset + location());
+    IntPoint adjustedPaintOffset = roundedIntPoint(paintOffset + location() + computedCSSContentBoxRect().location());
     
-    RenderBoxModelObject* baseWrapper = toRenderBoxModelObject(lastChild());
+    int baseHeight = roundToInt(getBoxModelObjectHeight(firstChild()));
     
-    int baseHeight = baseWrapper->pixelSnappedOffsetHeight();
-    // default to the font size in pixels if we're empty
-    if (!baseHeight)
-        baseHeight = style()->fontSize();
-    int overbarWidth = baseWrapper->pixelSnappedOffsetWidth();
+    int overbarWidth = roundToInt(getBoxModelObjectWidth(firstChild())) + m_overbarLeftPointShift;
+    int indexWidth = index()->pixelSnappedOffsetWidth();
+    int frontWidth = static_cast<int>(roundf(gFrontWidthEms * style()->fontSize()));
+    int startX = adjustedPaintOffset.x() + indexWidth + m_overbarLeftPointShift;
     
-    int indexWidth = 0;
-    RenderObject* current = firstChild();
-    while (current != lastChild()) {
-        if (current->isBoxModelObject()) {
-            RenderBoxModelObject* box = toRenderBoxModelObject(current);
-            indexWidth += box->pixelSnappedOffsetWidth();
-        }
-        current = current->nextSibling();
-    }
+    int rootPad = static_cast<int>(roundf(gSpaceAboveEms * style()->fontSize()));
+    adjustedPaintOffset.setY(adjustedPaintOffset.y() + m_intrinsicPaddingBefore - rootPad);
     
-    int frontWidth = static_cast<int>(style()->fontSize() * gFrontWidthEms);
-    int overbarLeftPointShift = 0;
-    // Base height above which the shape of the root changes
-    int thresholdHeight = static_cast<int>(gThresholdBaseHeightEms * style()->fontSize());
-    
-    if (baseHeight > thresholdHeight && thresholdHeight) {
-        float shift = (baseHeight - thresholdHeight) / static_cast<float>(thresholdHeight);
-        if (shift > 1.)
-            shift = 1.0f;
-        overbarLeftPointShift = static_cast<int>(gRadicalBottomPointXFront * frontWidth * shift);
-    }
-    
-    overbarWidth += overbarLeftPointShift;
-    
-    int rootPad = static_cast<int>(gRootPaddingEms * style()->fontSize());
-    int startX = adjustedPaintOffset.x() + indexWidth + gRadicalLeftExtra + style()->paddingLeft().value() - rootPad;
-    adjustedPaintOffset.setY(adjustedPaintOffset.y() + style()->paddingTop().value() - rootPad);
-    
-    FloatPoint overbarLeftPoint(startX - overbarLeftPointShift, adjustedPaintOffset.y());
+    FloatPoint overbarLeftPoint(startX - m_overbarLeftPointShift, adjustedPaintOffset.y());
     FloatPoint bottomPoint(startX - gRadicalBottomPointXFront * frontWidth, adjustedPaintOffset.y() + baseHeight + gRadicalBottomPointLower);
     FloatPoint dipLeftPoint(startX - gRadicalDipLeftPointXFront * frontWidth, adjustedPaintOffset.y() + gRadicalDipLeftPointYPos * baseHeight);
     FloatPoint leftEnd(startX - frontWidth, dipLeftPoint.y() + gRadicalLeftEndYShiftEms * style()->fontSize());
@@ -190,60 +157,42 @@
 {
     RenderBlock::layout();
 
-    if (!firstChild() || !lastChild())
+    if (!index())
         return;
 
-    int baseHeight = toRenderBoxModelObject(lastChild())->pixelSnappedOffsetHeight();
-    if (!baseHeight)
-        baseHeight = style()->fontSize();
+    int baseHeight = roundToInt(getBoxModelObjectHeight(firstChild()));
     
-    RenderObject* base = lastChild()->firstChild();
-    if (base)
-        base->style()->setVerticalAlign(BASELINE); // FIXME: Can this style be modified?
-    
     // Base height above which the shape of the root changes
-    int thresholdHeight = static_cast<int>(gThresholdBaseHeightEms * style()->fontSize());
-    int overbarLeftPointShift = 0;
-    
-    // FIXME: Can style() and indexBox->style() be modified (4 times below)?
+    float thresholdHeight = gThresholdBaseHeightEms * style()->fontSize();
     if (baseHeight > thresholdHeight && thresholdHeight) {
-        float shift = (baseHeight - thresholdHeight) / static_cast<float>(thresholdHeight);
-        if (shift > 1.)
-            shift = 1.0f;
-        int frontWidth = static_cast<int>(style()->fontSize() * gFrontWidthEms);
-        overbarLeftPointShift = static_cast<int>(gRadicalBottomPointXFront * frontWidth * shift);
-        
-        style()->setPaddingBottom(Length(static_cast<int>(gBigRootBottomPaddingEms * style()->fontSize()), Fixed));
+        float shift = min<float>((baseHeight - thresholdHeight) / thresholdHeight, 1.0f);
+        int frontWidth = static_cast<int>(roundf(gFrontWidthEms * style()->fontSize()));
+        m_overbarLeftPointShift = static_cast<int>(shift * gRadicalBottomPointXFront * frontWidth);
+        m_intrinsicPaddingAfter = static_cast<int>(roundf(gBigRootBottomPaddingEms * style()->fontSize()));
+    } else {
+        m_overbarLeftPointShift = 0;
+        m_intrinsicPaddingAfter = 0;
     }
     
-    // Positioning of the index
-    RenderObject* possibleIndex = firstChild()->firstChild();
-    while (possibleIndex && !possibleIndex->isBoxModelObject())
-        possibleIndex = possibleIndex->nextSibling();
-    RenderBoxModelObject* indexBox = toRenderBoxModelObject(possibleIndex);
-    if (!indexBox)
-        return;
+    RenderBoxModelObject* index = this->index();
     
-    int shiftForIndex = indexBox->pixelSnappedOffsetWidth() + overbarLeftPointShift;
-    int partDipHeight = static_cast<int>((1 - gRadicalDipLeftPointYPos) * baseHeight);
-    int rootExtraTop = partDipHeight + style()->paddingBottom().value() + indexBox->pixelSnappedOffsetHeight()
-        - (baseHeight + static_cast<int>(gRootPaddingEms * style()->fontSize()));
+    m_intrinsicPaddingStart = index->pixelSnappedOffsetWidth() + m_overbarLeftPointShift;
     
-    style()->setPaddingLeft(Length(shiftForIndex, Fixed));
-    if (rootExtraTop > 0)
-        style()->setPaddingTop(Length(rootExtraTop + static_cast<int>(gRootPaddingEms * style()->fontSize()), Fixed));
+    int rootPad = static_cast<int>(roundf(gSpaceAboveEms * style()->fontSize()));
+    int partDipHeight = static_cast<int>(roundf((1 - gRadicalDipLeftPointYPos) * baseHeight));
+    int rootExtraTop = partDipHeight + index->pixelSnappedOffsetHeight() - (baseHeight + rootPad);
+    m_intrinsicPaddingBefore = rootPad + max(rootExtraTop, 0);
     
-    setNeedsLayout(true);
+    setNeedsLayout(true, MarkOnlyThis);
     setPreferredLogicalWidthsDirty(true, MarkOnlyThis); // FIXME: Can this really be right?
+    // FIXME: Preferred logical widths are currently wrong the first time through, relying on layout() to set m_intrinsicPaddingStart.
     RenderBlock::layout();
-
-    indexBox->style()->setBottom(Length(partDipHeight + style()->paddingBottom().value(), Fixed));
-
-    // Now that we've potentially changed its position, we need layout the index again.
-    indexBox->setNeedsLayout(true);
-    indexBox->layout();
-}
     
+    // |index| should be a RenderBlock here, unless the user has overriden its { position: absolute }.
+    if (rootExtraTop < 0 && index->isBox())
+        toRenderBox(index)->setLogicalTop(-rootExtraTop);
 }
 
+}
+
 #endif // ENABLE(MATHML)

Modified: trunk/Source/WebCore/rendering/mathml/RenderMathMLRoot.h (114011 => 114012)


--- trunk/Source/WebCore/rendering/mathml/RenderMathMLRoot.h	2012-04-12 19:03:38 UTC (rev 114011)
+++ trunk/Source/WebCore/rendering/mathml/RenderMathMLRoot.h	2012-04-12 19:07:07 UTC (rev 114012)
@@ -36,15 +36,19 @@
 class RenderMathMLRoot : public RenderMathMLBlock {
 public:
     RenderMathMLRoot(Element*);
-    virtual void addChild(RenderObject* child, RenderObject* beforeChild = 0);
     
-    virtual void paint(PaintInfo&, const LayoutPoint&);
+protected:
+    virtual void layout() OVERRIDE;
     
-protected:
-    virtual void layout();
+    virtual void paint(PaintInfo&, const LayoutPoint&) OVERRIDE;
 
 private:
     virtual const char* renderName() const { return "RenderMathMLRoot"; }
+    
+    // This may return 0 for a non-MathML index (which won't occur in valid MathML).
+    RenderBoxModelObject* index() const;
+    
+    int m_overbarLeftPointShift;
 };
     
 }

Modified: trunk/Source/WebCore/rendering/mathml/RenderMathMLSquareRoot.cpp (114011 => 114012)


--- trunk/Source/WebCore/rendering/mathml/RenderMathMLSquareRoot.cpp	2012-04-12 19:03:38 UTC (rev 114011)
+++ trunk/Source/WebCore/rendering/mathml/RenderMathMLSquareRoot.cpp	2012-04-12 19:07:07 UTC (rev 114012)
@@ -35,6 +35,8 @@
 #include "PaintInfo.h"
 #include "RenderMathMLRow.h"
 
+using namespace std;
+
 namespace WebCore {
     
 using namespace MathMLNames;
@@ -52,7 +54,7 @@
 // Lower the radical sign's bottom point (px)
 const int gRadicalBottomPointLower = 3;
 // Horizontal position of the top left point of the radical "dip" (* frontWidth)
-const float gRadicalDipLeftPointXFront = 0.2f;
+const float gRadicalDipLeftPointXFront = 0.8f;
 // Vertical position of the top left point of the radical "dip" (* baseHeight)
 const float gRadicalDipLeftPointYPos = 0.5f; 
 // Vertical shift of the left end point of the radical (em)
@@ -128,19 +130,19 @@
     float thresholdHeight = gThresholdBaseHeightEms * style()->fontSize();
     
     if (baseHeight > thresholdHeight && thresholdHeight) {
-        float shift = (baseHeight - thresholdHeight) / thresholdHeight;
-        if (shift > 1.)
-            shift = 1.0f;
-        overbarLeftPointShift = static_cast<int>(gRadicalBottomPointXFront * frontWidth * shift);
+        float shift = min<float>((baseHeight - thresholdHeight) / thresholdHeight, 1.0f);
+        overbarLeftPointShift = static_cast<int>(shift * gRadicalBottomPointXFront * frontWidth);
     }
     
     overbarWidth += overbarLeftPointShift;
     
-    FloatPoint overbarLeftPoint(adjustedPaintOffset.x() + frontWidth - overbarLeftPointShift, adjustedPaintOffset.y());
-    FloatPoint bottomPoint(adjustedPaintOffset.x() + frontWidth * gRadicalBottomPointXFront, adjustedPaintOffset.y() + baseHeight + gRadicalBottomPointLower);
-    FloatPoint dipLeftPoint(adjustedPaintOffset.x() + frontWidth * gRadicalDipLeftPointXFront, adjustedPaintOffset.y() + gRadicalDipLeftPointYPos * baseHeight);
-    FloatPoint leftEnd(adjustedPaintOffset.x(), dipLeftPoint.y() + gRadicalLeftEndYShiftEms * style()->fontSize());
+    int startX = adjustedPaintOffset.x() + frontWidth;
     
+    FloatPoint overbarLeftPoint(startX - overbarLeftPointShift, adjustedPaintOffset.y());
+    FloatPoint bottomPoint(startX - gRadicalBottomPointXFront * frontWidth, adjustedPaintOffset.y() + baseHeight + gRadicalBottomPointLower);
+    FloatPoint dipLeftPoint(startX - gRadicalDipLeftPointXFront * frontWidth, adjustedPaintOffset.y() + gRadicalDipLeftPointYPos * baseHeight);
+    FloatPoint leftEnd(startX - frontWidth, dipLeftPoint.y() + gRadicalLeftEndYShiftEms * style()->fontSize());
+    
     GraphicsContextStateSaver stateSaver(*info.context);
     
     info.context->setStrokeThickness(gRadicalLineThicknessEms * style()->fontSize());
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to