| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 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 are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * 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 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 static void indexedPropertyGetterCallback(uint32_t index, const v8::PropertyCall
backInfo<v8::Value>& info) | 122 static void indexedPropertyGetterCallback(uint32_t index, const v8::PropertyCall
backInfo<v8::Value>& info) |
| 123 { | 123 { |
| 124 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMIndexedProperty"); | 124 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMIndexedProperty"); |
| 125 TestEventTargetV8Internal::indexedPropertyGetter(index, info); | 125 TestEventTargetV8Internal::indexedPropertyGetter(index, info); |
| 126 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); | 126 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); |
| 127 } | 127 } |
| 128 | 128 |
| 129 static void indexedPropertySetter(uint32_t index, v8::Local<v8::Value> jsValue,
const v8::PropertyCallbackInfo<v8::Value>& info) | 129 static void indexedPropertySetter(uint32_t index, v8::Local<v8::Value> jsValue,
const v8::PropertyCallbackInfo<v8::Value>& info) |
| 130 { | 130 { |
| 131 TestEventTarget* imp = V8TestEventTarget::toNative(info.Holder()); | 131 TestEventTarget* imp = V8TestEventTarget::toNative(info.Holder()); |
| 132 V8TRYCATCH_VOID(Node*, propertyValue, V8Node::hasInstance(jsValue, info.GetI
solate()) ? V8Node::toNative(v8::Handle<v8::Object>::Cast(jsValue)) : 0); | 132 V8TRYCATCH_VOID(Node*, propertyValue, V8Node::toNativeWithTypeCheck(info.Get
Isolate(), jsValue)); |
| 133 if (!isUndefinedOrNull(jsValue) && !V8Node::hasInstance(jsValue, info.GetIso
late())) { | 133 if (!isUndefinedOrNull(jsValue) && !V8Node::hasInstance(jsValue, info.GetIso
late())) { |
| 134 exceptionState.throwTypeError("The provided value is not of type 'Node'.
"); | 134 exceptionState.throwTypeError("The provided value is not of type 'Node'.
"); |
| 135 exceptionState.throwIfNeeded(); | 135 exceptionState.throwIfNeeded(); |
| 136 return; | 136 return; |
| 137 } | 137 } |
| 138 bool result = imp->anonymousIndexedSetter(index, propertyValue); | 138 bool result = imp->anonymousIndexedSetter(index, propertyValue); |
| 139 if (!result) | 139 if (!result) |
| 140 return; | 140 return; |
| 141 v8SetReturnValue(info, jsValue); | 141 v8SetReturnValue(info, jsValue); |
| 142 } | 142 } |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 308 data->templateMap(currentWorldType).add(&wrapperTypeInfo, UnsafePersistent<v
8::FunctionTemplate>(isolate, templ)); | 308 data->templateMap(currentWorldType).add(&wrapperTypeInfo, UnsafePersistent<v
8::FunctionTemplate>(isolate, templ)); |
| 309 return handleScope.Escape(templ); | 309 return handleScope.Escape(templ); |
| 310 } | 310 } |
| 311 | 311 |
| 312 bool V8TestEventTarget::hasInstance(v8::Handle<v8::Value> jsValue, v8::Isolate*
isolate) | 312 bool V8TestEventTarget::hasInstance(v8::Handle<v8::Value> jsValue, v8::Isolate*
isolate) |
| 313 { | 313 { |
| 314 return V8PerIsolateData::from(isolate)->hasInstanceInMainWorld(&wrapperTypeI
nfo, jsValue) | 314 return V8PerIsolateData::from(isolate)->hasInstanceInMainWorld(&wrapperTypeI
nfo, jsValue) |
| 315 || V8PerIsolateData::from(isolate)->hasInstanceInNonMainWorld(&wrapperTy
peInfo, jsValue); | 315 || V8PerIsolateData::from(isolate)->hasInstanceInNonMainWorld(&wrapperTy
peInfo, jsValue); |
| 316 } | 316 } |
| 317 | 317 |
| 318 TestEventTarget* V8TestEventTarget::toNativeWithTypeCheck(v8::Isolate* isolate,
v8::Handle<v8::Value> value) |
| 319 { |
| 320 return hasInstance(value, isolate) ? fromInternalPointer(v8::Handle<v8::Obje
ct>::Cast(value)->GetAlignedPointerFromInternalField(v8DOMWrapperObjectIndex)) :
0; |
| 321 } |
| 322 |
| 318 EventTarget* V8TestEventTarget::toEventTarget(v8::Handle<v8::Object> object) | 323 EventTarget* V8TestEventTarget::toEventTarget(v8::Handle<v8::Object> object) |
| 319 { | 324 { |
| 320 return toNative(object); | 325 return toNative(object); |
| 321 } | 326 } |
| 322 | 327 |
| 323 v8::Handle<v8::Object> V8TestEventTarget::createWrapper(PassRefPtr<TestEventTarg
et> impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate) | 328 v8::Handle<v8::Object> V8TestEventTarget::createWrapper(PassRefPtr<TestEventTarg
et> impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate) |
| 324 { | 329 { |
| 325 ASSERT(impl); | 330 ASSERT(impl); |
| 326 ASSERT(!DOMDataStore::containsWrapper<V8TestEventTarget>(impl.get(), isolate
)); | 331 ASSERT(!DOMDataStore::containsWrapper<V8TestEventTarget>(impl.get(), isolate
)); |
| 327 if (ScriptWrappable::wrapperCanBeStoredInObject(impl.get())) { | 332 if (ScriptWrappable::wrapperCanBeStoredInObject(impl.get())) { |
| (...skipping 17 matching lines...) Expand all Loading... |
| 345 fromInternalPointer(object)->deref(); | 350 fromInternalPointer(object)->deref(); |
| 346 } | 351 } |
| 347 | 352 |
| 348 template<> | 353 template<> |
| 349 v8::Handle<v8::Value> toV8NoInline(TestEventTarget* impl, v8::Handle<v8::Object>
creationContext, v8::Isolate* isolate) | 354 v8::Handle<v8::Value> toV8NoInline(TestEventTarget* impl, v8::Handle<v8::Object>
creationContext, v8::Isolate* isolate) |
| 350 { | 355 { |
| 351 return toV8(impl, creationContext, isolate); | 356 return toV8(impl, creationContext, isolate); |
| 352 } | 357 } |
| 353 | 358 |
| 354 } // namespace WebCore | 359 } // namespace WebCore |
| OLD | NEW |