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

Side by Side Diff: third_party/WebKit/Source/build/scripts/templates/ElementFactory.cpp.tmpl

Issue 2002063003: Change "bool createdByParser" of createElement() to enum (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@cestate
Patch Set: Add ImportNode Created 4 years, 6 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 | third_party/WebKit/Source/build/scripts/templates/ElementFactory.h.tmpl » ('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|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
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
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
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/build/scripts/templates/ElementFactory.h.tmpl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698