OLD | NEW |
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|groupby('interface') %} | 7 {% for tag in tags|groupby('interface') %} |
8 #include "core/{{namespace|lower}}/{{tag[0]}}.h" | 8 #include "core/{{namespace|lower}}/{{tag[0]}}.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/CustomElement.h" | 13 #include "core/dom/custom/CustomElement.h" |
14 #include "core/dom/custom/CustomElementRegistrationContext.h" | 14 #include "core/dom/custom/CustomElementRegistrationContext.h" |
15 #include "core/dom/Document.h" | 15 #include "core/dom/Document.h" |
16 #include "core/frame/Settings.h" | 16 #include "core/frame/Settings.h" |
17 #include "platform/RuntimeEnabledFeatures.h" | 17 #include "platform/RuntimeEnabledFeatures.h" |
18 #include "wtf/HashMap.h" | 18 #include "wtf/HashMap.h" |
19 | 19 |
20 namespace blink { | 20 namespace blink { |
21 | 21 |
22 using namespace {{namespace}}Names; | 22 using namespace {{namespace}}Names; |
23 | 23 |
24 typedef RawPtr<{{namespace}}Element> (*ConstructorFunction)( | 24 typedef {{namespace}}Element* (*ConstructorFunction)( |
25 Document&, | 25 Document&, |
26 {% if namespace == 'HTML' %} | 26 {% if namespace == 'HTML' %} |
27 HTMLFormElement*, | 27 HTMLFormElement*, |
28 {% endif %} | 28 {% endif %} |
29 bool createdByParser); | 29 bool createdByParser); |
30 | 30 |
31 typedef HashMap<AtomicString, ConstructorFunction> FunctionMap; | 31 typedef HashMap<AtomicString, ConstructorFunction> FunctionMap; |
32 | 32 |
33 static FunctionMap* g_constructors = 0; | 33 static FunctionMap* g_constructors = 0; |
34 | 34 |
35 {% for tag in tags|sort if not tag.noConstructor %} | 35 {% for tag in tags|sort if not tag.noConstructor %} |
36 static RawPtr<{{namespace}}Element> {{tag|symbol}}Constructor( | 36 static {{namespace}}Element* {{tag|symbol}}Constructor( |
37 Document& document, | 37 Document& document, |
38 {% if namespace == 'HTML' %} | 38 {% if namespace == 'HTML' %} |
39 HTMLFormElement* formElement, | 39 HTMLFormElement* formElement, |
40 {% endif %} | 40 {% endif %} |
41 bool createdByParser) | 41 bool createdByParser) |
42 { | 42 { |
43 {% if tag.runtimeEnabled %} | 43 {% if tag.runtimeEnabled %} |
44 if (!RuntimeEnabledFeatures::{{tag.runtimeEnabled}}Enabled()) | 44 if (!RuntimeEnabledFeatures::{{tag.runtimeEnabled}}Enabled()) |
45 return {{fallback_interface}}::create({{tag|symbol}}Tag, document); | 45 return {{fallback_interface}}::create({{tag|symbol}}Tag, document); |
46 {% endif %} | 46 {% endif %} |
(...skipping 19 matching lines...) Expand all Loading... |
66 // compile in MSVC. If tags list is empty, add check to skip this. | 66 // compile in MSVC. If tags list is empty, add check to skip this. |
67 static const Create{{namespace}}FunctionMapData data[] = { | 67 static const Create{{namespace}}FunctionMapData data[] = { |
68 {% for tag in tags|sort if not tag.noConstructor %} | 68 {% for tag in tags|sort if not tag.noConstructor %} |
69 { {{tag|symbol}}Tag, {{tag|symbol}}Constructor }, | 69 { {{tag|symbol}}Tag, {{tag|symbol}}Constructor }, |
70 {% endfor %} | 70 {% endfor %} |
71 }; | 71 }; |
72 for (size_t i = 0; i < WTF_ARRAY_LENGTH(data); i++) | 72 for (size_t i = 0; i < WTF_ARRAY_LENGTH(data); i++) |
73 g_constructors->set(data[i].tag.localName(), data[i].func); | 73 g_constructors->set(data[i].tag.localName(), data[i].func); |
74 } | 74 } |
75 | 75 |
76 RawPtr<{{namespace}}Element> {{namespace}}ElementFactory::create{{namespace}}Ele
ment( | 76 {{namespace}}Element* {{namespace}}ElementFactory::create{{namespace}}Element( |
77 const AtomicString& localName, | 77 const AtomicString& localName, |
78 Document& document, | 78 Document& document, |
79 {% if namespace == 'HTML' %} | 79 {% if namespace == 'HTML' %} |
80 HTMLFormElement* formElement, | 80 HTMLFormElement* formElement, |
81 {% endif %} | 81 {% endif %} |
82 bool createdByParser) | 82 bool createdByParser) |
83 { | 83 { |
84 if (!g_constructors) | 84 if (!g_constructors) |
85 create{{namespace}}FunctionMap(); | 85 create{{namespace}}FunctionMap(); |
86 if (ConstructorFunction function = g_constructors->get(localName)) | 86 if (ConstructorFunction function = g_constructors->get(localName)) |
87 return function(document, {% if namespace == 'HTML' %}formElement, {% en
dif %}createdByParser); | 87 return function(document, {% if namespace == 'HTML' %}formElement, {% en
dif %}createdByParser); |
88 | 88 |
89 if (document.registrationContext() && CustomElement::isValidName(localName))
{ | 89 if (document.registrationContext() && CustomElement::isValidName(localName))
{ |
90 Element* element = document.registrationContext()->createCustomTagElemen
t(document, QualifiedName(nullAtom, localName, {{namespace_prefix}}NamespaceURI)
); | 90 Element* element = document.registrationContext()->createCustomTagElemen
t(document, QualifiedName(nullAtom, localName, {{namespace_prefix}}NamespaceURI)
); |
91 ASSERT_WITH_SECURITY_IMPLICATION(element->is{{namespace}}Element()); | 91 ASSERT_WITH_SECURITY_IMPLICATION(element->is{{namespace}}Element()); |
92 return to{{namespace}}Element(element); | 92 return to{{namespace}}Element(element); |
93 } | 93 } |
94 | 94 |
95 return {{fallback_interface}}::create(QualifiedName(nullAtom, localName, {{n
amespace_prefix}}NamespaceURI), document); | 95 return {{fallback_interface}}::create(QualifiedName(nullAtom, localName, {{n
amespace_prefix}}NamespaceURI), document); |
96 } | 96 } |
97 | 97 |
98 } // namespace blink | 98 } // namespace blink |
OLD | NEW |