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

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

Issue 2329463004: ABANDONED CL: Changes needed to make things compile after running rewrite_to_chrome_style tool. (Closed)
Patch Set: Rebasing the fixes... Created 3 years, 10 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
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 20 matching lines...) Expand all
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 {{namespace}}Element* {{tag|symbol}}Constructor( 36 static {{namespace}}Element* {{tag|symbol}}Constructor(
37 Document& document, 37 Document& document,
38 CreateElementFlags flags) { 38 CreateElementFlags flags) {
39 {% if tag.runtimeEnabled %} 39 {% if tag.runtimeEnabled %}
40 if (!RuntimeEnabledFeatures::{{tag.runtimeEnabled}}Enabled()) 40 if (!RuntimeEnabledFeatures::{{tag.runtimeEnabled}}Enabled())
41 return {{fallback_interface}}::create({{tag|symbol}}Tag, document); 41 return {{fallback_interface}}::Create({{tag|symbol}}Tag, document);
42 {% endif %} 42 {% endif %}
43 return {{tag.interface}}::create( 43 return {{tag.interface}}::Create(
44 {%- if tag.multipleTagNames %}{{tag|symbol}}Tag, {% endif -%} 44 {%- if tag.multipleTagNames %}{{tag|symbol}}Tag, {% endif -%}
45 document 45 document
46 {%- if tag.constructorNeedsCreatedByParser %}, flags & CreatedByParser{% e ndif -%} 46 {%- if tag.constructorNeedsCreatedByParser %}, flags & kCreatedByParser{% endif -%}
47 ); 47 );
48 } 48 }
49 {% endfor %} 49 {% endfor %}
50 50
51 struct Create{{namespace}}FunctionMapData { 51 struct Create{{namespace}}FunctionMapData {
52 const QualifiedName& tag; 52 const QualifiedName& tag;
53 ConstructorFunction func; 53 ConstructorFunction func;
54 }; 54 };
55 55
56 static void create{{namespace}}FunctionMap() { 56 static void create{{namespace}}FunctionMap() {
57 ASSERT(!g_constructors); 57 ASSERT(!g_constructors);
58 g_constructors = new FunctionMap; 58 g_constructors = new FunctionMap;
59 // Empty array initializer lists are illegal [dcl.init.aggr] and will not 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. 60 // compile in MSVC. If tags list is empty, add check to skip this.
61 static const Create{{namespace}}FunctionMapData data[] = { 61 static const Create{{namespace}}FunctionMapData data[] = {
62 {% for tag in tags|sort if not tag.noConstructor %} 62 {% for tag in tags|sort if not tag.noConstructor %}
63 { {{tag|symbol}}Tag, {{tag|symbol}}Constructor }, 63 { {{tag|symbol}}Tag, {{tag|symbol}}Constructor },
64 {% endfor %} 64 {% endfor %}
65 }; 65 };
66 for (size_t i = 0; i < WTF_ARRAY_LENGTH(data); i++) 66 for (size_t i = 0; i < WTF_ARRAY_LENGTH(data); i++)
67 g_constructors->set(data[i].tag.localName(), data[i].func); 67 g_constructors->Set(data[i].tag.LocalName(), data[i].func);
68 } 68 }
69 69
70 {{namespace}}Element* {{namespace}}ElementFactory::create{{namespace}}Element( 70 {{namespace}}Element* {{namespace}}ElementFactory::create{{namespace}}Element(
71 const AtomicString& localName, 71 const AtomicString& localName,
72 Document& document, 72 Document& document,
73 CreateElementFlags flags) { 73 CreateElementFlags flags) {
74 if (!g_constructors) 74 if (!g_constructors)
75 create{{namespace}}FunctionMap(); 75 create{{namespace}}FunctionMap();
76 if (ConstructorFunction function = g_constructors->get(localName)) 76 if (ConstructorFunction function = g_constructors->Get(localName))
77 return function(document, flags); 77 return function(document, flags);
78 78
79 {% if namespace == 'HTML' %} 79 {% if namespace == 'HTML' %}
80 // createElement handles custom element creation itself in order to 80 // createElement handles custom element creation itself in order to
81 // transmit exceptions. 81 // transmit exceptions.
82 // TODO(dominicc): When the HTML parser can pass an error 82 // TODO(dominicc): When the HTML parser can pass an error
83 // reporting ExceptionState, and "v0" custom elements have been 83 // reporting ExceptionState, and "v0" custom elements have been
84 // removed, consolidate custom element creation into one place. 84 // removed, consolidate custom element creation into one place.
85 if (flags != CreatedByCreateElement && CustomElement::shouldCreateCustomElemen t(localName)) { 85 if (flags != kCreatedByCreateElement && CustomElement::ShouldCreateCustomEleme nt(localName)) {
86 QualifiedName tagName(nullAtom, localName, HTMLNames::xhtmlNamespaceURI); 86 QualifiedName tagName(g_null_atom, localName, HTMLNames::xhtmlNamespaceURI);
87 if (flags & AsynchronousCustomElements) 87 if (flags & kAsynchronousCustomElements)
88 return CustomElement::createCustomElementAsync(document, tagName); 88 return CustomElement::CreateCustomElementAsync(document, tagName);
89 return CustomElement::createCustomElementSync(document, tagName); 89 return CustomElement::CreateCustomElementSync(document, tagName);
90 } 90 }
91 {% endif %} 91 {% endif %}
92 92
93 if (document.registrationContext() && 93 if (document.RegistrationContext() &&
94 V0CustomElement::isValidName(localName)) { 94 V0CustomElement::IsValidName(localName)) {
95 Element* element = document.registrationContext()->createCustomTagElement( 95 Element* element = document.RegistrationContext()->CreateCustomTagElement(
96 document, QualifiedName(nullAtom, localName, {{namespace_prefix}}Namespa ceURI)); 96 document, QualifiedName(g_null_atom, localName, {{namespace_prefix}}Name spaceURI));
97 SECURITY_DCHECK(element->is{{namespace}}Element()); 97 SECURITY_DCHECK(element->Is{{namespace}}Element());
98 return to{{namespace}}Element(element); 98 return To{{namespace}}Element(element);
99 } 99 }
100 100
101 return {{fallback_interface}}::create(QualifiedName(nullAtom, localName, {{nam espace_prefix}}NamespaceURI), document); 101 return {{fallback_interface}}::Create(QualifiedName(g_null_atom, localName, {{ namespace_prefix}}NamespaceURI), document);
102 } 102 }
103 103
104 } // namespace blink 104 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698