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

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

Issue 189463005: Generate the isSVG*Element() / toSVG*Element() helper functions (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Remove blank line change 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/build/scripts/make_element_type_helpers.py ('k') | Source/core/core_generated.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 %} 14 {% for tag in tags|sort if not tag.multipleTagNames and not tag.noTypeHelpers %}
15 class {{tag.interface}}; 15 class {{tag.interface}};
16 void is{{tag.interface}}(const {{tag.interface}}&); // Catch unnecessary runtime check of type known at compile time. 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 inline bool is{{tag.interface}}(const Element& element) { 18 inline bool is{{tag.interface}}(const Element& element) {
19 {%- if tag.contextConditional %} 19 {%- if tag.contextConditional %}
20 if (!ContextFeatures::{{tag.contextConditional}}Enabled(&element.document()) ) 20 if (!ContextFeatures::{{tag.contextConditional}}Enabled(&element.document()) )
21 return false; 21 return false;
22 {%- endif %} 22 {%- endif %}
23 {%- if tag.runtimeEnabled %} 23 {%- if tag.runtimeEnabled %}
24 if (!RuntimeEnabledFeatures::{{tag.runtimeEnabled}}Enabled()) 24 if (!RuntimeEnabledFeatures::{{tag.runtimeEnabled}}Enabled())
25 return false; 25 return false;
26 {%- endif %} 26 {%- endif %}
27 return element.hasTagName({{namespace}}Names::{{tag.name}}Tag); 27 return element.hasTagName({{namespace}}Names::{{tag|symbol}}Tag);
28 } 28 }
29 inline bool is{{tag.interface}}(const Element* element) { ASSERT(element); retur n is{{tag.interface}}(*element); } 29 inline bool is{{tag.interface}}(const Element* element) { ASSERT(element); retur n is{{tag.interface}}(*element); }
30 inline bool is{{tag.interface}}(const Node& node) { return node.isElementNode() ? is{{tag.interface}}(toElement(node)) : false; } 30 inline bool is{{tag.interface}}(const Node& node) { return node.isElementNode() ? is{{tag.interface}}(toElement(node)) : false; }
31 inline bool is{{tag.interface}}(const Node* node) { ASSERT(node); return node->i sElementNode() ? is{{tag.interface}}(*toElement(node)) : false; } 31 inline bool is{{tag.interface}}(const Node* node) { ASSERT(node); return node->i sElementNode() ? is{{tag.interface}}(*toElement(node)) : false; }
32 template <> inline bool isElementOfType<const {{tag.interface}}>(const Element& element) { return is{{tag.interface}}(element); } 32 template <> inline bool isElementOfType<const {{tag.interface}}>(const Element& element) { return is{{tag.interface}}(element); }
33 {% endfor %} 33 {% endfor %}
34 34
35 // Using macros because the types are forward-declared and we don't want to use reinterpret_cast in the 35 // Using macros because the types are forward-declared and we don't want to use reinterpret_cast in the
36 // casting functions above. reinterpret_cast would be unsafe due to multiple inh eritence. 36 // casting functions above. reinterpret_cast would be unsafe due to multiple inh eritence.
37 {% for tag in tags|sort if not tag.multipleTagNames %} 37 {% for tag in tags|sort if not tag.multipleTagNames and not tag.noTypeHelpers %}
38 #define to{{tag.interface}}(x) WebCore::toElement<WebCore::{{tag.interface}}>(x) 38 #define to{{tag.interface}}(x) WebCore::toElement<WebCore::{{tag.interface}}>(x)
39 {% endfor %} 39 {% endfor %}
40 } // WebCore 40 } // WebCore
41 41
42 #endif 42 #endif
OLDNEW
« no previous file with comments | « Source/build/scripts/make_element_type_helpers.py ('k') | Source/core/core_generated.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698