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

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

Issue 577303002: IDL: Support [DeprecateAs] and [MeasureAs] on constants (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: adjusted encrypted-media-constants-expected.txt Created 6 years, 3 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
« no previous file with comments | « Source/bindings/core/v8/V8DOMConfiguration.h ('k') | Source/bindings/scripts/v8_interface.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/bindings/core/v8/V8DOMConfiguration.cpp
diff --git a/Source/bindings/core/v8/V8DOMConfiguration.cpp b/Source/bindings/core/v8/V8DOMConfiguration.cpp
index b15b9869d3633a94af91e4294075c2b384efa07d..f3e6dfd9a19272692b3964eaa6e746903e4c9383 100644
--- a/Source/bindings/core/v8/V8DOMConfiguration.cpp
+++ b/Source/bindings/core/v8/V8DOMConfiguration.cpp
@@ -70,6 +70,15 @@ void V8DOMConfiguration::installAccessors(v8::Handle<v8::ObjectTemplate> prototy
}
}
+// Constant installation
+//
+// installConstants() is be used for simple constants. It installs constants
+// using v8::Template::Set(), which results in a property that is much faster to
+// access from scripts.
+// installConstant() is used when some C++ code needs to be executed when the
+// constant is accessed, e.g. to handle deprecation or measuring usage. The
+// property appears the same to scripts, but is slower to access.
+
void V8DOMConfiguration::installConstants(v8::Handle<v8::FunctionTemplate> functionDescriptor, v8::Handle<v8::ObjectTemplate> prototype, const ConstantConfiguration* constants, size_t constantCount, v8::Isolate* isolate)
{
for (size_t i = 0; i < constantCount; ++i) {
@@ -101,6 +110,13 @@ void V8DOMConfiguration::installConstants(v8::Handle<v8::FunctionTemplate> funct
}
}
+void V8DOMConfiguration::installConstant(v8::Handle<v8::FunctionTemplate> functionDescriptor, v8::Handle<v8::ObjectTemplate> prototype, const char* name, v8::AccessorGetterCallback getter, v8::Isolate* isolate)
+{
+ v8::Handle<v8::String> constantName = v8AtomicString(isolate, name);
+ functionDescriptor->SetNativeDataProperty(constantName, getter, 0, v8::Handle<v8::Value>(), static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontDelete));
+ prototype->SetNativeDataProperty(constantName, getter, 0, v8::Handle<v8::Value>(), static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontDelete));
+}
+
void V8DOMConfiguration::installMethods(v8::Handle<v8::ObjectTemplate> prototype, v8::Handle<v8::Signature> signature, v8::PropertyAttribute attributes, const MethodConfiguration* callbacks, size_t callbackCount, v8::Isolate* isolate)
{
for (size_t i = 0; i < callbackCount; ++i)
« no previous file with comments | « Source/bindings/core/v8/V8DOMConfiguration.h ('k') | Source/bindings/scripts/v8_interface.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698