Changeset 203688 in webkit


Ignore:
Timestamp:
Jul 25, 2016 10:13:04 AM (8 years ago)
Author:
commit-queue@webkit.org
Message:

Introduce a MathMLOperatorElement class
https://bugs.webkit.org/show_bug.cgi?id=160034

Patch by Frederic Wang <fwang@igalia.com> on 2016-07-25
Reviewed by Darin Adler.

No new tests, rendering is unchaned.

  • CMakeLists.txt: Add MathMLOperatorElement to the build file.
  • WebCore.xcodeproj/project.pbxproj: Ditto.
  • mathml/MathMLAllInOne.cpp: Ditto.
  • mathml/MathMLOperatorElement.cpp: New DOM class for <mo> element.

(WebCore::MathMLOperatorElement::MathMLOperatorElement):
(WebCore::MathMLOperatorElement::create):
(WebCore::MathMLOperatorElement::parseAttribute): Handle mo attributes.
(WebCore::MathMLOperatorElement::createElementRenderer): Create RenderMathMLOperator.

  • mathml/MathMLOperatorElement.h: Declare a class deriving from MathMLTextElement.
  • mathml/MathMLTextElement.cpp: Remove all the RenderMathMLOperator parts.

(WebCore::MathMLTextElement::MathMLTextElement): Remove inline keyword so that the class can
be overriden.
(WebCore::MathMLTextElement::parseAttribute): Remove code handled in MathMLOperatorElement.
(WebCore::MathMLTextElement::createElementRenderer): Ditto.

  • mathml/MathMLTextElement.h: Make class and members overridable.
  • mathml/mathtags.in: Map mo to MathMLOperatorElement.
  • rendering/mathml/RenderMathMLOperator.cpp:

(WebCore::RenderMathMLOperator::RenderMathMLOperator): Make the constructor take a
MathMLOperatorElement.

  • rendering/mathml/RenderMathMLOperator.h: Ditto.
Location:
trunk/Source/WebCore
Files:
9 edited
2 copied

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/CMakeLists.txt

    r203675 r203688  
    19901990    mathml/MathMLMencloseElement.cpp
    19911991    mathml/MathMLOperatorDictionary.cpp
     1992    mathml/MathMLOperatorElement.cpp
    19921993    mathml/MathMLPaddedElement.cpp
    19931994    mathml/MathMLScriptsElement.cpp
  • trunk/Source/WebCore/ChangeLog

    r203686 r203688  
     12016-07-25  Frederic Wang  <fwang@igalia.com>
     2
     3        Introduce a MathMLOperatorElement class
     4        https://bugs.webkit.org/show_bug.cgi?id=160034
     5
     6        Reviewed by Darin Adler.
     7
     8        No new tests, rendering is unchaned.
     9
     10        * CMakeLists.txt: Add MathMLOperatorElement to the build file.
     11        * WebCore.xcodeproj/project.pbxproj: Ditto.
     12        * mathml/MathMLAllInOne.cpp: Ditto.
     13        * mathml/MathMLOperatorElement.cpp: New DOM class for <mo> element.
     14        (WebCore::MathMLOperatorElement::MathMLOperatorElement):
     15        (WebCore::MathMLOperatorElement::create):
     16        (WebCore::MathMLOperatorElement::parseAttribute): Handle mo attributes.
     17        (WebCore::MathMLOperatorElement::createElementRenderer): Create RenderMathMLOperator.
     18        * mathml/MathMLOperatorElement.h: Declare a class deriving from MathMLTextElement.
     19        * mathml/MathMLTextElement.cpp: Remove all the RenderMathMLOperator parts.
     20        (WebCore::MathMLTextElement::MathMLTextElement): Remove inline keyword so that the class can
     21        be overriden.
     22        (WebCore::MathMLTextElement::parseAttribute): Remove code handled in MathMLOperatorElement.
     23        (WebCore::MathMLTextElement::createElementRenderer): Ditto.
     24        * mathml/MathMLTextElement.h: Make class and members overridable.
     25        * mathml/mathtags.in: Map mo to MathMLOperatorElement.
     26        * rendering/mathml/RenderMathMLOperator.cpp:
     27        (WebCore::RenderMathMLOperator::RenderMathMLOperator): Make the constructor take a
     28        MathMLOperatorElement.
     29        * rendering/mathml/RenderMathMLOperator.h: Ditto.
     30
    1312016-07-25  Darin Adler  <darin@apple.com>
    232
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r203632 r203688  
    69066906                F98FFF4511A2676200F548E8 /* CSSOMUtils.h in Headers */ = {isa = PBXBuildFile; fileRef = F98FFF4311A2676200F548E8 /* CSSOMUtils.h */; };
    69076907                F9F0ED7A0DB50CA200D16DB9 /* XMLHttpRequestProgressEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = F9F0ED770DB50CA200D16DB9 /* XMLHttpRequestProgressEvent.h */; };
     6908                FA654A6B1108ABED002616F1 /* MathMLOperatorElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FA654A691108ABED002616F1 /* MathMLOperatorElement.cpp */; };
     6909                FA654A6C1108ABED002616F1 /* MathMLOperatorElement.h in Headers */ = {isa = PBXBuildFile; fileRef = FA654A6A1108ABED002616F1 /* MathMLOperatorElement.h */; };
    69086910                FA654A6B1108ABED002615E0 /* MathMLTextElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FA654A691108ABED002615E0 /* MathMLTextElement.cpp */; };
    69096911                FA654A6C1108ABED002615E0 /* MathMLTextElement.h in Headers */ = {isa = PBXBuildFile; fileRef = FA654A6A1108ABED002615E0 /* MathMLTextElement.h */; };
     
    1508615088                FA654A631108ABB7002615E0 /* mathml.css */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.css; path = mathml.css; sourceTree = "<group>"; };
    1508715089                FA654A671108ABE2002615E0 /* mathattrs.in */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = mathattrs.in; sourceTree = "<group>"; };
     15090                FA654A691108ABED002616F1 /* MathMLOperatorElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MathMLOperatorElement.cpp; sourceTree = "<group>"; };
     15091                FA654A6A1108ABED002616F1 /* MathMLOperatorElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MathMLOperatorElement.h; sourceTree = "<group>"; };
    1508815092                FA654A691108ABED002615E0 /* MathMLTextElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MathMLTextElement.cpp; sourceTree = "<group>"; };
    1508915093                FA654A6A1108ABED002615E0 /* MathMLTextElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MathMLTextElement.h; sourceTree = "<group>"; };
     
    2491124915                                4FA65A691108ABED002615E0 /* MathMLSpaceElement.cpp */,
    2491224916                                4FA65A6A1108ABED002615E0 /* MathMLSpaceElement.h */,
     24917                                FA654A691108ABED002616F1 /* MathMLOperatorElement.cpp */,
     24918                                FA654A6A1108ABED002616F1 /* MathMLOperatorElement.h */,
    2491324919                                FA654A691108ABED002615E0 /* MathMLTextElement.cpp */,
    2491424920                                FA654A6A1108ABED002615E0 /* MathMLTextElement.h */,
     
    2745227458                                439176E012DA25E17BAF80A2 /* MathMLStyle.h in Headers */,
    2745327459                                4FA65A6C1108ABED002615E0 /* MathMLSpaceElement.h in Headers */,
     27460                                FA654A6C1108ABED002616F1 /* MathMLOperatorElement.h in Headers */,
    2745427461                                FA654A6C1108ABED002615E0 /* MathMLTextElement.h in Headers */,
    2745527462                                FA654A6C1108ABED002626F1 /* MathMLUnderOverElement.h in Headers */,
     
    3128531292                                FED48390CED66C3255F72C59 /* MathMLSelectElement.cpp in Sources */,
    3128631293                                4FA65A6B1108ABED002615E0 /* MathMLSpaceElement.cpp in Sources */,
     31294                                FA654A6B1108ABED002616F1 /* MathMLOperatorElement.cpp in Sources */,
    3128731295                                FA654A6B1108ABED002615E0 /* MathMLTextElement.cpp in Sources */,
    3128831296                                FA654A6B1108ABED002626F1 /* MathMLUnderOverElement.cpp in Sources */,
  • trunk/Source/WebCore/mathml/MathMLAllInOne.cpp

    r203553 r203688  
    3232#include "MathMLMencloseElement.cpp"
    3333#include "MathMLOperatorDictionary.cpp"
     34#include "MathMLOperatorElement.cpp"
    3435#include "MathMLPaddedElement.cpp"
    3536#include "MathMLScriptsElement.cpp"
  • trunk/Source/WebCore/mathml/MathMLOperatorElement.cpp

    r203687 r203688  
    11/*
    2  * Copyright (C) 2009 Alex Milowski (alex@milowski.com). All rights reserved.
    3  * Copyright (C) 2010 Apple Inc. All rights reserved.
    4  * Copyright (C) 2016 Igalia S.L.
     2 * Copyright (C) 2016 Igalia S.L. All rights reserved.
    53 *
    64 * Redistribution and use in source and binary forms, with or without
     
    2422 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
    2523 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     24 *
    2625 */
    2726
    28 #pragma once
     27#include "config.h"
    2928
    3029#if ENABLE(MATHML)
    31 #include "MathMLElement.h"
     30#include "MathMLOperatorElement.h"
     31
     32#include "RenderMathMLOperator.h"
    3233
    3334namespace WebCore {
    3435
    35 class MathMLTextElement final : public MathMLElement {
    36 public:
    37     static Ref<MathMLTextElement> create(const QualifiedName& tagName, Document&);
    38     bool acceptsMathVariantAttribute() final { return true; }
     36using namespace MathMLNames;
    3937
    40 private:
    41     MathMLTextElement(const QualifiedName& tagName, Document&);
     38MathMLOperatorElement::MathMLOperatorElement(const QualifiedName& tagName, Document& document)
     39    : MathMLTextElement(tagName, document)
     40{
     41}
    4242
    43     RenderPtr<RenderElement> createElementRenderer(RenderStyle&&, const RenderTreePosition&) final;
    44     bool childShouldCreateRenderer(const Node&) const final;
     43Ref<MathMLOperatorElement> MathMLOperatorElement::create(const QualifiedName& tagName, Document& document)
     44{
     45    return adoptRef(*new MathMLOperatorElement(tagName, document));
     46}
    4547
    46     void childrenChanged(const ChildChange&) final;
    47     void parseAttribute(const QualifiedName&, const AtomicString&) final;
    48     void didAttachRenderers() final;
     48void MathMLOperatorElement::parseAttribute(const QualifiedName& name, const AtomicString& value)
     49{
     50    if ((name == stretchyAttr || name == lspaceAttr || name == rspaceAttr || name == movablelimitsAttr) && renderer()) {
     51        downcast<RenderMathMLOperator>(*renderer()).updateFromElement();
     52        return;
     53    }
    4954
    50     bool isPresentationMathML() const final { return true; }
    51 };
     55    MathMLTextElement::parseAttribute(name, value);
     56}
     57
     58RenderPtr<RenderElement> MathMLOperatorElement::createElementRenderer(RenderStyle&& style, const RenderTreePosition&)
     59{
     60    ASSERT(hasTagName(MathMLNames::moTag));
     61    return createRenderer<RenderMathMLOperator>(*this, WTFMove(style));
     62}
    5263
    5364}
  • trunk/Source/WebCore/mathml/MathMLOperatorElement.h

    r203687 r203688  
    11/*
    2  * Copyright (C) 2009 Alex Milowski (alex@milowski.com). All rights reserved.
    3  * Copyright (C) 2010 Apple Inc. All rights reserved.
    4  * Copyright (C) 2016 Igalia S.L.
     2 * Copyright (C) 2016 Igalia S.L. All rights reserved.
    53 *
    64 * Redistribution and use in source and binary forms, with or without
     
    2927
    3028#if ENABLE(MATHML)
    31 #include "MathMLElement.h"
     29#include "MathMLTextElement.h"
    3230
    3331namespace WebCore {
    3432
    35 class MathMLTextElement final : public MathMLElement {
     33class MathMLOperatorElement final : public MathMLTextElement {
    3634public:
    37     static Ref<MathMLTextElement> create(const QualifiedName& tagName, Document&);
    38     bool acceptsMathVariantAttribute() final { return true; }
    39 
     35    static Ref<MathMLOperatorElement> create(const QualifiedName& tagName, Document&);
    4036private:
    41     MathMLTextElement(const QualifiedName& tagName, Document&);
    42 
     37    MathMLOperatorElement(const QualifiedName& tagName, Document&);
    4338    RenderPtr<RenderElement> createElementRenderer(RenderStyle&&, const RenderTreePosition&) final;
    44     bool childShouldCreateRenderer(const Node&) const final;
    45 
    46     void childrenChanged(const ChildChange&) final;
    4739    void parseAttribute(const QualifiedName&, const AtomicString&) final;
    48     void didAttachRenderers() final;
    49 
    50     bool isPresentationMathML() const final { return true; }
    5140};
    5241
  • trunk/Source/WebCore/mathml/MathMLTextElement.cpp

    r203679 r203688  
    3232
    3333#include "MathMLNames.h"
    34 #include "RenderMathMLOperator.h"
    3534#include "RenderMathMLToken.h"
    3635
     
    3938using namespace MathMLNames;
    4039
    41 inline MathMLTextElement::MathMLTextElement(const QualifiedName& tagName, Document& document)
     40MathMLTextElement::MathMLTextElement(const QualifiedName& tagName, Document& document)
    4241    : MathMLElement(tagName, document)
    4342{
     
    6665void MathMLTextElement::parseAttribute(const QualifiedName& name, const AtomicString& value)
    6766{
    68     if (name == stretchyAttr || name == lspaceAttr || name == rspaceAttr || name == movablelimitsAttr) {
    69         if (is<RenderMathMLOperator>(renderer()))
    70             downcast<RenderMathMLOperator>(*renderer()).updateFromElement();
    71         return;
    72     }
    73 
    7467    if (name == mathvariantAttr) {
    7568        m_mathVariant.dirty = true;
     
    8376RenderPtr<RenderElement> MathMLTextElement::createElementRenderer(RenderStyle&& style, const RenderTreePosition& insertionPosition)
    8477{
    85     if (hasTagName(MathMLNames::moTag))
    86         return createRenderer<RenderMathMLOperator>(*this, WTFMove(style));
    8778    if (hasTagName(MathMLNames::annotationTag))
    8879        return MathMLElement::createElementRenderer(WTFMove(style), insertionPosition);
  • trunk/Source/WebCore/mathml/MathMLTextElement.h

    r203679 r203688  
    3333namespace WebCore {
    3434
    35 class MathMLTextElement final : public MathMLElement {
     35class MathMLTextElement : public MathMLElement {
    3636public:
    3737    static Ref<MathMLTextElement> create(const QualifiedName& tagName, Document&);
    3838    bool acceptsMathVariantAttribute() final { return true; }
    3939
     40protected:
     41    MathMLTextElement(const QualifiedName& tagName, Document&);
     42    void parseAttribute(const QualifiedName&, const AtomicString&) override;
     43
    4044private:
    41     MathMLTextElement(const QualifiedName& tagName, Document&);
    42 
    43     RenderPtr<RenderElement> createElementRenderer(RenderStyle&&, const RenderTreePosition&) final;
     45    RenderPtr<RenderElement> createElementRenderer(RenderStyle&&, const RenderTreePosition&) override;
    4446    bool childShouldCreateRenderer(const Node&) const final;
    4547
    4648    void childrenChanged(const ChildChange&) final;
    47     void parseAttribute(const QualifiedName&, const AtomicString&) final;
    4849    void didAttachRenderers() final;
    4950
  • trunk/Source/WebCore/mathml/mathtags.in

    r203553 r203688  
    2323mi interfaceName=MathMLTextElement
    2424mn interfaceName=MathMLTextElement
    25 mo interfaceName=MathMLTextElement
     25mo interfaceName=MathMLOperatorElement
    2626mtext interfaceName=MathMLTextElement
    2727ms interfaceName=MathMLTextElement
  • trunk/Source/WebCore/rendering/mathml/RenderMathMLOperator.cpp

    r203324 r203688  
    3434#include "FontSelector.h"
    3535#include "MathMLNames.h"
     36#include "MathMLOperatorElement.h"
    3637#include "PaintInfo.h"
    3738#include "RenderBlockFlow.h"
     
    4748using namespace MathMLNames;
    4849
    49 RenderMathMLOperator::RenderMathMLOperator(MathMLElement& element, RenderStyle&& style)
     50RenderMathMLOperator::RenderMathMLOperator(MathMLOperatorElement& element, RenderStyle&& style)
    5051    : RenderMathMLToken(element, WTFMove(style))
    5152    , m_stretchHeightAboveBaseline(0)
  • trunk/Source/WebCore/rendering/mathml/RenderMathMLOperator.h

    r203289 r203688  
    3535namespace WebCore {
    3636
     37class MathMLOperatorElement;
     38
    3739class RenderMathMLOperator final : public RenderMathMLToken {
    3840public:
    39     RenderMathMLOperator(MathMLElement&, RenderStyle&&);
     41    RenderMathMLOperator(MathMLOperatorElement&, RenderStyle&&);
    4042    RenderMathMLOperator(Document&, RenderStyle&&, const String& operatorString, MathMLOperatorDictionary::Form, unsigned short flags = 0);
    4143
Note: See TracChangeset for help on using the changeset viewer.