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

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

Issue 236673002: Simplify whitespace handling in build/ Jinja templates (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: One more FIXME Created 6 years, 8 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
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 {# FIXME: remove blank line #}
16
15 class {{tag.interface}}; 17 class {{tag.interface}};
16 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.
17 void is{{tag.interface}}(const {{tag.interface}}*); // Catch unnecessary runtime check of type known at compile time. 19 void is{{tag.interface}}(const {{tag.interface}}*); // Catch unnecessary runtime check of type known at compile time.
18 20
19 {# For HTML Elements, call hasLocalName() instead of hasTagName() to avoid check ing the namespace unnecessarily #} 21 {# For HTML Elements, call hasLocalName() instead of hasTagName() to avoid check ing the namespace unnecessarily #}
20 {%- if namespace == "HTML" -%} 22 {% if namespace == "HTML" %}
21 inline bool is{{tag.interface}}(const HTMLElement& element) { 23 inline bool is{{tag.interface}}(const HTMLElement& element) {
22 {%- if tag.runtimeEnabled or tag.contextConditional %} 24 {% if tag.runtimeEnabled or tag.contextConditional %}
23 if (element.isHTMLUnknownElement()) 25 if (element.isHTMLUnknownElement())
24 return false; 26 return false;
25 {%- endif %} 27 {% endif %}
26 return element.hasLocalName(HTMLNames::{{tag|symbol}}Tag); 28 return element.hasLocalName(HTMLNames::{{tag|symbol}}Tag);
27 } 29 }
28 inline bool is{{tag.interface}}(const Element& element) { 30 inline bool is{{tag.interface}}(const Element& element) {
29 return element.isHTMLElement() && is{{tag.interface}}(toHTMLElement(element) ); 31 return element.isHTMLElement() && is{{tag.interface}}(toHTMLElement(element) );
30 } 32 }
31 inline bool is{{tag.interface}}(const HTMLElement* element) { return element && is{{tag.interface}}(*element); } 33 inline bool is{{tag.interface}}(const HTMLElement* element) { return element && is{{tag.interface}}(*element); }
32 {% else %} 34 {# FIXME: remove - #}
35 {%- else %}
36 {# FIXME: remove blank line #}
37
33 inline bool is{{tag.interface}}(const Element& element) { 38 inline bool is{{tag.interface}}(const Element& element) {
34 {%- if tag.contextConditional %} 39 {% if tag.contextConditional %}
35 if (!ContextFeatures::{{tag.contextConditional}}Enabled(&element.document()) ) 40 if (!ContextFeatures::{{tag.contextConditional}}Enabled(&element.document()) )
36 return false; 41 return false;
37 {%- endif %} 42 {% endif %}
38 {%- if tag.runtimeEnabled %} 43 {% if tag.runtimeEnabled %}
39 if (!RuntimeEnabledFeatures::{{tag.runtimeEnabled}}Enabled()) 44 if (!RuntimeEnabledFeatures::{{tag.runtimeEnabled}}Enabled())
40 return false; 45 return false;
41 {%- endif %} 46 {% endif %}
42 return element.hasTagName({{namespace}}Names::{{tag|symbol}}Tag); 47 return element.hasTagName({{namespace}}Names::{{tag|symbol}}Tag);
48 {# FIXME: remove the - #}
43 } 49 }
44 {%- endif -%} 50 {%- endif -%}
45 51
46 inline bool is{{tag.interface}}(const Element* element) { return element && is{{ tag.interface}}(*element); } 52 inline bool is{{tag.interface}}(const Element* element) { return element && is{{ tag.interface}}(*element); }
47 template<typename T> inline bool is{{tag.interface}}(const PassRefPtr<T>& node) { return is{{tag.interface}}(node.get()); } 53 template<typename T> inline bool is{{tag.interface}}(const PassRefPtr<T>& node) { return 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()); } 54 template<typename T> inline bool is{{tag.interface}}(const RefPtr<T>& node) { re turn is{{tag.interface}}(node.get()); }
49 inline bool is{{tag.interface}}(const Node& node) { return node.isElementNode() ? is{{tag.interface}}(toElement(node)) : false; } 55 inline bool is{{tag.interface}}(const Node& node) { return node.isElementNode() ? 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; } 56 inline bool is{{tag.interface}}(const Node* node) { return node && node->isEleme ntNode() ? is{{tag.interface}}(*toElement(node)) : false; }
51 template <> inline bool isElementOfType<const {{tag.interface}}>(const Element& element) { return is{{tag.interface}}(element); } 57 template <> inline bool isElementOfType<const {{tag.interface}}>(const Element& element) { return is{{tag.interface}}(element); }
52 {%- if namespace == "HTML" %} 58 {% if namespace == "HTML" %}
53 template <> inline bool isElementOfType<const {{tag.interface}}>(const HTMLEleme nt& element) { return is{{tag.interface}}(element); } 59 template <> inline bool isElementOfType<const {{tag.interface}}>(const HTMLEleme nt& element) { return is{{tag.interface}}(element); }
54 {%- endif %} 60 {% endif %}
55 61
56 {% endfor %} 62 {% endfor %}
63 {# FIXME: remove excess blank lines #}
64
57 65
58 // Using macros because the types are forward-declared and we don't want to use reinterpret_cast in the 66 // Using macros because the types are forward-declared and we don't want to use reinterpret_cast in the
59 // casting functions above. reinterpret_cast would be unsafe due to multiple inh eritence. 67 // casting functions above. reinterpret_cast would be unsafe due to multiple inh eritence.
68
60 {% for tag in tags|sort if not tag.multipleTagNames and not tag.noTypeHelpers %} 69 {% for tag in tags|sort if not tag.multipleTagNames and not tag.noTypeHelpers %}
61 #define to{{tag.interface}}(x) WebCore::toElement<WebCore::{{tag.interface}}>(x) 70 #define to{{tag.interface}}(x) WebCore::toElement<WebCore::{{tag.interface}}>(x)
71 {# FIXME: remove blank line #}
72
62 {% endfor %} 73 {% endfor %}
63 } // WebCore 74 } // WebCore
64 75
65 #endif 76 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698