Changeset 163553 in webkit


Ignore:
Timestamp:
Feb 6, 2014 12:00:20 PM (10 years ago)
Author:
commit-queue@webkit.org
Message:

Do not draw multi-characters <mi> in italic.
https://bugs.webkit.org/show_bug.cgi?id=44208

Patch by Frédéric Wang <fred.wang@free.fr> on 2014-02-06
Reviewed by Chris Fleizach.

Source/WebCore:

This test prevents multi-char <mi> to be drawn in italic and prepare
further improvements to MathML token and mfenced elements (bugs 124838
and bug 99620).

Test: mathml/presentation/tokenElements-dynamic.html

  • CMakeLists.txt:
  • GNUmakefile.list.am:
  • WebCore.vcxproj/WebCore.vcxproj:
  • WebCore.vcxproj/WebCore.vcxproj.filters:
  • WebCore.xcodeproj/project.pbxproj:
  • css/mathml.css:

(mi, mo, mrow, mfenced, mfrac, msub, msup, msubsup, mmultiscripts, mprescripts, none, munder, mover, munderover, msqrt, mroot, merror, mphantom, mstyle, menclose):

  • mathml/MathMLTextElement.cpp:

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

  • rendering/RenderObject.h:

(WebCore::RenderObject::isRenderMathMLToken):

  • rendering/mathml/RenderMathMLToken.cpp: Added.

(WebCore::RenderMathMLToken::RenderMathMLToken):
(WebCore::RenderMathMLToken::addChild):
(WebCore::RenderMathMLToken::createWrapperIfNeeded):
(WebCore::RenderMathMLToken::updateTokenContent):
(WebCore::RenderMathMLToken::updateStyle):
(WebCore::RenderMathMLToken::styleDidChange):
(WebCore::RenderMathMLToken::updateFromElement):

  • rendering/mathml/RenderMathMLToken.h: Added.

(WebCore::RenderMathMLToken::element):
(WebCore::RenderMathMLToken>):

LayoutTests:

Add tests for single-char/multi-char <mi> elements, the mathvariant
attribute and MathML token elements dynamically modified.

  • mathml/presentation/attributes-mathvariant-expected.html:
  • mathml/presentation/attributes-mathvariant.html:
  • mathml/presentation/tokenElements-dynamic-expected.html: Added.
  • mathml/presentation/tokenElements-dynamic.html: Added.
  • mathml/presentation/tokenElements-mathvariant-expected.html:
  • mathml/presentation/tokenElements-mathvariant.html:
Location:
trunk
Files:
4 added
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r163548 r163553  
     12014-02-06  Frédéric Wang  <fred.wang@free.fr>
     2
     3        Do not draw multi-characters <mi> in italic.
     4        https://bugs.webkit.org/show_bug.cgi?id=44208
     5
     6        Reviewed by Chris Fleizach.
     7
     8        Add tests for single-char/multi-char <mi> elements, the mathvariant
     9        attribute and MathML token elements dynamically modified.
     10
     11        * mathml/presentation/attributes-mathvariant-expected.html:
     12        * mathml/presentation/attributes-mathvariant.html:
     13        * mathml/presentation/tokenElements-dynamic-expected.html: Added.
     14        * mathml/presentation/tokenElements-dynamic.html: Added.
     15        * mathml/presentation/tokenElements-mathvariant-expected.html:
     16        * mathml/presentation/tokenElements-mathvariant.html:
     17
    1182014-02-06  Alexey Proskuryakov  <ap@apple.com>
    219
  • trunk/LayoutTests/mathml/presentation/attributes-mathvariant-expected.html

    r152777 r163553  
    1616      -->
    1717    <div>
     18      <!-- FIXME: we add new lines to workaround a width/spacing bug. -->
    1819      <math>
    19         <mi style="font-style: normal;">A</mi>
    20         <mi style="font-style: italic;">A</mi>
     20        <mtext style="font-style: normal;">A</mtext>
     21      </math><br/>
     22      <math>
    2123        <mtext style="font-style: italic;">A</mtext>
    22         <mi style="font-style: normal; font-weight: bold;">A</mi>
    23         <mi style="font-weight: bold; font-style: italic;">A</mi>
     24      </math><br/>
     25      <math>
     26        <mtext style="font-style: italic;">A</mtext>
     27      </math><br/>
     28      <math>
     29        <mtext style="font-weight: bold;">A</mtext>
     30      </math><br/>
     31      <math>
     32        <mtext style="font-weight: bold; font-style: italic;">A</mtext>
    2433      </math>
    2534    </div>
  • trunk/LayoutTests/mathml/presentation/attributes-mathvariant.html

    r152777 r163553  
    1212      <math>
    1313        <mi mathvariant="normal">A</mi>
     14      </math><br/>
     15      <math>
    1416        <mi>A</mi>
     17      </math><br/>
     18      <math>
    1519        <mtext mathvariant="italic">A</mtext>
     20      </math><br/>
     21      <math>
    1622        <mi mathvariant="bold">A</mi>
     23      </math><br/>
     24      <math>
    1725        <mi mathvariant="bold-italic">A</mi>
    1826      </math>
  • trunk/LayoutTests/mathml/presentation/tokenElements-mathvariant-expected.html

    r152777 r163553  
    1212        <mtext style="font-style: normal; font-weight: normal;">text</mtext>
    1313        <ms style="font-style: normal; font-weight: normal;">&amp;</ms>
     14        <mtext style="font-style: normal; font-weight: normal;">sin</mtext>
    1415      </math>
    1516    </p>
    16     <p>Following element should be in italic:
     17    <p>Following elements should be in italic:
    1718      <math>
    18         <mi style="font-style: italic;">x</mi>
     19        <mtext style="font-style: italic; font-weight: normal;">x</mtext>
     20      </math><br/>
     21      <math>
     22        <!-- FIXME: the whitespace should be removed in the reference when
     23             bug 125628 is fixed. -->
     24        <mtext style="font-style: italic; font-weight: normal;">&#x20;&#x9;&#xD;&#xA;x&#x20;&#x9;&#xD;&#xA;</mtext>
    1925      </math>
    2026    </p>
  • trunk/LayoutTests/mathml/presentation/tokenElements-mathvariant.html

    r152777 r163553  
    1212        <mtext>text</mtext>
    1313        <ms>&amp;</ms>
     14        <mi>sin</mi>
    1415      </math>
    1516    </p>
    16     <p>Following element should be in italic:
     17    <p>Following elements should be in italic:
     18      <!-- FIXME: we add a new line to workaround a width/spacing bug. -->
    1719      <math>
    1820        <mi>x</mi>
     21      </math><br/>
     22      <math>
     23        <mi>&#x20;&#x9;&#xD;&#xA;x&#x20;&#x9;&#xD;&#xA;</mi>
    1924      </math>
    2025    </p>
  • trunk/Source/WebCore/CMakeLists.txt

    r163440 r163553  
    22212221    rendering/mathml/RenderMathMLSpace.cpp
    22222222    rendering/mathml/RenderMathMLSquareRoot.cpp
     2223    rendering/mathml/RenderMathMLToken.cpp
    22232224    rendering/mathml/RenderMathMLUnderOver.cpp
    22242225
  • trunk/Source/WebCore/ChangeLog

    r163552 r163553  
     12014-02-06  Frédéric Wang  <fred.wang@free.fr>
     2
     3        Do not draw multi-characters <mi> in italic.
     4        https://bugs.webkit.org/show_bug.cgi?id=44208
     5
     6        Reviewed by Chris Fleizach.
     7
     8        This test prevents multi-char <mi> to be drawn in italic and prepare
     9        further improvements to MathML token and mfenced elements (bugs 124838
     10        and bug 99620).
     11
     12        Test: mathml/presentation/tokenElements-dynamic.html
     13
     14        * CMakeLists.txt:
     15        * GNUmakefile.list.am:
     16        * WebCore.vcxproj/WebCore.vcxproj:
     17        * WebCore.vcxproj/WebCore.vcxproj.filters:
     18        * WebCore.xcodeproj/project.pbxproj:
     19        * css/mathml.css:
     20        (mi, mo, mrow, mfenced, mfrac, msub, msup, msubsup, mmultiscripts, mprescripts, none, munder, mover, munderover, msqrt, mroot, merror, mphantom, mstyle, menclose):
     21        * mathml/MathMLTextElement.cpp:
     22        (WebCore::MathMLTextElement::didAttachRenderers):
     23        (WebCore::MathMLTextElement::childrenChanged):
     24        (WebCore::MathMLTextElement::createElementRenderer):
     25        * rendering/RenderObject.h:
     26        (WebCore::RenderObject::isRenderMathMLToken):
     27        * rendering/mathml/RenderMathMLToken.cpp: Added.
     28        (WebCore::RenderMathMLToken::RenderMathMLToken):
     29        (WebCore::RenderMathMLToken::addChild):
     30        (WebCore::RenderMathMLToken::createWrapperIfNeeded):
     31        (WebCore::RenderMathMLToken::updateTokenContent):
     32        (WebCore::RenderMathMLToken::updateStyle):
     33        (WebCore::RenderMathMLToken::styleDidChange):
     34        (WebCore::RenderMathMLToken::updateFromElement):
     35        * rendering/mathml/RenderMathMLToken.h: Added.
     36        (WebCore::RenderMathMLToken::element):
     37        (WebCore::RenderMathMLToken>):
     38
    1392014-02-06  Zoltan Horvath  <zoltan@webkit.org>
    240
  • trunk/Source/WebCore/GNUmakefile.list.am

    r163505 r163553  
    45324532        Source/WebCore/rendering/mathml/RenderMathMLScripts.cpp \
    45334533        Source/WebCore/rendering/mathml/RenderMathMLScripts.h \
     4534        Source/WebCore/rendering/mathml/RenderMathMLToken.cpp \
     4535        Source/WebCore/rendering/mathml/RenderMathMLToken.h \
    45344536        Source/WebCore/rendering/mathml/RenderMathMLUnderOver.cpp \
    45354537        Source/WebCore/rendering/mathml/RenderMathMLUnderOver.h \
  • trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj

    r163359 r163553  
    1121411214    <ClCompile Include="..\rendering\mathml\RenderMathMLSquareRoot.cpp" />
    1121511215    <ClCompile Include="..\rendering\mathml\RenderMathMLScripts.cpp" />
     11216    <ClCompile Include="..\rendering\mathml\RenderMathMLToken.cpp" />
    1121611217    <ClCompile Include="..\rendering\mathml\RenderMathMLUnderOver.cpp" />
    1121711218    <ClCompile Include="..\rendering\style\BasicShapes.cpp" />
     
    1990519906    <ClInclude Include="..\rendering\mathml\RenderMathMLSquareRoot.h" />
    1990619907    <ClInclude Include="..\rendering\mathml\RenderMathMLScripts.h" />
     19908    <ClInclude Include="..\rendering\mathml\RenderMathMLToken.h" />
    1990719909    <ClInclude Include="..\rendering\mathml\RenderMathMLUnderOver.h" />
    1990819910    <ClInclude Include="..\rendering\style\BasicShapes.h" />
  • trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj.filters

    r163359 r163553  
    27462746      <Filter>rendering\mathml</Filter>
    27472747    </ClCompile>
     2748    <ClCompile Include="..\rendering\mathml\RenderMathMLToken.cpp">
     2749      <Filter>rendering\mathml</Filter>
     2750    </ClCompile>
    27482751    <ClCompile Include="..\rendering\mathml\RenderMathMLUnderOver.cpp">
    27492752      <Filter>rendering\mathml</Filter>
     
    95899592    </ClInclude>
    95909593    <ClInclude Include="..\rendering\mathml\RenderMathMLScripts.h">
     9594      <Filter>rendering\mathml</Filter>
     9595    </ClInclude>
     9596    <ClInclude Include="..\rendering\mathml\RenderMathMLToken.h">
    95919597      <Filter>rendering\mathml</Filter>
    95929598    </ClInclude>
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r163515 r163553  
    14571457                439046E712DA25E800AF80A2 /* RenderMathMLScripts.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 439046D312DA25E800AF80A2 /* RenderMathMLScripts.cpp */; };
    14581458                439046E812DA25E800AF80A2 /* RenderMathMLScripts.h in Headers */ = {isa = PBXBuildFile; fileRef = 439046D412DA25E800AF80A2 /* RenderMathMLScripts.h */; };
     1459                439046EB12DA25E800AF80A9 /* RenderMathMLToken.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 439046D712DA25E800AF80A9 /* RenderMathMLToken.cpp */; };
     1460                439046EC12DA25E800AF80A9 /* RenderMathMLToken.h in Headers */ = {isa = PBXBuildFile; fileRef = 439046D812DA25E800AF80A9 /* RenderMathMLToken.h */; };
    14591461                439046E912DA25E800AF80A2 /* RenderMathMLUnderOver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 439046D512DA25E800AF80A2 /* RenderMathMLUnderOver.cpp */; };
    14601462                439046EA12DA25E800AF80A2 /* RenderMathMLUnderOver.h in Headers */ = {isa = PBXBuildFile; fileRef = 439046D612DA25E800AF80A2 /* RenderMathMLUnderOver.h */; };
     
    83228324                439046D312DA25E800AF80A2 /* RenderMathMLScripts.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = RenderMathMLScripts.cpp; path = mathml/RenderMathMLScripts.cpp; sourceTree = "<group>"; };
    83238325                439046D412DA25E800AF80A2 /* RenderMathMLScripts.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RenderMathMLScripts.h; path = mathml/RenderMathMLScripts.h; sourceTree = "<group>"; };
     8326                439046D712DA25E800AF80A9 /* RenderMathMLToken.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = RenderMathMLToken.cpp; path = mathml/RenderMathMLToken.cpp; sourceTree = "<group>"; };
     8327                439046D812DA25E800AF80A9 /* RenderMathMLToken.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RenderMathMLToken.h; path = mathml/RenderMathMLToken.h; sourceTree = "<group>"; };
    83248328                439046D512DA25E800AF80A2 /* RenderMathMLUnderOver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = RenderMathMLUnderOver.cpp; path = mathml/RenderMathMLUnderOver.cpp; sourceTree = "<group>"; };
    83258329                439046D612DA25E800AF80A2 /* RenderMathMLUnderOver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RenderMathMLUnderOver.h; path = mathml/RenderMathMLUnderOver.h; sourceTree = "<group>"; };
     
    1525815262                                439046D312DA25E800AF80A2 /* RenderMathMLScripts.cpp */,
    1525915263                                439046D412DA25E800AF80A2 /* RenderMathMLScripts.h */,
     15264                                439046D712DA25E800AF80A9 /* RenderMathMLToken.cpp */,
     15265                                439046D812DA25E800AF80A9 /* RenderMathMLToken.h */,
    1526015266                                439046D512DA25E800AF80A2 /* RenderMathMLUnderOver.cpp */,
    1526115267                                439046D612DA25E800AF80A2 /* RenderMathMLUnderOver.h */,
     
    2497924985                                0783228518013ED800999E0C /* MediaStreamAudioSource.h in Headers */,
    2498024986                                439046E812DA25E800AF80A2 /* RenderMathMLScripts.h in Headers */,
     24987                                439046EC12DA25E800AF80A9 /* RenderMathMLToken.h in Headers */,
    2498124988                                439046EA12DA25E800AF80A2 /* RenderMathMLUnderOver.h in Headers */,
    2498224989                                E4C279590CF9741900E97B98 /* RenderMedia.h in Headers */,
     
    2832828335                                439046E512DA25E800AF80A2 /* RenderMathMLSquareRoot.cpp in Sources */,
    2832928336                                439046E712DA25E800AF80A2 /* RenderMathMLScripts.cpp in Sources */,
     28337                                439046EB12DA25E800AF80A9 /* RenderMathMLToken.cpp in Sources */,
    2833028338                                439046E912DA25E800AF80A2 /* RenderMathMLUnderOver.cpp in Sources */,
    2833128339                                E4C279580CF9741900E97B98 /* RenderMedia.cpp in Sources */,
  • trunk/Source/WebCore/css/mathml.css

    r162933 r163553  
    4343}
    4444
    45 mo, mrow, mfenced, mfrac, msub, msup, msubsup, mmultiscripts, mprescripts, none, munder, mover, munderover, msqrt, mroot, merror, mphantom, mstyle, menclose {
     45mi, mo, mrow, mfenced, mfrac, msub, msup, msubsup, mmultiscripts, mprescripts, none, munder, mover, munderover, msqrt, mroot, merror, mphantom, mstyle, menclose {
    4646    display: -webkit-inline-flex !important;
    4747}
     
    9797
    9898mi {
    99     font-style: italic;
    10099    -webkit-padding-end: 0.1em;
    101100}
  • trunk/Source/WebCore/mathml/MathMLTextElement.cpp

    r161181 r163553  
    3434#include "RenderMathMLOperator.h"
    3535#include "RenderMathMLSpace.h"
     36#include "RenderMathMLToken.h"
    3637
    3738namespace WebCore {
     
    5354{
    5455    MathMLElement::didAttachRenderers();
    55     if (renderer())
    56         renderer()->updateFromElement();
     56    if (renderer()) {
     57        if (renderer()->isRenderMathMLToken())
     58            toRenderMathMLToken(renderer())->updateTokenContent();
     59        else
     60            renderer()->updateFromElement();
     61    }
    5762}
    5863
     
    6065{
    6166    MathMLElement::childrenChanged(change);
    62     if (renderer())
    63         renderer()->updateFromElement();
     67    if (renderer()) {
     68        if (renderer()->isRenderMathMLToken())
     69            toRenderMathMLToken(renderer())->updateTokenContent();
     70        else
     71            renderer()->updateFromElement();
     72    }
    6473}
    6574
     
    6877    if (hasLocalName(MathMLNames::moTag))
    6978        return createRenderer<RenderMathMLOperator>(*this, std::move(style));
     79    if (hasLocalName(MathMLNames::miTag))
     80        return createRenderer<RenderMathMLToken>(*this, std::move(style));
    7081    if (hasLocalName(MathMLNames::mspaceTag))
    7182        return createRenderer<RenderMathMLSpace>(*this, std::move(style));
  • trunk/Source/WebCore/rendering/RenderObject.h

    r163440 r163553  
    415415    virtual bool isRenderMathMLScripts() const { return false; }
    416416    virtual bool isRenderMathMLScriptsWrapper() const { return false; }
     417    virtual bool isRenderMathMLToken() const { return false; }
    417418    virtual bool isRenderMathMLUnderOver() const { return false; }
    418419#endif // ENABLE(MATHML)
Note: See TracChangeset for help on using the changeset viewer.