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

Unified Diff: third_party/WebKit/Source/bindings/core/v8/V8DOMConfiguration.cpp

Issue 2717183002: Slim V8DOMConfiguration::MethodConfiguration by refactoring per-world bindings. (Closed)
Patch Set: haraken Created 3 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/bindings/core/v8/V8DOMConfiguration.cpp
diff --git a/third_party/WebKit/Source/bindings/core/v8/V8DOMConfiguration.cpp b/third_party/WebKit/Source/bindings/core/v8/V8DOMConfiguration.cpp
index 51531b9d2c7fcec9f686dc8dfb07e62d75486203..c34dd2d5fe7ccf806305780102d9994d98bcf816 100644
--- a/third_party/WebKit/Source/bindings/core/v8/V8DOMConfiguration.cpp
+++ b/third_party/WebKit/Source/bindings/core/v8/V8DOMConfiguration.cpp
@@ -324,6 +324,22 @@ void installConstantInternal(
}
template <class Configuration>
+bool worldConfigurationApplies(const Configuration& config,
+ const DOMWrapperWorld& world) {
+ const auto currentWorldConfig = world.isMainWorld()
+ ? V8DOMConfiguration::MainWorld
+ : V8DOMConfiguration::NonMainWorlds;
+ return config.worldConfiguration & currentWorldConfig;
+}
+
+template <>
+bool worldConfigurationApplies(
+ const V8DOMConfiguration::SymbolKeyedMethodConfiguration&,
+ const DOMWrapperWorld&) {
+ return true;
+}
+
+template <class Configuration>
void installMethodInternal(v8::Isolate* isolate,
v8::Local<v8::ObjectTemplate> instanceTemplate,
v8::Local<v8::ObjectTemplate> prototypeTemplate,
@@ -331,8 +347,11 @@ void installMethodInternal(v8::Isolate* isolate,
v8::Local<v8::Signature> signature,
const Configuration& method,
const DOMWrapperWorld& world) {
+ if (!worldConfigurationApplies(method, world))
+ return;
+
v8::Local<v8::Name> name = method.methodName(isolate);
- v8::FunctionCallback callback = method.callbackForWorld(world);
+ v8::FunctionCallback callback = method.callback;
// Promise-returning functions need to return a reject promise when
// an exception occurs. This includes a case that the receiver object is not
// of the type. So, we disable the type check of the receiver object on V8
@@ -383,8 +402,11 @@ void installMethodInternal(
v8::Local<v8::Signature> signature,
const V8DOMConfiguration::MethodConfiguration& method,
const DOMWrapperWorld& world) {
+ if (!worldConfigurationApplies(method, world))
+ return;
+
v8::Local<v8::Name> name = method.methodName(isolate);
- v8::FunctionCallback callback = method.callbackForWorld(world);
+ v8::FunctionCallback callback = method.callback;
// Promise-returning functions need to return a reject promise when
// an exception occurs. This includes a case that the receiver object is not
// of the type. So, we disable the type check of the receiver object on V8

Powered by Google App Engine
This is Rietveld 408576698