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

Side by Side 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 if (attribute.propertyLocationConfiguration & V8DOMConfiguration::OnPrototype) 112 if (attribute.propertyLocationConfiguration & V8DOMConfiguration::OnPrototype)
113 prototype 113 prototype
114 ->DefineOwnProperty( 114 ->DefineOwnProperty(
115 isolate->GetCurrentContext(), name, data, 115 isolate->GetCurrentContext(), name, data,
116 static_cast<v8::PropertyAttribute>(attribute.attribute)) 116 static_cast<v8::PropertyAttribute>(attribute.attribute))
117 .ToChecked(); 117 .ToChecked();
118 if (attribute.propertyLocationConfiguration & V8DOMConfiguration::OnInterface) 118 if (attribute.propertyLocationConfiguration & V8DOMConfiguration::OnInterface)
119 NOTREACHED(); 119 NOTREACHED();
120 } 120 }
121 121
122 void installLazyDataAttributeInternal(
123 v8::Isolate* isolate,
124 v8::Local<v8::ObjectTemplate> instanceTemplate,
125 v8::Local<v8::ObjectTemplate> prototypeTemplate,
126 const V8DOMConfiguration::AttributeConfiguration& attribute,
127 const DOMWrapperWorld& world) {
128 if (attribute.exposeConfiguration ==
129 V8DOMConfiguration::OnlyExposedToPrivateScript &&
130 !world.isPrivateScriptIsolatedWorld())
131 return;
132
133 v8::Local<v8::Name> name = v8AtomicString(isolate, attribute.name);
134 v8::AccessorNameGetterCallback getter = attribute.getter;
135 DCHECK(!attribute.setter);
136 DCHECK(!attribute.getterForMainWorld);
137 DCHECK(!attribute.setterForMainWorld);
138 v8::Local<v8::Value> data =
139 v8::External::New(isolate, const_cast<WrapperTypeInfo*>(attribute.data));
140 DCHECK(static_cast<v8::AccessControl>(attribute.settings) == v8::DEFAULT);
141
142 DCHECK(attribute.propertyLocationConfiguration);
143 if (attribute.propertyLocationConfiguration &
144 V8DOMConfiguration::OnInstance) {
145 instanceTemplate->SetLazyDataProperty(
146 name, getter, data,
147 static_cast<v8::PropertyAttribute>(attribute.attribute));
148 }
149 if (attribute.propertyLocationConfiguration &
150 V8DOMConfiguration::OnPrototype) {
151 prototypeTemplate->SetLazyDataProperty(
152 name, getter, data,
153 static_cast<v8::PropertyAttribute>(attribute.attribute));
154 }
155 if (attribute.propertyLocationConfiguration & V8DOMConfiguration::OnInterface)
156 NOTREACHED();
157 }
158
122 template <class FunctionOrTemplate> 159 template <class FunctionOrTemplate>
123 v8::Local<FunctionOrTemplate> createAccessorFunctionOrTemplate( 160 v8::Local<FunctionOrTemplate> createAccessorFunctionOrTemplate(
124 v8::Isolate*, 161 v8::Isolate*,
125 v8::FunctionCallback, 162 v8::FunctionCallback,
126 v8::Local<v8::Value> data, 163 v8::Local<v8::Value> data,
127 v8::Local<v8::Signature>, 164 v8::Local<v8::Signature>,
128 int length); 165 int length);
129 166
130 template <> 167 template <>
131 v8::Local<v8::FunctionTemplate> 168 v8::Local<v8::FunctionTemplate>
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
416 453
417 void V8DOMConfiguration::installAttribute( 454 void V8DOMConfiguration::installAttribute(
418 v8::Isolate* isolate, 455 v8::Isolate* isolate,
419 const DOMWrapperWorld& world, 456 const DOMWrapperWorld& world,
420 v8::Local<v8::Object> instance, 457 v8::Local<v8::Object> instance,
421 v8::Local<v8::Object> prototype, 458 v8::Local<v8::Object> prototype,
422 const AttributeConfiguration& attribute) { 459 const AttributeConfiguration& attribute) {
423 installAttributeInternal(isolate, instance, prototype, attribute, world); 460 installAttributeInternal(isolate, instance, prototype, attribute, world);
424 } 461 }
425 462
463 void V8DOMConfiguration::installLazyDataAttributes(
464 v8::Isolate* isolate,
465 const DOMWrapperWorld& world,
466 v8::Local<v8::ObjectTemplate> instanceTemplate,
467 v8::Local<v8::ObjectTemplate> prototypeTemplate,
468 const AttributeConfiguration* attributes,
469 size_t attributeCount) {
470 for (size_t i = 0; i < attributeCount; ++i) {
471 installLazyDataAttributeInternal(isolate, instanceTemplate,
472 prototypeTemplate, attributes[i], world);
473 }
474 }
475
426 void V8DOMConfiguration::installAccessors( 476 void V8DOMConfiguration::installAccessors(
427 v8::Isolate* isolate, 477 v8::Isolate* isolate,
428 const DOMWrapperWorld& world, 478 const DOMWrapperWorld& world,
429 v8::Local<v8::ObjectTemplate> instanceTemplate, 479 v8::Local<v8::ObjectTemplate> instanceTemplate,
430 v8::Local<v8::ObjectTemplate> prototypeTemplate, 480 v8::Local<v8::ObjectTemplate> prototypeTemplate,
431 v8::Local<v8::FunctionTemplate> interfaceTemplate, 481 v8::Local<v8::FunctionTemplate> interfaceTemplate,
432 v8::Local<v8::Signature> signature, 482 v8::Local<v8::Signature> signature,
433 const AccessorConfiguration* accessors, 483 const AccessorConfiguration* accessors,
434 size_t accessorCount) { 484 size_t accessorCount) {
435 for (size_t i = 0; i < accessorCount; ++i) 485 for (size_t i = 0; i < accessorCount; ++i)
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
602 void V8DOMConfiguration::setClassString( 652 void V8DOMConfiguration::setClassString(
603 v8::Isolate* isolate, 653 v8::Isolate* isolate,
604 v8::Local<v8::ObjectTemplate> objectTemplate, 654 v8::Local<v8::ObjectTemplate> objectTemplate,
605 const char* classString) { 655 const char* classString) {
606 objectTemplate->Set( 656 objectTemplate->Set(
607 v8::Symbol::GetToStringTag(isolate), v8AtomicString(isolate, classString), 657 v8::Symbol::GetToStringTag(isolate), v8AtomicString(isolate, classString),
608 static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontEnum)); 658 static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontEnum));
609 } 659 }
610 660
611 } // namespace blink 661 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698