Use SPECIALIZE_TYPE_TRAITS_*() macro for MathMLElement
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 29 Sep 2014 20:50:45 +0000 (20:50 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 29 Sep 2014 20:50:45 +0000 (20:50 +0000)
https://bugs.webkit.org/show_bug.cgi?id=137222

Reviewed by Ryosuke Niwa.

Use SPECIALIZE_TYPE_TRAITS_*() macro for MathMLElement instead of
NODE_TYPE_CASTS() + NodeTypeCastTraits template specialization.

No new tests, no behavior change.

* accessibility/AccessibilityNodeObject.cpp:
(WebCore::AccessibilityNodeObject::accessibilityDescription):
* accessibility/AccessibilityRenderObject.cpp:
(WebCore::AccessibilityRenderObject::isMathElement):
* css/CSSDefaultStyleSheets.cpp:
(WebCore::CSSDefaultStyleSheets::ensureDefaultStyleSheetsForElement):
* mathml/MathMLElement.cpp:
(WebCore::MathMLElement::attributeChanged):
* mathml/MathMLElement.h:
(WebCore::isMathMLElement):
* mathml/MathMLSelectElement.cpp:
(WebCore::MathMLSelectElement::getSelectedSemanticsChild):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@174084 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/accessibility/AccessibilityNodeObject.cpp
Source/WebCore/accessibility/AccessibilityRenderObject.cpp
Source/WebCore/css/CSSDefaultStyleSheets.cpp
Source/WebCore/mathml/MathMLElement.cpp
Source/WebCore/mathml/MathMLElement.h
Source/WebCore/mathml/MathMLSelectElement.cpp

index 8e3ce31..ed50572 100644 (file)
@@ -1,3 +1,28 @@
+2014-09-29  Christophe Dumez  <cdumez@apple.com>
+
+        Use SPECIALIZE_TYPE_TRAITS_*() macro for MathMLElement
+        https://bugs.webkit.org/show_bug.cgi?id=137222
+
+        Reviewed by Ryosuke Niwa.
+
+        Use SPECIALIZE_TYPE_TRAITS_*() macro for MathMLElement instead of
+        NODE_TYPE_CASTS() + NodeTypeCastTraits template specialization.
+
+        No new tests, no behavior change.
+
+        * accessibility/AccessibilityNodeObject.cpp:
+        (WebCore::AccessibilityNodeObject::accessibilityDescription):
+        * accessibility/AccessibilityRenderObject.cpp:
+        (WebCore::AccessibilityRenderObject::isMathElement):
+        * css/CSSDefaultStyleSheets.cpp:
+        (WebCore::CSSDefaultStyleSheets::ensureDefaultStyleSheetsForElement):
+        * mathml/MathMLElement.cpp:
+        (WebCore::MathMLElement::attributeChanged):
+        * mathml/MathMLElement.h:
+        (WebCore::isMathMLElement):
+        * mathml/MathMLSelectElement.cpp:
+        (WebCore::MathMLSelectElement::getSelectedSemanticsChild):
+
 2014-09-29  Eric Carlson  <eric.carlson@apple.com>
 
         [Mac] Remove MediaPlayerPrivateQTKit frame rate code
index 1c3739c..0262ffd 100644 (file)
@@ -63,6 +63,7 @@
 #include "HitTestResult.h"
 #include "LabelableElement.h"
 #include "LocalizedStrings.h"
+#include "MathMLElement.h"
 #include "MathMLNames.h"
 #include "NodeList.h"
 #include "NodeTraversal.h"
@@ -1502,7 +1503,7 @@ String AccessibilityNodeObject::accessibilityDescription() const
         return downcast<SVGElement>(*m_node).title();
     
 #if ENABLE(MATHML)
-    if (m_node && m_node->isMathMLElement())
+    if (m_node && is<MathMLElement>(*m_node))
         return getAttribute(MathMLNames::alttextAttr);
 #endif
 
index 45bb61a..85605e9 100644 (file)
@@ -3491,7 +3491,7 @@ bool AccessibilityRenderObject::isMathElement() const
     if (!m_renderer || !node)
         return false;
     
-    return node->isMathMLElement();
+    return is<MathMLElement>(node);
 }
 
 bool AccessibilityRenderObject::isMathFraction() const
index a247ce9..72880bc 100644 (file)
@@ -34,6 +34,7 @@
 #include "HTMLAnchorElement.h"
 #include "HTMLAudioElement.h"
 #include "HTMLBRElement.h"
+#include "MathMLElement.h"
 #include "MediaQueryEvaluator.h"
 #include "Page.h"
 #include "RenderTheme.h"
@@ -166,7 +167,7 @@ void CSSDefaultStyleSheets::ensureDefaultStyleSheetsForElement(Element& element,
     }
 
 #if ENABLE(MATHML)
-    if (element.isMathMLElement() && !mathMLStyleSheet) {
+    if (is<MathMLElement>(element) && !mathMLStyleSheet) {
         // MathML rules.
         mathMLStyleSheet = parseUASheet(mathmlUserAgentStyleSheet, sizeof(mathmlUserAgentStyleSheet));
         defaultStyle->addRulesFromSheet(mathMLStyleSheet, screenEval());
index 31f6fc4..967ba55 100644 (file)
@@ -294,7 +294,7 @@ void MathMLElement::attributeChanged(const QualifiedName& name, const AtomicStri
 {
     if (isSemanticAnnotation() && (name == MathMLNames::srcAttr || name == MathMLNames::encodingAttr)) {
         Element* parent = parentElement();
-        if (parent && parent->isMathMLElement() && parent->hasTagName(semanticsTag))
+        if (parent && is<MathMLElement>(parent) && parent->hasTagName(semanticsTag))
             downcast<MathMLElement>(*parent).updateSelectedChild();
     }
     StyledElement::attributeChanged(name, oldValue, newValue, reason);
index 67cab7b..e099067 100644 (file)
@@ -73,15 +73,9 @@ private:
     virtual void updateSelectedChild() { }
 };
 
-void isMathMLElement(const MathMLElement&); // Catch unnecessary runtime check of type known at compile time.
-inline bool isMathMLElement(const Node& node) { return node.isMathMLElement(); }
-
-template <typename ArgType>
-struct NodeTypeCastTraits<const MathMLElement, ArgType> {
-    static bool isType(ArgType& node) { return isMathMLElement(node); }
-};
-
-NODE_TYPE_CASTS(MathMLElement)
+SPECIALIZE_TYPE_TRAITS_BEGIN(MathMLElement)
+    static bool isMathMLElement(const Node& node) { return node.isMathMLElement(); }
+SPECIALIZE_TYPE_TRAITS_END()
 
 inline bool Node::hasTagName(const MathMLQualifiedName& name) const
 {
index 26cb583..247f9c2 100644 (file)
@@ -157,7 +157,7 @@ Element* MathMLSelectElement::getSelectedSemanticsChild()
     if (!child)
         return nullptr;
 
-    if (!child->isMathMLElement() || !downcast<MathMLElement>(*child).isPresentationMathML()) {
+    if (!is<MathMLElement>(child) || !downcast<MathMLElement>(*child).isPresentationMathML()) {
         // The first child is not a presentation MathML element. Hence we move to the second child and start searching an annotation child that could be displayed.
         child = child->nextElementSibling();
     } else if (!downcast<MathMLElement>(*child).isSemanticAnnotation()) {
@@ -167,7 +167,7 @@ Element* MathMLSelectElement::getSelectedSemanticsChild()
     // Otherwise, the first child is an <annotation> or <annotation-xml> element. This is invalid, but some people use this syntax so we take care of this case too and start the search from this first child.
 
     for ( ; child; child = child->nextElementSibling()) {
-        if (!child->isMathMLElement())
+        if (!is<MathMLElement>(child))
             continue;
 
         if (child->hasTagName(MathMLNames::annotationTag)) {