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

Unified Diff: Source/core/html/HTMLElement.h

Issue 202813005: Add DEFINE_HTMLELEMENT_TYPE_CASTS_WITH_FUNCTION() macro (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Slight clean up Created 6 years, 9 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/editing/Editor.cpp ('k') | Source/core/html/HTMLFormControlElement.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"
« no previous file with comments | « Source/core/editing/Editor.cpp ('k') | Source/core/html/HTMLFormControlElement.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698