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 %} |
(...skipping 11 matching lines...) Expand all Loading... |
22 | 22 |
23 namespace blink { | 23 namespace blink { |
24 | 24 |
25 using namespace {{namespace}}Names; | 25 using namespace {{namespace}}Names; |
26 | 26 |
27 typedef {{namespace}}Element* (*ConstructorFunction)( | 27 typedef {{namespace}}Element* (*ConstructorFunction)( |
28 Document&, | 28 Document&, |
29 {% if namespace == 'HTML' %} | 29 {% if namespace == 'HTML' %} |
30 HTMLFormElement*, | 30 HTMLFormElement*, |
31 {% endif %} | 31 {% endif %} |
32 bool createdByParser); | 32 CreateElementFlags); |
33 | 33 |
34 typedef HashMap<AtomicString, ConstructorFunction> FunctionMap; | 34 typedef HashMap<AtomicString, ConstructorFunction> FunctionMap; |
35 | 35 |
36 static FunctionMap* g_constructors = 0; | 36 static FunctionMap* g_constructors = 0; |
37 | 37 |
38 {% for tag in tags|sort if not tag.noConstructor %} | 38 {% for tag in tags|sort if not tag.noConstructor %} |
39 static {{namespace}}Element* {{tag|symbol}}Constructor( | 39 static {{namespace}}Element* {{tag|symbol}}Constructor( |
40 Document& document, | 40 Document& document, |
41 {% if namespace == 'HTML' %} | 41 {% if namespace == 'HTML' %} |
42 HTMLFormElement* formElement, | 42 HTMLFormElement* formElement, |
43 {% endif %} | 43 {% endif %} |
44 bool createdByParser) | 44 CreateElementFlags flags) |
45 { | 45 { |
46 {% if tag.runtimeEnabled %} | 46 {% if tag.runtimeEnabled %} |
47 if (!RuntimeEnabledFeatures::{{tag.runtimeEnabled}}Enabled()) | 47 if (!RuntimeEnabledFeatures::{{tag.runtimeEnabled}}Enabled()) |
48 return {{fallback_interface}}::create({{tag|symbol}}Tag, document); | 48 return {{fallback_interface}}::create({{tag|symbol}}Tag, document); |
49 {% endif %} | 49 {% endif %} |
50 return {{tag.interface}}::create( | 50 return {{tag.interface}}::create( |
51 {%- if tag.multipleTagNames %}{{tag|symbol}}Tag, {% endif -%} | 51 {%- if tag.multipleTagNames %}{{tag|symbol}}Tag, {% endif -%} |
52 document | 52 document |
53 {%- if namespace == 'HTML' and tag.constructorNeedsFormElement %}, formE
lement{% endif -%} | 53 {%- if namespace == 'HTML' and tag.constructorNeedsFormElement %}, formE
lement{% endif -%} |
54 {%- if tag.constructorNeedsCreatedByParser %}, createdByParser{% endif -
%} | 54 {%- if tag.constructorNeedsCreatedByParser %}, flags & CreatedByParser{%
endif -%} |
55 ); | 55 ); |
56 } | 56 } |
57 {% endfor %} | 57 {% endfor %} |
58 | 58 |
59 struct Create{{namespace}}FunctionMapData { | 59 struct Create{{namespace}}FunctionMapData { |
60 const QualifiedName& tag; | 60 const QualifiedName& tag; |
61 ConstructorFunction func; | 61 ConstructorFunction func; |
62 }; | 62 }; |
63 | 63 |
64 static void create{{namespace}}FunctionMap() | 64 static void create{{namespace}}FunctionMap() |
(...skipping 10 matching lines...) Expand all Loading... |
75 for (size_t i = 0; i < WTF_ARRAY_LENGTH(data); i++) | 75 for (size_t i = 0; i < WTF_ARRAY_LENGTH(data); i++) |
76 g_constructors->set(data[i].tag.localName(), data[i].func); | 76 g_constructors->set(data[i].tag.localName(), data[i].func); |
77 } | 77 } |
78 | 78 |
79 {{namespace}}Element* {{namespace}}ElementFactory::create{{namespace}}Element( | 79 {{namespace}}Element* {{namespace}}ElementFactory::create{{namespace}}Element( |
80 const AtomicString& localName, | 80 const AtomicString& localName, |
81 Document& document, | 81 Document& document, |
82 {% if namespace == 'HTML' %} | 82 {% if namespace == 'HTML' %} |
83 HTMLFormElement* formElement, | 83 HTMLFormElement* formElement, |
84 {% endif %} | 84 {% endif %} |
85 bool createdByParser) | 85 CreateElementFlags flags) |
86 { | 86 { |
87 if (!g_constructors) | 87 if (!g_constructors) |
88 create{{namespace}}FunctionMap(); | 88 create{{namespace}}FunctionMap(); |
89 if (ConstructorFunction function = g_constructors->get(localName)) | 89 if (ConstructorFunction function = g_constructors->get(localName)) |
90 return function(document, {% if namespace == 'HTML' %}formElement, {% en
dif %}createdByParser); | 90 return function(document, {% if namespace == 'HTML' %}formElement, {% en
dif %}flags); |
91 | 91 |
92 {% if namespace == 'HTML' %} | 92 {% if namespace == 'HTML' %} |
93 if (CustomElement::shouldCreateCustomElement(document, localName)) | 93 if (CustomElement::shouldCreateCustomElement(document, localName)) |
94 return CustomElement::createCustomElement(document, localName); | 94 return CustomElement::createCustomElement(document, localName, flags); |
95 {% endif %} | 95 {% endif %} |
96 | 96 |
97 if (document.registrationContext() && V0CustomElement::isValidName(localName
)) { | 97 if (document.registrationContext() && V0CustomElement::isValidName(localName
)) { |
98 Element* element = document.registrationContext()->createCustomTagElemen
t(document, QualifiedName(nullAtom, localName, {{namespace_prefix}}NamespaceURI)
); | 98 Element* element = document.registrationContext()->createCustomTagElemen
t(document, QualifiedName(nullAtom, localName, {{namespace_prefix}}NamespaceURI)
); |
99 ASSERT_WITH_SECURITY_IMPLICATION(element->is{{namespace}}Element()); | 99 ASSERT_WITH_SECURITY_IMPLICATION(element->is{{namespace}}Element()); |
100 return to{{namespace}}Element(element); | 100 return to{{namespace}}Element(element); |
101 } | 101 } |
102 | 102 |
103 return {{fallback_interface}}::create(QualifiedName(nullAtom, localName, {{n
amespace_prefix}}NamespaceURI), document); | 103 return {{fallback_interface}}::create(QualifiedName(nullAtom, localName, {{n
amespace_prefix}}NamespaceURI), document); |
104 } | 104 } |
105 | 105 |
106 } // namespace blink | 106 } // namespace blink |
OLD | NEW |