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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 54 | 54 |
| 55 DCHECK(attribute.propertyLocationConfiguration); | 55 DCHECK(attribute.propertyLocationConfiguration); |
| 56 if (attribute.propertyLocationConfiguration & V8DOMConfiguration::OnInstance ) | 56 if (attribute.propertyLocationConfiguration & V8DOMConfiguration::OnInstance ) |
| 57 instanceTemplate->SetNativeDataProperty(name, getter, setter, data, stat ic_cast<v8::PropertyAttribute>(attribute.attribute), v8::Local<v8::AccessorSigna ture>(), static_cast<v8::AccessControl>(attribute.settings)); | 57 instanceTemplate->SetNativeDataProperty(name, getter, setter, data, stat ic_cast<v8::PropertyAttribute>(attribute.attribute), v8::Local<v8::AccessorSigna ture>(), static_cast<v8::AccessControl>(attribute.settings)); |
| 58 if (attribute.propertyLocationConfiguration & V8DOMConfiguration::OnPrototyp e) | 58 if (attribute.propertyLocationConfiguration & V8DOMConfiguration::OnPrototyp e) |
| 59 prototypeTemplate->SetNativeDataProperty(name, getter, setter, data, sta tic_cast<v8::PropertyAttribute>(attribute.attribute), v8::Local<v8::AccessorSign ature>(), static_cast<v8::AccessControl>(attribute.settings)); | 59 prototypeTemplate->SetNativeDataProperty(name, getter, setter, data, sta tic_cast<v8::PropertyAttribute>(attribute.attribute), v8::Local<v8::AccessorSign ature>(), static_cast<v8::AccessControl>(attribute.settings)); |
| 60 if (attribute.propertyLocationConfiguration & V8DOMConfiguration::OnInterfac e) | 60 if (attribute.propertyLocationConfiguration & V8DOMConfiguration::OnInterfac e) |
| 61 NOTREACHED(); | 61 NOTREACHED(); |
| 62 } | 62 } |
| 63 | 63 |
| 64 void installAttributeInternal(v8::Isolate* isolate, v8::Local<v8::Object> instan ce, v8::Local<v8::Object> prototype, const V8DOMConfiguration::AttributeConfigur ation& attribute, const DOMWrapperWorld& world) | 64 void installAttributeInternal(v8::Isolate* isolate, v8::Local<v8::Object> instan ce, v8::Local<v8::Object> prototype, const V8DOMConfiguration::AttributeConfigur ation& attribute, const DOMWrapperWorld& world) |
|
haraken
2016/05/27 00:01:42
Now you're using SetAccessor, this method should b
iclelland
2016/05/27 03:19:43
That's a really good question. I started reading t
Yuki
2016/05/27 09:59:42
For historical reasons, "attribute" in this file (
iclelland
2016/05/27 13:51:26
This file is very confusing :)
constants are data
Yuki
2016/05/27 15:09:42
1. This function is currently NOT used. So it's o
iclelland
2016/05/27 15:27:01
(I presume here that you're talking about this new
Yuki
2016/05/30 08:14:19
Should work for the interface objects because the
iclelland
2016/05/30 12:15:35
I'll take a closer look to see what was going on w
Yuki
2016/05/30 13:07:58
Is this where you were trying to install an interf
iclelland
2016/05/30 15:07:46
That method works, and I've switched installAttrib
| |
| 65 { | 65 { |
| 66 if (attribute.exposeConfiguration == V8DOMConfiguration::OnlyExposedToPrivat eScript | 66 if (attribute.exposeConfiguration == V8DOMConfiguration::OnlyExposedToPrivat eScript |
| 67 && !world.isPrivateScriptIsolatedWorld()) | 67 && !world.isPrivateScriptIsolatedWorld()) |
| 68 return; | 68 return; |
| 69 | 69 |
| 70 v8::Local<v8::Name> name = v8AtomicString(isolate, attribute.name); | 70 v8::Local<v8::Name> name = v8AtomicString(isolate, attribute.name); |
| 71 v8::AccessorNameGetterCallback getter = attribute.getter; | |
| 72 v8::AccessorNameSetterCallback setter = attribute.setter; | |
| 73 if (world.isMainWorld()) { | |
| 74 if (attribute.getterForMainWorld) | |
| 75 getter = attribute.getterForMainWorld; | |
| 76 if (attribute.setterForMainWorld) | |
| 77 setter = attribute.setterForMainWorld; | |
| 78 } | |
| 71 v8::Local<v8::Value> data = v8::External::New(isolate, const_cast<WrapperTyp eInfo*>(attribute.data)); | 79 v8::Local<v8::Value> data = v8::External::New(isolate, const_cast<WrapperTyp eInfo*>(attribute.data)); |
| 72 | 80 |
| 73 DCHECK(attribute.propertyLocationConfiguration); | 81 DCHECK(attribute.propertyLocationConfiguration); |
| 74 if (attribute.propertyLocationConfiguration & V8DOMConfiguration::OnInstance ) | 82 if (attribute.propertyLocationConfiguration & V8DOMConfiguration::OnInstance ) |
| 75 v8CallOrCrash(instance->DefineOwnProperty(isolate->GetCurrentContext(), name, data, static_cast<v8::PropertyAttribute>(attribute.attribute))); | 83 v8CallOrCrash(instance->SetAccessor(isolate->GetCurrentContext(), name, getter, setter, data, static_cast<v8::AccessControl>(attribute.settings), static _cast<v8::PropertyAttribute>(attribute.attribute))); |
| 76 if (attribute.propertyLocationConfiguration & V8DOMConfiguration::OnPrototyp e) | 84 if (attribute.propertyLocationConfiguration & V8DOMConfiguration::OnPrototyp e) |
| 77 v8CallOrCrash(prototype->DefineOwnProperty(isolate->GetCurrentContext(), name, data, static_cast<v8::PropertyAttribute>(attribute.attribute))); | 85 v8CallOrCrash(prototype->SetAccessor(isolate->GetCurrentContext(), name, getter, setter, data, static_cast<v8::AccessControl>(attribute.settings), stati c_cast<v8::PropertyAttribute>(attribute.attribute))); |
| 78 if (attribute.propertyLocationConfiguration & V8DOMConfiguration::OnInterfac e) | 86 if (attribute.propertyLocationConfiguration & V8DOMConfiguration::OnInterfac e) |
| 79 NOTREACHED(); | 87 NOTREACHED(); |
| 80 } | 88 } |
| 81 | 89 |
| 82 template<class FunctionOrTemplate> | 90 template<class FunctionOrTemplate> |
| 83 v8::Local<FunctionOrTemplate> createAccessorFunctionOrTemplate(v8::Isolate*, v8: :FunctionCallback, v8::Local<v8::Value> data, v8::Local<v8::Signature>, int leng th); | 91 v8::Local<FunctionOrTemplate> createAccessorFunctionOrTemplate(v8::Isolate*, v8: :FunctionCallback, v8::Local<v8::Value> data, v8::Local<v8::Signature>, int leng th); |
| 84 | 92 |
| 85 template<> | 93 template<> |
| 86 v8::Local<v8::FunctionTemplate> createAccessorFunctionOrTemplate<v8::FunctionTem plate>(v8::Isolate* isolate, v8::FunctionCallback callback, v8::Local<v8::Value> data, v8::Local<v8::Signature> signature, int length) | 94 v8::Local<v8::FunctionTemplate> createAccessorFunctionOrTemplate<v8::FunctionTem plate>(v8::Isolate* isolate, v8::FunctionCallback callback, v8::Local<v8::Value> data, v8::Local<v8::Signature> signature, int length) |
| 87 { | 95 { |
| (...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 353 data->setInterfaceTemplate(world, wrapperTypeInfo, result); | 361 data->setInterfaceTemplate(world, wrapperTypeInfo, result); |
| 354 return result; | 362 return result; |
| 355 } | 363 } |
| 356 | 364 |
| 357 void V8DOMConfiguration::setClassString(v8::Isolate* isolate, v8::Local<v8::Obje ctTemplate> objectTemplate, const char* classString) | 365 void V8DOMConfiguration::setClassString(v8::Isolate* isolate, v8::Local<v8::Obje ctTemplate> objectTemplate, const char* classString) |
| 358 { | 366 { |
| 359 objectTemplate->Set(v8::Symbol::GetToStringTag(isolate), v8AtomicString(isol ate, classString), static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontEnu m)); | 367 objectTemplate->Set(v8::Symbol::GetToStringTag(isolate), v8AtomicString(isol ate, classString), static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontEnu m)); |
| 360 } | 368 } |
| 361 | 369 |
| 362 } // namespace blink | 370 } // namespace blink |
| OLD | NEW |