| OLD | NEW |
| 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" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 {% if namespace == 'HTML' %} | 28 {% if namespace == 'HTML' %} |
| 29 HTMLFormElement*, | 29 HTMLFormElement*, |
| 30 {% endif %} | 30 {% endif %} |
| 31 bool createdByParser); | 31 bool createdByParser); |
| 32 | 32 |
| 33 typedef HashMap<AtomicString, ConstructorFunction> FunctionMap; | 33 typedef HashMap<AtomicString, ConstructorFunction> FunctionMap; |
| 34 | 34 |
| 35 static FunctionMap* g_constructors = 0; | 35 static FunctionMap* g_constructors = 0; |
| 36 | 36 |
| 37 {% for tag in tags|sort if not tag.noConstructor %} | 37 {% for tag in tags|sort if not tag.noConstructor %} |
| 38 {% filter enable_conditional(tag.Conditional) %} |
| 38 static PassRefPtrWillBeRawPtr<{{namespace}}Element> {{tag|symbol}}Constructor( | 39 static PassRefPtrWillBeRawPtr<{{namespace}}Element> {{tag|symbol}}Constructor( |
| 39 Document& document, | 40 Document& document, |
| 40 {% if namespace == 'HTML' %} | 41 {% if namespace == 'HTML' %} |
| 41 HTMLFormElement* formElement, | 42 HTMLFormElement* formElement, |
| 42 {% endif %} | 43 {% endif %} |
| 43 bool createdByParser) | 44 bool createdByParser) |
| 44 { | 45 { |
| 45 {% if tag.contextConditional %} | 46 {% if tag.contextConditional %} |
| 46 if (!ContextFeatures::{{tag.contextConditional}}Enabled(&document)) | 47 if (!ContextFeatures::{{tag.contextConditional}}Enabled(&document)) |
| 47 return {{fallback_interface}}::create({{tag|symbol}}Tag, document); | 48 return {{fallback_interface}}::create({{tag|symbol}}Tag, document); |
| 48 {% endif %} | 49 {% endif %} |
| 49 {% if tag.runtimeEnabled %} | 50 {% if tag.runtimeEnabled %} |
| 50 if (!RuntimeEnabledFeatures::{{tag.runtimeEnabled}}Enabled()) | 51 if (!RuntimeEnabledFeatures::{{tag.runtimeEnabled}}Enabled()) |
| 51 return {{fallback_interface}}::create({{tag|symbol}}Tag, document); | 52 return {{fallback_interface}}::create({{tag|symbol}}Tag, document); |
| 52 {% endif %} | 53 {% endif %} |
| 53 return {{tag.interface}}::create( | 54 return {{tag.interface}}::create( |
| 54 {%- if tag.multipleTagNames %}{{tag|symbol}}Tag, {% endif -%} | 55 {%- if tag.multipleTagNames %}{{tag|symbol}}Tag, {% endif -%} |
| 55 document | 56 document |
| 56 {%- if namespace == 'HTML' and tag.constructorNeedsFormElement %}, formE
lement{% endif -%} | 57 {%- if namespace == 'HTML' and tag.constructorNeedsFormElement %}, formE
lement{% endif -%} |
| 57 {%- if tag.constructorNeedsCreatedByParser %}, createdByParser{% endif -
%} | 58 {%- if tag.constructorNeedsCreatedByParser %}, createdByParser{% endif -
%} |
| 58 ); | 59 ); |
| 59 } | 60 } |
| 61 {% endfilter %} |
| 60 {% endfor %} | 62 {% endfor %} |
| 61 | 63 |
| 62 struct Create{{namespace}}FunctionMapData { | 64 struct Create{{namespace}}FunctionMapData { |
| 63 const QualifiedName& tag; | 65 const QualifiedName& tag; |
| 64 ConstructorFunction func; | 66 ConstructorFunction func; |
| 65 }; | 67 }; |
| 66 | 68 |
| 67 static void create{{namespace}}FunctionMap() | 69 static void create{{namespace}}FunctionMap() |
| 68 { | 70 { |
| 69 ASSERT(!g_constructors); | 71 ASSERT(!g_constructors); |
| 70 g_constructors = new FunctionMap; | 72 g_constructors = new FunctionMap; |
| 73 // Empty array initializer lists are illegal [dcl.init.aggr] and will not |
| 74 // compile in MSVC. If tags list is empty, add check to skip this. |
| 71 static const Create{{namespace}}FunctionMapData data[] = { | 75 static const Create{{namespace}}FunctionMapData data[] = { |
| 72 {% for tag in tags|sort if not tag.noConstructor %} | 76 {% for tag in tags|sort if not tag.noConstructor %} |
| 77 {% filter enable_conditional(tag.Conditional) %} |
| 73 { {{tag|symbol}}Tag, {{tag|symbol}}Constructor }, | 78 { {{tag|symbol}}Tag, {{tag|symbol}}Constructor }, |
| 79 {% endfilter %} |
| 74 {% endfor %} | 80 {% endfor %} |
| 75 }; | 81 }; |
| 76 for (size_t i = 0; i < WTF_ARRAY_LENGTH(data); i++) | 82 for (size_t i = 0; i < WTF_ARRAY_LENGTH(data); i++) |
| 77 g_constructors->set(data[i].tag.localName(), data[i].func); | 83 g_constructors->set(data[i].tag.localName(), data[i].func); |
| 78 } | 84 } |
| 79 | 85 |
| 80 PassRefPtrWillBeRawPtr<{{namespace}}Element> {{namespace}}ElementFactory::create
{{namespace}}Element( | 86 PassRefPtrWillBeRawPtr<{{namespace}}Element> {{namespace}}ElementFactory::create
{{namespace}}Element( |
| 81 const AtomicString& localName, | 87 const AtomicString& localName, |
| 82 Document& document, | 88 Document& document, |
| 83 {% if namespace == 'HTML' %} | 89 {% if namespace == 'HTML' %} |
| 84 HTMLFormElement* formElement, | 90 HTMLFormElement* formElement, |
| 85 {% endif %} | 91 {% endif %} |
| 86 bool createdByParser) | 92 bool createdByParser) |
| 87 { | 93 { |
| 88 if (!g_constructors) | 94 if (!g_constructors) |
| 89 create{{namespace}}FunctionMap(); | 95 create{{namespace}}FunctionMap(); |
| 90 if (ConstructorFunction function = g_constructors->get(localName)) | 96 if (ConstructorFunction function = g_constructors->get(localName)) |
| 91 return function(document, {% if namespace == 'HTML' %}formElement, {% en
dif %}createdByParser); | 97 return function(document, {% if namespace == 'HTML' %}formElement, {% en
dif %}createdByParser); |
| 92 | 98 |
| 93 if (document.registrationContext() && CustomElement::isValidName(localName))
{ | 99 if (document.registrationContext() && CustomElement::isValidName(localName))
{ |
| 94 RefPtrWillBeRawPtr<Element> element = document.registrationContext()->cr
eateCustomTagElement(document, QualifiedName(nullAtom, localName, {{namespace_pr
efix}}NamespaceURI)); | 100 RefPtrWillBeRawPtr<Element> element = document.registrationContext()->cr
eateCustomTagElement(document, QualifiedName(nullAtom, localName, {{namespace_pr
efix}}NamespaceURI)); |
| 95 ASSERT_WITH_SECURITY_IMPLICATION(element->is{{namespace}}Element()); | 101 ASSERT_WITH_SECURITY_IMPLICATION(element->is{{namespace}}Element()); |
| 96 return static_pointer_cast<{{namespace}}Element>(element.release()); | 102 return static_pointer_cast<{{namespace}}Element>(element.release()); |
| 97 } | 103 } |
| 98 | 104 |
| 99 return {{fallback_interface}}::create(QualifiedName(nullAtom, localName, {{n
amespace_prefix}}NamespaceURI), document); | 105 return {{fallback_interface}}::create(QualifiedName(nullAtom, localName, {{n
amespace_prefix}}NamespaceURI), document); |
| 100 } | 106 } |
| 101 | 107 |
| 102 } // namespace WebCore | 108 } // namespace WebCore |
| OLD | NEW |