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

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: Addressing comments from PS#2 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..0dc2c061db7f690660f2208c14269d3429d93447 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,29 @@ 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::Object> prototype, const V8DOMConfiguration::ConstantConfiguration& constant, const WrapperTypeInfo* type)
+{
+ V8PerContextData* perContextData = V8PerContextData::from(isolate->GetCurrentContext());
+ v8::Local<v8::Function> interface = perContextData->constructorForType(type);
Yuki 2016/06/16 08:01:08 I'd prefer that the caller passes |interface| to i
iclelland 2016/06/16 22:55:37 Done. I've made the interface consistent, and redu
+ v8::Local<v8::Name> name = v8AtomicString(isolate, constant.name);
+ v8::Local<v8::Primitive> value = valueForConstant(isolate, constant);
+ v8CallOrCrash(interface->DefineOwnProperty(isolate->GetCurrentContext(), name, value));
Yuki 2016/06/16 08:01:08 You need to specify the fourth argument |attribute
iclelland 2016/06/16 22:55:37 Done.
+ v8CallOrCrash(prototype->DefineOwnProperty(isolate->GetCurrentContext(), name, value));
+}
+
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 +314,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::Object> prototype, const ConstantConfiguration& constant, const WrapperTypeInfo* type)
+{
+ installConstantInternal(isolate, prototype, constant, type);
+}
+
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