Source/WebCore/ChangeLog

 12012-05-20 Kentaro Hara <haraken@chromium.org>
 2
 3 [V8] Pass Isolate to V8NPObject::npObjectGetProperty() and V8NPObject::npObjectSetProperty()
 4 https://bugs.webkit.org/show_bug.cgi?id=86979
 5
 6 Reviewed by NOBODY (OOPS!).
 7
 8 The objective is to pass Isolate around in V8 bindings.
 9 This patch passes Isolate to V8NPObject::npObjectGetProperty()
 10 and V8NPObject::npObjectSetProperty().
 11
 12 No tests. No change in behavior.
 13
 14 * bindings/v8/V8NPObject.cpp:
 15 (WebCore::npObjectGetProperty):
 16 (WebCore::npObjectNamedPropertyGetter):
 17 (WebCore::npObjectIndexedPropertyGetter):
 18 (WebCore::npObjectGetNamedProperty):
 19 (WebCore::npObjectGetIndexedProperty):
 20 (WebCore::npObjectQueryProperty):
 21 (WebCore::npObjectSetProperty):
 22 (WebCore::npObjectNamedPropertySetter):
 23 (WebCore::npObjectIndexedPropertySetter):
 24 (WebCore::npObjectSetNamedProperty):
 25 (WebCore::npObjectSetIndexedProperty):
 26 * bindings/v8/V8NPObject.h:
 27 (WebCore):
 28 * bindings/v8/custom/V8HTMLPlugInElementCustom.cpp:
 29 (WebCore::npObjectNamedGetter):
 30 (WebCore::npObjectNamedSetter):
 31 (WebCore::npObjectIndexedGetter):
 32 (WebCore::npObjectIndexedSetter):
 33
1342012-05-20 George Staikos <staikos@webkit.org>
235
336 Use reinterpret_cast_ptr<> to fix an alignment warning.

Source/WebCore/bindings/v8/V8NPObject.cpp

@@static void weakTemplateCallback(v8::Persistent<v8::Value> object, void* paramet
183183}
184184
185185
186 static v8::Handle<v8::Value> npObjectGetProperty(v8::Local<v8::Object> self, NPIdentifier identifier, v8::Local<v8::Value> key)
 186static v8::Handle<v8::Value> npObjectGetProperty(v8::Local<v8::Object> self, NPIdentifier identifier, v8::Local<v8::Value> key, v8::Isolate* isolate)
187187{
188188 NPObject* npObject = v8ObjectToNPObject(self);
189189
190190 // Verify that our wrapper wasn't using a NPObject which
191191 // has already been deleted.
192192 if (!npObject || !_NPN_IsAlive(npObject))
193  return V8Proxy::throwError(V8Proxy::ReferenceError, "NPObject deleted");
 193 return V8Proxy::throwError(V8Proxy::ReferenceError, "NPObject deleted", isolate);
194194
195195
196196 if (npObject->_class->hasProperty && npObject->_class->getProperty && npObject->_class->hasProperty(npObject, identifier)) {
197197 if (!_NPN_IsAlive(npObject))
198  return V8Proxy::throwError(V8Proxy::ReferenceError, "NPObject deleted");
 198 return V8Proxy::throwError(V8Proxy::ReferenceError, "NPObject deleted", isolate);
199199
200200 NPVariant result;
201201 VOID_TO_NPVARIANT(result);

@@static v8::Handle<v8::Value> npObjectGetProperty(v8::Local<v8::Object> self, NPI
211211 }
212212
213213 if (!_NPN_IsAlive(npObject))
214  return V8Proxy::throwError(V8Proxy::ReferenceError, "NPObject deleted");
 214 return V8Proxy::throwError(V8Proxy::ReferenceError, "NPObject deleted", isolate);
215215
216216 if (key->IsString() && npObject->_class->hasMethod && npObject->_class->hasMethod(npObject, identifier)) {
217217 if (!_NPN_IsAlive(npObject))
218  return V8Proxy::throwError(V8Proxy::ReferenceError, "NPObject deleted");
 218 return V8Proxy::throwError(V8Proxy::ReferenceError, "NPObject deleted", isolate);
219219
220220 PrivateIdentifier* id = static_cast<PrivateIdentifier*>(identifier);
221221 v8::Persistent<v8::FunctionTemplate> functionTemplate = staticTemplateMap().get(id);

@@static v8::Handle<v8::Value> npObjectGetProperty(v8::Local<v8::Object> self, NPI
240240v8::Handle<v8::Value> npObjectNamedPropertyGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)
241241{
242242 NPIdentifier identifier = getStringIdentifier(name);
243  return npObjectGetProperty(info.Holder(), identifier, name);
 243 return npObjectGetProperty(info.Holder(), identifier, name, info.GetIsolate());
244244}
245245
246246v8::Handle<v8::Value> npObjectIndexedPropertyGetter(uint32_t index, const v8::AccessorInfo& info)
247247{
248248 NPIdentifier identifier = _NPN_GetIntIdentifier(index);
249  return npObjectGetProperty(info.Holder(), identifier, v8::Number::New(index));
 249 return npObjectGetProperty(info.Holder(), identifier, v8::Number::New(index), info.GetIsolate());
250250}
251251
252 v8::Handle<v8::Value> npObjectGetNamedProperty(v8::Local<v8::Object> self, v8::Local<v8::String> name)
 252v8::Handle<v8::Value> npObjectGetNamedProperty(v8::Local<v8::Object> self, v8::Local<v8::String> name, const v8::AccessorInfo& info)
253253{
254254 NPIdentifier identifier = getStringIdentifier(name);
255  return npObjectGetProperty(self, identifier, name);
 255 return npObjectGetProperty(self, identifier, name, info.GetIsolate());
256256}
257257
258 v8::Handle<v8::Value> npObjectGetIndexedProperty(v8::Local<v8::Object> self, uint32_t index)
 258v8::Handle<v8::Value> npObjectGetIndexedProperty(v8::Local<v8::Object> self, uint32_t index, const v8::AccessorInfo& info)
259259{
260260 NPIdentifier identifier = _NPN_GetIntIdentifier(index);
261  return npObjectGetProperty(self, identifier, v8::Number::New(index));
 261 return npObjectGetProperty(self, identifier, v8::Number::New(index), info.GetIsolate());
262262}
263263
264264v8::Handle<v8::Integer> npObjectQueryProperty(v8::Local<v8::String> name, const v8::AccessorInfo& info)
265265{
266266 NPIdentifier identifier = getStringIdentifier(name);
267  return npObjectGetProperty(info.Holder(), identifier, name).IsEmpty() ? v8::Handle<v8::Integer>() : v8::Integer::New(v8::None);
 267 return npObjectGetProperty(info.Holder(), identifier, name, info.GetIsolate()).IsEmpty() ? v8::Handle<v8::Integer>() : v8::Integer::New(v8::None);
268268}
269269
270 static v8::Handle<v8::Value> npObjectSetProperty(v8::Local<v8::Object> self, NPIdentifier identifier, v8::Local<v8::Value> value)
 270static v8::Handle<v8::Value> npObjectSetProperty(v8::Local<v8::Object> self, NPIdentifier identifier, v8::Local<v8::Value> value, v8::Isolate* isolate)
271271{
272272 NPObject* npObject = v8ObjectToNPObject(self);
273273
274274 // Verify that our wrapper wasn't using a NPObject which has already been deleted.
275275 if (!npObject || !_NPN_IsAlive(npObject)) {
276  V8Proxy::throwError(V8Proxy::ReferenceError, "NPObject deleted");
 276 V8Proxy::throwError(V8Proxy::ReferenceError, "NPObject deleted", isolate);
277277 return value; // Intercepted, but an exception was thrown.
278278 }
279279
280280 if (npObject->_class->hasProperty && npObject->_class->setProperty && npObject->_class->hasProperty(npObject, identifier)) {
281281 if (!_NPN_IsAlive(npObject))
282  return V8Proxy::throwError(V8Proxy::ReferenceError, "NPObject deleted");
 282 return V8Proxy::throwError(V8Proxy::ReferenceError, "NPObject deleted", isolate);
283283
284284 NPVariant npValue;
285285 VOID_TO_NPVARIANT(npValue);

@@static v8::Handle<v8::Value> npObjectSetProperty(v8::Local<v8::Object> self, NPI
296296v8::Handle<v8::Value> npObjectNamedPropertySetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info)
297297{
298298 NPIdentifier identifier = getStringIdentifier(name);
299  return npObjectSetProperty(info.Holder(), identifier, value);
 299 return npObjectSetProperty(info.Holder(), identifier, value, info.GetIsolate());
300300}
301301
302302
303303v8::Handle<v8::Value> npObjectIndexedPropertySetter(uint32_t index, v8::Local<v8::Value> value, const v8::AccessorInfo& info)
304304{
305305 NPIdentifier identifier = _NPN_GetIntIdentifier(index);
306  return npObjectSetProperty(info.Holder(), identifier, value);
 306 return npObjectSetProperty(info.Holder(), identifier, value, info.GetIsolate());
307307}
308308
309 v8::Handle<v8::Value> npObjectSetNamedProperty(v8::Local<v8::Object> self, v8::Local<v8::String> name, v8::Local<v8::Value> value)
 309v8::Handle<v8::Value> npObjectSetNamedProperty(v8::Local<v8::Object> self, v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info)
310310{
311311 NPIdentifier identifier = getStringIdentifier(name);
312  return npObjectSetProperty(self, identifier, value);
 312 return npObjectSetProperty(self, identifier, value, info.GetIsolate());
313313}
314314
315 v8::Handle<v8::Value> npObjectSetIndexedProperty(v8::Local<v8::Object> self, uint32_t index, v8::Local<v8::Value> value)
 315v8::Handle<v8::Value> npObjectSetIndexedProperty(v8::Local<v8::Object> self, uint32_t index, v8::Local<v8::Value> value, const v8::AccessorInfo& info)
316316{
317317 NPIdentifier identifier = _NPN_GetIntIdentifier(index);
318  return npObjectSetProperty(self, identifier, value);
 318 return npObjectSetProperty(self, identifier, value, info.GetIsolate());
319319}
320320
321321v8::Handle<v8::Array> npObjectPropertyEnumerator(const v8::AccessorInfo& info, bool namedProperty)

Source/WebCore/bindings/v8/V8NPObject.h

@@namespace WebCore {
4545// Getters
4646v8::Handle<v8::Value> npObjectNamedPropertyGetter(v8::Local<v8::String> name, const v8::AccessorInfo&);
4747v8::Handle<v8::Value> npObjectIndexedPropertyGetter(uint32_t index, const v8::AccessorInfo&);
48 v8::Handle<v8::Value> npObjectGetNamedProperty(v8::Local<v8::Object> self, v8::Local<v8::String> name);
49 v8::Handle<v8::Value> npObjectGetIndexedProperty(v8::Local<v8::Object> self, uint32_t index);
 48v8::Handle<v8::Value> npObjectGetNamedProperty(v8::Local<v8::Object> self, v8::Local<v8::String> name, const v8::AccessorInfo&);
 49v8::Handle<v8::Value> npObjectGetIndexedProperty(v8::Local<v8::Object> self, uint32_t index, const v8::AccessorInfo&);
5050
5151// Setters
5252v8::Handle<v8::Value> npObjectNamedPropertySetter(v8::Local<v8::String> name, v8::Local<v8::Value>, const v8::AccessorInfo&);
5353v8::Handle<v8::Value> npObjectIndexedPropertySetter(uint32_t index, const v8::AccessorInfo&);
54 v8::Handle<v8::Value> npObjectSetNamedProperty(v8::Local<v8::Object> self, v8::Local<v8::String> name, v8::Local<v8::Value>);
55 v8::Handle<v8::Value> npObjectSetIndexedProperty(v8::Local<v8::Object> self, uint32_t index, v8::Local<v8::Value>);
 54v8::Handle<v8::Value> npObjectSetNamedProperty(v8::Local<v8::Object> self, v8::Local<v8::String> name, v8::Local<v8::Value>, const v8::AccessorInfo&);
 55v8::Handle<v8::Value> npObjectSetIndexedProperty(v8::Local<v8::Object> self, uint32_t index, v8::Local<v8::Value>, const v8::AccessorInfo&);
5656
5757v8::Handle<v8::Value> npObjectInvokeDefaultHandler(const v8::Arguments&);
5858

Source/WebCore/bindings/v8/custom/V8HTMLPlugInElementCustom.cpp

@@static v8::Handle<v8::Value> npObjectNamedGetter(v8::Local<v8::String> name, con
5656 if (instance.IsEmpty())
5757 return notHandledByInterceptor();
5858
59  return npObjectGetNamedProperty(instance, name);
 59 return npObjectGetNamedProperty(instance, name, info);
6060}
6161
6262template <class C>

@@static v8::Handle<v8::Value> npObjectNamedSetter(v8::Local<v8::String> name, v8:
7171 if (instance.IsEmpty())
7272 return notHandledByInterceptor();
7373
74  return npObjectSetNamedProperty(instance, name, value);
 74 return npObjectSetNamedProperty(instance, name, value, info);
7575}
7676
7777v8::Handle<v8::Value> V8HTMLAppletElement::namedPropertyGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)

@@v8::Handle<v8::Value> npObjectIndexedGetter(uint32_t index, const v8::AccessorIn
141141 if (instance.IsEmpty())
142142 return notHandledByInterceptor();
143143
144  return npObjectGetIndexedProperty(instance, index);
 144 return npObjectGetIndexedProperty(instance, index, info);
145145}
146146
147147template <class C>

@@v8::Handle<v8::Value> npObjectIndexedSetter(uint32_t index, v8::Local<v8::Value>
157157 if (instance.IsEmpty())
158158 return notHandledByInterceptor();
159159
160  return npObjectSetIndexedProperty(instance, index, value);
 160 return npObjectSetIndexedProperty(instance, index, value, info);
161161}
162162
163163v8::Handle<v8::Value> V8HTMLAppletElement::indexedPropertyGetter(uint32_t index, const v8::AccessorInfo& info)