Changeset 165436 in webkit


Ignore:
Timestamp:
Mar 11, 2014 12:51:27 AM (10 years ago)
Author:
fred.wang@free.fr
Message:

Improve renderer classes for MathML Token elements.
https://bugs.webkit.org/show_bug.cgi?id=124838

Reviewed by Chris Fleizach.

Source/WebCore:

This patch continues the refactoring of token elements that has been
started in bug 44208. The <mo> element now derives from the
RenderMathMLToken class, which was already used for the <mi> element.
The behavior of anonymous <mo> elements created by the <mfenced> element
is now more consistent with the one of "standard" <mo> elements and the
spacing around them is now handled in RenderMathMLOperator. This is a
first step towards fixing bugs 115787 and 118843. The only visible
rendering change is how <mfenced> open/close attributes handle
whitespace and multiple characters and some tests are added for that.
Other features are already covered by other tests. Finally, this also
removes some code from AccessibilityRenderObject that was used to
workaround issues with <mo> elements.

  • accessibility/AccessibilityRenderObject.cpp:

(WebCore::startOfContinuations):
(WebCore::AccessibilityRenderObject::textUnderElement):
(WebCore::AccessibilityRenderObject::isMathOperator):
(WebCore::AccessibilityRenderObject::isIgnoredElementWithinMathTree):

  • mathml/MathMLTextElement.cpp:

(WebCore::MathMLTextElement::didAttachRenderers):
(WebCore::MathMLTextElement::childrenChanged):

  • rendering/mathml/RenderMathMLBlock.cpp:

(WebCore::RenderMathMLBlock::RenderMathMLBlock):

  • rendering/mathml/RenderMathMLBlock.h:
  • rendering/mathml/RenderMathMLFenced.cpp:

(WebCore::RenderMathMLFenced::RenderMathMLFenced):
(WebCore::RenderMathMLFenced::updateFromElement):
(WebCore::RenderMathMLFenced::createMathMLOperator):
(WebCore::RenderMathMLFenced::makeFences):
(WebCore::RenderMathMLFenced::addChild):

  • rendering/mathml/RenderMathMLFenced.h:
  • rendering/mathml/RenderMathMLOperator.cpp:

(WebCore::RenderMathMLOperator::RenderMathMLOperator):
(WebCore::RenderMathMLOperator::setOperatorFlagFromAttribute):
(WebCore::RenderMathMLOperator::setOperatorPropertiesFromOpDictEntry):
(WebCore::RenderMathMLOperator::SetOperatorProperties):
(WebCore::RenderMathMLOperator::computePreferredLogicalWidths):
(WebCore::RenderMathMLOperator::rebuildTokenContent):
(WebCore::RenderMathMLOperator::updateTokenContent):
(WebCore::RenderMathMLOperator::updateStyle):
(WebCore::RenderMathMLOperator::firstLineBaseline):
(WebCore::RenderMathMLOperator::paint):
(WebCore::RenderMathMLOperator::paintChildren):

  • rendering/mathml/RenderMathMLOperator.h:
  • rendering/mathml/RenderMathMLToken.cpp:

(WebCore::RenderMathMLToken::createWrapperIfNeeded):

LayoutTests:

Two tests are added to fenced-mi in order to verify that the open/close
attributes of the mfenced element collapse whitespace and accept values
with multiple characters.

  • mathml/presentation/fenced-mi-expected.html:
  • mathml/presentation/fenced-mi.html:
  • platform/mac/accessibility/mathml-elements.html: fix bad closing tag and disable the test for now.
  • platform/mac/mathml/presentation/mo-stretch-expected.txt: update text reference.
Location:
trunk
Files:
16 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r165430 r165436  
     12014-03-10  Frédéric Wang  <fred.wang@free.fr>
     2
     3        Improve renderer classes for MathML Token elements.
     4        https://bugs.webkit.org/show_bug.cgi?id=124838
     5
     6        Reviewed by Chris Fleizach.
     7
     8        Two tests are added to fenced-mi in order to verify that the open/close
     9        attributes of the mfenced element collapse whitespace and accept values
     10        with multiple characters.
     11
     12        * mathml/presentation/fenced-mi-expected.html:
     13        * mathml/presentation/fenced-mi.html:
     14        * platform/mac/accessibility/mathml-elements.html: fix bad closing tag and disable the test for now.
     15        * platform/mac/mathml/presentation/mo-stretch-expected.txt: update text reference.
     16
    1172014-03-10  James Craig  <jcraig@apple.com>
    218
  • trunk/LayoutTests/mathml/presentation/fenced-mi-expected.html

    r152923 r165436  
    6969    </p>
    7070
     71    <p>
     72      <math>
     73        <mrow>
     74          <mo>ABC</mo>
     75          <mrow>
     76            <mi>x</mi>
     77          </mrow>
     78          <mo>DEF</mo>
     79        </mrow>
     80      </math>
     81    </p>
     82
     83    <p>
     84      <math>
     85        <mfenced open="[" close="]" separators="12"><mi>x</mi><mi>y</mi><mi>z</mi></mfenced>
     86      </math>
     87    </p>
     88
    7189  </body>
    7290</html>
  • trunk/LayoutTests/mathml/presentation/fenced-mi.html

    r152923 r165436  
    3434    </p>
    3535
     36    <!-- Test for open/close operators with multiple characters -->
     37    <p>
     38      <math>
     39        <mfenced open="ABC" close="DEF">
     40          <mi>x</mi>
     41        </mfenced>
     42      </math>
     43    </p>
     44
     45    <!-- Test that whitespace is ignored. -->
     46    <p>
     47      <math>
     48        <mfenced open="&#x20;&#x9;&#xD;&#xA;[&#x20;&#x9;&#xD;&#xA;" close="&#x20;&#x9;&#xD;&#xA;]&#x20;&#x9;&#xD;&#xA;" separators="&#x20;&#x9;&#xD;&#xA;1&#x20;&#x9;&#xD;&#xA;2&#x20;&#x9;&#xD;&#xA;"><mi>x</mi><mi>y</mi><mi>z</mi></mfenced>
     49      </math>
     50    </p>
     51
    3652  </body>
    3753</html>
  • trunk/LayoutTests/platform/mac/TestExpectations

    r165360 r165436  
    13291329
    13301330webkit.org/b/129758 js/dom/create-lots-of-workers.html [ Skip ]
     1331
     1332# This test fails because the structure of mfenced/mo operators was changed in bug 124838.
     1333webkit.org/b/124836 platform/mac/accessibility/mathml-elements.html [ Failure ]
  • trunk/LayoutTests/platform/mac/accessibility/mathml-elements.html

    r155282 r165436  
    2121
    2222<math id="fenced">
    23 <mfenced open="{" close="}" separators=",,"><mi>2</mi><mi>a</mi><mi>e</mi></mroot>
     23<mfenced open="{" close="}" separators=",,"><mi>2</mi><mi>a</mi><mi>e</mi></mfenced>
    2424</math><br>
    2525
  • trunk/LayoutTests/platform/mac/mathml/presentation/mo-stretch-expected.txt

    r164700 r165436  
    77        RenderMathMLRow {mrow} at (1,0) size 193x25
    88          RenderMathMLOperator {mo} at (1,5) size 8x14
    9             RenderMathMLBlock (flex) {mo} at (0,0) size 7x14
     9            RenderMathMLBlock (anonymous, flex) at (0,0) size 7x14
    1010              RenderBlock (anonymous) at (0,0) size 5x14
    1111                RenderText at (0,-6) size 5x24
    1212                  text run at (0,-6) width 5: "("
    1313          RenderMathMLOperator {mo} at (13,5) size 8x14
    14             RenderMathMLBlock (flex) {mo} at (0,0) size 7x14
     14            RenderMathMLBlock (anonymous, flex) at (0,0) size 7x14
    1515              RenderBlock (anonymous) at (0,0) size 5x14
    1616                RenderText at (0,-6) size 5x24
    1717                  text run at (0,-6) width 5: ")"
    1818          RenderMathMLOperator {mo} at (26,5) size 11x14
    19             RenderMathMLBlock (flex) {mo} at (0,0) size 10x14
     19            RenderMathMLBlock (anonymous, flex) at (0,0) size 10x14
    2020              RenderBlock (anonymous) at (0,0) size 8x14
    2121                RenderText at (0,-6) size 8x24
    2222                  text run at (0,-6) width 8: "{"
    2323          RenderMathMLOperator {mo} at (43,5) size 11x14
    24             RenderMathMLBlock (flex) {mo} at (0,0) size 10x14
     24            RenderMathMLBlock (anonymous, flex) at (0,0) size 10x14
    2525              RenderBlock (anonymous) at (0,0) size 8x14
    2626                RenderText at (0,-6) size 8x24
    2727                  text run at (0,-6) width 8: "}"
    2828          RenderMathMLOperator {mo} at (59,5) size 8x14
    29             RenderMathMLBlock (flex) {mo} at (0,0) size 7x14
     29            RenderMathMLBlock (anonymous, flex) at (0,0) size 7x14
    3030              RenderBlock (anonymous) at (0,0) size 5x14
    3131                RenderText at (0,-6) size 5x24
    3232                  text run at (0,-6) width 5: "["
    3333          RenderMathMLOperator {mo} at (72,5) size 8x14
    34             RenderMathMLBlock (flex) {mo} at (0,0) size 7x14
     34            RenderMathMLBlock (anonymous, flex) at (0,0) size 7x14
    3535              RenderBlock (anonymous) at (0,0) size 5x14
    3636                RenderText at (0,-6) size 5x24
    3737                  text run at (0,-6) width 5: "]"
    3838          RenderMathMLOperator {mo} at (86,4) size 9x16
    39             RenderMathMLBlock (flex) {mo} at (0,0) size 8x16
     39            RenderMathMLBlock (anonymous, flex) at (0,0) size 8x16
    4040              RenderBlock (anonymous) at (0,0) size 8x16
    4141                RenderText at (0,-5) size 8x24
    4242                  text run at (0,-5) width 8: "\x{2308}"
    4343          RenderMathMLOperator {mo} at (100,4) size 9x16
    44             RenderMathMLBlock (flex) {mo} at (0,0) size 8x16
     44            RenderMathMLBlock (anonymous, flex) at (0,0) size 8x16
    4545              RenderBlock (anonymous) at (0,0) size 8x16
    4646                RenderText at (0,-5) size 8x24
    4747                  text run at (0,-5) width 8: "\x{2309}"
    4848          RenderMathMLOperator {mo} at (115,4) size 8x16
    49             RenderMathMLBlock (flex) {mo} at (0,0) size 8x16
     49            RenderMathMLBlock (anonymous, flex) at (0,0) size 8x16
    5050              RenderBlock (anonymous) at (0,0) size 8x16
    5151                RenderText at (0,-5) size 8x24
    5252                  text run at (0,-5) width 8: "\x{230A}"
    5353          RenderMathMLOperator {mo} at (129,4) size 9x16
    54             RenderMathMLBlock (flex) {mo} at (0,0) size 8x16
     54            RenderMathMLBlock (anonymous, flex) at (0,0) size 8x16
    5555              RenderBlock (anonymous) at (0,0) size 8x16
    5656                RenderText at (0,-5) size 8x24
    5757                  text run at (0,-5) width 8: "\x{230B}"
    5858          RenderMathMLOperator {mo} at (143,2) size 12x20
    59             RenderMathMLBlock (flex) {mo} at (0,0) size 11x20
     59            RenderMathMLBlock (anonymous, flex) at (0,0) size 11x20
    6060              RenderBlock (anonymous) at (0,0) size 7x20
    6161                RenderText at (0,-3) size 7x24
    6262                  text run at (0,-3) width 7: "\x{222B}"
    6363          RenderMathMLOperator {mo} at (161,0) size 4x25
    64             RenderMathMLBlock (flex) {mo} at (0,0) size 3x12
     64            RenderMathMLBlock (anonymous, flex) at (0,0) size 3x12
    6565              RenderBlock (anonymous) at (0,0) size 3x12
    6666                RenderText at (0,-6) size 3x24
    6767                  text run at (0,-6) width 3: "|"
    6868          RenderMathMLOperator {mo} at (170,4) size 9x16
    69             RenderMathMLBlock (flex) {mo} at (0,0) size 8x16
     69            RenderMathMLBlock (anonymous, flex) at (0,0) size 8x16
    7070              RenderBlock (anonymous) at (0,0) size 8x16
    7171                RenderText at (0,-5) size 8x24
    7272                  text run at (0,-5) width 8: "\x{2016}"
    7373          RenderMathMLOperator {mo} at (183,4) size 9x16
    74             RenderMathMLBlock (flex) {mo} at (0,0) size 8x16
     74            RenderMathMLBlock (anonymous, flex) at (0,0) size 8x16
    7575              RenderBlock (anonymous) at (0,0) size 8x16
    7676                RenderText at (0,-5) size 8x24
     
    8282        RenderMathMLRow {mrow} at (1,0) size 197x143
    8383          RenderMathMLOperator {mo} at (1,0) size 8x143
    84             RenderMathMLBlock (flex) {mo} at (0,0) size 7x14
     84            RenderMathMLBlock (anonymous, flex) at (0,0) size 7x14
    8585              RenderBlock (anonymous) at (0,0) size 5x14
    8686                RenderText at (0,-6) size 5x24
    8787                  text run at (0,-6) width 5: "("
    8888          RenderMathMLOperator {mo} at (13,0) size 8x143
    89             RenderMathMLBlock (flex) {mo} at (0,0) size 7x14
     89            RenderMathMLBlock (anonymous, flex) at (0,0) size 7x14
    9090              RenderBlock (anonymous) at (0,0) size 5x14
    9191                RenderText at (0,-6) size 5x24
    9292                  text run at (0,-6) width 5: ")"
    9393          RenderMathMLOperator {mo} at (26,0) size 11x143
    94             RenderMathMLBlock (flex) {mo} at (0,0) size 10x14
     94            RenderMathMLBlock (anonymous, flex) at (0,0) size 10x14
    9595              RenderBlock (anonymous) at (0,0) size 8x14
    9696                RenderText at (0,-6) size 8x24
    9797                  text run at (0,-6) width 8: "{"
    9898          RenderMathMLOperator {mo} at (43,0) size 11x143
    99             RenderMathMLBlock (flex) {mo} at (0,0) size 10x14
     99            RenderMathMLBlock (anonymous, flex) at (0,0) size 10x14
    100100              RenderBlock (anonymous) at (0,0) size 8x14
    101101                RenderText at (0,-6) size 8x24
    102102                  text run at (0,-6) width 8: "}"
    103103          RenderMathMLOperator {mo} at (59,0) size 8x143
    104             RenderMathMLBlock (flex) {mo} at (0,0) size 7x14
     104            RenderMathMLBlock (anonymous, flex) at (0,0) size 7x14
    105105              RenderBlock (anonymous) at (0,0) size 5x14
    106106                RenderText at (0,-6) size 5x24
    107107                  text run at (0,-6) width 5: "["
    108108          RenderMathMLOperator {mo} at (72,0) size 8x143
    109             RenderMathMLBlock (flex) {mo} at (0,0) size 7x14
     109            RenderMathMLBlock (anonymous, flex) at (0,0) size 7x14
    110110              RenderBlock (anonymous) at (0,0) size 5x14
    111111                RenderText at (0,-6) size 5x24
    112112                  text run at (0,-6) width 5: "]"
    113113          RenderMathMLOperator {mo} at (86,0) size 9x143
    114             RenderMathMLBlock (flex) {mo} at (0,0) size 8x16
     114            RenderMathMLBlock (anonymous, flex) at (0,0) size 8x16
    115115              RenderBlock (anonymous) at (0,0) size 8x16
    116116                RenderText at (0,-5) size 8x24
    117117                  text run at (0,-5) width 8: "\x{2308}"
    118118          RenderMathMLOperator {mo} at (100,0) size 9x143
    119             RenderMathMLBlock (flex) {mo} at (0,0) size 8x16
     119            RenderMathMLBlock (anonymous, flex) at (0,0) size 8x16
    120120              RenderBlock (anonymous) at (0,0) size 8x16
    121121                RenderText at (0,-5) size 8x24
    122122                  text run at (0,-5) width 8: "\x{2309}"
    123123          RenderMathMLOperator {mo} at (115,0) size 8x143
    124             RenderMathMLBlock (flex) {mo} at (0,0) size 8x16
     124            RenderMathMLBlock (anonymous, flex) at (0,0) size 8x16
    125125              RenderBlock (anonymous) at (0,0) size 8x16
    126126                RenderText at (0,-5) size 8x24
    127127                  text run at (0,-5) width 8: "\x{230A}"
    128128          RenderMathMLOperator {mo} at (129,0) size 9x143
    129             RenderMathMLBlock (flex) {mo} at (0,0) size 8x16
     129            RenderMathMLBlock (anonymous, flex) at (0,0) size 8x16
    130130              RenderBlock (anonymous) at (0,0) size 8x16
    131131                RenderText at (0,-5) size 8x24
    132132                  text run at (0,-5) width 8: "\x{230B}"
    133133          RenderMathMLOperator {mo} at (143,0) size 12x143
    134             RenderMathMLBlock (flex) {mo} at (0,0) size 11x20
     134            RenderMathMLBlock (anonymous, flex) at (0,0) size 11x20
    135135              RenderBlock (anonymous) at (0,0) size 7x20
    136136                RenderText at (0,-3) size 7x24
    137137                  text run at (0,-3) width 7: "\x{222B}"
    138138          RenderMathMLOperator {mo} at (161,0) size 4x143
    139             RenderMathMLBlock (flex) {mo} at (0,0) size 3x12
     139            RenderMathMLBlock (anonymous, flex) at (0,0) size 3x12
    140140              RenderBlock (anonymous) at (0,0) size 3x12
    141141                RenderText at (0,-6) size 3x24
    142142                  text run at (0,-6) width 3: "|"
    143143          RenderMathMLOperator {mo} at (170,0) size 9x76
    144             RenderMathMLBlock (flex) {mo} at (0,0) size 8x16
     144            RenderMathMLBlock (anonymous, flex) at (0,0) size 8x16
    145145              RenderBlock (anonymous) at (0,0) size 8x16
    146146                RenderText at (0,-5) size 8x24
    147147                  text run at (0,-5) width 8: "\x{2016}"
    148148          RenderMathMLOperator {mo} at (184,0) size 9x76
    149             RenderMathMLBlock (flex) {mo} at (0,0) size 8x16
     149            RenderMathMLBlock (anonymous, flex) at (0,0) size 8x16
    150150              RenderBlock (anonymous) at (0,0) size 8x16
    151151                RenderText at (0,-5) size 8x24
     
    157157        RenderMathMLRow {mrow} at (1,0) size 197x93
    158158          RenderMathMLOperator {mo} at (1,0) size 8x93
    159             RenderMathMLBlock (flex) {mo} at (0,0) size 7x14
     159            RenderMathMLBlock (anonymous, flex) at (0,0) size 7x14
    160160              RenderBlock (anonymous) at (0,0) size 5x14
    161161                RenderText at (0,-6) size 5x24
    162162                  text run at (0,-6) width 5: "("
    163163          RenderMathMLOperator {mo} at (13,0) size 8x93
    164             RenderMathMLBlock (flex) {mo} at (0,0) size 7x14
     164            RenderMathMLBlock (anonymous, flex) at (0,0) size 7x14
    165165              RenderBlock (anonymous) at (0,0) size 5x14
    166166                RenderText at (0,-6) size 5x24
    167167                  text run at (0,-6) width 5: ")"
    168168          RenderMathMLOperator {mo} at (26,0) size 11x93
    169             RenderMathMLBlock (flex) {mo} at (0,0) size 10x14
     169            RenderMathMLBlock (anonymous, flex) at (0,0) size 10x14
    170170              RenderBlock (anonymous) at (0,0) size 8x14
    171171                RenderText at (0,-6) size 8x24
    172172                  text run at (0,-6) width 8: "{"
    173173          RenderMathMLOperator {mo} at (43,0) size 11x93
    174             RenderMathMLBlock (flex) {mo} at (0,0) size 10x14
     174            RenderMathMLBlock (anonymous, flex) at (0,0) size 10x14
    175175              RenderBlock (anonymous) at (0,0) size 8x14
    176176                RenderText at (0,-6) size 8x24
    177177                  text run at (0,-6) width 8: "}"
    178178          RenderMathMLOperator {mo} at (59,0) size 8x93
    179             RenderMathMLBlock (flex) {mo} at (0,0) size 7x14
     179            RenderMathMLBlock (anonymous, flex) at (0,0) size 7x14
    180180              RenderBlock (anonymous) at (0,0) size 5x14
    181181                RenderText at (0,-6) size 5x24
    182182                  text run at (0,-6) width 5: "["
    183183          RenderMathMLOperator {mo} at (72,0) size 8x93
    184             RenderMathMLBlock (flex) {mo} at (0,0) size 7x14
     184            RenderMathMLBlock (anonymous, flex) at (0,0) size 7x14
    185185              RenderBlock (anonymous) at (0,0) size 5x14
    186186                RenderText at (0,-6) size 5x24
    187187                  text run at (0,-6) width 5: "]"
    188188          RenderMathMLOperator {mo} at (86,0) size 9x93
    189             RenderMathMLBlock (flex) {mo} at (0,0) size 8x16
     189            RenderMathMLBlock (anonymous, flex) at (0,0) size 8x16
    190190              RenderBlock (anonymous) at (0,0) size 8x16
    191191                RenderText at (0,-5) size 8x24
    192192                  text run at (0,-5) width 8: "\x{2308}"
    193193          RenderMathMLOperator {mo} at (100,0) size 9x93
    194             RenderMathMLBlock (flex) {mo} at (0,0) size 8x16
     194            RenderMathMLBlock (anonymous, flex) at (0,0) size 8x16
    195195              RenderBlock (anonymous) at (0,0) size 8x16
    196196                RenderText at (0,-5) size 8x24
    197197                  text run at (0,-5) width 8: "\x{2309}"
    198198          RenderMathMLOperator {mo} at (115,0) size 8x93
    199             RenderMathMLBlock (flex) {mo} at (0,0) size 8x16
     199            RenderMathMLBlock (anonymous, flex) at (0,0) size 8x16
    200200              RenderBlock (anonymous) at (0,0) size 8x16
    201201                RenderText at (0,-5) size 8x24
    202202                  text run at (0,-5) width 8: "\x{230A}"
    203203          RenderMathMLOperator {mo} at (129,0) size 9x93
    204             RenderMathMLBlock (flex) {mo} at (0,0) size 8x16
     204            RenderMathMLBlock (anonymous, flex) at (0,0) size 8x16
    205205              RenderBlock (anonymous) at (0,0) size 8x16
    206206                RenderText at (0,-5) size 8x24
    207207                  text run at (0,-5) width 8: "\x{230B}"
    208208          RenderMathMLOperator {mo} at (143,0) size 12x93
    209             RenderMathMLBlock (flex) {mo} at (0,0) size 11x20
     209            RenderMathMLBlock (anonymous, flex) at (0,0) size 11x20
    210210              RenderBlock (anonymous) at (0,0) size 7x20
    211211                RenderText at (0,-3) size 7x24
    212212                  text run at (0,-3) width 7: "\x{222B}"
    213213          RenderMathMLOperator {mo} at (161,0) size 4x93
    214             RenderMathMLBlock (flex) {mo} at (0,0) size 3x12
     214            RenderMathMLBlock (anonymous, flex) at (0,0) size 3x12
    215215              RenderBlock (anonymous) at (0,0) size 3x12
    216216                RenderText at (0,-6) size 3x24
    217217                  text run at (0,-6) width 3: "|"
    218218          RenderMathMLOperator {mo} at (170,0) size 9x51
    219             RenderMathMLBlock (flex) {mo} at (0,0) size 8x16
     219            RenderMathMLBlock (anonymous, flex) at (0,0) size 8x16
    220220              RenderBlock (anonymous) at (0,0) size 8x16
    221221                RenderText at (0,-5) size 8x24
    222222                  text run at (0,-5) width 8: "\x{2016}"
    223223          RenderMathMLOperator {mo} at (184,0) size 9x51
    224             RenderMathMLBlock (flex) {mo} at (0,0) size 8x16
     224            RenderMathMLBlock (anonymous, flex) at (0,0) size 8x16
    225225              RenderBlock (anonymous) at (0,0) size 8x16
    226226                RenderText at (0,-5) size 8x24
     
    232232        RenderMathMLRow {mrow} at (1,0) size 197x33
    233233          RenderMathMLOperator {mo} at (1,0) size 8x33
    234             RenderMathMLBlock (flex) {mo} at (0,0) size 7x14
     234            RenderMathMLBlock (anonymous, flex) at (0,0) size 7x14
    235235              RenderBlock (anonymous) at (0,0) size 5x14
    236236                RenderText at (0,-6) size 5x24
    237237                  text run at (0,-6) width 5: "("
    238238          RenderMathMLOperator {mo} at (13,0) size 8x33
    239             RenderMathMLBlock (flex) {mo} at (0,0) size 7x14
     239            RenderMathMLBlock (anonymous, flex) at (0,0) size 7x14
    240240              RenderBlock (anonymous) at (0,0) size 5x14
    241241                RenderText at (0,-6) size 5x24
    242242                  text run at (0,-6) width 5: ")"
    243243          RenderMathMLOperator {mo} at (26,9) size 11x14
    244             RenderMathMLBlock (flex) {mo} at (0,0) size 10x14
     244            RenderMathMLBlock (anonymous, flex) at (0,0) size 10x14
    245245              RenderBlock (anonymous) at (0,0) size 8x14
    246246                RenderText at (0,-6) size 8x24
    247247                  text run at (0,-6) width 8: "{"
    248248          RenderMathMLOperator {mo} at (43,9) size 11x14
    249             RenderMathMLBlock (flex) {mo} at (0,0) size 10x14
     249            RenderMathMLBlock (anonymous, flex) at (0,0) size 10x14
    250250              RenderBlock (anonymous) at (0,0) size 8x14
    251251                RenderText at (0,-6) size 8x24
    252252                  text run at (0,-6) width 8: "}"
    253253          RenderMathMLOperator {mo} at (59,0) size 8x33
    254             RenderMathMLBlock (flex) {mo} at (0,0) size 7x14
     254            RenderMathMLBlock (anonymous, flex) at (0,0) size 7x14
    255255              RenderBlock (anonymous) at (0,0) size 5x14
    256256                RenderText at (0,-6) size 5x24
    257257                  text run at (0,-6) width 5: "["
    258258          RenderMathMLOperator {mo} at (72,0) size 8x33
    259             RenderMathMLBlock (flex) {mo} at (0,0) size 7x14
     259            RenderMathMLBlock (anonymous, flex) at (0,0) size 7x14
    260260              RenderBlock (anonymous) at (0,0) size 5x14
    261261                RenderText at (0,-6) size 5x24
    262262                  text run at (0,-6) width 5: "]"
    263263          RenderMathMLOperator {mo} at (86,0) size 9x33
    264             RenderMathMLBlock (flex) {mo} at (0,0) size 8x16
     264            RenderMathMLBlock (anonymous, flex) at (0,0) size 8x16
    265265              RenderBlock (anonymous) at (0,0) size 8x16
    266266                RenderText at (0,-5) size 8x24
    267267                  text run at (0,-5) width 8: "\x{2308}"
    268268          RenderMathMLOperator {mo} at (100,0) size 9x33
    269             RenderMathMLBlock (flex) {mo} at (0,0) size 8x16
     269            RenderMathMLBlock (anonymous, flex) at (0,0) size 8x16
    270270              RenderBlock (anonymous) at (0,0) size 8x16
    271271                RenderText at (0,-5) size 8x24
    272272                  text run at (0,-5) width 8: "\x{2309}"
    273273          RenderMathMLOperator {mo} at (115,0) size 8x33
    274             RenderMathMLBlock (flex) {mo} at (0,0) size 8x16
     274            RenderMathMLBlock (anonymous, flex) at (0,0) size 8x16
    275275              RenderBlock (anonymous) at (0,0) size 8x16
    276276                RenderText at (0,-5) size 8x24
    277277                  text run at (0,-5) width 8: "\x{230A}"
    278278          RenderMathMLOperator {mo} at (129,0) size 9x33
    279             RenderMathMLBlock (flex) {mo} at (0,0) size 8x16
     279            RenderMathMLBlock (anonymous, flex) at (0,0) size 8x16
    280280              RenderBlock (anonymous) at (0,0) size 8x16
    281281                RenderText at (0,-5) size 8x24
    282282                  text run at (0,-5) width 8: "\x{230B}"
    283283          RenderMathMLOperator {mo} at (143,6) size 12x20
    284             RenderMathMLBlock (flex) {mo} at (0,0) size 11x20
     284            RenderMathMLBlock (anonymous, flex) at (0,0) size 11x20
    285285              RenderBlock (anonymous) at (0,0) size 7x20
    286286                RenderText at (0,-3) size 7x24
    287287                  text run at (0,-3) width 7: "\x{222B}"
    288288          RenderMathMLOperator {mo} at (161,0) size 4x33
    289             RenderMathMLBlock (flex) {mo} at (0,0) size 3x12
     289            RenderMathMLBlock (anonymous, flex) at (0,0) size 3x12
    290290              RenderBlock (anonymous) at (0,0) size 3x12
    291291                RenderText at (0,-6) size 3x24
    292292                  text run at (0,-6) width 3: "|"
    293293          RenderMathMLOperator {mo} at (170,8) size 9x16
    294             RenderMathMLBlock (flex) {mo} at (0,0) size 8x16
     294            RenderMathMLBlock (anonymous, flex) at (0,0) size 8x16
    295295              RenderBlock (anonymous) at (0,0) size 8x16
    296296                RenderText at (0,-5) size 8x24
    297297                  text run at (0,-5) width 8: "\x{2016}"
    298298          RenderMathMLOperator {mo} at (184,8) size 9x16
    299             RenderMathMLBlock (flex) {mo} at (0,0) size 8x16
     299            RenderMathMLBlock (anonymous, flex) at (0,0) size 8x16
    300300              RenderBlock (anonymous) at (0,0) size 8x16
    301301                RenderText at (0,-5) size 8x24
     
    309309          RenderMathMLRow (anonymous) at (12,3) size 197x73
    310310            RenderMathMLOperator {mo} at (1,0) size 8x73
    311               RenderMathMLBlock (flex) {mo} at (0,0) size 7x14
     311              RenderMathMLBlock (anonymous, flex) at (0,0) size 7x14
    312312                RenderBlock (anonymous) at (0,0) size 5x14
    313313                  RenderText at (0,-6) size 5x24
    314314                    text run at (0,-6) width 5: "("
    315315            RenderMathMLOperator {mo} at (13,0) size 8x73
    316               RenderMathMLBlock (flex) {mo} at (0,0) size 7x14
     316              RenderMathMLBlock (anonymous, flex) at (0,0) size 7x14
    317317                RenderBlock (anonymous) at (0,0) size 5x14
    318318                  RenderText at (0,-6) size 5x24
    319319                    text run at (0,-6) width 5: ")"
    320320            RenderMathMLOperator {mo} at (26,0) size 11x73
    321               RenderMathMLBlock (flex) {mo} at (0,0) size 10x14
     321              RenderMathMLBlock (anonymous, flex) at (0,0) size 10x14
    322322                RenderBlock (anonymous) at (0,0) size 8x14
    323323                  RenderText at (0,-6) size 8x24
    324324                    text run at (0,-6) width 8: "{"
    325325            RenderMathMLOperator {mo} at (43,0) size 11x73
    326               RenderMathMLBlock (flex) {mo} at (0,0) size 10x14
     326              RenderMathMLBlock (anonymous, flex) at (0,0) size 10x14
    327327                RenderBlock (anonymous) at (0,0) size 8x14
    328328                  RenderText at (0,-6) size 8x24
    329329                    text run at (0,-6) width 8: "}"
    330330            RenderMathMLOperator {mo} at (59,0) size 8x73
    331               RenderMathMLBlock (flex) {mo} at (0,0) size 7x14
     331              RenderMathMLBlock (anonymous, flex) at (0,0) size 7x14
    332332                RenderBlock (anonymous) at (0,0) size 5x14
    333333                  RenderText at (0,-6) size 5x24
    334334                    text run at (0,-6) width 5: "["
    335335            RenderMathMLOperator {mo} at (72,0) size 8x73
    336               RenderMathMLBlock (flex) {mo} at (0,0) size 7x14
     336              RenderMathMLBlock (anonymous, flex) at (0,0) size 7x14
    337337                RenderBlock (anonymous) at (0,0) size 5x14
    338338                  RenderText at (0,-6) size 5x24
    339339                    text run at (0,-6) width 5: "]"
    340340            RenderMathMLOperator {mo} at (86,0) size 9x73
    341               RenderMathMLBlock (flex) {mo} at (0,0) size 8x16
     341              RenderMathMLBlock (anonymous, flex) at (0,0) size 8x16
    342342                RenderBlock (anonymous) at (0,0) size 8x16
    343343                  RenderText at (0,-5) size 8x24
    344344                    text run at (0,-5) width 8: "\x{2308}"
    345345            RenderMathMLOperator {mo} at (100,0) size 9x73
    346               RenderMathMLBlock (flex) {mo} at (0,0) size 8x16
     346              RenderMathMLBlock (anonymous, flex) at (0,0) size 8x16
    347347                RenderBlock (anonymous) at (0,0) size 8x16
    348348                  RenderText at (0,-5) size 8x24
    349349                    text run at (0,-5) width 8: "\x{2309}"
    350350            RenderMathMLOperator {mo} at (115,0) size 8x73
    351               RenderMathMLBlock (flex) {mo} at (0,0) size 8x16
     351              RenderMathMLBlock (anonymous, flex) at (0,0) size 8x16
    352352                RenderBlock (anonymous) at (0,0) size 8x16
    353353                  RenderText at (0,-5) size 8x24
    354354                    text run at (0,-5) width 8: "\x{230A}"
    355355            RenderMathMLOperator {mo} at (129,0) size 9x73
    356               RenderMathMLBlock (flex) {mo} at (0,0) size 8x16
     356              RenderMathMLBlock (anonymous, flex) at (0,0) size 8x16
    357357                RenderBlock (anonymous) at (0,0) size 8x16
    358358                  RenderText at (0,-5) size 8x24
    359359                    text run at (0,-5) width 8: "\x{230B}"
    360360            RenderMathMLOperator {mo} at (143,0) size 12x73
    361               RenderMathMLBlock (flex) {mo} at (0,0) size 11x20
     361              RenderMathMLBlock (anonymous, flex) at (0,0) size 11x20
    362362                RenderBlock (anonymous) at (0,0) size 7x20
    363363                  RenderText at (0,-3) size 7x24
    364364                    text run at (0,-3) width 7: "\x{222B}"
    365365            RenderMathMLOperator {mo} at (161,0) size 4x73
    366               RenderMathMLBlock (flex) {mo} at (0,0) size 3x12
     366              RenderMathMLBlock (anonymous, flex) at (0,0) size 3x12
    367367                RenderBlock (anonymous) at (0,0) size 3x12
    368368                  RenderText at (0,-6) size 3x24
    369369                    text run at (0,-6) width 3: "|"
    370370            RenderMathMLOperator {mo} at (170,0) size 9x41
    371               RenderMathMLBlock (flex) {mo} at (0,0) size 8x16
     371              RenderMathMLBlock (anonymous, flex) at (0,0) size 8x16
    372372                RenderBlock (anonymous) at (0,0) size 8x16
    373373                  RenderText at (0,-5) size 8x24
    374374                    text run at (0,-5) width 8: "\x{2016}"
    375375            RenderMathMLOperator {mo} at (184,0) size 9x41
    376               RenderMathMLBlock (flex) {mo} at (0,0) size 8x16
     376              RenderMathMLBlock (anonymous, flex) at (0,0) size 8x16
    377377                RenderBlock (anonymous) at (0,0) size 8x16
    378378                  RenderText at (0,-5) size 8x24
  • trunk/Source/WebCore/ChangeLog

    r165430 r165436  
     12014-03-10  Frédéric Wang  <fred.wang@free.fr>
     2
     3        Improve renderer classes for MathML Token elements.
     4        https://bugs.webkit.org/show_bug.cgi?id=124838
     5
     6        Reviewed by Chris Fleizach.
     7
     8        This patch continues the refactoring of token elements that has been
     9        started in bug 44208. The <mo> element now derives from the
     10        RenderMathMLToken class, which was already used for the <mi> element.
     11        The behavior of anonymous <mo> elements created by the <mfenced> element
     12        is now more consistent with the one of "standard" <mo> elements and the
     13        spacing around them is now handled in RenderMathMLOperator. This is a
     14        first step towards fixing bugs 115787 and 118843. The only visible
     15        rendering change is how <mfenced> open/close attributes handle
     16        whitespace and multiple characters and some tests are added for that.
     17        Other features are already covered by other tests. Finally, this also
     18        removes some code from AccessibilityRenderObject that was used to
     19        workaround issues with <mo> elements.
     20
     21        * accessibility/AccessibilityRenderObject.cpp:
     22        (WebCore::startOfContinuations):
     23        (WebCore::AccessibilityRenderObject::textUnderElement):
     24        (WebCore::AccessibilityRenderObject::isMathOperator):
     25        (WebCore::AccessibilityRenderObject::isIgnoredElementWithinMathTree):
     26        * mathml/MathMLTextElement.cpp:
     27        (WebCore::MathMLTextElement::didAttachRenderers):
     28        (WebCore::MathMLTextElement::childrenChanged):
     29        * rendering/mathml/RenderMathMLBlock.cpp:
     30        (WebCore::RenderMathMLBlock::RenderMathMLBlock):
     31        * rendering/mathml/RenderMathMLBlock.h:
     32        * rendering/mathml/RenderMathMLFenced.cpp:
     33        (WebCore::RenderMathMLFenced::RenderMathMLFenced):
     34        (WebCore::RenderMathMLFenced::updateFromElement):
     35        (WebCore::RenderMathMLFenced::createMathMLOperator):
     36        (WebCore::RenderMathMLFenced::makeFences):
     37        (WebCore::RenderMathMLFenced::addChild):
     38        * rendering/mathml/RenderMathMLFenced.h:
     39        * rendering/mathml/RenderMathMLOperator.cpp:
     40        (WebCore::RenderMathMLOperator::RenderMathMLOperator):
     41        (WebCore::RenderMathMLOperator::setOperatorFlagFromAttribute):
     42        (WebCore::RenderMathMLOperator::setOperatorPropertiesFromOpDictEntry):
     43        (WebCore::RenderMathMLOperator::SetOperatorProperties):
     44        (WebCore::RenderMathMLOperator::computePreferredLogicalWidths):
     45        (WebCore::RenderMathMLOperator::rebuildTokenContent):
     46        (WebCore::RenderMathMLOperator::updateTokenContent):
     47        (WebCore::RenderMathMLOperator::updateStyle):
     48        (WebCore::RenderMathMLOperator::firstLineBaseline):
     49        (WebCore::RenderMathMLOperator::paint):
     50        (WebCore::RenderMathMLOperator::paintChildren):
     51        * rendering/mathml/RenderMathMLOperator.h:
     52        * rendering/mathml/RenderMathMLToken.cpp:
     53        (WebCore::RenderMathMLToken::createWrapperIfNeeded):
     54
    1552014-03-10  James Craig  <jcraig@apple.com>
    256
  • trunk/Source/WebCore/accessibility/AccessibilityRenderObject.cpp

    r164964 r165436  
    254254static inline RenderInline* startOfContinuations(RenderObject* r)
    255255{
    256     if (r->isInlineElementContinuation()) {
    257 #if ENABLE(MATHML)
    258         // MathML elements make anonymous RenderObjects, then set their node to the parent's node.
    259         // This makes it so that the renderer() != renderer()->node()->renderer()
    260         // (which is what isInlineElementContinuation() uses as a determinant).
    261         if (r->node()->isMathMLElement())
    262             return nullptr;
    263 #endif
    264        
     256    if (r->isInlineElementContinuation())
    265257        return toRenderInline(r->node()->renderer());
    266     }
    267258
    268259    // Blocks with a previous continuation always have a next continuation
     
    655646    // Math operators create RenderText nodes on the fly that are not tied into the DOM in a reasonable way,
    656647    // so rangeOfContents does not work for them (nor does regular text selection).
    657     if (m_renderer->isText() && isMathElement()) {
    658         if (ancestorsOfType<RenderMathMLOperator>(*m_renderer).first())
    659             return toRenderText(*m_renderer).text();
    660     }
     648    if (m_renderer->isText() && m_renderer->isAnonymous() && ancestorsOfType<RenderMathMLOperator>(*m_renderer).first())
     649        return toRenderText(*m_renderer).text();
    661650#endif
    662651
     
    35033492        return false;
    35043493
    3505     // Ensure that this is actually a render MathML operator because
    3506     // MathML will create MathMLBlocks and use the original node as the node
    3507     // of this new block that is not tied to the DOM.
    3508     return isMathElement() && node()->hasTagName(MathMLNames::moTag);
     3494    return true;
    35093495}
    35103496
     
    35653551        return true;
    35663552   
    3567     // Ignore items that were created for layout purposes only.
    3568     if (m_renderer->isRenderMathMLBlock() && toRenderMathMLBlock(m_renderer)->ignoreInAccessibilityTree())
    3569         return true;
    3570 
    3571     // Ignore anonymous renderers inside math blocks.
     3553    // We ignore anonymous renderers inside math blocks.
     3554    // However, we do not exclude anonymous RenderMathMLOperator nodes created by the mfenced element nor RenderText nodes created by math operators so that the text can be exposed by AccessibilityRenderObject::textUnderElement.
    35723555    if (m_renderer->isAnonymous()) {
     3556        if (m_renderer->isRenderMathMLOperator())
     3557            return false;
    35733558        for (AccessibilityObject* parent = parentObject(); parent; parent = parent->parentObject()) {
    35743559            if (parent->isMathElement())
    3575                 return true;
     3560                return !(m_renderer->isText() && ancestorsOfType<RenderMathMLOperator>(*m_renderer).first());
    35763561        }
    35773562    }
  • trunk/Source/WebCore/mathml/MathMLTextElement.cpp

    r163626 r165436  
    5454{
    5555    MathMLElement::didAttachRenderers();
    56     if (renderer()) {
    57         if (renderer()->isRenderMathMLToken())
    58             toRenderMathMLToken(renderer())->updateTokenContent();
    59         else
    60             renderer()->updateFromElement();
    61     }
     56    if (renderer() && renderer()->isRenderMathMLToken())
     57        toRenderMathMLToken(renderer())->updateTokenContent();
    6258}
    6359
     
    6561{
    6662    MathMLElement::childrenChanged(change);
    67     if (renderer()) {
    68         if (renderer()->isRenderMathMLToken())
    69             toRenderMathMLToken(renderer())->updateTokenContent();
    70         else
    71             renderer()->updateFromElement();
    72     }
     63    if (renderer() && renderer()->isRenderMathMLToken())
     64        toRenderMathMLToken(renderer())->updateTokenContent();
    7365}
    7466
  • trunk/Source/WebCore/rendering/mathml/RenderMathMLBlock.cpp

    r161482 r165436  
    4646RenderMathMLBlock::RenderMathMLBlock(Element& container, PassRef<RenderStyle> style)
    4747    : RenderFlexibleBox(container, std::move(style))
    48     , m_ignoreInAccessibilityTree(false)
    4948{
    5049}
     
    5251RenderMathMLBlock::RenderMathMLBlock(Document& document, PassRef<RenderStyle> style)
    5352    : RenderFlexibleBox(document, std::move(style))
    54     , m_ignoreInAccessibilityTree(false)
    5553{
    5654}
  • trunk/Source/WebCore/rendering/mathml/RenderMathMLBlock.h

    r164536 r165436  
    6565    RenderPtr<RenderMathMLBlock> createAnonymousMathMLBlock();
    6666   
    67     void setIgnoreInAccessibilityTree(bool flag) { m_ignoreInAccessibilityTree = flag; }
    68     bool ignoreInAccessibilityTree() const { return m_ignoreInAccessibilityTree; }
    69    
    7067private:
    7168    virtual bool isRenderMathMLBlock() const override final { return true; }
    7269    virtual const char* renderName() const override;
    73 
    74     bool m_ignoreInAccessibilityTree;
    7570};
    7671
  • trunk/Source/WebCore/rendering/mathml/RenderMathMLFenced.cpp

    r164418 r165436  
    4141using namespace MathMLNames;
    4242   
    43 enum Braces { OpeningBraceChar = 0x28, ClosingBraceChar = 0x29 };
    44    
    45 static const float gSeparatorMarginEndEms = 0.25f;
    46 static const float gFenceMarginEms = 0.1f;
     43static const char* gOpeningBraceChar = "(";
     44static const char* gClosingBraceChar = ")";
    4745
    4846RenderMathMLFenced::RenderMathMLFenced(MathMLInlineContainerElement& element, PassRef<RenderStyle> style)
    4947    : RenderMathMLRow(element, std::move(style))
    50     , m_open(OpeningBraceChar)
    51     , m_close(ClosingBraceChar)
    5248    , m_closeFenceRenderer(nullptr)
    5349{
     
    5854    const auto& fenced = element();
    5955 
    60     // FIXME: Handle open/close values with more than one character (they should be treated like text).
    61     AtomicString openValue = fenced.getAttribute(MathMLNames::openAttr);
    62     if (openValue.length() > 0)
    63         m_open = openValue[0];
    64     AtomicString closeValue = fenced.getAttribute(MathMLNames::closeAttr);
    65     if (closeValue.length() > 0)
    66         m_close = closeValue[0];
    67    
    68     AtomicString separators = fenced.getAttribute(MathMLNames::separatorsAttr);
     56    // The open operator defaults to a left parenthesis.
     57    AtomicString open = fenced.fastGetAttribute(MathMLNames::openAttr);
     58    m_open = open.isNull() ? gOpeningBraceChar : open;
     59
     60    // The close operator defaults to a right parenthesis.
     61    AtomicString close = fenced.fastGetAttribute(MathMLNames::closeAttr);
     62    m_close = close.isNull() ? gClosingBraceChar : close;
     63
     64    AtomicString separators = fenced.fastGetAttribute(MathMLNames::separatorsAttr);
    6965    if (!separators.isNull()) {
    7066        StringBuilder characters;
     
    8177    if (isEmpty())
    8278        makeFences();
     79    else {
     80        // FIXME: The mfenced element fails to update dynamically when its open, close and separators attributes are changed (https://bugs.webkit.org/show_bug.cgi?id=57696).
     81        toRenderMathMLOperator(firstChild())->updateTokenContent(m_open);
     82        m_closeFenceRenderer->updateTokenContent(m_close);
     83    }
    8384}
    8485
    85 RenderPtr<RenderMathMLOperator> RenderMathMLFenced::createMathMLOperator(UChar uChar, MathMLOperatorDictionary::Form form, MathMLOperatorDictionary::Flag flag)
     86RenderPtr<RenderMathMLOperator> RenderMathMLFenced::createMathMLOperator(const String& operatorString, MathMLOperatorDictionary::Form form, MathMLOperatorDictionary::Flag flag)
    8687{
    87     auto newStyle = RenderStyle::createAnonymousStyleWithDisplay(&style(), FLEX);
    88     newStyle.get().setFlexDirection(FlowColumn);
    89     newStyle.get().setMarginEnd(Length((flag == MathMLOperatorDictionary::Fence ? gFenceMarginEms : gSeparatorMarginEndEms) * style().fontSize(), Fixed));
    90     if (flag == MathMLOperatorDictionary::Fence)
    91         newStyle.get().setMarginStart(Length(gFenceMarginEms * style().fontSize(), Fixed));
    92     RenderPtr<RenderMathMLOperator> newOperator = createRenderer<RenderMathMLOperator>(element(), std::move(newStyle), uChar, form, flag);
     88    RenderPtr<RenderMathMLOperator> newOperator = createRenderer<RenderMathMLOperator>(document(), RenderStyle::createAnonymousStyleWithDisplay(&style(), FLEX), operatorString, form, flag);
    9389    newOperator->initializeStyle();
    9490    return newOperator;
     
    9894{
    9995    RenderPtr<RenderMathMLOperator> openFence = createMathMLOperator(m_open, MathMLOperatorDictionary::Prefix, MathMLOperatorDictionary::Fence);
    100     RenderMathMLOperator* openFencePtr = openFence.get();
    10196    RenderMathMLRow::addChild(openFence.leakPtr(), firstChild());
    10297
     
    10499    m_closeFenceRenderer = closeFence.get();
    105100    RenderMathMLRow::addChild(closeFence.leakPtr());
    106 
    107     openFencePtr->updateFromElement();
    108     m_closeFenceRenderer->updateFromElement();
    109101}
    110102
     
    115107        updateFromElement();
    116108   
    117     // FIXME: Adding or removing a child should possibly cause all later separators to shift places if they're different,
    118     // as later child positions change by +1 or -1.
     109    // FIXME: Adding or removing a child should possibly cause all later separators to shift places if they're different, as later child positions change by +1 or -1. This should also handle surrogate pairs. See https://bugs.webkit.org/show_bug.cgi?id=125938.
    119110   
    120111    RenderPtr<RenderMathMLOperator> separatorRenderer;
     
    140131                separator = (*m_separators.get())[count - 1];
    141132               
    142             separatorRenderer = createMathMLOperator(separator, MathMLOperatorDictionary::Infix, MathMLOperatorDictionary::Separator);
     133            StringBuilder builder;
     134            builder.append(separator);
     135            separatorRenderer = createMathMLOperator(builder.toString(), MathMLOperatorDictionary::Infix, MathMLOperatorDictionary::Separator);
    143136        }
    144137    }
     
    157150}
    158151
    159 // FIXME: Change createMathMLOperator() above to create an isAnonymous() operator, and remove this styleDidChange() function.
    160 void RenderMathMLFenced::styleDidChange(StyleDifference diff, const RenderStyle* oldStyle)
    161 {
    162     RenderMathMLBlock::styleDidChange(diff, oldStyle);
    163    
    164     for (RenderObject* child = firstChild(); child; child = child->nextSibling()) {
    165         if (child->node() == &element()) {
    166             ASSERT(child->style().refCount() == 1);
    167             child->style().inheritFrom(&style());
    168             bool isFence = child == firstChild() || child == lastChild();
    169             child->style().setMarginEnd(Length((isFence ? gFenceMarginEms : gSeparatorMarginEndEms) * style().fontSize(), Fixed));
    170             if (isFence) {
    171                 RenderMathMLBlock* block = toRenderMathMLBlock(child);
    172                 toRenderMathMLOperator(block)->updateFromElement();
    173                 child->style().setMarginStart(Length(gFenceMarginEms * style().fontSize(), Fixed));
    174             }
    175         }
    176     }
    177 }
    178 
    179152}   
    180153
  • trunk/Source/WebCore/rendering/mathml/RenderMathMLFenced.h

    r164418 r165436  
    4444    virtual const char* renderName() const override { return "RenderMathMLFenced"; }
    4545    virtual void addChild(RenderObject* child, RenderObject* beforeChild) override;
    46     virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle) override;
    47 
    4846    virtual void updateFromElement() override;
    4947
    50     RenderPtr<RenderMathMLOperator> createMathMLOperator(UChar, MathMLOperatorDictionary::Form, MathMLOperatorDictionary::Flag);
     48    RenderPtr<RenderMathMLOperator> createMathMLOperator(const String& operatorString, MathMLOperatorDictionary::Form, MathMLOperatorDictionary::Flag);
    5149    void makeFences();
    5250
    53     UChar m_open;
    54     UChar m_close;
     51    String m_open;
     52    String m_close;
    5553    RefPtr<StringImpl> m_separators;
    5654   
  • trunk/Source/WebCore/rendering/mathml/RenderMathMLOperator.cpp

    r164700 r165436  
    11201120
    11211121RenderMathMLOperator::RenderMathMLOperator(MathMLElement& element, PassRef<RenderStyle> style)
    1122     : RenderMathMLBlock(element, std::move(style))
     1122    : RenderMathMLToken(element, std::move(style))
    11231123    , m_stretchHeightAboveBaseline(0)
    11241124    , m_stretchDepthBelowBaseline(0)
    11251125    , m_operator(0)
    11261126    , m_stretchyCharacter(nullptr)
    1127     , m_isFencedOperator(false)
    1128 {
    1129     SetOperatorProperties();
    1130 }
    1131 
    1132 RenderMathMLOperator::RenderMathMLOperator(MathMLElement& element, PassRef<RenderStyle> style, UChar operatorChar, MathMLOperatorDictionary::Form form, MathMLOperatorDictionary::Flag flag)
    1133     : RenderMathMLBlock(element, std::move(style))
     1127{
     1128    updateTokenContent();
     1129}
     1130
     1131RenderMathMLOperator::RenderMathMLOperator(Document& document, PassRef<RenderStyle> style, const String& operatorString, MathMLOperatorDictionary::Form form, MathMLOperatorDictionary::Flag flag)
     1132    : RenderMathMLToken(document, std::move(style))
    11341133    , m_stretchHeightAboveBaseline(0)
    11351134    , m_stretchDepthBelowBaseline(0)
    1136     , m_operator(operatorChar == hyphenMinus ? minusSign : operatorChar)
     1135    , m_operator(0)
    11371136    , m_stretchyCharacter(nullptr)
    1138     , m_isFencedOperator(true)
    11391137    , m_operatorForm(form)
    11401138    , m_operatorFlags(flag)
    11411139{
    1142     SetOperatorProperties();
     1140    updateTokenContent(operatorString);
    11431141}
    11441142
    11451143void RenderMathMLOperator::setOperatorFlagFromAttribute(MathMLOperatorDictionary::Flag flag, const QualifiedName& name)
    11461144{
     1145    ASSERT(!isFencedOperator());
    11471146    const AtomicString& attributeValue = element().fastGetAttribute(name);
    11481147    if (attributeValue == "true")
     
    11561155{
    11571156    // If this operator has been created by RenderMathMLFenced, we preserve the Fence and Separator properties.
    1158     if (m_isFencedOperator)
     1157    if (isFencedOperator())
    11591158        m_operatorFlags = (m_operatorFlags & (MathMLOperatorDictionary::Fence | MathMLOperatorDictionary::Separator)) | entry->flags;
    11601159    else
     
    11681167void RenderMathMLOperator::SetOperatorProperties()
    11691168{
    1170     // We verify whether the operator text can be represented by a single UChar.
    1171     if (!m_isFencedOperator) {
    1172         // FIXME: This does not handle surrogate pairs (https://bugs.webkit.org/show_bug.cgi?id=122296).
    1173         // FIXME: This does not handle <mo> operators with multiple characters (https://bugs.webkit.org/show_bug.cgi?id=124828).
    1174         String opText = element().textContent().stripWhiteSpace().simplifyWhiteSpace().replace(hyphenMinus, minusSign).impl();
    1175         if (opText.length() == 1)
    1176             m_operator = opText[0];
    1177     }
    1178 
    11791169    // We determine the form of the operator.
    11801170    bool explicitForm = true;
    1181     if (!m_isFencedOperator) {
     1171    if (!isFencedOperator()) {
    11821172        const AtomicString& form = element().fastGetAttribute(MathMLNames::formAttr);
    11831173        if (form == "prefix")
     
    12021192
    12031193    // First we initialize with the default values for unknown operators.
    1204     m_operatorFlags = 0; // This sets all the properties to "false".
     1194    if (isFencedOperator())
     1195        m_operatorFlags &= MathMLOperatorDictionary::Fence | MathMLOperatorDictionary::Separator; // This resets all but the Fence and Separator properties.
     1196    else
     1197        m_operatorFlags = 0; // This resets all the operator properties.
    12051198    m_leadingSpace = 5 * style().fontSize() / 18; // This sets leading space to "thickmathspace".
    12061199    m_trailingSpace = 5 * style().fontSize() / 18; // This sets trailing space to "thickmathspace".
     
    12261219#undef MATHML_OPDICT_SIZE
    12271220
    1228     if (!m_isFencedOperator) {
     1221    if (!isFencedOperator()) {
    12291222        // Finally, we make the attribute values override the default.
    12301223
     
    12441237        if (maxsize != "infinity")
    12451238            parseMathMLLength(maxsize, m_maxSize, &style(), false);
     1239    }
     1240
     1241    // FIXME: this should be removed when operator spacing is implemented (https://bugs.webkit.org/show_bug.cgi?id=115787). At the moment spacing for normal <mo> elements is handled in mathml.css and mfenced uses the arbitrary constants below.
     1242    if (isFencedOperator()) {
     1243        if (hasOperatorFlag(MathMLOperatorDictionary::Fence)) {
     1244            m_leadingSpace = 0.1f * style().fontSize();
     1245            m_trailingSpace = 0.1f * style().fontSize();
     1246        } else if (hasOperatorFlag(MathMLOperatorDictionary::Separator)) {
     1247            m_leadingSpace = 0;
     1248            m_trailingSpace = 0.25f * style().fontSize();
     1249        }
     1250    } else {
     1251        m_leadingSpace = 0;
     1252        m_trailingSpace = 0;
    12461253    }
    12471254}
     
    12841291}
    12851292
    1286 void RenderMathMLOperator::styleDidChange(StyleDifference diff, const RenderStyle* oldStyle)
    1287 {
    1288     RenderMathMLBlock::styleDidChange(diff, oldStyle);
    1289     updateFromElement();
    1290 }
    1291 
    12921293FloatRect RenderMathMLOperator::glyphBoundsForCharacter(UChar character)
    12931294{
     
    13151316    bool allowStretching = shouldAllowStretching(stretchedCharacter);
    13161317    if (!allowStretching) {
    1317         RenderMathMLBlock::computePreferredLogicalWidths();
     1318        RenderMathMLToken::computePreferredLogicalWidths();
    13181319        return;
    13191320    }
     
    13331334        if (character.middleGlyph)
    13341335            maximumGlyphWidth = std::max(maximumGlyphWidth, advanceForCharacter(character.middleGlyph));
    1335         m_maxPreferredLogicalWidth = m_minPreferredLogicalWidth = maximumGlyphWidth;
     1336        m_maxPreferredLogicalWidth = m_minPreferredLogicalWidth = m_leadingSpace + maximumGlyphWidth + m_trailingSpace;
    13361337        return;
    13371338    }
    13381339
    1339     m_maxPreferredLogicalWidth = m_minPreferredLogicalWidth = maximumGlyphWidth;
    1340 }
    1341 
    1342 // FIXME: It's cleaner to only call updateFromElement when an attribute has changed. The body of
    1343 // this method should probably be moved to a private stretchHeightChanged or checkStretchHeight
    1344 // method. Probably at the same time, addChild/removeChild methods should be made to work for
    1345 // dynamic DOM changes.
    1346 void RenderMathMLOperator::updateFromElement()
    1347 {
    1348     RenderElement* savedRenderer = element().renderer();
    1349 
    1350     // Destroy our current children
    1351     destroyLeftoverChildren();
    1352 
    1353     // Since we share a node with our children, destroying our children may set our node's
    1354     // renderer to 0, so we need to restore it.
    1355     element().setRenderer(savedRenderer);
    1356 
    1357     RenderPtr<RenderMathMLBlock> container = createRenderer<RenderMathMLBlock>(element(), RenderStyle::createAnonymousStyleWithDisplay(&style(), FLEX));
    1358     // This container doesn't offer any useful information to accessibility.
    1359     container->setIgnoreInAccessibilityTree(true);
    1360     container->initializeStyle();
    1361 
    1362     RenderPtr<RenderText> text;
    1363     if (m_isFencedOperator)
    1364         text = createRenderer<RenderText>(document(), String(&m_operator, 1));
    1365     else
    1366         text = createRenderer<RenderText>(document(), element().textContent().replace(hyphenMinus, minusSign).impl());
    1367 
    1368     container->addChild(text.leakPtr());
    1369     addChild(container.leakPtr());
    1370 
     1340    m_maxPreferredLogicalWidth = m_minPreferredLogicalWidth = m_leadingSpace + maximumGlyphWidth + m_trailingSpace;
     1341}
     1342
     1343void RenderMathMLOperator::rebuildTokenContent(const String& operatorString)
     1344{
     1345    // We collapse the whitespace and replace the hyphens by minus signs.
     1346    AtomicString textContent = operatorString.stripWhiteSpace().simplifyWhiteSpace().replace(hyphenMinus, minusSign).impl();
     1347
     1348    // We destroy the wrapper and rebuild it.
     1349    // FIXME: Using this RenderText make the text inaccessible to the dumpAsText/selection code (https://bugs.webkit.org/show_bug.cgi?id=125597).
     1350    if (firstChild())
     1351        toRenderElement(firstChild())->destroy();
     1352    createWrapperIfNeeded();
     1353    RenderPtr<RenderText> text = createRenderer<RenderText>(document(), textContent);
     1354    toRenderElement(firstChild())->addChild(text.leakPtr());
     1355
     1356    // We verify whether the operator text can be represented by a single UChar.
     1357    // FIXME: This does not handle surrogate pairs (https://bugs.webkit.org/show_bug.cgi?id=122296).
     1358    // FIXME: This does not handle <mo> operators with multiple characters (https://bugs.webkit.org/show_bug.cgi?id=124828).
     1359    m_operator = textContent.length() == 1 ? textContent[0] : 0;
    13711360    SetOperatorProperties();
    13721361    updateStyle();
    13731362    setNeedsLayoutAndPrefWidthsRecalc();
     1363}
     1364
     1365void RenderMathMLOperator::updateTokenContent(const String& operatorString)
     1366{
     1367    ASSERT(isFencedOperator());
     1368    rebuildTokenContent(operatorString);
     1369}
     1370
     1371void RenderMathMLOperator::updateTokenContent()
     1372{
     1373    ASSERT(!isFencedOperator());
     1374    rebuildTokenContent(element().textContent());
    13741375}
    13751376
     
    14251426    if (!m_stretchyCharacter)
    14261427        m_isStretched = false;
     1428
     1429    // We add spacing around the operator.
     1430    const auto& wrapper = toRenderElement(firstChild());
     1431    auto newStyle = RenderStyle::createAnonymousStyleWithDisplay(&style(), FLEX);
     1432    newStyle.get().setMarginStart(Length(m_leadingSpace, Fixed));
     1433    newStyle.get().setMarginEnd(Length(m_trailingSpace, Fixed));
     1434    wrapper->setStyle(std::move(newStyle));
     1435    wrapper->setNeedsLayoutAndPrefWidthsRecalc();
    14271436}
    14281437
     
    14311440    if (m_isStretched)
    14321441        return m_stretchHeightAboveBaseline;
    1433     return RenderMathMLBlock::firstLineBaseline();
     1442    return RenderMathMLToken::firstLineBaseline();
    14341443}
    14351444
     
    15191528void RenderMathMLOperator::paint(PaintInfo& info, const LayoutPoint& paintOffset)
    15201529{
    1521     RenderMathMLBlock::paint(info, paintOffset);
    1522 
    15231530    if (info.context->paintingDisabled() || info.phase != PaintPhaseForeground || style().visibility() != VISIBLE)
    15241531        return;
    15251532
    15261533    if (!m_isStretched && !m_stretchyCharacter) {
    1527         RenderMathMLBlock::paint(info, paintOffset);
     1534        RenderMathMLToken::paint(info, paintOffset);
    15281535        return;
    15291536    }
    15301537
     1538    // FIXME: This painting should work in RTL mode too (https://bugs.webkit.org/show_bug.cgi?id=123018).
     1539
    15311540    GraphicsContextStateSaver stateSaver(*info.context);
    15321541    info.context->setFillColor(style().visitedDependentColor(CSSPropertyColor), style().colorSpace());
     
    15361545
    15371546    // We are positioning the glyphs so that the edge of the tight glyph bounds line up exactly with the edges of our paint box.
    1538     LayoutPoint operatorTopLeft = ceiledIntPoint(paintOffset + location());
     1547    LayoutPoint operatorTopLeft = paintOffset + location();
     1548    operatorTopLeft.move(m_leadingSpace, 0);
     1549    operatorTopLeft = ceiledIntPoint(operatorTopLeft);
    15391550    FloatRect topGlyphBounds = glyphBoundsForCharacter(m_stretchyCharacter->topGlyph);
    15401551    LayoutPoint topGlyphOrigin(operatorTopLeft.x(), operatorTopLeft.y() - topGlyphBounds.y());
     
    15631574    if (m_isStretched)
    15641575        return;
    1565     RenderMathMLBlock::paintChildren(paintInfo, paintOffset, paintInfoForChild, usePrintRect);
     1576    RenderMathMLToken::paintChildren(paintInfo, paintOffset, paintInfoForChild, usePrintRect);
    15661577}
    15671578   
  • trunk/Source/WebCore/rendering/mathml/RenderMathMLOperator.h

    r164700 r165436  
    3030
    3131#include "MathMLElement.h"
    32 #include "RenderMathMLBlock.h"
     32#include "RenderMathMLToken.h"
    3333#include <wtf/unicode/CharacterNames.h>
    3434
     
    5858}
    5959
    60 class RenderMathMLOperator final : public RenderMathMLBlock {
     60class RenderMathMLOperator final : public RenderMathMLToken {
    6161public:
    6262    RenderMathMLOperator(MathMLElement&, PassRef<RenderStyle>);
    63     RenderMathMLOperator(MathMLElement&, PassRef<RenderStyle>, UChar operatorChar, MathMLOperatorDictionary::Form, MathMLOperatorDictionary::Flag);
    64 
    65     MathMLElement& element() { return toMathMLElement(nodeForNonAnonymous()); }
     63    RenderMathMLOperator(Document&, PassRef<RenderStyle>, const String& operatorString, MathMLOperatorDictionary::Form, MathMLOperatorDictionary::Flag);
    6664
    6765    void stretchTo(LayoutUnit heightAboveBaseline, LayoutUnit depthBelowBaseline);
     
    7068    bool hasOperatorFlag(MathMLOperatorDictionary::Flag flag) const { return m_operatorFlags & flag; }
    7169
    72     void updateStyle();
     70    void updateStyle() override final;
    7371
    7472    void paint(PaintInfo&, const LayoutPoint&);
     
    8280    };
    8381
    84     virtual void updateFromElement() override;
     82    void updateTokenContent(const String& operatorString);
     83    void updateTokenContent() override final;
    8584
    8685private:
    8786    virtual const char* renderName() const override { return isAnonymous() ? "RenderMathMLOperator (anonymous)" : "RenderMathMLOperator"; }
    88     virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle) override;
    8987    virtual void paintChildren(PaintInfo& forSelf, const LayoutPoint&, PaintInfo& forChild, bool usePrintRect) override;
    9088    virtual bool isRenderMathMLOperator() const override { return true; }
     89    bool isFencedOperator() { return isAnonymous(); }
    9190    virtual bool isChildAllowed(const RenderObject&, const RenderStyle&) const override;
    9291    virtual void computePreferredLogicalWidths() override;
     
    9493    virtual int firstLineBaseline() const override;
    9594    virtual RenderMathMLOperator* unembellishedOperator() override { return this; }
     95    void rebuildTokenContent(const String& operatorString);
    9696
    9797    bool shouldAllowStretching(UChar& characterForStretching);
     
    117117    UChar m_operator;
    118118    StretchyCharacter* m_stretchyCharacter;
    119     bool m_isFencedOperator;
    120119    MathMLOperatorDictionary::Form m_operatorForm;
    121120    unsigned short m_operatorFlags;
  • trunk/Source/WebCore/rendering/mathml/RenderMathMLToken.cpp

    r163553 r165436  
    5555    if (!firstChild()) {
    5656        RenderPtr<RenderMathMLBlock> wrapper = createAnonymousMathMLBlock();
    57         // This container doesn't offer any useful information to accessibility.
    58         wrapper->setIgnoreInAccessibilityTree(true);
    5957        RenderMathMLBlock::addChild(wrapper.leakPtr());
    6058    }
Note: See TracChangeset for help on using the changeset viewer.