Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(996)

Unified Diff: Source/core/svg/SVGElement.h

Issue 403343005: Make manual isSVG*Element() helpers as efficient as the generated ones (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fix macro name Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/svg/SVGAnimateElement.cpp ('k') | Source/core/svg/SVGFELightElement.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/svg/SVGElement.h
diff --git a/Source/core/svg/SVGElement.h b/Source/core/svg/SVGElement.h
index fd95c19b67d17ea85eb5caae5ad6d3e06b47519e..47fc74e159feb5ef5930ac98ac89b6d3960503c8 100644
--- a/Source/core/svg/SVGElement.h
+++ b/Source/core/svg/SVGElement.h
@@ -271,6 +271,18 @@ inline bool Node::hasTagName(const SVGQualifiedName& name) const
return isSVGElement() && toSVGElement(*this).hasTagName(name);
}
+// This requires isSVG*Element(const SVGElement&).
+#define DEFINE_SVGELEMENT_TYPE_CASTS_WITH_FUNCTION(thisType) \
+ inline bool is##thisType(const thisType* element); \
+ inline bool is##thisType(const thisType& element); \
+ inline bool is##thisType(const SVGElement* element) { return element && is##thisType(*element); } \
+ inline bool is##thisType(const Node& node) { return node.isSVGElement() ? is##thisType(toSVGElement(node)) : false; } \
+ inline bool is##thisType(const Node* node) { return node && is##thisType(*node); } \
+ template<typename T> inline bool is##thisType(const PassRefPtr<T>& node) { return is##thisType(node.get()); } \
+ template<typename T> inline bool is##thisType(const RefPtr<T>& node) { return is##thisType(node.get()); } \
+ template <> inline bool isElementOfType<const thisType>(const SVGElement& element) { return is##thisType(element); } \
+ DEFINE_ELEMENT_TYPE_CASTS_WITH_FUNCTION(thisType)
+
}
#include "core/SVGElementTypeHelpers.h"
« no previous file with comments | « Source/core/svg/SVGAnimateElement.cpp ('k') | Source/core/svg/SVGFELightElement.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698