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

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

Issue 2891063003: bindings: Use an alias for @@iterator in certain declarations. (Closed)
Patch Set: Rebase patch Created 3 years, 7 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 6ba91f90f2b367f41ae0b675ab5120949308f498..cff7f2b161fc40ff6fd05cc7d66ba6c4efc02cee 100644
--- a/third_party/WebKit/Source/bindings/core/v8/V8DOMConfiguration.cpp
+++ b/third_party/WebKit/Source/bindings/core/v8/V8DOMConfiguration.cpp
@@ -333,6 +333,33 @@ void InstallConstantInternal(
}
template <class Configuration>
+void AddMethodToTemplate(v8::Isolate* isolate,
+ v8::Local<v8::Template> v8_template,
+ v8::Local<v8::FunctionTemplate> function_template,
+ const Configuration& method) {
+ v8_template->Set(method.MethodName(isolate), function_template,
+ static_cast<v8::PropertyAttribute>(method.attribute));
+}
+
+template <>
+void AddMethodToTemplate(
+ v8::Isolate* isolate,
+ v8::Local<v8::Template> v8_template,
+ v8::Local<v8::FunctionTemplate> function_template,
+ const V8DOMConfiguration::SymbolKeyedMethodConfiguration& method) {
+ // The order matters here: if the Symbol is added first, the Function object
+ // will have no associated name. For example, WebIDL states, among other
+ // things, that a pair iterator's @@iterator Function object's name must be
+ // set to "entries".
+ if (method.symbol_alias) {
+ v8_template->Set(V8AtomicString(isolate, method.symbol_alias),
+ function_template);
+ }
+ v8_template->Set(method.MethodName(isolate), function_template,
+ static_cast<v8::PropertyAttribute>(method.attribute));
+}
+
+template <class Configuration>
void InstallMethodInternal(v8::Isolate* isolate,
v8::Local<v8::ObjectTemplate> instance_template,
v8::Local<v8::ObjectTemplate> prototype_template,
@@ -343,7 +370,6 @@ void InstallMethodInternal(v8::Isolate* isolate,
if (!WorldConfigurationApplies(method, world))
return;
- v8::Local<v8::Name> name = method.MethodName(isolate);
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
@@ -364,15 +390,15 @@ void InstallMethodInternal(v8::Isolate* isolate,
if (method.access_check_configuration == V8DOMConfiguration::kCheckAccess)
function_template->SetAcceptAnyReceiver(false);
if (method.property_location_configuration &
- V8DOMConfiguration::kOnInstance)
- instance_template->Set(
- name, function_template,
- static_cast<v8::PropertyAttribute>(method.attribute));
+ V8DOMConfiguration::kOnInstance) {
+ AddMethodToTemplate(isolate, instance_template, function_template,
+ method);
+ }
if (method.property_location_configuration &
- V8DOMConfiguration::kOnPrototype)
- prototype_template->Set(
- name, function_template,
- static_cast<v8::PropertyAttribute>(method.attribute));
+ V8DOMConfiguration::kOnPrototype) {
+ AddMethodToTemplate(isolate, prototype_template, function_template,
+ method);
+ }
}
if (method.property_location_configuration &
V8DOMConfiguration::kOnInterface) {
@@ -385,9 +411,7 @@ void InstallMethodInternal(v8::Isolate* isolate,
function_template->RemovePrototype();
// Similarly, there is no need to do an access check for static methods, as
// there is no holder to check against.
- interface_template->Set(
- name, function_template,
- static_cast<v8::PropertyAttribute>(method.attribute));
+ AddMethodToTemplate(isolate, interface_template, function_template, method);
}
}

Powered by Google App Engine
This is Rietveld 408576698