| 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" |
| 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/frame/Settings.h" | 19 #include "core/frame/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)(Document&, | 26 typedef PassRefPtr<{{namespace}}Element> (*ConstructorFunction)(Document&, |
| 27 {%- if namespace
== 'HTML' %} | 27 {% if namespace
== 'HTML' %} |
| 28 HTMLFormElement*
, | 28 HTMLFormElement*
, |
| 29 {%- endif %} | 29 {% endif %} |
| 30 bool createdByPa
rser); | 30 bool createdByPa
rser); |
| 31 | 31 |
| 32 typedef HashMap<AtomicString, ConstructorFunction> FunctionMap; | 32 typedef HashMap<AtomicString, ConstructorFunction> FunctionMap; |
| 33 | 33 |
| 34 static FunctionMap* g_constructors = 0; | 34 static FunctionMap* g_constructors = 0; |
| 35 | 35 {# FIXME: add blank line #} |
| 36 {%- for tag in tags|sort if not tag.noConstructor %} | 36 {% for tag in tags|sort if not tag.noConstructor %} |
| 37 static PassRefPtr<{{namespace}}Element> {{tag|symbol}}Constructor( | 37 static PassRefPtr<{{namespace}}Element> {{tag|symbol}}Constructor( |
| 38 Document& document, | 38 Document& document, |
| 39 {%- if namespace == 'HTML' %} | 39 {% if namespace == 'HTML' %} |
| 40 HTMLFormElement* formElement, | 40 HTMLFormElement* formElement, |
| 41 {%- endif %} | 41 {% endif %} |
| 42 bool createdByParser) | 42 bool createdByParser) |
| 43 { | 43 { |
| 44 {%- if tag.contextConditional %} | 44 {% if tag.contextConditional %} |
| 45 if (!ContextFeatures::{{tag.contextConditional}}Enabled(&document)) | 45 if (!ContextFeatures::{{tag.contextConditional}}Enabled(&document)) |
| 46 return {{fallback_interface}}::create({{tag|symbol}}Tag, document); | 46 return {{fallback_interface}}::create({{tag|symbol}}Tag, document); |
| 47 {%- endif %} | 47 {% endif %} |
| 48 {%- if tag.runtimeEnabled %} | 48 {% if tag.runtimeEnabled %} |
| 49 if (!RuntimeEnabledFeatures::{{tag.runtimeEnabled}}Enabled()) | 49 if (!RuntimeEnabledFeatures::{{tag.runtimeEnabled}}Enabled()) |
| 50 return {{fallback_interface}}::create({{tag|symbol}}Tag, document); | 50 return {{fallback_interface}}::create({{tag|symbol}}Tag, document); |
| 51 {%- endif %} | 51 {% endif %} |
| 52 {# FIXME: replace with an |args| variable #} |
| 52 return {{tag.interface}}::create( | 53 return {{tag.interface}}::create( |
| 53 {%- if tag.multipleTagNames -%} {{tag|symbol}}Tag, {% endif -%} | 54 {%- if tag.multipleTagNames %}{{tag|symbol}}Tag, {% endif -%} |
| 54 document | 55 document |
| 55 {%- if namespace == 'HTML' and tag.constructorNeedsFormElement %}, formElement{%
endif -%} | 56 {%- if namespace == 'HTML' and tag.constructorNeedsFormElement %}, formE
lement{% endif %} |
| 56 {%- if tag.constructorNeedsCreatedByParser %}, createdByParser{% endif -%} | 57 {%- if tag.constructorNeedsCreatedByParser %}, createdByParser{% endif -
%} |
| 57 ); | 58 ); |
| 58 } | 59 } |
| 59 {%- endfor %} | 60 {% endfor %} |
| 60 | 61 |
| 61 struct Create{{namespace}}FunctionMapData { | 62 struct Create{{namespace}}FunctionMapData { |
| 62 const QualifiedName& tag; | 63 const QualifiedName& tag; |
| 63 ConstructorFunction func; | 64 ConstructorFunction func; |
| 64 }; | 65 }; |
| 65 | 66 |
| 66 static void create{{namespace}}FunctionMap() | 67 static void create{{namespace}}FunctionMap() |
| 67 { | 68 { |
| 68 ASSERT(!g_constructors); | 69 ASSERT(!g_constructors); |
| 69 g_constructors = new FunctionMap; | 70 g_constructors = new FunctionMap; |
| 70 static const Create{{namespace}}FunctionMapData data[] = { | 71 static const Create{{namespace}}FunctionMapData data[] = { |
| 71 {%- for tag in tags|sort if not tag.noConstructor %} | 72 {% for tag in tags|sort if not tag.noConstructor %} |
| 72 { {{tag|symbol}}Tag, {{tag|symbol}}Constructor }, | 73 { {{tag|symbol}}Tag, {{tag|symbol}}Constructor }, |
| 73 {%- endfor %} | 74 {% endfor %} |
| 74 }; | 75 }; |
| 75 for (size_t i = 0; i < WTF_ARRAY_LENGTH(data); i++) | 76 for (size_t i = 0; i < WTF_ARRAY_LENGTH(data); i++) |
| 76 g_constructors->set(data[i].tag.localName(), data[i].func); | 77 g_constructors->set(data[i].tag.localName(), data[i].func); |
| 77 } | 78 } |
| 78 | 79 |
| 79 PassRefPtr<{{namespace}}Element> {{namespace}}ElementFactory::create{{namespace}
}Element( | 80 PassRefPtr<{{namespace}}Element> {{namespace}}ElementFactory::create{{namespace}
}Element( |
| 80 const AtomicString& localName, | 81 const AtomicString& localName, |
| 81 Document& document, | 82 Document& document, |
| 82 {%- if namespace == 'HTML' %} | 83 {% if namespace == 'HTML' %} |
| 83 HTMLFormElement* formElement, | 84 HTMLFormElement* formElement, |
| 84 {%- endif %} | 85 {% endif %} |
| 85 bool createdByParser) | 86 bool createdByParser) |
| 86 { | 87 { |
| 87 if (!g_constructors) | 88 if (!g_constructors) |
| 88 create{{namespace}}FunctionMap(); | 89 create{{namespace}}FunctionMap(); |
| 89 if (ConstructorFunction function = g_constructors->get(localName)) | 90 if (ConstructorFunction function = g_constructors->get(localName)) |
| 90 return function(document, {%- if namespace == 'HTML' %}formElement,{% en
dif %} createdByParser); | 91 {# FIXME: add missing space; should be: |
| 92 return function(document, {% if namespace == 'HTML' %}formElement, {% en
dif %}createdByParser); #} |
| 93 return function(document,{% if namespace == 'HTML' %}formElement,{% endi
f %} createdByParser); |
| 91 | 94 |
| 92 if (document.registrationContext() && CustomElement::isValidName(localName))
{ | 95 if (document.registrationContext() && CustomElement::isValidName(localName))
{ |
| 93 RefPtr<Element> element = document.registrationContext()->createCustomTa
gElement(document, QualifiedName(nullAtom, localName, {{namespace_prefix}}Namesp
aceURI)); | 96 RefPtr<Element> element = document.registrationContext()->createCustomTa
gElement(document, QualifiedName(nullAtom, localName, {{namespace_prefix}}Namesp
aceURI)); |
| 94 ASSERT_WITH_SECURITY_IMPLICATION(element->is{{namespace}}Element()); | 97 ASSERT_WITH_SECURITY_IMPLICATION(element->is{{namespace}}Element()); |
| 95 return static_pointer_cast<{{namespace}}Element>(element.release()); | 98 return static_pointer_cast<{{namespace}}Element>(element.release()); |
| 96 } | 99 } |
| 97 | 100 |
| 98 return {{fallback_interface}}::create(QualifiedName(nullAtom, localName, {{n
amespace_prefix}}NamespaceURI), document); | 101 return {{fallback_interface}}::create(QualifiedName(nullAtom, localName, {{n
amespace_prefix}}NamespaceURI), document); |
| 99 } | 102 } |
| 100 | 103 |
| 101 } // namespace WebCore | 104 } // namespace WebCore |
| OLD | NEW |