| 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 "V8{{namespace}}ElementWrapperFactory.h" | 5 #include "V8{{namespace}}ElementWrapperFactory.h" |
| 6 | 6 |
| 7 #include "RuntimeEnabledFeatures.h" | 7 #include "RuntimeEnabledFeatures.h" |
| 8 #include "{{namespace}}Names.h" | 8 #include "{{namespace}}Names.h" |
| 9 #include "bindings/v8/CustomElementWrapper.h" | 9 #include "bindings/v8/CustomElementWrapper.h" |
| 10 {%- for tag in tags|sort if tag.has_js_interface %} | 10 {% for tag in tags|sort if tag.has_js_interface %} |
| 11 #include "V8{{tag.interface}}.h" | 11 #include "V8{{tag.interface}}.h" |
| 12 {%- endfor %} | 12 {% endfor %} |
| 13 {%- for tag in tags|sort if tag.has_js_interface %} | 13 {% for tag in tags|sort if tag.has_js_interface %} |
| 14 #include "core/{{namespace|lower}}/{{tag.js_interface}}.h" | 14 #include "core/{{namespace|lower}}/{{tag.js_interface}}.h" |
| 15 {%- endfor %} | 15 {% endfor %} |
| 16 #include "core/{{namespace|lower}}/{{fallback_js_interface}}.h" | 16 #include "core/{{namespace|lower}}/{{fallback_js_interface}}.h" |
| 17 #include "core/dom/ContextFeatures.h" | 17 #include "core/dom/ContextFeatures.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/StdLibExtras.h" | 20 #include "wtf/StdLibExtras.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 v8::Handle<v8::Object> (*Create{{namespace}}ElementWrapperFunction)({{na
mespace}}Element*, v8::Handle<v8::Object> creationContext, v8::Isolate*); | 26 typedef v8::Handle<v8::Object> (*Create{{namespace}}ElementWrapperFunction)({{na
mespace}}Element*, v8::Handle<v8::Object> creationContext, v8::Isolate*); |
| 27 | 27 |
| 28 static v8::Handle<v8::Object> create{{namespace}}ElementWrapper({{namespace}}Ele
ment*, v8::Handle<v8::Object>, v8::Isolate*) | 28 static v8::Handle<v8::Object> create{{namespace}}ElementWrapper({{namespace}}Ele
ment*, v8::Handle<v8::Object>, v8::Isolate*) |
| 29 { | 29 { |
| 30 ASSERT_NOT_REACHED(); | 30 ASSERT_NOT_REACHED(); |
| 31 return v8::Handle<v8::Object>(); | 31 return v8::Handle<v8::Object>(); |
| 32 } | 32 } |
| 33 | 33 {% for js_interface, list in tags|sort|selectattr('has_js_interface')|groupby('j
s_interface') %} |
| 34 {%- for js_interface, list in tags|sort|selectattr('has_js_interface')|groupby('
js_interface') %} | |
| 35 static v8::Handle<v8::Object> create{{js_interface}}Wrapper({{namespace}}Element
* element, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate) | 34 static v8::Handle<v8::Object> create{{js_interface}}Wrapper({{namespace}}Element
* element, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate) |
| 36 { | 35 { |
| 37 {%- if list[0].contextConditional %} | 36 {% if list[0].contextConditional %} |
| 38 if (!ContextFeatures::{{list[0].contextConditional}}Enabled(&element->docume
nt())) | 37 if (!ContextFeatures::{{list[0].contextConditional}}Enabled(&element->docume
nt())) |
| 39 return createV8{{namespace}}FallbackWrapper(to{{fallback_js_interface}}(
element), creationContext, isolate); | 38 return createV8{{namespace}}FallbackWrapper(to{{fallback_js_interface}}(
element), creationContext, isolate); |
| 40 {%- endif %} | 39 {% endif %} |
| 41 {%- if list[0].runtimeEnabled %} | 40 {% if list[0].runtimeEnabled %} |
| 42 if (!RuntimeEnabledFeatures::{{list[0].runtimeEnabled}}Enabled()) | 41 if (!RuntimeEnabledFeatures::{{list[0].runtimeEnabled}}Enabled()) |
| 43 return createV8{{namespace}}FallbackWrapper(to{{fallback_js_interface}}(
element), creationContext, isolate); | 42 return createV8{{namespace}}FallbackWrapper(to{{fallback_js_interface}}(
element), creationContext, isolate); |
| 44 {%- endif %} | 43 {% endif %} |
| 45 return wrap(static_cast<{{js_interface}}*>(element), creationContext, isolat
e); | 44 return wrap(static_cast<{{js_interface}}*>(element), creationContext, isolat
e); |
| 46 } | 45 } |
| 47 {%- endfor %} | 46 {% endfor %} |
| 48 | 47 |
| 49 v8::Handle<v8::Object> createV8{{namespace}}Wrapper({{namespace}}Element* elemen
t, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate) | 48 v8::Handle<v8::Object> createV8{{namespace}}Wrapper({{namespace}}Element* elemen
t, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate) |
| 50 { | 49 { |
| 51 typedef HashMap<StringImpl*, Create{{namespace}}ElementWrapperFunction> Func
tionMap; | 50 typedef HashMap<StringImpl*, Create{{namespace}}ElementWrapperFunction> Func
tionMap; |
| 52 DEFINE_STATIC_LOCAL(FunctionMap, map, ()); | 51 DEFINE_STATIC_LOCAL(FunctionMap, map, ()); |
| 53 if (map.isEmpty()) { | 52 if (map.isEmpty()) { |
| 54 {%- for tag in tags|sort %} | 53 {% for tag in tags|sort %} |
| 55 map.set({{tag|symbol}}Tag.localName().impl(), create{{tag.js_interface}}
Wrapper); | 54 map.set({{tag|symbol}}Tag.localName().impl(), create{{tag.js_interface}}
Wrapper); |
| 56 {%- endfor %} | 55 {% endfor %} |
| 57 } | 56 } |
| 58 | 57 |
| 59 Create{{namespace}}ElementWrapperFunction createWrapperFunction = map.get(el
ement->localName().impl()); | 58 Create{{namespace}}ElementWrapperFunction createWrapperFunction = map.get(el
ement->localName().impl()); |
| 60 if (createWrapperFunction == create{{namespace}}ElementWrapper) | 59 if (createWrapperFunction == create{{namespace}}ElementWrapper) |
| 61 createWrapperFunction = createV8{{namespace}}DirectWrapper; | 60 createWrapperFunction = createV8{{namespace}}DirectWrapper; |
| 62 if (element->isCustomElement()) | 61 if (element->isCustomElement()) |
| 63 return CustomElementWrapper<{{namespace}}Element, V8{{namespace}}Element
>::wrap(element, creationContext, isolate, createWrapperFunction); | 62 return CustomElementWrapper<{{namespace}}Element, V8{{namespace}}Element
>::wrap(element, creationContext, isolate, createWrapperFunction); |
| 64 | 63 |
| 65 if (createWrapperFunction) | 64 if (createWrapperFunction) |
| 66 return createWrapperFunction(element, creationContext, isolate); | 65 return createWrapperFunction(element, creationContext, isolate); |
| 67 {%- if fallback_js_interface == namespace + "Element" %} | 66 {% if fallback_js_interface == namespace + 'Element' %} |
| 68 return V8{{fallback_js_interface}}::createWrapper(element, creationContext,
isolate); | 67 return V8{{fallback_js_interface}}::createWrapper(element, creationContext,
isolate); |
| 69 {%- else %} | 68 {% else %} |
| 70 return wrap(to{{fallback_js_interface}}(element), creationContext, isolate); | 69 return wrap(to{{fallback_js_interface}}(element), creationContext, isolate); |
| 71 {%- endif %} | 70 {% endif %} |
| 72 } | 71 } |
| 73 | 72 |
| 74 const WrapperTypeInfo* findWrapperTypeFor{{namespace}}TagName(const AtomicString
& name) | 73 const WrapperTypeInfo* findWrapperTypeFor{{namespace}}TagName(const AtomicString
& name) |
| 75 { | 74 { |
| 76 typedef HashMap<StringImpl*, const WrapperTypeInfo*> NameTypeMap; | 75 typedef HashMap<StringImpl*, const WrapperTypeInfo*> NameTypeMap; |
| 77 DEFINE_STATIC_LOCAL(NameTypeMap, map, ()); | 76 DEFINE_STATIC_LOCAL(NameTypeMap, map, ()); |
| 78 if (map.isEmpty()) { | 77 if (map.isEmpty()) { |
| 79 // FIXME: This seems wrong. We should list every interface here, not | 78 // FIXME: This seems wrong. We should list every interface here, not |
| 80 // just the ones that have specialized JavaScript interfaces. | 79 // just the ones that have specialized JavaScript interfaces. |
| 81 {%- for tag in tags|sort if tag.has_js_interface %} | 80 {% for tag in tags|sort if tag.has_js_interface %} |
| 82 map.set({{tag|symbol}}Tag.localName().impl(), &V8{{tag.js_interface}}::w
rapperTypeInfo); | 81 map.set({{tag|symbol}}Tag.localName().impl(), &V8{{tag.js_interface}}::w
rapperTypeInfo); |
| 83 {%- endfor %} | 82 {% endfor %} |
| 84 } | 83 } |
| 85 | 84 |
| 86 if (const WrapperTypeInfo* result = map.get(name.impl())) | 85 if (const WrapperTypeInfo* result = map.get(name.impl())) |
| 87 return result; | 86 return result; |
| 88 | 87 |
| 89 return &V8{{fallback_js_interface}}::wrapperTypeInfo; | 88 return &V8{{fallback_js_interface}}::wrapperTypeInfo; |
| 90 } | 89 } |
| 91 | 90 |
| 92 } | 91 } |
| OLD | NEW |