Title: [204692] trunk/Source/WebCore
Revision
204692
Author
[email protected]
Date
2016-08-21 05:18:43 -0700 (Sun, 21 Aug 2016)

Log Message

Introduce a MathMLAnnotationElement class for the annotation/annotation-xml elements
https://bugs.webkit.org/show_bug.cgi?id=160540

Patch by Frederic Wang <[email protected]> on 2016-08-21
Reviewed by Darin Adler.

The <annotation> element can only contain text whereas the <annotation-xml> element can
contain some elements as described in the HTML5 RelaxNG schema. For this reason, they have
been implemented in the separate MathMLTextElement and MathMLInlineContainerElement
respectively. However, they are actually closer to each other than to token elements or
presentation containers. In particular they support very different attributes and are
considered by the <semantics> tag. Hence we move their implementations in a new
MathMLAnnotation class.

No new tests, already covered by existing tests.

* CMakeLists.txt: Add MathMLAnnotationElement.
* mathml/MathMLAllInOne.cpp: Ditto.
* WebCore.xcodeproj/project.pbxproj: Ditto.
* mathml/MathMLAnnotationElement.cpp: Added.
(WebCore::MathMLAnnotationElement::MathMLAnnotationElement): ASSERT that this class is only
for annotation and annotation-xml.
(WebCore::MathMLAnnotationElement::create):
(WebCore::MathMLAnnotationElement::createElementRenderer): Move implementation from
MathMLTextElement and MathMLInlineContainerElement.
(WebCore::MathMLAnnotationElement::childShouldCreateRenderer): Move implementation from
MathMLTextElement and MathMLElement.
(WebCore::MathMLAnnotationElement::attributeChanged): Move implementation from MathMLElement.
* mathml/MathMLAnnotationElement.h: Override isSemanticAnnotation and isPresentationMathML
to return true.
* mathml/MathMLElement.cpp:
(WebCore::MathMLElement::childShouldCreateRenderer): Move the annotation-xml case into
MathMLAnnotationElement.
(WebCore::MathMLElement::attributeChanged): Deleted. This was only used for semantic
annotations and so the code is moved into MathMLAnnotationElement.
* mathml/MathMLElement.h:
(WebCore::MathMLElement::isMathMLToken): Return false and let derived class override this.
(WebCore::MathMLElement::isSemanticAnnotation): Ditto.
(WebCore::MathMLElement::updateSelectedChild): Make this public so that is can be used
by MathMLAnnotationElement::attributeChanged.
* mathml/MathMLInlineContainerElement.cpp:
(WebCore::MathMLInlineContainerElement::createElementRenderer): The annotation-xml case is
now handled in MathMLAnnotationElement.
* mathml/MathMLTextElement.cpp:
(WebCore::MathMLTextElement::createElementRenderer): The annotation case is handled is now
handled in  MathMLAnnotationElement.
(WebCore::MathMLTextElement::childShouldCreateRenderer): Ditto.
* mathml/MathMLTextElement.h: Override isToken to return true.
* mathml/mathtags.in: Map annotation and annotation-xml to MathMLAnnotationElement.

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebCore/CMakeLists.txt (204691 => 204692)


--- trunk/Source/WebCore/CMakeLists.txt	2016-08-21 10:55:31 UTC (rev 204691)
+++ trunk/Source/WebCore/CMakeLists.txt	2016-08-21 12:18:43 UTC (rev 204692)
@@ -2002,6 +2002,7 @@
     loader/icon/IconRecord.cpp
     loader/icon/PageURLRecord.cpp
 
+    mathml/MathMLAnnotationElement.cpp
     mathml/MathMLElement.cpp
     mathml/MathMLFractionElement.cpp
     mathml/MathMLInlineContainerElement.cpp

Modified: trunk/Source/WebCore/ChangeLog (204691 => 204692)


--- trunk/Source/WebCore/ChangeLog	2016-08-21 10:55:31 UTC (rev 204691)
+++ trunk/Source/WebCore/ChangeLog	2016-08-21 12:18:43 UTC (rev 204692)
@@ -1,3 +1,54 @@
+2016-08-21  Frederic Wang  <[email protected]>
+
+        Introduce a MathMLAnnotationElement class for the annotation/annotation-xml elements
+        https://bugs.webkit.org/show_bug.cgi?id=160540
+
+        Reviewed by Darin Adler.
+
+        The <annotation> element can only contain text whereas the <annotation-xml> element can
+        contain some elements as described in the HTML5 RelaxNG schema. For this reason, they have
+        been implemented in the separate MathMLTextElement and MathMLInlineContainerElement
+        respectively. However, they are actually closer to each other than to token elements or
+        presentation containers. In particular they support very different attributes and are
+        considered by the <semantics> tag. Hence we move their implementations in a new
+        MathMLAnnotation class.
+
+        No new tests, already covered by existing tests.
+
+        * CMakeLists.txt: Add MathMLAnnotationElement.
+        * mathml/MathMLAllInOne.cpp: Ditto.
+        * WebCore.xcodeproj/project.pbxproj: Ditto.
+        * mathml/MathMLAnnotationElement.cpp: Added.
+        (WebCore::MathMLAnnotationElement::MathMLAnnotationElement): ASSERT that this class is only
+        for annotation and annotation-xml.
+        (WebCore::MathMLAnnotationElement::create):
+        (WebCore::MathMLAnnotationElement::createElementRenderer): Move implementation from
+        MathMLTextElement and MathMLInlineContainerElement.
+        (WebCore::MathMLAnnotationElement::childShouldCreateRenderer): Move implementation from
+        MathMLTextElement and MathMLElement.
+        (WebCore::MathMLAnnotationElement::attributeChanged): Move implementation from MathMLElement.
+        * mathml/MathMLAnnotationElement.h: Override isSemanticAnnotation and isPresentationMathML
+        to return true.
+        * mathml/MathMLElement.cpp:
+        (WebCore::MathMLElement::childShouldCreateRenderer): Move the annotation-xml case into
+        MathMLAnnotationElement.
+        (WebCore::MathMLElement::attributeChanged): Deleted. This was only used for semantic
+        annotations and so the code is moved into MathMLAnnotationElement.
+        * mathml/MathMLElement.h:
+        (WebCore::MathMLElement::isMathMLToken): Return false and let derived class override this.
+        (WebCore::MathMLElement::isSemanticAnnotation): Ditto.
+        (WebCore::MathMLElement::updateSelectedChild): Make this public so that is can be used
+        by MathMLAnnotationElement::attributeChanged.
+        * mathml/MathMLInlineContainerElement.cpp:
+        (WebCore::MathMLInlineContainerElement::createElementRenderer): The annotation-xml case is
+        now handled in MathMLAnnotationElement.
+        * mathml/MathMLTextElement.cpp:
+        (WebCore::MathMLTextElement::createElementRenderer): The annotation case is handled is now
+        handled in  MathMLAnnotationElement.
+        (WebCore::MathMLTextElement::childShouldCreateRenderer): Ditto.
+        * mathml/MathMLTextElement.h: Override isToken to return true.
+        * mathml/mathtags.in: Map annotation and annotation-xml to MathMLAnnotationElement.
+
 2016-08-21  Michael Catanzaro  <[email protected]>
 
         [GTK] Clean up CursorGtk.cpp

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (204691 => 204692)


--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2016-08-21 10:55:31 UTC (rev 204691)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2016-08-21 12:18:43 UTC (rev 204692)
@@ -6715,6 +6715,8 @@
 		FA654A6C1108ABED002615E0 /* MathMLTextElement.h in Headers */ = {isa = PBXBuildFile; fileRef = FA654A6A1108ABED002615E0 /* MathMLTextElement.h */; };
 		FA654A6C1108ABED002616F1 /* MathMLOperatorElement.h in Headers */ = {isa = PBXBuildFile; fileRef = FA654A6A1108ABED002616F1 /* MathMLOperatorElement.h */; };
 		FA654A6C1108ABED002626F1 /* MathMLUnderOverElement.h in Headers */ = {isa = PBXBuildFile; fileRef = FA654A6A1108ABED002626F1 /* MathMLUnderOverElement.h */; };
+		FABE72F41059C1EB00D888CC /* MathMLAnnotationElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FABE72ED1059C1EB00D888CC /* MathMLAnnotationElement.cpp */; };
+		FABE72F51059C1EB00D888CC /* MathMLAnnotationElement.h in Headers */ = {isa = PBXBuildFile; fileRef = FABE72EE1059C1EB00D888CC /* MathMLAnnotationElement.h */; };
 		FABE72F41059C1EB00D999DD /* MathMLElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FABE72ED1059C1EB00D999DD /* MathMLElement.cpp */; };
 		FABE72F51059C1EB00D999DD /* MathMLElement.h in Headers */ = {isa = PBXBuildFile; fileRef = FABE72EE1059C1EB00D999DD /* MathMLElement.h */; };
 		FABE72F61059C1EB00D999DD /* MathMLInlineContainerElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FABE72EF1059C1EB00D999DD /* MathMLInlineContainerElement.cpp */; };
@@ -14692,6 +14694,8 @@
 		FA654A6A1108ABED002616F1 /* MathMLOperatorElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MathMLOperatorElement.h; sourceTree = "<group>"; };
 		FA654A6A1108ABED002626F1 /* MathMLUnderOverElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MathMLUnderOverElement.h; sourceTree = "<group>"; };
 		FA6E466FCD0418A9966A5B60 /* DNSResolveQueue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DNSResolveQueue.h; sourceTree = "<group>"; };
+		FABE72ED1059C1EB00D888CC /* MathMLAnnotationElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MathMLAnnotationElement.cpp; sourceTree = "<group>"; };
+		FABE72EE1059C1EB00D888CC /* MathMLAnnotationElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MathMLAnnotationElement.h; sourceTree = "<group>"; };
 		FABE72ED1059C1EB00D999DD /* MathMLElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MathMLElement.cpp; sourceTree = "<group>"; };
 		FABE72EE1059C1EB00D999DD /* MathMLElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MathMLElement.h; sourceTree = "<group>"; };
 		FABE72EF1059C1EB00D999DD /* MathMLInlineContainerElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MathMLInlineContainerElement.cpp; sourceTree = "<group>"; };
@@ -24344,6 +24348,8 @@
 			isa = PBXGroup;
 			children = (
 				FA654A671108ABE2002615E0 /* mathattrs.in */,
+				FABE72ED1059C1EB00D888CC /* MathMLAnnotationElement.cpp */,
+				FABE72EE1059C1EB00D888CC /* MathMLAnnotationElement.h */,
 				FABE72ED1059C1EB00D999DD /* MathMLElement.cpp */,
 				FABE72EE1059C1EB00D999DD /* MathMLElement.h */,
 				0BCF83EF1059C1EB00D999DD /* MathMLFractionElement.cpp */,
@@ -26791,6 +26797,7 @@
 				93309DF8099E64920056E581 /* markup.h in Headers */,
 				9728C3141268E4390041E89B /* MarkupAccumulator.h in Headers */,
 				00C60E3F13D76D7E0092A275 /* MarkupTokenizerInlines.h in Headers */,
+				FABE72F51059C1EB00D888CC /* MathMLAnnotationElement.h in Headers */,
 				FABE72F51059C1EB00D999DD /* MathMLElement.h in Headers */,
 				44A28AAC12DFB8AC00AE923B /* MathMLElementFactory.h in Headers */,
 				0BCF83F71059C1EB00D999DD /* MathMLFractionElement.h in Headers */,
@@ -30599,6 +30606,7 @@
 				1A8F6BC50DB55CDC001DB794 /* ManifestParser.cpp in Sources */,
 				93309DF7099E64920056E581 /* markup.cpp in Sources */,
 				9728C3131268E4390041E89B /* MarkupAccumulator.cpp in Sources */,
+				FABE72F41059C1EB00D888CC /* MathMLAnnotationElement.cpp in Sources */,
 				FABE72F41059C1EB00D999DD /* MathMLElement.cpp in Sources */,
 				FABE72FD1059C21100D999DD /* MathMLElementFactory.cpp in Sources */,
 				0BCF83F61059C1EB00D999DD /* MathMLFractionElement.cpp in Sources */,

Modified: trunk/Source/WebCore/mathml/MathMLAllInOne.cpp (204691 => 204692)


--- trunk/Source/WebCore/mathml/MathMLAllInOne.cpp	2016-08-21 10:55:31 UTC (rev 204691)
+++ trunk/Source/WebCore/mathml/MathMLAllInOne.cpp	2016-08-21 12:18:43 UTC (rev 204692)
@@ -25,6 +25,7 @@
 
 // This all-in-one cpp file cuts down on template bloat to allow us to build our Windows release build.
 
+#include "MathMLAnnotationElement.cpp"
 #include "MathMLElement.cpp"
 #include "MathMLFractionElement.cpp"
 #include "MathMLInlineContainerElement.cpp"

Added: trunk/Source/WebCore/mathml/MathMLAnnotationElement.cpp (0 => 204692)


--- trunk/Source/WebCore/mathml/MathMLAnnotationElement.cpp	                        (rev 0)
+++ trunk/Source/WebCore/mathml/MathMLAnnotationElement.cpp	2016-08-21 12:18:43 UTC (rev 204692)
@@ -0,0 +1,108 @@
+/*
+ * Copyright (C) 2016 Igalia S.L. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#include "config.h"
+
+#if ENABLE(MATHML)
+#include "MathMLAnnotationElement.h"
+
+#include "HTMLHtmlElement.h"
+#include "MathMLMathElement.h"
+#include "MathMLNames.h"
+#include "MathMLSelectElement.h"
+#include "RenderMathMLRow.h"
+#include "SVGSVGElement.h"
+
+namespace WebCore {
+
+using namespace MathMLNames;
+
+MathMLAnnotationElement::MathMLAnnotationElement(const QualifiedName& tagName, Document& document)
+    : MathMLElement(tagName, document)
+{
+    ASSERT(hasTagName(annotationTag) || hasTagName(annotation_xmlTag));
+}
+
+Ref<MathMLAnnotationElement> MathMLAnnotationElement::create(const QualifiedName& tagName, Document& document)
+{
+    return adoptRef(*new MathMLAnnotationElement(tagName, document));
+}
+
+RenderPtr<RenderElement> MathMLAnnotationElement::createElementRenderer(RenderStyle&& style, const RenderTreePosition& insertionPosition)
+{
+    if (hasTagName(MathMLNames::annotationTag))
+        return MathMLElement::createElementRenderer(WTFMove(style), insertionPosition);
+
+    // FIXME: Do we really need to create a RenderMathMLRow?
+    ASSERT(hasTagName(annotation_xmlTag));
+    return createRenderer<RenderMathMLRow>(*this, WTFMove(style));
+}
+
+bool MathMLAnnotationElement::childShouldCreateRenderer(const Node& child) const
+{
+    // For <annotation>, only text children are allowed.
+    if (hasTagName(MathMLNames::annotationTag))
+        return child.isTextNode();
+
+    // For <annotation-xml>, we follow these definitions from the HTML5 RelaxNG schema:
+    // - annotation-xml.model.mathml
+    // - annotation-xml.model.svg
+    // - annotation-xml.model.xhtml
+
+    ASSERT(hasTagName(annotation_xmlTag));
+    auto& value = attributeWithoutSynchronization(encodingAttr);
+
+    if (is<MathMLElement>(child) && (MathMLSelectElement::isMathMLEncoding(value) || MathMLSelectElement::isHTMLEncoding(value))) {
+        auto& mathmlElement = downcast<MathMLElement>(child);
+        return is<MathMLMathElement>(mathmlElement);
+    }
+
+    if (is<SVGElement>(child) && (MathMLSelectElement::isSVGEncoding(value) || MathMLSelectElement::isHTMLEncoding(value))) {
+        auto& svgElement = downcast<SVGElement>(child);
+        return is<SVGSVGElement>(svgElement);
+    }
+
+    if (is<HTMLElement>(child) && MathMLSelectElement::isHTMLEncoding(value)) {
+        auto& htmlElement = downcast<HTMLElement>(child);
+        return is<HTMLHtmlElement>(htmlElement) || (isFlowContent(htmlElement) && StyledElement::childShouldCreateRenderer(child));
+    }
+
+    return false;
+}
+
+void MathMLAnnotationElement::attributeChanged(const QualifiedName& name, const AtomicString& oldValue, const AtomicString& newValue, AttributeModificationReason reason)
+{
+    if (name == MathMLNames::srcAttr || name == MathMLNames::encodingAttr) {
+        auto* parent = parentElement();
+        if (is<MathMLElement>(parent) && parent->hasTagName(semanticsTag))
+            downcast<MathMLElement>(*parent).updateSelectedChild();
+    }
+    MathMLElement::attributeChanged(name, oldValue, newValue, reason);
+}
+
+}
+
+#endif // ENABLE(MATHML)

Copied: trunk/Source/WebCore/mathml/MathMLAnnotationElement.h (from rev 204691, trunk/Source/WebCore/mathml/MathMLTextElement.h) (0 => 204692)


--- trunk/Source/WebCore/mathml/MathMLAnnotationElement.h	                        (rev 0)
+++ trunk/Source/WebCore/mathml/MathMLAnnotationElement.h	2016-08-21 12:18:43 UTC (rev 204692)
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2016 Igalia S.L. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#if ENABLE(MATHML)
+#include "MathMLElement.h"
+
+namespace WebCore {
+
+class MathMLAnnotationElement final : public MathMLElement {
+public:
+    static Ref<MathMLAnnotationElement> create(const QualifiedName& tagName, Document&);
+private:
+    MathMLAnnotationElement(const QualifiedName& tagName, Document&);
+    RenderPtr<RenderElement> createElementRenderer(RenderStyle&&, const RenderTreePosition&) final;
+
+    bool isSemanticAnnotation() const final { return true; }
+    bool isPresentationMathML() const final { return true; }
+
+    bool childShouldCreateRenderer(const Node&) const final;
+    void attributeChanged(const QualifiedName&, const AtomicString& oldValue, const AtomicString& newValue, AttributeModificationReason) final;
+};
+
+}
+
+#endif // ENABLE(MATHML)

Modified: trunk/Source/WebCore/mathml/MathMLElement.cpp (204691 => 204692)


--- trunk/Source/WebCore/mathml/MathMLElement.cpp	2016-08-21 10:55:31 UTC (rev 204691)
+++ trunk/Source/WebCore/mathml/MathMLElement.cpp	2016-08-21 12:18:43 UTC (rev 204692)
@@ -279,43 +279,10 @@
 
 bool MathMLElement::childShouldCreateRenderer(const Node& child) const
 {
-    if (hasTagName(annotation_xmlTag)) {
-        auto& value = attributeWithoutSynchronization(MathMLNames::encodingAttr);
-
-        // See annotation-xml.model.mathml, annotation-xml.model.svg and annotation-xml.model.xhtml in the HTML5 RelaxNG schema.
-
-        if (is<MathMLElement>(child) && (MathMLSelectElement::isMathMLEncoding(value) || MathMLSelectElement::isHTMLEncoding(value))) {
-            auto& mathmlElement = downcast<MathMLElement>(child);
-            return is<MathMLMathElement>(mathmlElement);
-        }
-
-        if (is<SVGElement>(child) && (MathMLSelectElement::isSVGEncoding(value) || MathMLSelectElement::isHTMLEncoding(value))) {
-            auto& svgElement = downcast<SVGElement>(child);
-            return is<SVGSVGElement>(svgElement);
-        }
-
-        if (is<HTMLElement>(child) && MathMLSelectElement::isHTMLEncoding(value)) {
-            auto& htmlElement = downcast<HTMLElement>(child);
-            return is<HTMLHtmlElement>(htmlElement) || (isFlowContent(htmlElement) && StyledElement::childShouldCreateRenderer(child));
-        }
-
-        return false;
-    }
-
     // In general, only MathML children are allowed. Text nodes are only visible in token MathML elements.
     return is<MathMLElement>(child);
 }
 
-void MathMLElement::attributeChanged(const QualifiedName& name, const AtomicString& oldValue, const AtomicString& newValue, AttributeModificationReason reason)
-{
-    if (isSemanticAnnotation() && (name == MathMLNames::srcAttr || name == MathMLNames::encodingAttr)) {
-        auto* parent = parentElement();
-        if (is<MathMLElement>(parent) && parent->hasTagName(semanticsTag))
-            downcast<MathMLElement>(*parent).updateSelectedChild();
-    }
-    StyledElement::attributeChanged(name, oldValue, newValue, reason);
-}
-
 bool MathMLElement::willRespondToMouseClickEvents()
 {
     return isLink() || StyledElement::willRespondToMouseClickEvents();

Modified: trunk/Source/WebCore/mathml/MathMLElement.h (204691 => 204692)


--- trunk/Source/WebCore/mathml/MathMLElement.h	2016-08-21 10:55:31 UTC (rev 204691)
+++ trunk/Source/WebCore/mathml/MathMLElement.h	2016-08-21 12:18:43 UTC (rev 204692)
@@ -42,16 +42,8 @@
     unsigned colSpan() const;
     unsigned rowSpan() const;
 
-    bool isMathMLToken() const
-    {
-        return hasTagName(MathMLNames::miTag) || hasTagName(MathMLNames::mnTag) || hasTagName(MathMLNames::moTag) || hasTagName(MathMLNames::msTag) || hasTagName(MathMLNames::mtextTag);
-    }
-
-    bool isSemanticAnnotation() const
-    {
-        return hasTagName(MathMLNames::annotationTag) || hasTagName(MathMLNames::annotation_xmlTag);
-    }
-
+    virtual bool isMathMLToken() const { return false; }
+    virtual bool isSemanticAnnotation() const { return false; }
     virtual bool isPresentationMathML() const;
 
     bool hasTagName(const MathMLQualifiedName& name) const { return hasLocalName(name.localName()); }
@@ -96,12 +88,13 @@
     virtual Optional<bool> specifiedDisplayStyle();
     Optional<MathVariant> specifiedMathVariant();
 
+    virtual void updateSelectedChild() { }
+
 protected:
     MathMLElement(const QualifiedName& tagName, Document&);
 
     void parseAttribute(const QualifiedName&, const AtomicString&) override;
     bool childShouldCreateRenderer(const Node&) const override;
-    void attributeChanged(const QualifiedName&, const AtomicString& oldValue, const AtomicString& newValue, AttributeModificationReason) override;
 
     bool isPresentationAttribute(const QualifiedName&) const override;
     void collectStyleForPresentationAttribute(const QualifiedName&, const AtomicString&, MutableStyleProperties&) override;
@@ -123,7 +116,6 @@
     Optional<MathVariant> m_mathVariant;
 
 private:
-    virtual void updateSelectedChild() { }
     static Length parseNumberAndUnit(const StringView&);
     static Length parseNamedSpace(const StringView&);
     static MathVariant parseMathVariantAttribute(const AtomicString& attributeValue);

Modified: trunk/Source/WebCore/mathml/MathMLInlineContainerElement.cpp (204691 => 204692)


--- trunk/Source/WebCore/mathml/MathMLInlineContainerElement.cpp	2016-08-21 10:55:31 UTC (rev 204691)
+++ trunk/Source/WebCore/mathml/MathMLInlineContainerElement.cpp	2016-08-21 12:18:43 UTC (rev 204692)
@@ -65,7 +65,7 @@
 
 RenderPtr<RenderElement> MathMLInlineContainerElement::createElementRenderer(RenderStyle&& style, const RenderTreePosition&)
 {
-    if (hasTagName(annotation_xmlTag) || hasTagName(merrorTag) || hasTagName(mphantomTag) || hasTagName(mrowTag) || hasTagName(mstyleTag))
+    if (hasTagName(merrorTag) || hasTagName(mphantomTag) || hasTagName(mrowTag) || hasTagName(mstyleTag))
         return createRenderer<RenderMathMLRow>(*this, WTFMove(style));
     if (hasTagName(msqrtTag) || hasTagName(mrootTag))
         return createRenderer<RenderMathMLRoot>(*this, WTFMove(style));

Modified: trunk/Source/WebCore/mathml/MathMLTextElement.cpp (204691 => 204692)


--- trunk/Source/WebCore/mathml/MathMLTextElement.cpp	2016-08-21 10:55:31 UTC (rev 204691)
+++ trunk/Source/WebCore/mathml/MathMLTextElement.cpp	2016-08-21 12:18:43 UTC (rev 204692)
@@ -73,11 +73,8 @@
     MathMLElement::parseAttribute(name, value);
 }
 
-RenderPtr<RenderElement> MathMLTextElement::createElementRenderer(RenderStyle&& style, const RenderTreePosition& insertionPosition)
+RenderPtr<RenderElement> MathMLTextElement::createElementRenderer(RenderStyle&& style, const RenderTreePosition&)
 {
-    if (hasTagName(MathMLNames::annotationTag))
-        return MathMLElement::createElementRenderer(WTFMove(style), insertionPosition);
-
     ASSERT(hasTagName(MathMLNames::miTag) || hasTagName(MathMLNames::mnTag) || hasTagName(MathMLNames::msTag) || hasTagName(MathMLNames::mtextTag));
 
     return createRenderer<RenderMathMLToken>(*this, WTFMove(style));
@@ -88,9 +85,6 @@
     if (hasTagName(MathMLNames::mspaceTag))
         return false;
 
-    if (hasTagName(MathMLNames::annotationTag))
-        return child.isTextNode();
-
     // The HTML specification defines <mi>, <mo>, <mn>, <ms> and <mtext> as insertion points.
     return isPhrasingContent(child) && StyledElement::childShouldCreateRenderer(child);
 }

Modified: trunk/Source/WebCore/mathml/MathMLTextElement.h (204691 => 204692)


--- trunk/Source/WebCore/mathml/MathMLTextElement.h	2016-08-21 10:55:31 UTC (rev 204691)
+++ trunk/Source/WebCore/mathml/MathMLTextElement.h	2016-08-21 12:18:43 UTC (rev 204692)
@@ -48,6 +48,7 @@
 
     void didAttachRenderers() final;
 
+    bool isMathMLToken() const final { return true; }
     bool isPresentationMathML() const final { return true; }
 };
 

Modified: trunk/Source/WebCore/mathml/mathtags.in (204691 => 204692)


--- trunk/Source/WebCore/mathml/mathtags.in	2016-08-21 10:55:31 UTC (rev 204691)
+++ trunk/Source/WebCore/mathml/mathtags.in	2016-08-21 12:18:43 UTC (rev 204692)
@@ -3,8 +3,8 @@
 guardFactoryWith="ENABLE(MATHML)"
 fallbackInterfaceName="MathMLElement"
 
-annotation interfaceName=MathMLTextElement
-annotation-xml interfaceName=MathMLInlineContainerElement
+annotation interfaceName=MathMLAnnotationElement
+annotation-xml interfaceName=MathMLAnnotationElement
 maction interfaceName=MathMLSelectElement
 math
 mfrac interfaceName=MathMLFractionElement
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to