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

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

Issue 35423004: Move SVGNames to Python (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Add comment Created 7 years, 2 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 | Annotate | Revision Log
OLDNEW
1 {% from "macros.tmpl" import license -%} 1 {% from "macros.tmpl" import license -%}
2 {{ license() }} 2 {{ license() }}
3 3
4 #include "config.h" 4 #include "config.h"
5 #include "{{namespace}}ElementFactory.h" 5 #include "{{namespace}}ElementFactory.h"
6 6
7 #include "RuntimeEnabledFeatures.h" 7 #include "RuntimeEnabledFeatures.h"
8 #include "{{namespace}}Names.h" 8 #include "{{namespace}}Names.h"
9 {%- for tag in tags|sort %} 9 {%- for tag in tags|sort %}
10 #include "core/{{namespace|lower}}/{{tag|interface}}.h" 10 #include "core/{{namespace|lower}}/{{tag.interface}}.h"
11 {%- endfor %} 11 {%- endfor %}
12 {%- if fallback_interface %} 12 {%- if fallback_interface %}
13 #include "core/{{namespace|lower}}/{{fallback_interface}}.h" 13 #include "core/{{namespace|lower}}/{{fallback_interface}}.h"
14 {%- endif %} 14 {%- endif %}
15 #include "core/dom/ContextFeatures.h" 15 #include "core/dom/ContextFeatures.h"
16 #include "core/dom/custom/CustomElement.h" 16 #include "core/dom/custom/CustomElement.h"
17 #include "core/dom/custom/CustomElementRegistrationContext.h" 17 #include "core/dom/custom/CustomElementRegistrationContext.h"
18 #include "core/dom/Document.h" 18 #include "core/dom/Document.h"
19 #include "core/page/Settings.h" 19 #include "core/page/Settings.h"
20 #include "wtf/HashMap.h" 20 #include "wtf/HashMap.h"
21 21
22 namespace WebCore { 22 namespace WebCore {
23 23
24 using namespace {{namespace}}Names; 24 using namespace {{namespace}}Names;
25 25
26 typedef PassRefPtr<{{namespace}}Element> (*ConstructorFunction)(const QualifiedN ame&, Document&, HTMLFormElement*, bool createdByParser); 26 typedef PassRefPtr<{{namespace}}Element> (*ConstructorFunction)(const QualifiedN ame&,
27 Document&,
28 {%- if namespace == 'HTML' %}
29 HTMLFormElement* ,
30 {%- endif %}
31 bool createdByPa rser);
32
27 typedef HashMap<StringImpl*, ConstructorFunction> FunctionMap; 33 typedef HashMap<StringImpl*, ConstructorFunction> FunctionMap;
28 34
29 static FunctionMap* g_constructors = 0; 35 static FunctionMap* g_constructors = 0;
30 36
31 {%- for tag in tags|sort if not tag.mapToTagName and not tag.noConstructor %} 37 {%- for tag in tags|sort if not tag.mapToTagName and not tag.noConstructor %}
32 static PassRefPtr<{{namespace}}Element> {{tag|symbol}}Constructor(const Qualifie dName& tagName, Document& document, HTMLFormElement* formElement, bool createdBy Parser) 38 static PassRefPtr<{{namespace}}Element> {{tag|symbol}}Constructor(
39 const QualifiedName& tagName,
40 Document& document,
41 {%- if namespace == 'HTML' %}
42 HTMLFormElement* formElement,
43 {%- endif %}
44 bool createdByParser)
33 { 45 {
34 {%- if tag.wrapperOnlyIfMediaIsAvailable %} 46 {%- if tag.wrapperOnlyIfMediaIsAvailable %}
35 Settings* settings = document.settings(); 47 Settings* settings = document.settings();
36 if (!RuntimeEnabledFeatures::mediaEnabled() || (settings && !settings->media Enabled())) 48 if (!RuntimeEnabledFeatures::mediaEnabled() || (settings && !settings->media Enabled()))
37 return 0; 49 return 0;
38 {%- endif %} 50 {%- endif %}
39 {%- if tag.contextConditional %} 51 {%- if tag.contextConditional %}
40 if (!ContextFeatures::{{tag.contextConditional}}Enabled(&document)) 52 if (!ContextFeatures::{{tag.contextConditional}}Enabled(&document))
41 return 0; 53 return 0;
42 {%- endif %} 54 {%- endif %}
43 return {{tag|interface}}::create(tagName, document 55 return {{tag.interface}}::create(tagName, document
44 {%- if tag.constructorNeedsFormElement %}, formElement{% endif -%} 56 {%- if namespace == 'HTML' and tag.constructorNeedsFormElement %}, formElement{% endif -%}
45 {%- if tag.constructorNeedsCreatedByParser %}, createdByParser{% endif -%} 57 {%- if tag.constructorNeedsCreatedByParser %}, createdByParser{% endif -%}
46 ); 58 );
47 } 59 }
48 {%- endfor %} 60 {%- endfor %}
49 61
50 {%- for tag in tags|sort if tag.mapToTagName %} 62 {%- for tag in tags|sort if tag.mapToTagName %}
51 static PassRefPtr<HTMLElement> {{tag|symbol}}Constructor(const QualifiedName& ta gName, Document& document, HTMLFormElement* formElement, bool createdByParser) 63 static PassRefPtr<HTMLElement> {{tag|symbol}}Constructor(const QualifiedName& ta gName, Document& document, HTMLFormElement* formElement, bool createdByParser)
52 { 64 {
53 return {{tag.mapToTagName}}Constructor(QualifiedName(tagName.prefix(), {{tag .mapToTagName}}Tag.localName(), tagName.namespaceURI()), document, formElement, createdByParser); 65 return {{tag.mapToTagName}}Constructor(QualifiedName(tagName.prefix(), {{tag .mapToTagName}}Tag.localName(), tagName.namespaceURI()), document, formElement, createdByParser);
54 } 66 }
55 {%- endfor %} 67 {%- endfor %}
56 68
57 static void addTag(const QualifiedName& tag, ConstructorFunction func) 69 static void addTag(const QualifiedName& tag, ConstructorFunction func)
58 { 70 {
59 g_constructors->set(tag.localName().impl(), func); 71 g_constructors->set(tag.localName().impl(), func);
60 } 72 }
61 73
62 static void createFunctionMap() 74 static void createFunctionMap()
63 { 75 {
64 ASSERT(!g_constructors); 76 ASSERT(!g_constructors);
65 g_constructors = new FunctionMap; 77 g_constructors = new FunctionMap;
66 {%- for tag in tags|sort if not tag.noConstructor %} 78 {%- for tag in tags|sort if not tag.noConstructor %}
67 addTag({{tag|symbol}}Tag, {{tag|symbol}}Constructor); 79 addTag({{tag|symbol}}Tag, {{tag|symbol}}Constructor);
68 {%- endfor %} 80 {%- endfor %}
69 } 81 }
70 82
71 PassRefPtr<{{namespace}}Element> {{namespace}}ElementFactory::create{{namespace} }Element(const QualifiedName& qName, Document* document, HTMLFormElement* formEl ement, bool createdByParser) 83 PassRefPtr<{{namespace}}Element> {{namespace}}ElementFactory::create{{namespace} }Element(
84 const QualifiedName& qName,
85 Document* document,
86 {%- if namespace == 'HTML' %}
87 HTMLFormElement* formElement,
88 {%- endif %}
89 bool createdByParser)
72 { 90 {
73 if (!document) 91 if (!document)
74 return 0; 92 return 0;
75 93
76 if (CustomElement::isValidName(qName.localName()) && document->registrationC ontext()) { 94 if (CustomElement::isValidName(qName.localName()) && document->registrationC ontext()) {
77 RefPtr<Element> element = document->registrationContext()->createCustomT agElement(*document, qName, createdByParser ? CustomElementRegistrationContext:: CreatedByParser : CustomElementRegistrationContext::NotCreatedByParser); 95 RefPtr<Element> element = document->registrationContext()->createCustomT agElement(*document, qName, createdByParser ? CustomElementRegistrationContext:: CreatedByParser : CustomElementRegistrationContext::NotCreatedByParser);
78 ASSERT_WITH_SECURITY_IMPLICATION(element->is{{namespace}}Element()); 96 ASSERT_WITH_SECURITY_IMPLICATION(element->is{{namespace}}Element());
79 return static_pointer_cast<{{namespace}}Element>(element.release()); 97 return static_pointer_cast<{{namespace}}Element>(element.release());
80 } 98 }
81 99
82 if (!g_constructors) 100 if (!g_constructors)
83 createFunctionMap(); 101 createFunctionMap();
84 if (ConstructorFunction function = g_constructors->get(qName.localName().imp l())) { 102 if (ConstructorFunction function = g_constructors->get(qName.localName().imp l())) {
85 if (PassRefPtr<{{namespace}}Element> element = function(qName, *document , formElement, createdByParser)) 103 if (PassRefPtr<{{namespace}}Element> element = function(qName,
104 *document,
105 {%- if namespace == 'HTML' %}formElement,{% endif %}
106 createdByParser) )
86 return element; 107 return element;
87 } 108 }
88 109
89 return {{fallback_interface}}::create(qName, *document); 110 return {{fallback_interface}}::create(qName, *document);
90 } 111 }
91 112
92 } // namespace WebCore 113 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/build/scripts/name_utilities.py ('k') | Source/build/scripts/templates/ElementFactory.h.tmpl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698