Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(307)

Side by Side Diff: Source/build/scripts/templates/ElementWrapperFactory.cpp.tmpl

Issue 531183003: bindings: Retires manual dispatching in createV8{HTML,SVG}Wrapper, etc. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Added FIXME comments. Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "{{namespace}}Names.h" 7 #include "{{namespace}}Names.h"
8 #include "bindings/core/v8/CustomElementWrapper.h"
9 {% for tag in tags|sort if tag.has_js_interface %} 8 {% for tag in tags|sort if tag.has_js_interface %}
10 #include "bindings/core/v8/V8{{tag.interface}}.h" 9 #include "bindings/core/v8/V8{{tag.interface}}.h"
11 {% endfor %} 10 {% endfor %}
12 {% for tag in tags|sort if tag.has_js_interface %} 11 {% for tag in tags|sort if tag.has_js_interface %}
13 #include "core/{{namespace|lower}}/{{tag.js_interface}}.h" 12 #include "core/{{namespace|lower}}/{{tag.js_interface}}.h"
14 {% endfor %} 13 {% endfor %}
15 #include "core/{{namespace|lower}}/{{fallback_js_interface}}.h" 14 #include "core/{{namespace|lower}}/{{fallback_js_interface}}.h"
16 #include "core/dom/Document.h" 15 #include "core/dom/Document.h"
17 #include "core/frame/Settings.h" 16 #include "core/frame/Settings.h"
18 #include "platform/RuntimeEnabledFeatures.h" 17 #include "platform/RuntimeEnabledFeatures.h"
19 #include "wtf/StdLibExtras.h" 18 #include "wtf/StdLibExtras.h"
20 19
21 namespace blink { 20 namespace blink {
22 21
23 using namespace {{namespace}}Names; 22 using namespace {{namespace}}Names;
24 23
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())
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;
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) 24 const WrapperTypeInfo* findWrapperTypeFor{{namespace}}TagName(const AtomicString & name)
73 { 25 {
74 typedef HashMap<StringImpl*, const WrapperTypeInfo*> NameTypeMap; 26 typedef HashMap<StringImpl*, const WrapperTypeInfo*> NameTypeMap;
75 DEFINE_STATIC_LOCAL(NameTypeMap, map, ()); 27 DEFINE_STATIC_LOCAL(NameTypeMap, map, ());
76 if (map.isEmpty()) { 28 if (map.isEmpty()) {
77 // FIXME: This seems wrong. We should list every interface here, not 29 // FIXME: This seems wrong. We should list every interface here, not
78 // just the ones that have specialized JavaScript interfaces. 30 // just the ones that have specialized JavaScript interfaces.
79 {% for tag in tags|sort if tag.has_js_interface %} 31 {% for tag in tags|sort if tag.has_js_interface %}
80 {% filter enable_conditional(tag.Conditional) %} 32 {% filter enable_conditional(tag.Conditional) %}
81 map.set({{tag|symbol}}Tag.localName().impl(), &V8{{tag.js_interface}}::w rapperTypeInfo); 33 map.set({{tag|symbol}}Tag.localName().impl(), &V8{{tag.js_interface}}::w rapperTypeInfo);
82 {% endfilter %} 34 {% endfilter %}
83 {% endfor %} 35 {% endfor %}
84 } 36 }
85 37
86 if (const WrapperTypeInfo* result = map.get(name.impl())) 38 if (const WrapperTypeInfo* result = map.get(name.impl()))
87 return result; 39 return result;
88 40
89 return &V8{{fallback_js_interface}}::wrapperTypeInfo; 41 return &V8{{fallback_js_interface}}::wrapperTypeInfo;
90 } 42 }
91 43
92 } 44 } // namespace blink
OLDNEW
« no previous file with comments | « Source/bindings/tests/results/V8TestTypedefs.cpp ('k') | Source/build/scripts/templates/ElementWrapperFactory.h.tmpl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698