Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 if (world.isMainWorld()) { | |
|
haraken
2016/11/01 07:17:31
Instead, can we add DCHECK(!attribute.getterForMai
jochen (gone - plz use gerrit)
2016/11/02 11:57:00
done
| |
| 137 if (attribute.getterForMainWorld) | |
| 138 getter = attribute.getterForMainWorld; | |
| 139 DCHECK(!attribute.setterForMainWorld); | |
| 140 } | |
| 141 v8::Local<v8::Value> data = | |
| 142 v8::External::New(isolate, const_cast<WrapperTypeInfo*>(attribute.data)); | |
| 143 DCHECK(static_cast<v8::AccessControl>(attribute.settings) == v8::DEFAULT); | |
| 144 | |
| 145 DCHECK(attribute.propertyLocationConfiguration); | |
| 146 if (attribute.propertyLocationConfiguration & | |
| 147 V8DOMConfiguration::OnInstance) { | |
| 148 instanceTemplate->SetLazyDataProperty( | |
| 149 name, getter, data, | |
| 150 static_cast<v8::PropertyAttribute>(attribute.attribute)); | |
| 151 } | |
| 152 if (attribute.propertyLocationConfiguration & | |
| 153 V8DOMConfiguration::OnPrototype) { | |
| 154 prototypeTemplate->SetLazyDataProperty( | |
| 155 name, getter, data, | |
| 156 static_cast<v8::PropertyAttribute>(attribute.attribute)); | |
| 157 } | |
| 158 if (attribute.propertyLocationConfiguration & V8DOMConfiguration::OnInterface) | |
| 159 NOTREACHED(); | |
| 160 } | |
| 161 | |
| 122 template <class FunctionOrTemplate> | 162 template <class FunctionOrTemplate> |
| 123 v8::Local<FunctionOrTemplate> createAccessorFunctionOrTemplate( | 163 v8::Local<FunctionOrTemplate> createAccessorFunctionOrTemplate( |
| 124 v8::Isolate*, | 164 v8::Isolate*, |
| 125 v8::FunctionCallback, | 165 v8::FunctionCallback, |
| 126 v8::Local<v8::Value> data, | 166 v8::Local<v8::Value> data, |
| 127 v8::Local<v8::Signature>, | 167 v8::Local<v8::Signature>, |
| 128 int length); | 168 int length); |
| 129 | 169 |
| 130 template <> | 170 template <> |
| 131 v8::Local<v8::FunctionTemplate> | 171 v8::Local<v8::FunctionTemplate> |
| (...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 416 | 456 |
| 417 void V8DOMConfiguration::installAttribute( | 457 void V8DOMConfiguration::installAttribute( |
| 418 v8::Isolate* isolate, | 458 v8::Isolate* isolate, |
| 419 const DOMWrapperWorld& world, | 459 const DOMWrapperWorld& world, |
| 420 v8::Local<v8::Object> instance, | 460 v8::Local<v8::Object> instance, |
| 421 v8::Local<v8::Object> prototype, | 461 v8::Local<v8::Object> prototype, |
| 422 const AttributeConfiguration& attribute) { | 462 const AttributeConfiguration& attribute) { |
| 423 installAttributeInternal(isolate, instance, prototype, attribute, world); | 463 installAttributeInternal(isolate, instance, prototype, attribute, world); |
| 424 } | 464 } |
| 425 | 465 |
| 466 void V8DOMConfiguration::installLazyDataAttributes( | |
| 467 v8::Isolate* isolate, | |
| 468 const DOMWrapperWorld& world, | |
| 469 v8::Local<v8::ObjectTemplate> instanceTemplate, | |
| 470 v8::Local<v8::ObjectTemplate> prototypeTemplate, | |
| 471 const AttributeConfiguration* attributes, | |
| 472 size_t attributeCount) { | |
| 473 for (size_t i = 0; i < attributeCount; ++i) { | |
| 474 installLazyDataAttributeInternal(isolate, instanceTemplate, | |
| 475 prototypeTemplate, attributes[i], world); | |
| 476 } | |
| 477 } | |
| 478 | |
| 426 void V8DOMConfiguration::installAccessors( | 479 void V8DOMConfiguration::installAccessors( |
| 427 v8::Isolate* isolate, | 480 v8::Isolate* isolate, |
| 428 const DOMWrapperWorld& world, | 481 const DOMWrapperWorld& world, |
| 429 v8::Local<v8::ObjectTemplate> instanceTemplate, | 482 v8::Local<v8::ObjectTemplate> instanceTemplate, |
| 430 v8::Local<v8::ObjectTemplate> prototypeTemplate, | 483 v8::Local<v8::ObjectTemplate> prototypeTemplate, |
| 431 v8::Local<v8::FunctionTemplate> interfaceTemplate, | 484 v8::Local<v8::FunctionTemplate> interfaceTemplate, |
| 432 v8::Local<v8::Signature> signature, | 485 v8::Local<v8::Signature> signature, |
| 433 const AccessorConfiguration* accessors, | 486 const AccessorConfiguration* accessors, |
| 434 size_t accessorCount) { | 487 size_t accessorCount) { |
| 435 for (size_t i = 0; i < accessorCount; ++i) | 488 for (size_t i = 0; i < accessorCount; ++i) |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 602 void V8DOMConfiguration::setClassString( | 655 void V8DOMConfiguration::setClassString( |
| 603 v8::Isolate* isolate, | 656 v8::Isolate* isolate, |
| 604 v8::Local<v8::ObjectTemplate> objectTemplate, | 657 v8::Local<v8::ObjectTemplate> objectTemplate, |
| 605 const char* classString) { | 658 const char* classString) { |
| 606 objectTemplate->Set( | 659 objectTemplate->Set( |
| 607 v8::Symbol::GetToStringTag(isolate), v8AtomicString(isolate, classString), | 660 v8::Symbol::GetToStringTag(isolate), v8AtomicString(isolate, classString), |
| 608 static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontEnum)); | 661 static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontEnum)); |
| 609 } | 662 } |
| 610 | 663 |
| 611 } // namespace blink | 664 } // namespace blink |
| OLD | NEW |