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