Changeset 114012 in webkit


Ignore:
Timestamp:
Apr 12, 2012 12:07:07 PM (12 years ago)
Author:
commit-queue@webkit.org
Message:

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

Patch by David Barton <Dave Barton> 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:
Location:
trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r114010 r114012  
     12012-04-12  David Barton  <dbarton@mathscribe.com>
     2
     3        Don't modify shared style objects in RenderMathMLRoot.cpp
     4        https://bugs.webkit.org/show_bug.cgi?id=83736
     5
     6        Reviewed by Julien Chaffraix.
     7
     8        * platform/mac/mathml/presentation/roots-expected.png:
     9        * platform/mac/mathml/presentation/roots-expected.txt:
     10
    1112012-04-12  Tom Sepez  <tsepez@chromium.org>
    212
  • trunk/LayoutTests/platform/mac/mathml/presentation/roots-expected.txt

    r113749 r114012  
    9191        RenderMathMLMath {math} at (75,0) size 47x22
    9292      RenderBlock {p} at (0,238) size 784x40
    93         RenderText {#text} at (0,10) size 185x18
    94           text run at (0,10) width 185: "long index w/ complex base: "
    95         RenderMathMLMath {math} at (185,0) size 73x40
     93        RenderText {#text} at (0,9) size 185x18
     94          text run at (0,9) width 185: "long index w/ complex base: "
     95        RenderMathMLMath {math} at (185,0) size 72x40
    9696      RenderBlock {p} at (0,294) size 784x48
    9797        RenderText {#text} at (0,29) size 75x18
     
    180180        RenderText {#text} at (0,36) size 110x18
    181181          text run at (0,36) width 110: "Imbricated roots: "
    182         RenderMathMLMath {math} at (110,0) size 328x76
     182        RenderMathMLMath {math} at (110,0) size 285x76
    183183        RenderText {#text} at (0,0) size 0x0
    184184layer at (182,180) size 20x20
    185185  RenderMathMLRoot {mroot} at (1,0) size 20x20
    186     RenderMathMLBlock {mroot} at (12,15) size 0x0
    187     RenderMathMLBlock {mroot} at (12,4) size 8x16
    188       RenderInline {mn} at (0,0) size 8x16
    189         RenderText {#text} at (0,0) size 8x16
    190           text run at (0,0) width 8: "2"
     186    RenderInline {mn} at (0,0) size 8x16
     187      RenderText {#text} at (12,4) size 8x16
     188        text run at (12,4) width 8: "2"
    191189layer at (182,180) size 12x14
    192190  RenderBlock (positioned) {mn} at (0,0) size 12x14
     
    195193layer at (84,216) size 45x22
    196194  RenderMathMLRoot {mroot} at (1,0) size 45x22
    197     RenderMathMLBlock {mroot} at (37,17) size 0x0
    198     RenderMathMLBlock {mroot} at (37,6) size 8x16
    199       RenderInline {mn} at (0,0) size 8x16
    200         RenderText {#text} at (0,0) size 8x16
    201           text run at (0,0) width 8: "2"
     195    RenderInline {mn} at (0,0) size 8x16
     196      RenderText {#text} at (37,6) size 8x16
     197        text run at (37,6) width 8: "2"
    202198layer at (84,216) size 37x16
    203199  RenderMathMLRow {mrow} at (0,0) size 37x16
     
    219215      RenderText {#text} at (28,0) size 5x12
    220216        text run at (28,0) width 5: "z"
    221 layer at (194,254) size 71x40
    222   RenderMathMLRoot {mroot} at (1,0) size 71x40
    223     RenderMathMLBlock {mroot} at (39,24) size 0x0
    224     RenderMathMLBlock {mroot} at (39,3) size 32x34
    225       RenderMathMLFraction {mfrac} at (1,0) size 31x34
    226         RenderMathMLBlock {mfrac} at (0,0) size 31x16
    227           RenderMathMLRow {mrow} at (3,0) size 25x16
    228             RenderInline {mi} at (0,0) size 7x16
    229               RenderText {#text} at (0,0) size 7x16
    230                 text run at (0,0) width 7: "x"
    231             RenderMathMLOperator {mo} at (7,0) size 10x16
    232               RenderMathMLBlock {mo} at (0,0) size 9x16
    233                 RenderText {mo} at (0,0) size 9x16
    234                   text run at (0,0) width 9: "+"
    235             RenderInline {mn} at (0,0) size 8x16
    236               RenderText {#text} at (17,0) size 8x16
    237                 text run at (17,0) width 8: "1"
    238         RenderMathMLBlock {mfrac} at (0,16) size 31x18
    239           RenderMathMLRow {mrow} at (3,2) size 25x16
    240             RenderInline {mi} at (0,0) size 7x16
    241               RenderText {#text} at (0,0) size 7x16
    242                 text run at (0,0) width 7: "x"
    243             RenderMathMLOperator {mo} at (7,0) size 10x16
    244               RenderMathMLBlock {mo} at (0,0) size 9x16
    245                 RenderText {mo} at (0,0) size 9x16
    246                   text run at (0,0) width 9: "+"
    247             RenderInline {mn} at (0,0) size 8x16
    248               RenderText {#text} at (17,0) size 8x16
    249                 text run at (17,0) width 8: "2"
    250 layer at (194,263) size 37x16
    251   RenderMathMLRow {mrow} at (0,9) size 37x16
     217layer at (194,254) size 70x40
     218  RenderMathMLRoot {mroot} at (1,0) size 70x40
     219    RenderMathMLFraction {mfrac} at (39,3) size 31x34
     220      RenderMathMLBlock {mfrac} at (0,0) size 31x16
     221        RenderMathMLRow {mrow} at (3,0) size 25x16
     222          RenderInline {mi} at (0,0) size 7x16
     223            RenderText {#text} at (0,0) size 7x16
     224              text run at (0,0) width 7: "x"
     225          RenderMathMLOperator {mo} at (7,0) size 10x16
     226            RenderMathMLBlock {mo} at (0,0) size 9x16
     227              RenderText {mo} at (0,0) size 9x16
     228                text run at (0,0) width 9: "+"
     229          RenderInline {mn} at (0,0) size 8x16
     230            RenderText {#text} at (17,0) size 8x16
     231              text run at (17,0) width 8: "1"
     232      RenderMathMLBlock {mfrac} at (0,16) size 31x18
     233        RenderMathMLRow {mrow} at (3,2) size 25x16
     234          RenderInline {mi} at (0,0) size 7x16
     235            RenderText {#text} at (0,0) size 7x16
     236              text run at (0,0) width 7: "x"
     237          RenderMathMLOperator {mo} at (7,0) size 10x16
     238            RenderMathMLBlock {mo} at (0,0) size 9x16
     239              RenderText {mo} at (0,0) size 9x16
     240                text run at (0,0) width 9: "+"
     241          RenderInline {mn} at (0,0) size 8x16
     242            RenderText {#text} at (17,0) size 8x16
     243              text run at (17,0) width 8: "2"
     244layer at (194,262) size 37x16
     245  RenderMathMLRow {mrow} at (0,8) size 37x16
    252246    RenderInline {mi} at (0,0) size 5x12
    253247      RenderText {#text} at (2,0) size 5x12
     
    269263layer at (84,310) size 27x48
    270264  RenderMathMLRoot {mroot} at (1,0) size 27x48
    271     RenderMathMLBlock {mroot} at (19,43) size 0x0
    272     RenderMathMLBlock {mroot} at (19,32) size 8x16
    273       RenderInline {mn} at (0,0) size 8x16
    274         RenderText {#text} at (0,0) size 8x16
    275           text run at (0,0) width 8: "2"
     265    RenderInline {mn} at (0,0) size 8x16
     266      RenderText {#text} at (19,32) size 8x16
     267        text run at (19,32) width 8: "2"
    276268layer at (84,310) size 19x42
    277269  RenderMathMLFraction {mfrac} at (0,0) size 19x42
     
    290282        RenderText {#text} at (4,2) size 5x12
    291283          text run at (4,2) width 5: "z"
    292 layer at (119,445) size 326x76
    293   RenderMathMLRoot {mroot} at (1,0) size 326x76
    294     RenderMathMLBlock {mroot} at (18,50) size 0x0
    295     RenderMathMLBlock {mroot} at (18,3) size 308x70
    296       RenderMathMLRow {mrow} at (11,0) size 297x70
    297         RenderInline {mn} at (0,0) size 8x16
    298           RenderText {#text} at (0,36) size 8x16
    299             text run at (0,36) width 8: "1"
    300         RenderMathMLOperator {mo} at (8,36) size 10x16
    301           RenderMathMLBlock {mo} at (0,0) size 9x16
    302             RenderText {mo} at (0,0) size 9x16
    303               text run at (0,0) width 9: "+"
    304 layer at (119,478) size 12x14
    305   RenderBlock (positioned) {mn} at (0,33) size 12x14
    306     RenderText {#text} at (2,0) size 6x12
    307       text run at (2,0) width 6: "3"
    308 layer at (166,448) size 279x70
    309   RenderMathMLRoot {mroot} at (18,0) size 279x70
    310     RenderMathMLBlock {mroot} at (18,47) size 0x0
    311     RenderMathMLBlock {mroot} at (18,3) size 261x64
    312       RenderMathMLRow {mrow} at (9,0) size 252x64
    313         RenderInline {mn} at (0,0) size 8x16
    314           RenderText {#text} at (0,33) size 8x16
    315             text run at (0,33) width 8: "2"
    316         RenderMathMLOperator {mo} at (8,33) size 10x16
    317           RenderMathMLBlock {mo} at (0,0) size 9x16
    318             RenderText {mo} at (0,0) size 9x16
    319               text run at (0,0) width 9: "+"
    320 layer at (166,477) size 12x14
    321   RenderBlock (positioned) {mn} at (0,29) size 12x14
    322     RenderText {#text} at (2,0) size 6x12
    323       text run at (2,0) width 6: "4"
    324 layer at (211,451) size 234x64
    325   RenderMathMLRoot {mroot} at (18,0) size 234x64
    326     RenderMathMLBlock {mroot} at (18,44) size 0x0
    327     RenderMathMLBlock {mroot} at (18,3) size 216x58
    328       RenderMathMLRow {mrow} at (8,0) size 208x58
    329         RenderInline {mn} at (0,0) size 8x16
    330           RenderText {#text} at (0,30) size 8x16
    331             text run at (0,30) width 8: "3"
    332         RenderMathMLOperator {mo} at (8,30) size 10x16
    333           RenderMathMLBlock {mo} at (0,0) size 9x16
    334             RenderText {mo} at (0,0) size 9x16
    335               text run at (0,0) width 9: "+"
    336 layer at (211,477) size 12x14
    337   RenderBlock (positioned) {mn} at (0,26) size 12x14
    338     RenderText {#text} at (2,0) size 6x12
    339       text run at (2,0) width 6: "5"
    340 layer at (255,454) size 190x58
    341   RenderMathMLRoot {mroot} at (18,0) size 190x58
    342     RenderMathMLBlock {mroot} at (18,41) size 0x0
    343     RenderMathMLBlock {mroot} at (18,3) size 172x52
    344       RenderMathMLRow {mrow} at (6,0) size 166x52
    345         RenderInline {mn} at (0,0) size 8x16
    346           RenderText {#text} at (0,27) size 8x16
    347             text run at (0,27) width 8: "4"
    348         RenderMathMLOperator {mo} at (8,27) size 10x16
    349           RenderMathMLBlock {mo} at (0,0) size 9x16
    350             RenderText {mo} at (0,0) size 9x16
    351               text run at (0,0) width 9: "+"
    352 layer at (255,476) size 12x14
    353   RenderBlock (positioned) {mn} at (0,22) size 12x14
    354     RenderText {#text} at (2,0) size 6x12
    355       text run at (2,0) width 6: "6"
    356 layer at (297,457) size 148x52
    357   RenderMathMLRoot {mroot} at (18,0) size 148x52
    358     RenderMathMLBlock {mroot} at (17,38) size 0x0
    359     RenderMathMLBlock {mroot} at (17,3) size 131x46
    360       RenderMathMLRow {mrow} at (4,0) size 127x46
    361         RenderInline {mn} at (0,0) size 8x16
    362           RenderText {#text} at (0,24) size 8x16
    363             text run at (0,24) width 8: "5"
    364         RenderMathMLOperator {mo} at (8,24) size 10x16
    365           RenderMathMLBlock {mo} at (0,0) size 9x16
    366             RenderText {mo} at (0,0) size 9x16
    367               text run at (0,0) width 9: "+"
    368 layer at (297,475) size 12x14
    369   RenderBlock (positioned) {mn} at (0,18) size 12x14
    370     RenderText {#text} at (2,0) size 6x12
    371       text run at (2,0) width 6: "7"
    372 layer at (336,460) size 109x46
    373   RenderMathMLRoot {mroot} at (18,0) size 109x46
    374     RenderMathMLBlock {mroot} at (16,35) size 0x0
    375     RenderMathMLBlock {mroot} at (16,3) size 93x40
    376       RenderMathMLRow {mrow} at (3,0) size 90x40
    377         RenderInline {mn} at (0,0) size 8x16
    378           RenderText {#text} at (0,21) size 8x16
    379             text run at (0,21) width 8: "6"
    380         RenderMathMLOperator {mo} at (8,21) size 10x16
    381           RenderMathMLBlock {mo} at (0,0) size 9x16
    382             RenderText {mo} at (0,0) size 9x16
    383               text run at (0,0) width 9: "+"
    384 layer at (336,474) size 12x14
    385   RenderBlock (positioned) {mn} at (0,14) size 12x14
    386     RenderText {#text} at (2,0) size 6x12
    387       text run at (2,0) width 6: "8"
    388 layer at (373,463) size 72x40
    389   RenderMathMLRoot {mroot} at (18,0) size 72x40
    390     RenderMathMLBlock {mroot} at (14,32) size 0x0
    391     RenderMathMLBlock {mroot} at (14,3) size 58x34
    392       RenderMathMLRow {mrow} at (2,0) size 56x34
    393         RenderInline {mn} at (0,0) size 8x16
    394           RenderText {#text} at (0,18) size 8x16
    395             text run at (0,18) width 8: "7"
    396         RenderMathMLOperator {mo} at (8,18) size 10x16
    397           RenderMathMLBlock {mo} at (0,0) size 9x16
    398             RenderText {mo} at (0,0) size 9x16
    399               text run at (0,0) width 9: "+"
    400 layer at (373,474) size 12x14
    401   RenderBlock (positioned) {mn} at (0,11) size 12x14
    402     RenderText {#text} at (2,0) size 6x12
    403       text run at (2,0) width 6: "9"
    404 layer at (407,466) size 38x34
     284layer at (119,445) size 283x76
     285  RenderMathMLRoot {mroot} at (1,0) size 283x76
     286    RenderMathMLRow {mrow} at (18,3) size 265x70
     287      RenderInline {mn} at (0,0) size 8x16
     288        RenderText {#text} at (0,36) size 8x16
     289          text run at (0,36) width 8: "1"
     290      RenderMathMLOperator {mo} at (8,36) size 10x16
     291        RenderMathMLBlock {mo} at (0,0) size 9x16
     292          RenderText {mo} at (0,0) size 9x16
     293            text run at (0,0) width 9: "+"
     294layer at (155,448) size 247x70
     295  RenderMathMLRoot {mroot} at (18,0) size 247x70
     296    RenderMathMLRow {mrow} at (18,3) size 229x64
     297      RenderInline {mn} at (0,0) size 8x16
     298        RenderText {#text} at (0,33) size 8x16
     299          text run at (0,33) width 8: "2"
     300      RenderMathMLOperator {mo} at (8,33) size 10x16
     301        RenderMathMLBlock {mo} at (0,0) size 9x16
     302          RenderText {mo} at (0,0) size 9x16
     303            text run at (0,0) width 9: "+"
     304layer at (191,451) size 211x64
     305  RenderMathMLRoot {mroot} at (18,0) size 211x64
     306    RenderMathMLRow {mrow} at (18,3) size 193x58
     307      RenderInline {mn} at (0,0) size 8x16
     308        RenderText {#text} at (0,30) size 8x16
     309          text run at (0,30) width 8: "3"
     310      RenderMathMLOperator {mo} at (8,30) size 10x16
     311        RenderMathMLBlock {mo} at (0,0) size 9x16
     312          RenderText {mo} at (0,0) size 9x16
     313            text run at (0,0) width 9: "+"
     314layer at (227,454) size 175x58
     315  RenderMathMLRoot {mroot} at (18,0) size 175x58
     316    RenderMathMLRow {mrow} at (18,3) size 157x52
     317      RenderInline {mn} at (0,0) size 8x16
     318        RenderText {#text} at (0,27) size 8x16
     319          text run at (0,27) width 8: "4"
     320      RenderMathMLOperator {mo} at (8,27) size 10x16
     321        RenderMathMLBlock {mo} at (0,0) size 9x16
     322          RenderText {mo} at (0,0) size 9x16
     323            text run at (0,0) width 9: "+"
     324layer at (263,457) size 139x52
     325  RenderMathMLRoot {mroot} at (18,0) size 139x52
     326    RenderMathMLRow {mrow} at (17,3) size 122x46
     327      RenderInline {mn} at (0,0) size 8x16
     328        RenderText {#text} at (0,24) size 8x16
     329          text run at (0,24) width 8: "5"
     330      RenderMathMLOperator {mo} at (8,24) size 10x16
     331        RenderMathMLBlock {mo} at (0,0) size 9x16
     332          RenderText {mo} at (0,0) size 9x16
     333            text run at (0,0) width 9: "+"
     334layer at (298,460) size 104x46
     335  RenderMathMLRoot {mroot} at (18,0) size 104x46
     336    RenderMathMLRow {mrow} at (16,3) size 88x40
     337      RenderInline {mn} at (0,0) size 8x16
     338        RenderText {#text} at (0,21) size 8x16
     339          text run at (0,21) width 8: "6"
     340      RenderMathMLOperator {mo} at (8,21) size 10x16
     341        RenderMathMLBlock {mo} at (0,0) size 9x16
     342          RenderText {mo} at (0,0) size 9x16
     343            text run at (0,0) width 9: "+"
     344layer at (332,463) size 70x40
     345  RenderMathMLRoot {mroot} at (18,0) size 70x40
     346    RenderMathMLRow {mrow} at (14,3) size 56x34
     347      RenderInline {mn} at (0,0) size 8x16
     348        RenderText {#text} at (0,18) size 8x16
     349          text run at (0,18) width 8: "7"
     350      RenderMathMLOperator {mo} at (8,18) size 10x16
     351        RenderMathMLBlock {mo} at (0,0) size 9x16
     352          RenderText {mo} at (0,0) size 9x16
     353            text run at (0,0) width 9: "+"
     354layer at (364,466) size 38x34
    405355  RenderMathMLRoot {mroot} at (18,0) size 38x34
    406     RenderMathMLBlock {mroot} at (28,29) size 0x0
    407     RenderMathMLBlock {mroot} at (28,18) size 10x16
    408       RenderInline {mi} at (0,0) size 10x16
    409         RenderText {#text} at (0,0) size 10x16
    410           text run at (0,0) width 10: "A"
    411 layer at (407,466) size 28x28
     356    RenderInline {mi} at (0,0) size 10x16
     357      RenderText {#text} at (28,18) size 10x16
     358        text run at (28,18) width 10: "A"
     359layer at (364,466) size 28x28
    412360  RenderMathMLFraction {mfrac} at (0,0) size 28x28
    413361    RenderMathMLBlock {mfrac} at (2,0) size 22x12
     
    427375        RenderText {#text} at (8,2) size 6x12
    428376          text run at (8,2) width 6: "z"
     377layer at (332,473) size 12x14
     378  RenderBlock (positioned) {mn} at (0,10) size 12x14
     379    RenderText {#text} at (2,0) size 6x12
     380      text run at (2,0) width 6: "9"
     381layer at (298,474) size 12x14
     382  RenderBlock (positioned) {mn} at (0,14) size 12x14
     383    RenderText {#text} at (2,0) size 6x12
     384      text run at (2,0) width 6: "8"
     385layer at (263,475) size 12x14
     386  RenderBlock (positioned) {mn} at (0,18) size 12x14
     387    RenderText {#text} at (2,0) size 6x12
     388      text run at (2,0) width 6: "7"
     389layer at (227,475) size 12x14
     390  RenderBlock (positioned) {mn} at (0,21) size 12x14
     391    RenderText {#text} at (2,0) size 6x12
     392      text run at (2,0) width 6: "6"
     393layer at (191,476) size 12x14
     394  RenderBlock (positioned) {mn} at (0,25) size 12x14
     395    RenderText {#text} at (2,0) size 6x12
     396      text run at (2,0) width 6: "5"
     397layer at (155,477) size 12x14
     398  RenderBlock (positioned) {mn} at (0,29) size 12x14
     399    RenderText {#text} at (2,0) size 6x12
     400      text run at (2,0) width 6: "4"
     401layer at (119,478) size 12x14
     402  RenderBlock (positioned) {mn} at (0,33) size 12x14
     403    RenderText {#text} at (2,0) size 6x12
     404      text run at (2,0) width 6: "3"
  • trunk/Source/WebCore/ChangeLog

    r114007 r114012  
     12012-04-12  David Barton  <dbarton@mathscribe.com>
     2
     3        Don't modify shared style objects in RenderMathMLRoot.cpp
     4        https://bugs.webkit.org/show_bug.cgi?id=83736
     5
     6        Reviewed by Julien Chaffraix.
     7
     8        To leave room for the radical sign and absolutely positioned "index", we switch to using
     9        intrinsic padding. RenderMathMLRoot.cpp is also cleaned up and prepared for merging with
     10        RenderMathMLSquareRoot.cpp. The base and index are no longer wrapped in extra renderers,
     11        and the child renderers are now in the same order as in the DOM. Some padding/placement
     12        terms are unified and debugged.
     13
     14        Tested by existing tests in roots.xhtml.
     15
     16        * css/mathml.css:
     17        (mroot):
     18        (mroot > * + *):
     19        (mroot > * + mrow, mroot > * + mfenced):
     20        * rendering/mathml/RenderMathMLRoot.cpp:
     21        (WebCore):
     22        (WebCore::RenderMathMLRoot::index):
     23        (WebCore::RenderMathMLRoot::paint):
     24        (WebCore::RenderMathMLRoot::layout):
     25        * rendering/mathml/RenderMathMLRoot.h:
     26        (RenderMathMLRoot):
     27        * rendering/mathml/RenderMathMLSquareRoot.cpp:
     28        (WebCore):
     29        (WebCore::RenderMathMLSquareRoot::paint):
     30
    1312012-04-12  Anders Carlsson  <andersca@apple.com>
    232
  • trunk/Source/WebCore/css/mathml.css

    r113749 r114012  
    152152    display: inline-block;
    153153    position: relative;
    154     padding-top: 0.2em;
    155     padding-left: 0.2em;
    156154}
    157155
    158156mroot > * + * {
    159157    font-size: 0.75em;
    160     vertical-align: bottom;
    161158    position: absolute;
    162     left: 0px;
     159    left: 0;
     160    top: 0;
    163161    padding-right: 0.4em;
    164162    padding-left: 0.2em;
    165     padding-bottom: 0.2em;
    166 }
    167 
    168 mroot > * + mrow, mroot > * + mfenced {
     163    padding-bottom: 0.2em; /* FIXME: change to 0.25em */
     164}
     165
     166mroot > * + mrow, mroot > * + mfenced { /* FIXME: eliminate */
    169167    padding-bottom: 0.4em;
    170168}
  • trunk/Source/WebCore/rendering/mathml/RenderMathMLRoot.cpp

    r112425 r114012  
    3535#include "PaintInfo.h"
    3636
     37using namespace std;
     38
    3739namespace WebCore {
    3840   
    3941using namespace MathMLNames;
    4042
    41 // Extra space on the left for the radical sign (px)
    42 const int gRadicalLeftExtra = 3;
     43// FIXME: This whole file should be changed to work with various writing modes. See https://bugs.webkit.org/show_bug.cgi?id=48951.
     44
     45// Threshold above which the radical shape is modified to look nice with big bases (em)
     46const float gThresholdBaseHeightEms = 1.5f;
     47// Normal width of the front of the radical sign, before the base & overbar (em)
     48const float gFrontWidthEms = 0.75f;
     49// Gap between the base and overbar (em)
     50const float gSpaceAboveEms = 0.2f;
     51// Horizontal position of the bottom point of the radical (* frontWidth)
     52const float gRadicalBottomPointXFront = 0.5f;
    4353// Lower the radical sign's bottom point (px)
    4454const int gRadicalBottomPointLower = 3;
    45 // Threshold above which the radical shape is modified to look nice with big bases (em)
    46 const float gThresholdBaseHeightEms = 1.5f;
    47 // Front width (em)
    48 const float gFrontWidthEms = 0.75f;
    49 // Horizontal position of the bottom point of the radical (* frontWidth)
    50 const float gRadicalBottomPointXFront = 0.5f;
    5155// Horizontal position of the top left point of the radical "dip" (* frontWidth)
    5256const float gRadicalDipLeftPointXFront = 0.8f;
     
    5559// Vertical shift of the left end point of the radical (em)
    5660const float gRadicalLeftEndYShiftEms = 0.05f;
    57 // Root padding around the base (em) (mroot padding-top/left from mathml.css)
    58 const float gRootPaddingEms = 0.2f;
    5961// Additional bottom root padding if baseHeight > threshold (em)
    6062const float gBigRootBottomPaddingEms = 0.2f;
     
    7072}
    7173
    72 void RenderMathMLRoot::addChild(RenderObject* child, RenderObject* )
     74RenderBoxModelObject* RenderMathMLRoot::index() const
    7375{
    74     if (isEmpty()) {
    75         // Add a block for the index
    76         RenderBlock* indexWrapper = createAlmostAnonymousBlock(INLINE_BLOCK);
    77         RenderBlock::addChild(indexWrapper);
    78        
    79         // FIXME: the wrapping does not seem to be needed anymore.
    80         // this is the base, so wrap it so we can pad it
    81         RenderBlock* baseWrapper = createAlmostAnonymousBlock(INLINE_BLOCK);
    82         baseWrapper->style()->setPaddingLeft(Length(5 * gFrontWidthEms, Percent));
    83         RenderBlock::addChild(baseWrapper);
    84         baseWrapper->addChild(child);
    85     } else {
    86         // always add to the index
    87         firstChild()->addChild(child);
    88     }
     76    if (!firstChild())
     77        return 0;
     78    RenderObject* index = firstChild()->nextSibling();
     79    if (!index || !index->isBoxModelObject())
     80        return 0;
     81    return toRenderBoxModelObject(index);
    8982}
    90    
     83
    9184void RenderMathMLRoot::paint(PaintInfo& info, const LayoutPoint& paintOffset)
    9285{
     
    9689        return;
    9790   
    98     if (!firstChild() || !lastChild())
     91    if (!index())
    9992        return;
    10093   
    101     IntPoint adjustedPaintOffset = roundedIntPoint(paintOffset + location());
     94    IntPoint adjustedPaintOffset = roundedIntPoint(paintOffset + location() + computedCSSContentBoxRect().location());
    10295   
    103     RenderBoxModelObject* baseWrapper = toRenderBoxModelObject(lastChild());
     96    int baseHeight = roundToInt(getBoxModelObjectHeight(firstChild()));
    10497   
    105     int baseHeight = baseWrapper->pixelSnappedOffsetHeight();
    106     // default to the font size in pixels if we're empty
    107     if (!baseHeight)
    108         baseHeight = style()->fontSize();
    109     int overbarWidth = baseWrapper->pixelSnappedOffsetWidth();
     98    int overbarWidth = roundToInt(getBoxModelObjectWidth(firstChild())) + m_overbarLeftPointShift;
     99    int indexWidth = index()->pixelSnappedOffsetWidth();
     100    int frontWidth = static_cast<int>(roundf(gFrontWidthEms * style()->fontSize()));
     101    int startX = adjustedPaintOffset.x() + indexWidth + m_overbarLeftPointShift;
    110102   
    111     int indexWidth = 0;
    112     RenderObject* current = firstChild();
    113     while (current != lastChild()) {
    114         if (current->isBoxModelObject()) {
    115             RenderBoxModelObject* box = toRenderBoxModelObject(current);
    116             indexWidth += box->pixelSnappedOffsetWidth();
    117         }
    118         current = current->nextSibling();
    119     }
     103    int rootPad = static_cast<int>(roundf(gSpaceAboveEms * style()->fontSize()));
     104    adjustedPaintOffset.setY(adjustedPaintOffset.y() + m_intrinsicPaddingBefore - rootPad);
    120105   
    121     int frontWidth = static_cast<int>(style()->fontSize() * gFrontWidthEms);
    122     int overbarLeftPointShift = 0;
    123     // Base height above which the shape of the root changes
    124     int thresholdHeight = static_cast<int>(gThresholdBaseHeightEms * style()->fontSize());
    125    
    126     if (baseHeight > thresholdHeight && thresholdHeight) {
    127         float shift = (baseHeight - thresholdHeight) / static_cast<float>(thresholdHeight);
    128         if (shift > 1.)
    129             shift = 1.0f;
    130         overbarLeftPointShift = static_cast<int>(gRadicalBottomPointXFront * frontWidth * shift);
    131     }
    132    
    133     overbarWidth += overbarLeftPointShift;
    134    
    135     int rootPad = static_cast<int>(gRootPaddingEms * style()->fontSize());
    136     int startX = adjustedPaintOffset.x() + indexWidth + gRadicalLeftExtra + style()->paddingLeft().value() - rootPad;
    137     adjustedPaintOffset.setY(adjustedPaintOffset.y() + style()->paddingTop().value() - rootPad);
    138    
    139     FloatPoint overbarLeftPoint(startX - overbarLeftPointShift, adjustedPaintOffset.y());
     106    FloatPoint overbarLeftPoint(startX - m_overbarLeftPointShift, adjustedPaintOffset.y());
    140107    FloatPoint bottomPoint(startX - gRadicalBottomPointXFront * frontWidth, adjustedPaintOffset.y() + baseHeight + gRadicalBottomPointLower);
    141108    FloatPoint dipLeftPoint(startX - gRadicalDipLeftPointXFront * frontWidth, adjustedPaintOffset.y() + gRadicalDipLeftPointYPos * baseHeight);
     
    191158    RenderBlock::layout();
    192159
    193     if (!firstChild() || !lastChild())
     160    if (!index())
    194161        return;
    195162
    196     int baseHeight = toRenderBoxModelObject(lastChild())->pixelSnappedOffsetHeight();
    197     if (!baseHeight)
    198         baseHeight = style()->fontSize();
    199    
    200     RenderObject* base = lastChild()->firstChild();
    201     if (base)
    202         base->style()->setVerticalAlign(BASELINE); // FIXME: Can this style be modified?
     163    int baseHeight = roundToInt(getBoxModelObjectHeight(firstChild()));
    203164   
    204165    // Base height above which the shape of the root changes
    205     int thresholdHeight = static_cast<int>(gThresholdBaseHeightEms * style()->fontSize());
    206     int overbarLeftPointShift = 0;
    207    
    208     // FIXME: Can style() and indexBox->style() be modified (4 times below)?
     166    float thresholdHeight = gThresholdBaseHeightEms * style()->fontSize();
    209167    if (baseHeight > thresholdHeight && thresholdHeight) {
    210         float shift = (baseHeight - thresholdHeight) / static_cast<float>(thresholdHeight);
    211         if (shift > 1.)
    212             shift = 1.0f;
    213         int frontWidth = static_cast<int>(style()->fontSize() * gFrontWidthEms);
    214         overbarLeftPointShift = static_cast<int>(gRadicalBottomPointXFront * frontWidth * shift);
    215        
    216         style()->setPaddingBottom(Length(static_cast<int>(gBigRootBottomPaddingEms * style()->fontSize()), Fixed));
     168        float shift = min<float>((baseHeight - thresholdHeight) / thresholdHeight, 1.0f);
     169        int frontWidth = static_cast<int>(roundf(gFrontWidthEms * style()->fontSize()));
     170        m_overbarLeftPointShift = static_cast<int>(shift * gRadicalBottomPointXFront * frontWidth);
     171        m_intrinsicPaddingAfter = static_cast<int>(roundf(gBigRootBottomPaddingEms * style()->fontSize()));
     172    } else {
     173        m_overbarLeftPointShift = 0;
     174        m_intrinsicPaddingAfter = 0;
    217175    }
    218176   
    219     // Positioning of the index
    220     RenderObject* possibleIndex = firstChild()->firstChild();
    221     while (possibleIndex && !possibleIndex->isBoxModelObject())
    222         possibleIndex = possibleIndex->nextSibling();
    223     RenderBoxModelObject* indexBox = toRenderBoxModelObject(possibleIndex);
    224     if (!indexBox)
    225         return;
     177    RenderBoxModelObject* index = this->index();
    226178   
    227     int shiftForIndex = indexBox->pixelSnappedOffsetWidth() + overbarLeftPointShift;
    228     int partDipHeight = static_cast<int>((1 - gRadicalDipLeftPointYPos) * baseHeight);
    229     int rootExtraTop = partDipHeight + style()->paddingBottom().value() + indexBox->pixelSnappedOffsetHeight()
    230         - (baseHeight + static_cast<int>(gRootPaddingEms * style()->fontSize()));
     179    m_intrinsicPaddingStart = index->pixelSnappedOffsetWidth() + m_overbarLeftPointShift;
    231180   
    232     style()->setPaddingLeft(Length(shiftForIndex, Fixed));
    233     if (rootExtraTop > 0)
    234         style()->setPaddingTop(Length(rootExtraTop + static_cast<int>(gRootPaddingEms * style()->fontSize()), Fixed));
     181    int rootPad = static_cast<int>(roundf(gSpaceAboveEms * style()->fontSize()));
     182    int partDipHeight = static_cast<int>(roundf((1 - gRadicalDipLeftPointYPos) * baseHeight));
     183    int rootExtraTop = partDipHeight + index->pixelSnappedOffsetHeight() - (baseHeight + rootPad);
     184    m_intrinsicPaddingBefore = rootPad + max(rootExtraTop, 0);
    235185   
    236     setNeedsLayout(true);
     186    setNeedsLayout(true, MarkOnlyThis);
    237187    setPreferredLogicalWidthsDirty(true, MarkOnlyThis); // FIXME: Can this really be right?
     188    // FIXME: Preferred logical widths are currently wrong the first time through, relying on layout() to set m_intrinsicPaddingStart.
    238189    RenderBlock::layout();
     190   
     191    // |index| should be a RenderBlock here, unless the user has overriden its { position: absolute }.
     192    if (rootExtraTop < 0 && index->isBox())
     193        toRenderBox(index)->setLogicalTop(-rootExtraTop);
     194}
    239195
    240     indexBox->style()->setBottom(Length(partDipHeight + style()->paddingBottom().value(), Fixed));
    241 
    242     // Now that we've potentially changed its position, we need layout the index again.
    243     indexBox->setNeedsLayout(true);
    244     indexBox->layout();
    245 }
    246    
    247196}
    248197
  • trunk/Source/WebCore/rendering/mathml/RenderMathMLRoot.h

    r111636 r114012  
    3737public:
    3838    RenderMathMLRoot(Element*);
    39     virtual void addChild(RenderObject* child, RenderObject* beforeChild = 0);
    40    
    41     virtual void paint(PaintInfo&, const LayoutPoint&);
    4239   
    4340protected:
    44     virtual void layout();
     41    virtual void layout() OVERRIDE;
     42   
     43    virtual void paint(PaintInfo&, const LayoutPoint&) OVERRIDE;
    4544
    4645private:
    4746    virtual const char* renderName() const { return "RenderMathMLRoot"; }
     47   
     48    // This may return 0 for a non-MathML index (which won't occur in valid MathML).
     49    RenderBoxModelObject* index() const;
     50   
     51    int m_overbarLeftPointShift;
    4852};
    4953   
  • trunk/Source/WebCore/rendering/mathml/RenderMathMLSquareRoot.cpp

    r113823 r114012  
    3636#include "RenderMathMLRow.h"
    3737
     38using namespace std;
     39
    3840namespace WebCore {
    3941   
     
    5355const int gRadicalBottomPointLower = 3;
    5456// Horizontal position of the top left point of the radical "dip" (* frontWidth)
    55 const float gRadicalDipLeftPointXFront = 0.2f;
     57const float gRadicalDipLeftPointXFront = 0.8f;
    5658// Vertical position of the top left point of the radical "dip" (* baseHeight)
    5759const float gRadicalDipLeftPointYPos = 0.5f;
     
    129131   
    130132    if (baseHeight > thresholdHeight && thresholdHeight) {
    131         float shift = (baseHeight - thresholdHeight) / thresholdHeight;
    132         if (shift > 1.)
    133             shift = 1.0f;
    134         overbarLeftPointShift = static_cast<int>(gRadicalBottomPointXFront * frontWidth * shift);
     133        float shift = min<float>((baseHeight - thresholdHeight) / thresholdHeight, 1.0f);
     134        overbarLeftPointShift = static_cast<int>(shift * gRadicalBottomPointXFront * frontWidth);
    135135    }
    136136   
    137137    overbarWidth += overbarLeftPointShift;
    138138   
    139     FloatPoint overbarLeftPoint(adjustedPaintOffset.x() + frontWidth - overbarLeftPointShift, adjustedPaintOffset.y());
    140     FloatPoint bottomPoint(adjustedPaintOffset.x() + frontWidth * gRadicalBottomPointXFront, adjustedPaintOffset.y() + baseHeight + gRadicalBottomPointLower);
    141     FloatPoint dipLeftPoint(adjustedPaintOffset.x() + frontWidth * gRadicalDipLeftPointXFront, adjustedPaintOffset.y() + gRadicalDipLeftPointYPos * baseHeight);
    142     FloatPoint leftEnd(adjustedPaintOffset.x(), dipLeftPoint.y() + gRadicalLeftEndYShiftEms * style()->fontSize());
     139    int startX = adjustedPaintOffset.x() + frontWidth;
     140   
     141    FloatPoint overbarLeftPoint(startX - overbarLeftPointShift, adjustedPaintOffset.y());
     142    FloatPoint bottomPoint(startX - gRadicalBottomPointXFront * frontWidth, adjustedPaintOffset.y() + baseHeight + gRadicalBottomPointLower);
     143    FloatPoint dipLeftPoint(startX - gRadicalDipLeftPointXFront * frontWidth, adjustedPaintOffset.y() + gRadicalDipLeftPointYPos * baseHeight);
     144    FloatPoint leftEnd(startX - frontWidth, dipLeftPoint.y() + gRadicalLeftEndYShiftEms * style()->fontSize());
    143145   
    144146    GraphicsContextStateSaver stateSaver(*info.context);
Note: See TracChangeset for help on using the changeset viewer.