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

Side by Side Diff: Source/build/scripts/templates/ElementTypeHelpers.h.tmpl

Issue 330093002: Add support in generate scripts to handle Conditional (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: sort by alpha Created 6 years, 6 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 unified diff | Download patch
OLDNEW
1 {% from "macros.tmpl" import license %} 1 {% from "macros.tmpl" import license %}
2 {{ license() }} 2 {{ license() }}
3 3
4 #ifndef {{namespace}}ElementTypeHelpers_h 4 #ifndef {{namespace}}ElementTypeHelpers_h
5 #define {{namespace}}ElementTypeHelpers_h 5 #define {{namespace}}ElementTypeHelpers_h
6 6
7 #include "core/dom/ContextFeatures.h" 7 #include "core/dom/ContextFeatures.h"
8 #include "core/dom/Element.h" 8 #include "core/dom/Element.h"
9 #include "{{namespace}}Names.h" 9 #include "{{namespace}}Names.h"
10 #include "RuntimeEnabledFeatures.h" 10 #include "RuntimeEnabledFeatures.h"
11 11
12 namespace WebCore { 12 namespace WebCore {
13 // Type checking. 13 // Type checking.
14 {% for tag in tags|sort if not tag.multipleTagNames and not tag.noTypeHelpers %} 14 {% for tag in tags|sort if not tag.multipleTagNames and not tag.noTypeHelpers %}
15 {% filter enable_conditional(tag.Conditional) %}
15 class {{tag.interface}}; 16 class {{tag.interface}};
16 void is{{tag.interface}}(const {{tag.interface}}&); // Catch unnecessary runtime check of type known at compile time. 17 void is{{tag.interface}}(const {{tag.interface}}&); // Catch unnecessary runtime check of type known at compile time.
17 void is{{tag.interface}}(const {{tag.interface}}*); // Catch unnecessary runtime check of type known at compile time. 18 void is{{tag.interface}}(const {{tag.interface}}*); // Catch unnecessary runtime check of type known at compile time.
18 19
19 {# For HTML Elements, call hasLocalName() instead of hasTagName() to avoid check ing the namespace unnecessarily #} 20 {# For HTML Elements, call hasLocalName() instead of hasTagName() to avoid check ing the namespace unnecessarily #}
20 {% if namespace == 'HTML' %} 21 {% if namespace == 'HTML' %}
21 inline bool is{{tag.interface}}(const HTMLElement& element) { 22 inline bool is{{tag.interface}}(const HTMLElement& element) {
22 {% if tag.runtimeEnabled or tag.contextConditional %} 23 {% if tag.runtimeEnabled or tag.contextConditional %}
23 if (element.isHTMLUnknownElement()) 24 if (element.isHTMLUnknownElement())
24 return false; 25 return false;
(...skipping 19 matching lines...) Expand all
44 {% endif %} 45 {% endif %}
45 inline bool is{{tag.interface}}(const Element* element) { return element && is{{ tag.interface}}(*element); } 46 inline bool is{{tag.interface}}(const Element* element) { return element && is{{ tag.interface}}(*element); }
46 template<typename T> inline bool is{{tag.interface}}(const PassRefPtr<T>& node) { return is{{tag.interface}}(node.get()); } 47 template<typename T> inline bool is{{tag.interface}}(const PassRefPtr<T>& node) { return is{{tag.interface}}(node.get()); }
47 template<typename T> inline bool is{{tag.interface}}(const RefPtr<T>& node) { re turn is{{tag.interface}}(node.get()); } 48 template<typename T> inline bool is{{tag.interface}}(const RefPtr<T>& node) { re turn is{{tag.interface}}(node.get()); }
48 inline bool is{{tag.interface}}(const Node& node) { return node.isElementNode() ? is{{tag.interface}}(toElement(node)) : false; } 49 inline bool is{{tag.interface}}(const Node& node) { return node.isElementNode() ? is{{tag.interface}}(toElement(node)) : false; }
49 inline bool is{{tag.interface}}(const Node* node) { return node && node->isEleme ntNode() ? is{{tag.interface}}(*toElement(node)) : false; } 50 inline bool is{{tag.interface}}(const Node* node) { return node && node->isEleme ntNode() ? is{{tag.interface}}(*toElement(node)) : false; }
50 template <> inline bool isElementOfType<const {{tag.interface}}>(const Element& element) { return is{{tag.interface}}(element); } 51 template <> inline bool isElementOfType<const {{tag.interface}}>(const Element& element) { return is{{tag.interface}}(element); }
51 {% if namespace == "HTML" %} 52 {% if namespace == "HTML" %}
52 template <> inline bool isElementOfType<const {{tag.interface}}>(const HTMLEleme nt& element) { return is{{tag.interface}}(element); } 53 template <> inline bool isElementOfType<const {{tag.interface}}>(const HTMLEleme nt& element) { return is{{tag.interface}}(element); }
53 {% endif %} 54 {% endif %}
54 55 {% endfilter %}
55 {% endfor %} 56 {% endfor %}
56 // Using macros because the types are forward-declared and we don't want to use reinterpret_cast in the 57 // Using macros because the types are forward-declared and we don't want to use reinterpret_cast in the
57 // casting functions above. reinterpret_cast would be unsafe due to multiple inh eritence. 58 // casting functions above. reinterpret_cast would be unsafe due to multiple inh eritence.
58 59
59 {% for tag in tags|sort if not tag.multipleTagNames and not tag.noTypeHelpers %} 60 {% for tag in tags|sort if not tag.multipleTagNames and not tag.noTypeHelpers %}
61 {% filter enable_conditional(tag.Conditional) %}
60 #define to{{tag.interface}}(x) WebCore::toElement<WebCore::{{tag.interface}}>(x) 62 #define to{{tag.interface}}(x) WebCore::toElement<WebCore::{{tag.interface}}>(x)
63 {% endfilter %}
61 {% endfor %} 64 {% endfor %}
62 } // WebCore 65 } // WebCore
63 66
64 #endif 67 #endif
OLDNEW
« no previous file with comments | « Source/build/scripts/templates/ElementFactory.cpp.tmpl ('k') | Source/build/scripts/templates/ElementWrapperFactory.cpp.tmpl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698