Index: Source/core/html/HTMLElement.h |
diff --git a/Source/core/html/HTMLElement.h b/Source/core/html/HTMLElement.h |
index 90c3963d63f8677f35c46a7f6541f614d5e854c8..d66f329309ee755f9503ccf897fb3f085f544e2d 100644 |
--- a/Source/core/html/HTMLElement.h |
+++ b/Source/core/html/HTMLElement.h |
@@ -137,6 +137,20 @@ inline HTMLElement::HTMLElement(const QualifiedName& tagName, Document& document |
ScriptWrappable::init(this); |
} |
+// This requires isHTML*Element(const Element&) and isHTML*Element(const HTMLElement&). |
+// When the input element is an HTMLElement, we don't need to check the namespace URI, just the local name. |
+#define DEFINE_HTMLELEMENT_TYPE_CASTS_WITH_FUNCTION(thisType) \ |
+ inline bool is##thisType(const thisType* element); \ |
+ inline bool is##thisType(const thisType& element); \ |
+ inline bool is##thisType(const HTMLElement* element) { return element && is##thisType(*element); } \ |
+ inline bool is##thisType(const Element* element) { return element && is##thisType(*element); } \ |
+ inline bool is##thisType(const Node& node) { return node.isElementNode() ? is##thisType(toElement(node)) : false; } \ |
+ inline bool is##thisType(const Node* node) { return node && node->isElementNode() ? is##thisType(*toElement(node)) : false; } \ |
+ 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 HTMLElement& element) { return is##thisType(element); } \ |
+ DEFINE_ELEMENT_TYPE_CASTS_WITH_FUNCTION(thisType) |
+ |
} // namespace WebCore |
#include "HTMLElementTypeHelpers.h" |