Introduce toSVGFontFaceElement, and use it
As a step to change static_cast with toSVGXXX, static_cast<SVGFontFaceElement*> can
be changed with toSVGFontFaceElement().
BUG=
Review URL: https://chromiumcodereview.appspot.com/21032002
git-svn-id: svn://svn.chromium.org/blink/trunk@155082 bbb929c8-8fbe-4397-9dbb-9b2b20218538
diff --git a/Source/core/css/CSSFontFaceSource.cpp b/Source/core/css/CSSFontFaceSource.cpp
index 7562455..c929c5d 100644
--- a/Source/core/css/CSSFontFaceSource.cpp
+++ b/Source/core/css/CSSFontFaceSource.cpp
@@ -144,7 +144,7 @@
// Select first <font-face> child
for (Node* fontChild = m_externalSVGFontElement->firstChild(); fontChild; fontChild = fontChild->nextSibling()) {
if (fontChild->hasTagName(SVGNames::font_faceTag)) {
- fontFaceElement = static_cast<SVGFontFaceElement*>(fontChild);
+ fontFaceElement = toSVGFontFaceElement(fontChild);
break;
}
}
diff --git a/Source/core/svg/SVGFontFaceElement.h b/Source/core/svg/SVGFontFaceElement.h
index 844ac29..0da43df 100644
--- a/Source/core/svg/SVGFontFaceElement.h
+++ b/Source/core/svg/SVGFontFaceElement.h
@@ -23,6 +23,7 @@
#define SVGFontFaceElement_h
#if ENABLE(SVG_FONTS)
+#include "SVGNames.h"
#include "core/svg/SVGElement.h"
namespace WebCore {
@@ -64,6 +65,12 @@
SVGFontElement* m_fontElement;
};
+inline SVGFontFaceElement* toSVGFontFaceElement(Node* node)
+{
+ ASSERT_WITH_SECURITY_IMPLICATION(!node || node->hasTagName(SVGNames::font_faceTag));
+ return static_cast<SVGFontFaceElement*>(node);
+}
+
} // namespace WebCore
#endif // ENABLE(SVG_FONTS)
diff --git a/Source/core/svg/SVGFontFaceFormatElement.cpp b/Source/core/svg/SVGFontFaceFormatElement.cpp
index c3835d1..ed83472 100644
--- a/Source/core/svg/SVGFontFaceFormatElement.cpp
+++ b/Source/core/svg/SVGFontFaceFormatElement.cpp
@@ -54,7 +54,7 @@
ancestor = ancestor->parentNode();
if (ancestor && ancestor->hasTagName(font_faceTag))
- static_cast<SVGFontFaceElement*>(ancestor)->rebuildFontFace();
+ toSVGFontFaceElement(ancestor)->rebuildFontFace();
}
}
diff --git a/Source/core/svg/SVGFontFaceSrcElement.cpp b/Source/core/svg/SVGFontFaceSrcElement.cpp
index a658996..3a64896 100644
--- a/Source/core/svg/SVGFontFaceSrcElement.cpp
+++ b/Source/core/svg/SVGFontFaceSrcElement.cpp
@@ -64,7 +64,7 @@
{
SVGElement::childrenChanged(changedByParser, beforeChange, afterChange, childCountDelta);
if (parentNode() && parentNode()->hasTagName(font_faceTag))
- static_cast<SVGFontFaceElement*>(parentNode())->rebuildFontFace();
+ toSVGFontFaceElement(parentNode())->rebuildFontFace();
}
}
diff --git a/Source/core/svg/SVGFontFaceUriElement.cpp b/Source/core/svg/SVGFontFaceUriElement.cpp
index caa59d2..eb726eb 100644
--- a/Source/core/svg/SVGFontFaceUriElement.cpp
+++ b/Source/core/svg/SVGFontFaceUriElement.cpp
@@ -79,7 +79,7 @@
ContainerNode* grandparent = parentNode()->parentNode();
if (grandparent && grandparent->hasTagName(font_faceTag))
- static_cast<SVGFontFaceElement*>(grandparent)->rebuildFontFace();
+ toSVGFontFaceElement(grandparent)->rebuildFontFace();
}
Node::InsertionNotificationRequest SVGFontFaceUriElement::insertedInto(ContainerNode* rootParent)