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

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

Issue 2460423002: Use new LazyDataProperty API for DOM constructors (Closed)
Patch Set: updates Created 4 years, 1 month 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 1f7d79ad77138ed6a703d0afcebaaea6af7ebb0f..6443e22a426527930834b92219dca27944c6a6e8 100644
--- a/third_party/WebKit/Source/bindings/core/v8/V8DOMConfiguration.cpp
+++ b/third_party/WebKit/Source/bindings/core/v8/V8DOMConfiguration.cpp
@@ -119,6 +119,43 @@ void installAttributeInternal(
NOTREACHED();
}
+void installLazyDataAttributeInternal(
+ v8::Isolate* isolate,
+ v8::Local<v8::ObjectTemplate> instanceTemplate,
+ v8::Local<v8::ObjectTemplate> prototypeTemplate,
+ const V8DOMConfiguration::AttributeConfiguration& attribute,
+ const DOMWrapperWorld& world) {
+ if (attribute.exposeConfiguration ==
+ V8DOMConfiguration::OnlyExposedToPrivateScript &&
+ !world.isPrivateScriptIsolatedWorld())
+ return;
+
+ v8::Local<v8::Name> name = v8AtomicString(isolate, attribute.name);
+ v8::AccessorNameGetterCallback getter = attribute.getter;
+ DCHECK(!attribute.setter);
+ DCHECK(!attribute.getterForMainWorld);
+ DCHECK(!attribute.setterForMainWorld);
+ v8::Local<v8::Value> data =
+ v8::External::New(isolate, const_cast<WrapperTypeInfo*>(attribute.data));
+ DCHECK(static_cast<v8::AccessControl>(attribute.settings) == v8::DEFAULT);
+
+ DCHECK(attribute.propertyLocationConfiguration);
+ if (attribute.propertyLocationConfiguration &
+ V8DOMConfiguration::OnInstance) {
+ instanceTemplate->SetLazyDataProperty(
+ name, getter, data,
+ static_cast<v8::PropertyAttribute>(attribute.attribute));
+ }
+ if (attribute.propertyLocationConfiguration &
+ V8DOMConfiguration::OnPrototype) {
+ prototypeTemplate->SetLazyDataProperty(
+ name, getter, data,
+ static_cast<v8::PropertyAttribute>(attribute.attribute));
+ }
+ if (attribute.propertyLocationConfiguration & V8DOMConfiguration::OnInterface)
+ NOTREACHED();
+}
+
template <class FunctionOrTemplate>
v8::Local<FunctionOrTemplate> createAccessorFunctionOrTemplate(
v8::Isolate*,
@@ -423,6 +460,19 @@ void V8DOMConfiguration::installAttribute(
installAttributeInternal(isolate, instance, prototype, attribute, world);
}
+void V8DOMConfiguration::installLazyDataAttributes(
+ v8::Isolate* isolate,
+ const DOMWrapperWorld& world,
+ v8::Local<v8::ObjectTemplate> instanceTemplate,
+ v8::Local<v8::ObjectTemplate> prototypeTemplate,
+ const AttributeConfiguration* attributes,
+ size_t attributeCount) {
+ for (size_t i = 0; i < attributeCount; ++i) {
+ installLazyDataAttributeInternal(isolate, instanceTemplate,
+ prototypeTemplate, attributes[i], world);
+ }
+}
+
void V8DOMConfiguration::installAccessors(
v8::Isolate* isolate,
const DOMWrapperWorld& world,

Powered by Google App Engine
This is Rietveld 408576698