diff options
author | haraken@chromium.org <haraken@chromium.org> | 2015-07-30 15:07:25 +0000 |
---|---|---|
committer | haraken@chromium.org <haraken@chromium.org> | 2015-07-30 15:07:25 +0000 |
commit | 2f2591ed2ba744c19c8e3fa871b506c917efe2eb (patch) | |
tree | b54f683676db933f6582f6dd4efe5cf50e3a2cb3 | |
parent | 01fa4ef29f43dc4b12fd22a8af87ea0656d276d4 (diff) | |
download | chromium_src-2f2591ed2ba744c19c8e3fa871b506c917efe2eb.zip chromium_src-2f2591ed2ba744c19c8e3fa871b506c917efe2eb.tar.gz chromium_src-2f2591ed2ba744c19c8e3fa871b506c917efe2eb.tar.bz2 |
Binding: Move code to install a shadow object to WindowProxy
Now we have no reason to have code to install a shadow object in the IDL compiler.
This CL moves it from the IDL compiler to WindowProxy.
Also this CL renames "shadow object" to "inner global object".
BUG=509936
Review URL: https://codereview.chromium.org/1267703002
git-svn-id: svn://svn.chromium.org/blink/trunk@199740 bbb929c8-8fbe-4397-9dbb-9b2b20218538
4 files changed, 36 insertions, 52 deletions
diff --git a/third_party/WebKit/Source/bindings/core/v8/WindowProxy.cpp b/third_party/WebKit/Source/bindings/core/v8/WindowProxy.cpp index 7b32263..caf2958 100644 --- a/third_party/WebKit/Source/bindings/core/v8/WindowProxy.cpp +++ b/third_party/WebKit/Source/bindings/core/v8/WindowProxy.cpp @@ -262,6 +262,41 @@ bool WindowProxy::initialize() return true; } +namespace { + +void configureInnerGlobalObjectTemplate(v8::Local<v8::ObjectTemplate> templ, v8::Isolate* isolate) +{ + // Install a security handler with V8. + templ->SetAccessCheckCallbacks(V8Window::namedSecurityCheckCustom, V8Window::indexedSecurityCheckCustom, v8::External::New(isolate, const_cast<WrapperTypeInfo*>(&V8Window::wrapperTypeInfo))); + templ->SetInternalFieldCount(V8Window::internalFieldCount); +} + +v8::Local<v8::ObjectTemplate> getInnerGlobalObjectTemplate(v8::Isolate* isolate) +{ + if (DOMWrapperWorld::current(isolate).isMainWorld()) { + DEFINE_STATIC_LOCAL(v8::Persistent<v8::ObjectTemplate>, V8WindowInnerGlobalObjectCacheForMainWorld, ()); + if (V8WindowInnerGlobalObjectCacheForMainWorld.IsEmpty()) { + TRACE_EVENT_SCOPED_SAMPLING_STATE("blink", "BuildDOMTemplate"); + v8::Local<v8::ObjectTemplate> templ = v8::ObjectTemplate::New(isolate); + configureInnerGlobalObjectTemplate(templ, isolate); + V8WindowInnerGlobalObjectCacheForMainWorld.Reset(isolate, templ); + return templ; + } + return v8::Local<v8::ObjectTemplate>::New(isolate, V8WindowInnerGlobalObjectCacheForMainWorld); + } + DEFINE_STATIC_LOCAL(v8::Persistent<v8::ObjectTemplate>, V8WindowInnerGlobalObjectCacheForNonMainWorld, ()); + if (V8WindowInnerGlobalObjectCacheForNonMainWorld.IsEmpty()) { + TRACE_EVENT_SCOPED_SAMPLING_STATE("blink", "BuildDOMTemplate"); + v8::Local<v8::ObjectTemplate> templ = v8::ObjectTemplate::New(isolate); + configureInnerGlobalObjectTemplate(templ, isolate); + V8WindowInnerGlobalObjectCacheForNonMainWorld.Reset(isolate, templ); + return templ; + } + return v8::Local<v8::ObjectTemplate>::New(isolate, V8WindowInnerGlobalObjectCacheForNonMainWorld); +} + +} // namespace + void WindowProxy::createContext() { // FIXME: This should be a null check of m_frame->client(), but there are still some edge cases @@ -271,7 +306,7 @@ void WindowProxy::createContext() // Create a new environment using an empty template for the shadow // object. Reuse the global object if one has been created earlier. - v8::Local<v8::ObjectTemplate> globalTemplate = V8Window::getShadowObjectTemplate(m_isolate); + v8::Local<v8::ObjectTemplate> globalTemplate = getInnerGlobalObjectTemplate(m_isolate); if (globalTemplate.IsEmpty()) return; diff --git a/third_party/WebKit/Source/bindings/templates/interface.cpp b/third_party/WebKit/Source/bindings/templates/interface.cpp index 387464d..3a760f1 100644 --- a/third_party/WebKit/Source/bindings/templates/interface.cpp +++ b/third_party/WebKit/Source/bindings/templates/interface.cpp @@ -612,20 +612,6 @@ void {{v8_class}}::constructorCallback(const v8::FunctionCallbackInfo<v8::Value> {% endblock %} -{##############################################################################} -{% block configure_shadow_object_template %} -{% if interface_name == 'Window' %} -static void configureShadowObjectTemplate(v8::Local<v8::ObjectTemplate> templ, v8::Isolate* isolate) -{ - // Install a security handler with V8. - templ->SetAccessCheckCallbacks(V8Window::namedSecurityCheckCustom, V8Window::indexedSecurityCheckCustom, v8::External::New(isolate, const_cast<WrapperTypeInfo*>(&V8Window::wrapperTypeInfo))); - templ->SetInternalFieldCount(V8Window::internalFieldCount); -} - -{% endif %} -{% endblock %} - - {######################################} {% macro install_do_not_check_security_signature(method, world_suffix) %} {# Methods that are [DoNotCheckSecurity] are always readable, but if they are @@ -872,38 +858,6 @@ ActiveDOMObject* {{v8_class}}::toActiveDOMObject(v8::Local<v8::Object> wrapper) {##############################################################################} -{% block get_shadow_object_template %} -{% if interface_name == 'Window' %} -v8::Local<v8::ObjectTemplate> V8Window::getShadowObjectTemplate(v8::Isolate* isolate) -{ - if (DOMWrapperWorld::current(isolate).isMainWorld()) { - DEFINE_STATIC_LOCAL(v8::Persistent<v8::ObjectTemplate>, V8WindowShadowObjectCacheForMainWorld, ()); - if (V8WindowShadowObjectCacheForMainWorld.IsEmpty()) { - TRACE_EVENT_SCOPED_SAMPLING_STATE("blink", "BuildDOMTemplate"); - v8::Local<v8::ObjectTemplate> templ = v8::ObjectTemplate::New(isolate); - configureShadowObjectTemplate(templ, isolate); - V8WindowShadowObjectCacheForMainWorld.Reset(isolate, templ); - return templ; - } - return v8::Local<v8::ObjectTemplate>::New(isolate, V8WindowShadowObjectCacheForMainWorld); - } else { - DEFINE_STATIC_LOCAL(v8::Persistent<v8::ObjectTemplate>, V8WindowShadowObjectCacheForNonMainWorld, ()); - if (V8WindowShadowObjectCacheForNonMainWorld.IsEmpty()) { - TRACE_EVENT_SCOPED_SAMPLING_STATE("blink", "BuildDOMTemplate"); - v8::Local<v8::ObjectTemplate> templ = v8::ObjectTemplate::New(isolate); - configureShadowObjectTemplate(templ, isolate); - V8WindowShadowObjectCacheForNonMainWorld.Reset(isolate, templ); - return templ; - } - return v8::Local<v8::ObjectTemplate>::New(isolate, V8WindowShadowObjectCacheForNonMainWorld); - } -} - -{% endif %} -{% endblock %} - - -{##############################################################################} {% block ref_object_and_deref_object %} void {{v8_class}}::refObject(ScriptWrappable* scriptWrappable) { diff --git a/third_party/WebKit/Source/bindings/templates/interface.h b/third_party/WebKit/Source/bindings/templates/interface.h index ef9482a..a8245b2 100644 --- a/third_party/WebKit/Source/bindings/templates/interface.h +++ b/third_party/WebKit/Source/bindings/templates/interface.h @@ -73,9 +73,6 @@ public: {% if is_active_dom_object %} static ActiveDOMObject* toActiveDOMObject(v8::Local<v8::Object>); {% endif %} - {% if interface_name == 'Window' %} - static v8::Local<v8::ObjectTemplate> getShadowObjectTemplate(v8::Isolate*); - {% endif %} {% for method in methods %} {% if method.is_custom %} {% filter conditional(method.conditional_string) %} diff --git a/third_party/WebKit/Source/bindings/templates/interface_base.cpp b/third_party/WebKit/Source/bindings/templates/interface_base.cpp index 2b3d9d8..4ac2859 100644 --- a/third_party/WebKit/Source/bindings/templates/interface_base.cpp +++ b/third_party/WebKit/Source/bindings/templates/interface_base.cpp @@ -278,7 +278,6 @@ static const V8DOMConfiguration::MethodConfiguration {{v8_class}}Methods[] = { {##############################################################################} {% block named_constructor %}{% endblock %} {% block constructor_callback %}{% endblock %} -{% block configure_shadow_object_template %}{% endblock %} {##############################################################################} {% block install_dom_template %} {% if not is_array_buffer_or_view %} @@ -490,7 +489,6 @@ static void install{{v8_class}}Template(v8::Local<v8::FunctionTemplate> function {% block prepare_prototype_object %}{% endblock %} {##############################################################################} {% block to_active_dom_object %}{% endblock %} -{% block get_shadow_object_template %}{% endblock %} {% block ref_object_and_deref_object %}{% endblock %} {% for method in methods if method.is_implemented_in_private_script and method.visible %} {{method_implemented_in_private_script(method)}} |