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

Side by Side Diff: sky/engine/build/scripts/templates/ElementFactory.cpp.tmpl

Issue 1215103007: Remove remaining HTML elements (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 5 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
« no previous file with comments | « no previous file | sky/engine/core/Init.cpp » ('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 #include "{{namespace}}ElementFactory.h" 4 #include "{{namespace}}ElementFactory.h"
5 5
6 #include "{{namespace}}Names.h" 6 #include "{{namespace}}Names.h"
7 {% for tag in tags|sort %} 7 {% for tag in tags|sort %}
8 #include "core/{{namespace|lower}}/{{tag.interface}}.h" 8 #include "core/{{namespace|lower}}/{{tag.interface}}.h"
9 {% endfor %} 9 {% endfor %}
10 {% if fallback_interface %} 10 {% if fallback_interface %}
11 #include "core/{{namespace|lower}}/{{fallback_interface}}.h" 11 #include "core/{{namespace|lower}}/{{fallback_interface}}.h"
12 {% endif %} 12 {% endif %}
13 #include "core/dom/custom/custom_element_registry.h" 13 #include "core/dom/custom/custom_element_registry.h"
14 #include "core/dom/Document.h" 14 #include "core/dom/Document.h"
15 #include "core/frame/Settings.h" 15 #include "core/frame/Settings.h"
16 #include "gen/sky/platform/RuntimeEnabledFeatures.h" 16 #include "gen/sky/platform/RuntimeEnabledFeatures.h"
17 #include "wtf/HashMap.h" 17 #include "wtf/HashMap.h"
18 18
19 namespace blink { 19 namespace blink {
20 20
21 using namespace {{namespace}}Names; 21 using namespace {{namespace}}Names;
22 22
23 typedef PassRefPtr<{{namespace}}Element> (*ConstructorFunction)( 23 typedef PassRefPtr<{{namespace}}Element> (*ConstructorFunction)(
24 Document&, 24 Document&,
25 bool createdByParser); 25 bool createdByParser);
26 26
27 typedef HashMap<AtomicString, ConstructorFunction> FunctionMap; 27 typedef HashMap<AtomicString, ConstructorFunction> FunctionMap;
28 28
29 static FunctionMap* g_constructors = 0;
30
31 {% for tag in tags|sort if not tag.noConstructor %} 29 {% for tag in tags|sort if not tag.noConstructor %}
32 {% filter enable_conditional(tag.Conditional) %} 30 {% filter enable_conditional(tag.Conditional) %}
33 static PassRefPtr<{{namespace}}Element> {{tag|symbol}}Constructor( 31 static PassRefPtr<{{namespace}}Element> {{tag|symbol}}Constructor(
34 Document& document, 32 Document& document,
35 bool createdByParser) 33 bool createdByParser)
36 { 34 {
37 {% if tag.runtimeEnabled %} 35 {% if tag.runtimeEnabled %}
38 if (!RuntimeEnabledFeatures::{{tag.runtimeEnabled}}Enabled()) 36 if (!RuntimeEnabledFeatures::{{tag.runtimeEnabled}}Enabled())
39 return {{fallback_interface}}::create({{tag|symbol}}Tag, document); 37 return {{fallback_interface}}::create({{tag|symbol}}Tag, document);
40 {% endif %} 38 {% endif %}
41 return {{tag.interface}}::create( 39 return {{tag.interface}}::create(
42 {%- if tag.multipleTagNames %}{{tag|symbol}}Tag, {% endif -%} 40 {%- if tag.multipleTagNames %}{{tag|symbol}}Tag, {% endif -%}
43 document 41 document
44 {%- if tag.constructorNeedsCreatedByParser %}, createdByParser{% endif - %} 42 {%- if tag.constructorNeedsCreatedByParser %}, createdByParser{% endif - %}
45 ); 43 );
46 } 44 }
47 {% endfilter %} 45 {% endfilter %}
48 {% endfor %} 46 {% endfor %}
49 47
50 struct Create{{namespace}}FunctionMapData { 48 struct Create{{namespace}}FunctionMapData {
51 const QualifiedName& tag; 49 const QualifiedName& tag;
52 ConstructorFunction func; 50 ConstructorFunction func;
53 }; 51 };
54 52
55 static void create{{namespace}}FunctionMap()
56 {
57 ASSERT(!g_constructors);
58 g_constructors = new FunctionMap;
59 // Empty array initializer lists are illegal [dcl.init.aggr] and will not
60 // compile in MSVC. If tags list is empty, add check to skip this.
61 static const Create{{namespace}}FunctionMapData data[] = {
62 {% for tag in tags|sort if not tag.noConstructor %}
63 {% filter enable_conditional(tag.Conditional) %}
64 { {{tag|symbol}}Tag, {{tag|symbol}}Constructor },
65 {% endfilter %}
66 {% endfor %}
67 };
68 for (size_t i = 0; i < WTF_ARRAY_LENGTH(data); i++)
69 g_constructors->set(data[i].tag.localName(), data[i].func);
70 }
71
72 PassRefPtr<Element> {{namespace}}ElementFactory::createElement( 53 PassRefPtr<Element> {{namespace}}ElementFactory::createElement(
73 const AtomicString& localName, 54 const AtomicString& localName,
74 Document& document, 55 Document& document,
75 bool createdByParser) 56 bool createdByParser)
76 { 57 {
77 if (!g_constructors)
78 create{{namespace}}FunctionMap();
79 if (ConstructorFunction function = g_constructors->get(localName))
80 return function(document, createdByParser);
81 return document.elementRegistry().CreateElement(document, localName); 58 return document.elementRegistry().CreateElement(document, localName);
82 } 59 }
83 60
84 } // namespace blink 61 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | sky/engine/core/Init.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698