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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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) |
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 |