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

Side by Side Diff: Source/bindings/templates/interface.cpp

Issue 209713003: Make DOMWrapperWorld::current() return a reference instead of a pointer (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 9 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 {% extends 'interface_base.cpp' %} 1 {% extends 'interface_base.cpp' %}
2 2
3 3
4 {##############################################################################} 4 {##############################################################################}
5 {% macro attribute_configuration(attribute) %} 5 {% macro attribute_configuration(attribute) %}
6 {% set getter_callback = 6 {% set getter_callback =
7 '%sV8Internal::%sAttributeGetterCallback' % 7 '%sV8Internal::%sAttributeGetterCallback' %
8 (cpp_class, attribute.name) 8 (cpp_class, attribute.name)
9 if not attribute.constructor_type else 9 if not attribute.constructor_type else
10 ('%sV8Internal::%sConstructorGetterCallback' % 10 ('%sV8Internal::%sConstructorGetterCallback' %
(...skipping 644 matching lines...) Expand 10 before | Expand all | Expand 10 after
655 {% if any_type_attributes and not interface_name == 'ErrorEvent' %} 655 {% if any_type_attributes and not interface_name == 'ErrorEvent' %}
656 {# If we're in an isolated world, create a SerializedScriptValue and store 656 {# If we're in an isolated world, create a SerializedScriptValue and store
657 it in the event for later cloning if the property is accessed from 657 it in the event for later cloning if the property is accessed from
658 another world. The main world case is handled lazily (in custom code). 658 another world. The main world case is handled lazily (in custom code).
659 659
660 We do not clone Error objects (exceptions), for 2 reasons: 660 We do not clone Error objects (exceptions), for 2 reasons:
661 1) Errors carry a reference to the isolated world's global object, and 661 1) Errors carry a reference to the isolated world's global object, and
662 thus passing it around would cause leakage. 662 thus passing it around would cause leakage.
663 2) Errors cannot be cloned (or serialized): 663 2) Errors cannot be cloned (or serialized):
664 http://www.whatwg.org/specs/web-apps/current-work/multipage/common-dom-in terfaces.html#safe-passing-of-structured-data #} 664 http://www.whatwg.org/specs/web-apps/current-work/multipage/common-dom-in terfaces.html#safe-passing-of-structured-data #}
665 if (DOMWrapperWorld::current(isolate)->isIsolatedWorld()) { 665 if (DOMWrapperWorld::current(isolate).isIsolatedWorld()) {
666 {% for attribute in any_type_attributes %} 666 {% for attribute in any_type_attributes %}
667 if (!{{attribute.name}}.IsEmpty()) 667 if (!{{attribute.name}}.IsEmpty())
668 event->setSerialized{{attribute.name | blink_capitalize}}(Serialized ScriptValue::createAndSwallowExceptions({{attribute.name}}, isolate)); 668 event->setSerialized{{attribute.name | blink_capitalize}}(Serialized ScriptValue::createAndSwallowExceptions({{attribute.name}}, isolate));
669 {% endfor %} 669 {% endfor %}
670 } 670 }
671 671
672 {% endif %} 672 {% endif %}
673 v8::Handle<v8::Object> wrapper = info.Holder(); 673 v8::Handle<v8::Object> wrapper = info.Holder();
674 V8DOMWrapper::associateObjectWithWrapper<{{v8_class}}>(event.release(), &{{v 8_class}}::wrapperTypeInfo, wrapper, isolate, {{wrapper_configuration}}); 674 V8DOMWrapper::associateObjectWithWrapper<{{v8_class}}>(event.release(), &{{v 8_class}}::wrapperTypeInfo, wrapper, isolate, {{wrapper_configuration}});
675 v8SetReturnValue(info, wrapper); 675 v8SetReturnValue(info, wrapper);
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after
968 {# Needed for legacy support of document.all #} 968 {# Needed for legacy support of document.all #}
969 functionTemplate->InstanceTemplate()->MarkAsUndetectable(); 969 functionTemplate->InstanceTemplate()->MarkAsUndetectable();
970 {% endif %} 970 {% endif %}
971 {% for method in methods if not method.do_not_check_signature %} 971 {% for method in methods if not method.do_not_check_signature %}
972 {# install_custom_signature #} 972 {# install_custom_signature #}
973 {% if not method.overload_index or method.overload_index == 1 %} 973 {% if not method.overload_index or method.overload_index == 1 %}
974 {# For overloaded methods, only generate one accessor #} 974 {# For overloaded methods, only generate one accessor #}
975 {% filter conditional(method.conditional_string) %} 975 {% filter conditional(method.conditional_string) %}
976 {% if method.is_do_not_check_security %} 976 {% if method.is_do_not_check_security %}
977 {% if method.is_per_world_bindings %} 977 {% if method.is_per_world_bindings %}
978 if (DOMWrapperWorld::current(isolate)->isMainWorld()) { 978 if (DOMWrapperWorld::current(isolate).isMainWorld()) {
979 {{install_do_not_check_security_signature(method, 'ForMainWorld')}} 979 {{install_do_not_check_security_signature(method, 'ForMainWorld')}}
980 } else { 980 } else {
981 {{install_do_not_check_security_signature(method)}} 981 {{install_do_not_check_security_signature(method)}}
982 } 982 }
983 {% else %} 983 {% else %}
984 {{install_do_not_check_security_signature(method)}} 984 {{install_do_not_check_security_signature(method)}}
985 {% endif %} 985 {% endif %}
986 {% else %}{# is_do_not_check_security #} 986 {% else %}{# is_do_not_check_security #}
987 {% if method.is_per_world_bindings %} 987 {% if method.is_per_world_bindings %}
988 if (DOMWrapperWorld::current(isolate)->isMainWorld()) { 988 if (DOMWrapperWorld::current(isolate).isMainWorld()) {
989 {% filter runtime_enabled(method.runtime_enabled_function) %} 989 {% filter runtime_enabled(method.runtime_enabled_function) %}
990 {{install_custom_signature(method, 'ForMainWorld')}} 990 {{install_custom_signature(method, 'ForMainWorld')}}
991 {% endfilter %} 991 {% endfilter %}
992 } else { 992 } else {
993 {% filter runtime_enabled(method.runtime_enabled_function) %} 993 {% filter runtime_enabled(method.runtime_enabled_function) %}
994 {{install_custom_signature(method)}} 994 {{install_custom_signature(method)}}
995 {% endfilter %} 995 {% endfilter %}
996 } 996 }
997 {% else %} 997 {% else %}
998 {% filter runtime_enabled(method.runtime_enabled_function) %} 998 {% filter runtime_enabled(method.runtime_enabled_function) %}
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
1196 1196
1197 {% endif %} 1197 {% endif %}
1198 {% endblock %} 1198 {% endblock %}
1199 1199
1200 1200
1201 {##############################################################################} 1201 {##############################################################################}
1202 {% block get_shadow_object_template %} 1202 {% block get_shadow_object_template %}
1203 {% if interface_name == 'Window' %} 1203 {% if interface_name == 'Window' %}
1204 v8::Handle<v8::ObjectTemplate> V8Window::getShadowObjectTemplate(v8::Isolate* is olate) 1204 v8::Handle<v8::ObjectTemplate> V8Window::getShadowObjectTemplate(v8::Isolate* is olate)
1205 { 1205 {
1206 if (DOMWrapperWorld::current(isolate)->isMainWorld()) { 1206 if (DOMWrapperWorld::current(isolate).isMainWorld()) {
1207 DEFINE_STATIC_LOCAL(v8::Persistent<v8::ObjectTemplate>, V8WindowShadowOb jectCacheForMainWorld, ()); 1207 DEFINE_STATIC_LOCAL(v8::Persistent<v8::ObjectTemplate>, V8WindowShadowOb jectCacheForMainWorld, ());
1208 if (V8WindowShadowObjectCacheForMainWorld.IsEmpty()) { 1208 if (V8WindowShadowObjectCacheForMainWorld.IsEmpty()) {
1209 TRACE_EVENT_SCOPED_SAMPLING_STATE("Blink", "BuildDOMTemplate"); 1209 TRACE_EVENT_SCOPED_SAMPLING_STATE("Blink", "BuildDOMTemplate");
1210 v8::Handle<v8::ObjectTemplate> templ = v8::ObjectTemplate::New(isola te); 1210 v8::Handle<v8::ObjectTemplate> templ = v8::ObjectTemplate::New(isola te);
1211 configureShadowObjectTemplate(templ, isolate); 1211 configureShadowObjectTemplate(templ, isolate);
1212 V8WindowShadowObjectCacheForMainWorld.Reset(isolate, templ); 1212 V8WindowShadowObjectCacheForMainWorld.Reset(isolate, templ);
1213 return templ; 1213 return templ;
1214 } 1214 }
1215 return v8::Local<v8::ObjectTemplate>::New(isolate, V8WindowShadowObjectC acheForMainWorld); 1215 return v8::Local<v8::ObjectTemplate>::New(isolate, V8WindowShadowObjectC acheForMainWorld);
1216 } else { 1216 } else {
(...skipping 20 matching lines...) Expand all
1237 { 1237 {
1238 ASSERT(impl); 1238 ASSERT(impl);
1239 {% for special_wrap_interface in special_wrap_for %} 1239 {% for special_wrap_interface in special_wrap_for %}
1240 if (impl->is{{special_wrap_interface}}()) 1240 if (impl->is{{special_wrap_interface}}())
1241 return wrap(to{{special_wrap_interface}}(impl), creationContext, isolate ); 1241 return wrap(to{{special_wrap_interface}}(impl), creationContext, isolate );
1242 {% endfor %} 1242 {% endfor %}
1243 v8::Handle<v8::Object> wrapper = {{v8_class}}::createWrapper(impl, creationC ontext, isolate); 1243 v8::Handle<v8::Object> wrapper = {{v8_class}}::createWrapper(impl, creationC ontext, isolate);
1244 {% if is_document %} 1244 {% if is_document %}
1245 if (wrapper.IsEmpty()) 1245 if (wrapper.IsEmpty())
1246 return wrapper; 1246 return wrapper;
1247 DOMWrapperWorld* world = DOMWrapperWorld::current(isolate); 1247 DOMWrapperWorld& world = DOMWrapperWorld::current(isolate);
1248 if (world->isMainWorld()) { 1248 if (world.isMainWorld()) {
1249 if (LocalFrame* frame = impl->frame()) 1249 if (LocalFrame* frame = impl->frame())
1250 frame->script().windowShell(world)->updateDocumentWrapper(wrapper); 1250 frame->script().windowShell(world)->updateDocumentWrapper(wrapper);
1251 } 1251 }
1252 {% endif %} 1252 {% endif %}
1253 return wrapper; 1253 return wrapper;
1254 } 1254 }
1255 1255
1256 {% endif %} 1256 {% endif %}
1257 {% endblock %} 1257 {% endblock %}
1258 1258
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
1315 {% endfilter %} 1315 {% endfilter %}
1316 } 1316 }
1317 1317
1318 template<> 1318 template<>
1319 v8::Handle<v8::Value> toV8NoInline({{cpp_class}}* impl, v8::Handle<v8::Object> c reationContext, v8::Isolate* isolate) 1319 v8::Handle<v8::Value> toV8NoInline({{cpp_class}}* impl, v8::Handle<v8::Object> c reationContext, v8::Isolate* isolate)
1320 { 1320 {
1321 return toV8(impl, creationContext, isolate); 1321 return toV8(impl, creationContext, isolate);
1322 } 1322 }
1323 1323
1324 {% endblock %} 1324 {% endblock %}
OLDNEW
« no previous file with comments | « Source/bindings/templates/interface.h ('k') | Source/bindings/tests/results/V8SVGTestInterface.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698