Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / build / scripts / templates / ElementTypeHelpers.h.tmpl
index 63d2834..124db34 100644 (file)
@@ -4,12 +4,11 @@
 #ifndef {{namespace}}ElementTypeHelpers_h
 #define {{namespace}}ElementTypeHelpers_h
 
-#include "core/dom/ContextFeatures.h"
 #include "core/dom/Element.h"
 #include "{{namespace}}Names.h"
 #include "platform/RuntimeEnabledFeatures.h"
 
-namespace WebCore {
+namespace blink {
 // Type checking.
 {% for tag in tags|sort if not tag.multipleTagNames and not tag.noTypeHelpers %}
 {% filter enable_conditional(tag.Conditional) %}
@@ -17,51 +16,31 @@ class {{tag.interface}};
 void is{{tag.interface}}(const {{tag.interface}}&); // Catch unnecessary runtime check of type known at compile time.
 void is{{tag.interface}}(const {{tag.interface}}*); // Catch unnecessary runtime check of type known at compile time.
 
-{# For HTML Elements, call hasLocalName() instead of hasTagName() to avoid checking the namespace unnecessarily #}
-{% if namespace == 'HTML' %}
-inline bool is{{tag.interface}}(const HTMLElement& element) {
-    {% if tag.runtimeEnabled or tag.contextConditional %}
-    if (element.isHTMLUnknownElement())
-        return false;
-    {% endif %}
-    return element.hasLocalName(HTMLNames::{{tag|symbol}}Tag);
-}
-inline bool is{{tag.interface}}(const Element& element) {
-    return element.isHTMLElement() && is{{tag.interface}}(toHTMLElement(element));
-}
-inline bool is{{tag.interface}}(const HTMLElement* element) { return element && is{{tag.interface}}(*element); }
-{% else %}
-inline bool is{{tag.interface}}(const Element& element) {
-    {% if tag.contextConditional %}
-    if (!ContextFeatures::{{tag.contextConditional}}Enabled(&element.document()))
-        return false;
-    {% endif %}
+inline bool is{{tag.interface}}(const {{namespace}}Element& element) {
     {% if tag.runtimeEnabled %}
     if (!RuntimeEnabledFeatures::{{tag.runtimeEnabled}}Enabled())
         return false;
     {% endif %}
     return element.hasTagName({{namespace}}Names::{{tag|symbol}}Tag);
 }
-{% endif %}
-inline bool is{{tag.interface}}(const Element* element) { return element && is{{tag.interface}}(*element); }
+inline bool is{{tag.interface}}(const {{namespace}}Element* element) { return element && is{{tag.interface}}(*element); }
 template<typename T> inline bool is{{tag.interface}}(const PassRefPtr<T>& node) { return is{{tag.interface}}(node.get()); }
 template<typename T> inline bool is{{tag.interface}}(const RefPtr<T>& node) { return is{{tag.interface}}(node.get()); }
-inline bool is{{tag.interface}}(const Node& node) { return node.isElementNode() ? is{{tag.interface}}(toElement(node)) : false; }
-inline bool is{{tag.interface}}(const Node* node) { return node && node->isElementNode() ? is{{tag.interface}}(*toElement(node)) : false; }
-template <> inline bool isElementOfType<const {{tag.interface}}>(const Element& element) { return is{{tag.interface}}(element); }
-{% if namespace == "HTML" %}
-template <> inline bool isElementOfType<const {{tag.interface}}>(const HTMLElement& element) { return is{{tag.interface}}(element); }
-{% endif %}
+inline bool is{{tag.interface}}(const Node& node) { return node.is{{namespace}}Element() && is{{tag.interface}}(to{{namespace}}Element(node)); }
+inline bool is{{tag.interface}}(const Node* node) { return node && is{{tag.interface}}(*node); }
+template <> inline bool isElementOfType<const {{tag.interface}}>(const Node& node) { return is{{tag.interface}}(node); }
+template <> inline bool isElementOfType<const {{tag.interface}}>(const {{namespace}}Element& element) { return is{{tag.interface}}(element); }
 {% endfilter %}
+
 {% endfor %}
 // Using macros because the types are forward-declared and we don't want to use reinterpret_cast in the
 // casting functions above. reinterpret_cast would be unsafe due to multiple inheritence.
 
 {% for tag in tags|sort if not tag.multipleTagNames and not tag.noTypeHelpers %}
 {% filter enable_conditional(tag.Conditional) %}
-#define to{{tag.interface}}(x) WebCore::toElement<WebCore::{{tag.interface}}>(x)
+#define to{{tag.interface}}(x) blink::toElement<blink::{{tag.interface}}>(x)
 {% endfilter %}
 {% endfor %}
-} // WebCore
+} // namespace blink
 
 #endif