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

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

Issue 330093002: Add support in generate scripts to handle Conditional (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: sort by alpha Created 6 years, 6 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
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 "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 %}
(...skipping 13 matching lines...) Expand all
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 {% for js_interface, list in tags|sort|selectattr('has_js_interface')|groupby('j s_interface') %} 33 {% for js_interface, list in tags|sort|selectattr('has_js_interface')|groupby('j s_interface') %}
34 {% 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 static v8::Handle<v8::Object> create{{js_interface}}Wrapper({{namespace}}Element * element, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
35 { 36 {
36 {% if list[0].contextConditional %} 37 {% if list[0].contextConditional %}
37 if (!ContextFeatures::{{list[0].contextConditional}}Enabled(&element->docume nt())) 38 if (!ContextFeatures::{{list[0].contextConditional}}Enabled(&element->docume nt()))
38 return createV8{{namespace}}FallbackWrapper(to{{fallback_js_interface}}( element), creationContext, isolate); 39 return createV8{{namespace}}FallbackWrapper(to{{fallback_js_interface}}( element), creationContext, isolate);
39 {% endif %} 40 {% endif %}
40 {% if list[0].runtimeEnabled %} 41 {% if list[0].runtimeEnabled %}
41 if (!RuntimeEnabledFeatures::{{list[0].runtimeEnabled}}Enabled()) 42 if (!RuntimeEnabledFeatures::{{list[0].runtimeEnabled}}Enabled())
42 return createV8{{namespace}}FallbackWrapper(to{{fallback_js_interface}}( element), creationContext, isolate); 43 return createV8{{namespace}}FallbackWrapper(to{{fallback_js_interface}}( element), creationContext, isolate);
43 {% endif %} 44 {% endif %}
44 return wrap(static_cast<{{js_interface}}*>(element), creationContext, isolat e); 45 return wrap(static_cast<{{js_interface}}*>(element), creationContext, isolat e);
45 } 46 }
47 {% endfilter %}
46 {% endfor %} 48 {% endfor %}
47 49
48 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)
49 { 51 {
50 typedef HashMap<StringImpl*, Create{{namespace}}ElementWrapperFunction> Func tionMap; 52 typedef HashMap<StringImpl*, Create{{namespace}}ElementWrapperFunction> Func tionMap;
51 DEFINE_STATIC_LOCAL(FunctionMap, map, ()); 53 DEFINE_STATIC_LOCAL(FunctionMap, map, ());
52 if (map.isEmpty()) { 54 if (map.isEmpty()) {
53 {% for tag in tags|sort %} 55 {% for tag in tags|sort %}
56 {% filter enable_conditional(tag.Conditional) %}
54 map.set({{tag|symbol}}Tag.localName().impl(), create{{tag.js_interface}} Wrapper); 57 map.set({{tag|symbol}}Tag.localName().impl(), create{{tag.js_interface}} Wrapper);
58 {% endfilter %}
55 {% endfor %} 59 {% endfor %}
56 } 60 }
57 61
58 Create{{namespace}}ElementWrapperFunction createWrapperFunction = map.get(el ement->localName().impl()); 62 Create{{namespace}}ElementWrapperFunction createWrapperFunction = map.get(el ement->localName().impl());
59 if (createWrapperFunction == create{{namespace}}ElementWrapper) 63 if (createWrapperFunction == create{{namespace}}ElementWrapper)
60 createWrapperFunction = createV8{{namespace}}DirectWrapper; 64 createWrapperFunction = createV8{{namespace}}DirectWrapper;
61 if (element->isCustomElement()) 65 if (element->isCustomElement())
62 return CustomElementWrapper<{{namespace}}Element, V8{{namespace}}Element >::wrap(element, creationContext, isolate, createWrapperFunction); 66 return CustomElementWrapper<{{namespace}}Element, V8{{namespace}}Element >::wrap(element, creationContext, isolate, createWrapperFunction);
63 67
64 if (createWrapperFunction) 68 if (createWrapperFunction)
65 return createWrapperFunction(element, creationContext, isolate); 69 return createWrapperFunction(element, creationContext, isolate);
66 {% if fallback_js_interface == namespace + 'Element' %} 70 {% if fallback_js_interface == namespace + 'Element' %}
67 return V8{{fallback_js_interface}}::createWrapper(element, creationContext, isolate); 71 return V8{{fallback_js_interface}}::createWrapper(element, creationContext, isolate);
68 {% else %} 72 {% else %}
69 return wrap(to{{fallback_js_interface}}(element), creationContext, isolate); 73 return wrap(to{{fallback_js_interface}}(element), creationContext, isolate);
70 {% endif %} 74 {% endif %}
71 } 75 }
72 76
73 const WrapperTypeInfo* findWrapperTypeFor{{namespace}}TagName(const AtomicString & name) 77 const WrapperTypeInfo* findWrapperTypeFor{{namespace}}TagName(const AtomicString & name)
74 { 78 {
75 typedef HashMap<StringImpl*, const WrapperTypeInfo*> NameTypeMap; 79 typedef HashMap<StringImpl*, const WrapperTypeInfo*> NameTypeMap;
76 DEFINE_STATIC_LOCAL(NameTypeMap, map, ()); 80 DEFINE_STATIC_LOCAL(NameTypeMap, map, ());
77 if (map.isEmpty()) { 81 if (map.isEmpty()) {
78 // FIXME: This seems wrong. We should list every interface here, not 82 // FIXME: This seems wrong. We should list every interface here, not
79 // just the ones that have specialized JavaScript interfaces. 83 // just the ones that have specialized JavaScript interfaces.
80 {% for tag in tags|sort if tag.has_js_interface %} 84 {% for tag in tags|sort if tag.has_js_interface %}
85 {% filter enable_conditional(tag.Conditional) %}
81 map.set({{tag|symbol}}Tag.localName().impl(), &V8{{tag.js_interface}}::w rapperTypeInfo); 86 map.set({{tag|symbol}}Tag.localName().impl(), &V8{{tag.js_interface}}::w rapperTypeInfo);
87 {% endfilter %}
82 {% endfor %} 88 {% endfor %}
83 } 89 }
84 90
85 if (const WrapperTypeInfo* result = map.get(name.impl())) 91 if (const WrapperTypeInfo* result = map.get(name.impl()))
86 return result; 92 return result;
87 93
88 return &V8{{fallback_js_interface}}::wrapperTypeInfo; 94 return &V8{{fallback_js_interface}}::wrapperTypeInfo;
89 } 95 }
90 96
91 } 97 }
OLDNEW
« no previous file with comments | « Source/build/scripts/templates/ElementTypeHelpers.h.tmpl ('k') | Source/build/scripts/templates/MakeNames.cpp.tmpl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698