OLD | NEW |
---|---|
1 {% from "macros.tmpl" import license %} | 1 {% from "macros.tmpl" import license %} |
haraken
2014/09/04 02:17:46
I hope you completely remove ElementWrapperFactory
Yuki
2014/09/04 04:47:29
Yes, will do.
| |
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 "{{namespace}}Names.h" | 7 #include "{{namespace}}Names.h" |
8 #include "bindings/core/v8/CustomElementWrapper.h" | 8 #include "bindings/core/v8/CustomElementWrapper.h" |
9 {% for tag in tags|sort if tag.has_js_interface %} | 9 {% for tag in tags|sort if tag.has_js_interface %} |
10 #include "bindings/core/v8/V8{{tag.interface}}.h" | 10 #include "bindings/core/v8/V8{{tag.interface}}.h" |
11 {% endfor %} | 11 {% endfor %} |
12 {% for tag in tags|sort if tag.has_js_interface %} | 12 {% for tag in tags|sort if tag.has_js_interface %} |
13 #include "core/{{namespace|lower}}/{{tag.js_interface}}.h" | 13 #include "core/{{namespace|lower}}/{{tag.js_interface}}.h" |
14 {% endfor %} | 14 {% endfor %} |
15 #include "core/{{namespace|lower}}/{{fallback_js_interface}}.h" | 15 #include "core/{{namespace|lower}}/{{fallback_js_interface}}.h" |
16 #include "core/dom/Document.h" | 16 #include "core/dom/Document.h" |
17 #include "core/frame/Settings.h" | 17 #include "core/frame/Settings.h" |
18 #include "platform/RuntimeEnabledFeatures.h" | 18 #include "platform/RuntimeEnabledFeatures.h" |
19 #include "wtf/StdLibExtras.h" | 19 #include "wtf/StdLibExtras.h" |
20 | 20 |
21 namespace blink { | 21 namespace blink { |
22 | 22 |
23 using namespace {{namespace}}Names; | 23 using namespace {{namespace}}Names; |
24 | 24 |
25 typedef v8::Handle<v8::Object> (*Create{{namespace}}ElementWrapperFunction)({{na mespace}}Element*, v8::Handle<v8::Object> creationContext, v8::Isolate*); | |
26 | |
27 static v8::Handle<v8::Object> create{{namespace}}ElementWrapper({{namespace}}Ele ment*, v8::Handle<v8::Object>, v8::Isolate*) | |
28 { | |
29 ASSERT_NOT_REACHED(); | |
30 return v8::Handle<v8::Object>(); | |
31 } | |
32 {% for js_interface, list in tags|sort|selectattr('has_js_interface')|groupby('j s_interface') %} | |
33 {% filter enable_conditional(list[0].Conditional) %} | |
34 static v8::Handle<v8::Object> create{{js_interface}}Wrapper({{namespace}}Element * element, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate) | |
35 { | |
36 {% if list[0].runtimeEnabled %} | |
37 if (!RuntimeEnabledFeatures::{{list[0].runtimeEnabled}}Enabled()) | |
haraken
2014/09/04 02:17:46
It is wrong to just remove this code. We need to f
Yuki
2014/09/04 04:47:29
Hmm. If the element is not runtime-enabled, then
haraken
2014/09/04 04:54:52
What happens if:
<div id="foo">
<audio></audio>
<
Yuki
2014/09/04 14:10:14
As talked offline, if the runtime flag is not enab
| |
38 return createV8{{namespace}}FallbackWrapper(to{{fallback_js_interface}}( element), creationContext, isolate); | |
39 {% endif %} | |
40 return wrap(static_cast<{{js_interface}}*>(element), creationContext, isolat e); | |
41 } | |
42 {% endfilter %} | |
43 {% endfor %} | |
44 | |
45 v8::Handle<v8::Object> createV8{{namespace}}Wrapper({{namespace}}Element* elemen t, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate) | |
46 { | |
47 typedef HashMap<StringImpl*, Create{{namespace}}ElementWrapperFunction> Func tionMap; | |
48 DEFINE_STATIC_LOCAL(FunctionMap, map, ()); | |
49 if (map.isEmpty()) { | |
50 {% for tag in tags|sort %} | |
51 {% filter enable_conditional(tag.Conditional) %} | |
52 map.set({{tag|symbol}}Tag.localName().impl(), create{{tag.js_interface}} Wrapper); | |
53 {% endfilter %} | |
54 {% endfor %} | |
55 } | |
56 | |
57 Create{{namespace}}ElementWrapperFunction createWrapperFunction = map.get(el ement->localName().impl()); | |
58 if (createWrapperFunction == create{{namespace}}ElementWrapper) | |
59 createWrapperFunction = createV8{{namespace}}DirectWrapper; | |
haraken
2014/09/04 02:17:46
I think it's correct to just remove createV8HTMLDi
Yuki
2014/09/04 04:47:29
That's right. In addition, it must be fine to use
haraken
2014/09/04 04:54:52
There is no V8T for the classes that had been usin
Yuki
2014/09/04 14:10:14
Yes, there are such cases. In those cases, they a
| |
60 if (element->isCustomElement()) | |
61 return CustomElementWrapper<{{namespace}}Element, V8{{namespace}}Element >::wrap(element, creationContext, isolate, createWrapperFunction); | |
62 | |
63 if (createWrapperFunction) | |
64 return createWrapperFunction(element, creationContext, isolate); | |
65 {% if fallback_js_interface == namespace + 'Element' %} | |
66 return V8{{fallback_js_interface}}::createWrapper(element, creationContext, isolate); | |
67 {% else %} | |
68 return wrap(to{{fallback_js_interface}}(element), creationContext, isolate); | |
69 {% endif %} | |
70 } | |
71 | |
72 const WrapperTypeInfo* findWrapperTypeFor{{namespace}}TagName(const AtomicString & name) | 25 const WrapperTypeInfo* findWrapperTypeFor{{namespace}}TagName(const AtomicString & name) |
73 { | 26 { |
74 typedef HashMap<StringImpl*, const WrapperTypeInfo*> NameTypeMap; | 27 typedef HashMap<StringImpl*, const WrapperTypeInfo*> NameTypeMap; |
75 DEFINE_STATIC_LOCAL(NameTypeMap, map, ()); | 28 DEFINE_STATIC_LOCAL(NameTypeMap, map, ()); |
76 if (map.isEmpty()) { | 29 if (map.isEmpty()) { |
77 // FIXME: This seems wrong. We should list every interface here, not | 30 // FIXME: This seems wrong. We should list every interface here, not |
78 // just the ones that have specialized JavaScript interfaces. | 31 // just the ones that have specialized JavaScript interfaces. |
79 {% for tag in tags|sort if tag.has_js_interface %} | 32 {% for tag in tags|sort if tag.has_js_interface %} |
80 {% filter enable_conditional(tag.Conditional) %} | 33 {% filter enable_conditional(tag.Conditional) %} |
81 map.set({{tag|symbol}}Tag.localName().impl(), &V8{{tag.js_interface}}::w rapperTypeInfo); | 34 map.set({{tag|symbol}}Tag.localName().impl(), &V8{{tag.js_interface}}::w rapperTypeInfo); |
82 {% endfilter %} | 35 {% endfilter %} |
83 {% endfor %} | 36 {% endfor %} |
84 } | 37 } |
85 | 38 |
86 if (const WrapperTypeInfo* result = map.get(name.impl())) | 39 if (const WrapperTypeInfo* result = map.get(name.impl())) |
87 return result; | 40 return result; |
88 | 41 |
89 return &V8{{fallback_js_interface}}::wrapperTypeInfo; | 42 return &V8{{fallback_js_interface}}::wrapperTypeInfo; |
90 } | 43 } |
91 | 44 |
92 } | 45 } // namespace blink |
OLD | NEW |