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

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

Issue 2057273002: [OriginTrials] Support OriginTrialEnabled IDL attribute on constants (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Move signature creation out of for loop Created 4 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 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 75998cd4faef55a876d90911f864e7accb3e9d9e..ba669b946697d45343bf25073a7e2db564a517d4 100644
--- a/third_party/WebKit/Source/bindings/core/v8/V8DOMConfiguration.cpp
+++ b/third_party/WebKit/Source/bindings/core/v8/V8DOMConfiguration.cpp
@@ -166,11 +166,8 @@ void installAccessorInternal(v8::Isolate* isolate, v8::Local<ObjectOrTemplate> i
}
}
-void installConstantInternal(v8::Isolate* isolate, v8::Local<v8::FunctionTemplate> interfaceTemplate, v8::Local<v8::ObjectTemplate> prototypeTemplate, const V8DOMConfiguration::ConstantConfiguration& constant)
+v8::Local<v8::Primitive> valueForConstant(v8::Isolate* isolate, const V8DOMConfiguration::ConstantConfiguration& constant)
{
- v8::Local<v8::String> constantName = v8AtomicString(isolate, constant.name);
- v8::PropertyAttribute attributes =
- static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontDelete);
v8::Local<v8::Primitive> value;
switch (constant.type) {
case V8DOMConfiguration::ConstantTypeShort:
@@ -188,10 +185,30 @@ void installConstantInternal(v8::Isolate* isolate, v8::Local<v8::FunctionTemplat
default:
NOTREACHED();
}
+ return value;
+}
+
+void installConstantInternal(v8::Isolate* isolate, v8::Local<v8::FunctionTemplate> interfaceTemplate, v8::Local<v8::ObjectTemplate> prototypeTemplate, const V8DOMConfiguration::ConstantConfiguration& constant)
+{
+ v8::Local<v8::String> constantName = v8AtomicString(isolate, constant.name);
+ v8::PropertyAttribute attributes =
+ static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontDelete);
+ v8::Local<v8::Primitive> value = valueForConstant(isolate, constant);
interfaceTemplate->Set(constantName, value, attributes);
prototypeTemplate->Set(constantName, value, attributes);
}
+void installConstantInternal(v8::Isolate* isolate, v8::Local<v8::Function> interface, v8::Local<v8::Object> prototype, const V8DOMConfiguration::ConstantConfiguration& constant)
+{
+ v8::Local<v8::Context> context = isolate->GetCurrentContext();
+ v8::Local<v8::Name> name = v8AtomicString(isolate, constant.name);
+ v8::PropertyAttribute attributes =
+ static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontDelete);
+ v8::Local<v8::Primitive> value = valueForConstant(isolate, constant);
+ v8CallOrCrash(interface->DefineOwnProperty(context, name, value, attributes));
+ v8CallOrCrash(prototype->DefineOwnProperty(context, name, value, attributes));
+}
+
template<class Configuration>
void installMethodInternal(v8::Isolate* isolate, v8::Local<v8::ObjectTemplate> instanceTemplate, v8::Local<v8::ObjectTemplate> prototypeTemplate, v8::Local<v8::FunctionTemplate> interfaceTemplate, v8::Local<v8::Signature> signature, const Configuration& method, const DOMWrapperWorld& world)
{
@@ -298,6 +315,11 @@ void V8DOMConfiguration::installConstant(v8::Isolate* isolate, v8::Local<v8::Fun
installConstantInternal(isolate, interfaceTemplate, prototypeTemplate, constant);
}
+void V8DOMConfiguration::installConstant(v8::Isolate* isolate, v8::Local<v8::Function> interface, v8::Local<v8::Object> prototype, const ConstantConfiguration& constant)
+{
+ installConstantInternal(isolate, interface, prototype, constant);
+}
+
void V8DOMConfiguration::installConstantWithGetter(v8::Isolate* isolate, v8::Local<v8::FunctionTemplate> interfaceTemplate, v8::Local<v8::ObjectTemplate> prototypeTemplate, const char* name, v8::AccessorNameGetterCallback getter)
{
v8::Local<v8::String> constantName = v8AtomicString(isolate, name);

Powered by Google App Engine
This is Rietveld 408576698