| 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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 static void animatedReflectedAttributeAttributeGetterCallback(v8::Local<v8::Stri
ng>, const v8::PropertyCallbackInfo<v8::Value>& info) | 84 static void animatedReflectedAttributeAttributeGetterCallback(v8::Local<v8::Stri
ng>, const v8::PropertyCallbackInfo<v8::Value>& info) |
| 85 { | 85 { |
| 86 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter"); | 86 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter"); |
| 87 TestSVGV8Internal::animatedReflectedAttributeAttributeGetter(info); | 87 TestSVGV8Internal::animatedReflectedAttributeAttributeGetter(info); |
| 88 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); | 88 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); |
| 89 } | 89 } |
| 90 | 90 |
| 91 static void animatedReflectedAttributeAttributeSetter(v8::Local<v8::Value> jsVal
ue, const v8::PropertyCallbackInfo<void>& info) | 91 static void animatedReflectedAttributeAttributeSetter(v8::Local<v8::Value> jsVal
ue, const v8::PropertyCallbackInfo<void>& info) |
| 92 { | 92 { |
| 93 TestSVG* imp = V8TestSVG::toNative(info.Holder()); | 93 TestSVG* imp = V8TestSVG::toNative(info.Holder()); |
| 94 V8TRYCATCH_VOID(SVGAnimatedString*, cppValue, V8SVGAnimatedString::hasInstan
ce(jsValue, info.GetIsolate()) ? V8SVGAnimatedString::toNative(v8::Handle<v8::Ob
ject>::Cast(jsValue)) : 0); | 94 V8TRYCATCH_VOID(SVGAnimatedString*, cppValue, V8SVGAnimatedString::toNativeW
ithTypeCheck(info.GetIsolate(), jsValue)); |
| 95 CustomElementCallbackDispatcher::CallbackDeliveryScope deliveryScope; | 95 CustomElementCallbackDispatcher::CallbackDeliveryScope deliveryScope; |
| 96 imp->setAttribute(HTMLNames::animatedreflectedattributeAttr, WTF::getPtr(cpp
Value)); | 96 imp->setAttribute(HTMLNames::animatedreflectedattributeAttr, WTF::getPtr(cpp
Value)); |
| 97 } | 97 } |
| 98 | 98 |
| 99 static void animatedReflectedAttributeAttributeSetterCallback(v8::Local<v8::Stri
ng>, v8::Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<void>& info) | 99 static void animatedReflectedAttributeAttributeSetterCallback(v8::Local<v8::Stri
ng>, v8::Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<void>& info) |
| 100 { | 100 { |
| 101 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMSetter"); | 101 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMSetter"); |
| 102 CustomElementCallbackDispatcher::CallbackDeliveryScope deliveryScope; | 102 CustomElementCallbackDispatcher::CallbackDeliveryScope deliveryScope; |
| 103 TestSVGV8Internal::animatedReflectedAttributeAttributeSetter(jsValue, info); | 103 TestSVGV8Internal::animatedReflectedAttributeAttributeSetter(jsValue, info); |
| 104 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); | 104 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); |
| 105 } | 105 } |
| 106 | 106 |
| 107 static void mutablePointAttributeGetter(const v8::PropertyCallbackInfo<v8::Value
>& info) | 107 static void mutablePointAttributeGetter(const v8::PropertyCallbackInfo<v8::Value
>& info) |
| 108 { | 108 { |
| 109 TestSVG* imp = V8TestSVG::toNative(info.Holder()); | 109 TestSVG* imp = V8TestSVG::toNative(info.Holder()); |
| 110 v8SetReturnValueFast(info, imp->mutablePoint(), imp); | 110 v8SetReturnValueFast(info, imp->mutablePoint(), imp); |
| 111 } | 111 } |
| 112 | 112 |
| 113 static void mutablePointAttributeGetterCallback(v8::Local<v8::String>, const v8:
:PropertyCallbackInfo<v8::Value>& info) | 113 static void mutablePointAttributeGetterCallback(v8::Local<v8::String>, const v8:
:PropertyCallbackInfo<v8::Value>& info) |
| 114 { | 114 { |
| 115 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter"); | 115 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter"); |
| 116 TestSVGV8Internal::mutablePointAttributeGetter(info); | 116 TestSVGV8Internal::mutablePointAttributeGetter(info); |
| 117 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); | 117 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); |
| 118 } | 118 } |
| 119 | 119 |
| 120 static void mutablePointAttributeSetter(v8::Local<v8::Value> jsValue, const v8::
PropertyCallbackInfo<void>& info) | 120 static void mutablePointAttributeSetter(v8::Local<v8::Value> jsValue, const v8::
PropertyCallbackInfo<void>& info) |
| 121 { | 121 { |
| 122 TestSVG* imp = V8TestSVG::toNative(info.Holder()); | 122 TestSVG* imp = V8TestSVG::toNative(info.Holder()); |
| 123 V8TRYCATCH_VOID(SVGPointTearOff*, cppValue, V8SVGPoint::hasInstance(jsValue,
info.GetIsolate()) ? V8SVGPoint::toNative(v8::Handle<v8::Object>::Cast(jsValue)
) : 0); | 123 V8TRYCATCH_VOID(SVGPointTearOff*, cppValue, V8SVGPoint::toNativeWithTypeChec
k(info.GetIsolate(), jsValue)); |
| 124 imp->setMutablePoint(WTF::getPtr(cppValue)); | 124 imp->setMutablePoint(WTF::getPtr(cppValue)); |
| 125 } | 125 } |
| 126 | 126 |
| 127 static void mutablePointAttributeSetterCallback(v8::Local<v8::String>, v8::Local
<v8::Value> jsValue, const v8::PropertyCallbackInfo<void>& info) | 127 static void mutablePointAttributeSetterCallback(v8::Local<v8::String>, v8::Local
<v8::Value> jsValue, const v8::PropertyCallbackInfo<void>& info) |
| 128 { | 128 { |
| 129 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMSetter"); | 129 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMSetter"); |
| 130 TestSVGV8Internal::mutablePointAttributeSetter(jsValue, info); | 130 TestSVGV8Internal::mutablePointAttributeSetter(jsValue, info); |
| 131 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); | 131 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); |
| 132 } | 132 } |
| 133 | 133 |
| 134 static void immutablePointAttributeGetter(const v8::PropertyCallbackInfo<v8::Val
ue>& info) | 134 static void immutablePointAttributeGetter(const v8::PropertyCallbackInfo<v8::Val
ue>& info) |
| 135 { | 135 { |
| 136 TestSVG* imp = V8TestSVG::toNative(info.Holder()); | 136 TestSVG* imp = V8TestSVG::toNative(info.Holder()); |
| 137 v8SetReturnValueFast(info, imp->immutablePoint(), imp); | 137 v8SetReturnValueFast(info, imp->immutablePoint(), imp); |
| 138 } | 138 } |
| 139 | 139 |
| 140 static void immutablePointAttributeGetterCallback(v8::Local<v8::String>, const v
8::PropertyCallbackInfo<v8::Value>& info) | 140 static void immutablePointAttributeGetterCallback(v8::Local<v8::String>, const v
8::PropertyCallbackInfo<v8::Value>& info) |
| 141 { | 141 { |
| 142 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter"); | 142 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter"); |
| 143 TestSVGV8Internal::immutablePointAttributeGetter(info); | 143 TestSVGV8Internal::immutablePointAttributeGetter(info); |
| 144 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); | 144 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); |
| 145 } | 145 } |
| 146 | 146 |
| 147 static void immutablePointAttributeSetter(v8::Local<v8::Value> jsValue, const v8
::PropertyCallbackInfo<void>& info) | 147 static void immutablePointAttributeSetter(v8::Local<v8::Value> jsValue, const v8
::PropertyCallbackInfo<void>& info) |
| 148 { | 148 { |
| 149 TestSVG* imp = V8TestSVG::toNative(info.Holder()); | 149 TestSVG* imp = V8TestSVG::toNative(info.Holder()); |
| 150 V8TRYCATCH_VOID(SVGPointTearOff*, cppValue, V8SVGPoint::hasInstance(jsValue,
info.GetIsolate()) ? V8SVGPoint::toNative(v8::Handle<v8::Object>::Cast(jsValue)
) : 0); | 150 V8TRYCATCH_VOID(SVGPointTearOff*, cppValue, V8SVGPoint::toNativeWithTypeChec
k(info.GetIsolate(), jsValue)); |
| 151 imp->setImmutablePoint(WTF::getPtr(cppValue)); | 151 imp->setImmutablePoint(WTF::getPtr(cppValue)); |
| 152 } | 152 } |
| 153 | 153 |
| 154 static void immutablePointAttributeSetterCallback(v8::Local<v8::String>, v8::Loc
al<v8::Value> jsValue, const v8::PropertyCallbackInfo<void>& info) | 154 static void immutablePointAttributeSetterCallback(v8::Local<v8::String>, v8::Loc
al<v8::Value> jsValue, const v8::PropertyCallbackInfo<void>& info) |
| 155 { | 155 { |
| 156 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMSetter"); | 156 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMSetter"); |
| 157 TestSVGV8Internal::immutablePointAttributeSetter(jsValue, info); | 157 TestSVGV8Internal::immutablePointAttributeSetter(jsValue, info); |
| 158 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); | 158 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); |
| 159 } | 159 } |
| 160 | 160 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 199 | 199 |
| 200 static void svgPointMethodMethod(const v8::FunctionCallbackInfo<v8::Value>& info
) | 200 static void svgPointMethodMethod(const v8::FunctionCallbackInfo<v8::Value>& info
) |
| 201 { | 201 { |
| 202 ExceptionState exceptionState(ExceptionState::ExecutionContext, "svgPointMet
hod", "TestSVG", info.Holder(), info.GetIsolate()); | 202 ExceptionState exceptionState(ExceptionState::ExecutionContext, "svgPointMet
hod", "TestSVG", info.Holder(), info.GetIsolate()); |
| 203 if (UNLIKELY(info.Length() < 2)) { | 203 if (UNLIKELY(info.Length() < 2)) { |
| 204 exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments(2, i
nfo.Length())); | 204 exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments(2, i
nfo.Length())); |
| 205 exceptionState.throwIfNeeded(); | 205 exceptionState.throwIfNeeded(); |
| 206 return; | 206 return; |
| 207 } | 207 } |
| 208 TestSVG* imp = V8TestSVG::toNative(info.Holder()); | 208 TestSVG* imp = V8TestSVG::toNative(info.Holder()); |
| 209 V8TRYCATCH_VOID(SVGPointTearOff*, item, V8SVGPoint::hasInstance(info[0], inf
o.GetIsolate()) ? V8SVGPoint::toNative(v8::Handle<v8::Object>::Cast(info[0])) :
0); | 209 V8TRYCATCH_VOID(SVGPointTearOff*, item, V8SVGPoint::toNativeWithTypeCheck(in
fo.GetIsolate(), info[0])); |
| 210 V8TRYCATCH_EXCEPTION_VOID(unsigned, index, toUInt32(info[1], exceptionState)
, exceptionState); | 210 V8TRYCATCH_EXCEPTION_VOID(unsigned, index, toUInt32(info[1], exceptionState)
, exceptionState); |
| 211 v8SetReturnValue(info, imp->svgPointMethod(item, index)); | 211 v8SetReturnValue(info, imp->svgPointMethod(item, index)); |
| 212 } | 212 } |
| 213 | 213 |
| 214 static void svgPointMethodMethodCallback(const v8::FunctionCallbackInfo<v8::Valu
e>& info) | 214 static void svgPointMethodMethodCallback(const v8::FunctionCallbackInfo<v8::Valu
e>& info) |
| 215 { | 215 { |
| 216 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod"); | 216 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod"); |
| 217 TestSVGV8Internal::svgPointMethodMethod(info); | 217 TestSVGV8Internal::svgPointMethodMethod(info); |
| 218 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); | 218 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); |
| 219 } | 219 } |
| 220 | 220 |
| 221 static void strictSVGPointMethodMethod(const v8::FunctionCallbackInfo<v8::Value>
& info) | 221 static void strictSVGPointMethodMethod(const v8::FunctionCallbackInfo<v8::Value>
& info) |
| 222 { | 222 { |
| 223 ExceptionState exceptionState(ExceptionState::ExecutionContext, "strictSVGPo
intMethod", "TestSVG", info.Holder(), info.GetIsolate()); | 223 ExceptionState exceptionState(ExceptionState::ExecutionContext, "strictSVGPo
intMethod", "TestSVG", info.Holder(), info.GetIsolate()); |
| 224 if (UNLIKELY(info.Length() < 2)) { | 224 if (UNLIKELY(info.Length() < 2)) { |
| 225 exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments(2, i
nfo.Length())); | 225 exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments(2, i
nfo.Length())); |
| 226 exceptionState.throwIfNeeded(); | 226 exceptionState.throwIfNeeded(); |
| 227 return; | 227 return; |
| 228 } | 228 } |
| 229 TestSVG* imp = V8TestSVG::toNative(info.Holder()); | 229 TestSVG* imp = V8TestSVG::toNative(info.Holder()); |
| 230 if (info.Length() > 0 && !V8SVGPoint::hasInstance(info[0], info.GetIsolate()
)) { | 230 if (info.Length() > 0 && !V8SVGPoint::hasInstance(info[0], info.GetIsolate()
)) { |
| 231 exceptionState.throwTypeError("parameter 1 is not of type 'SVGPoint'."); | 231 exceptionState.throwTypeError("parameter 1 is not of type 'SVGPoint'."); |
| 232 exceptionState.throwIfNeeded(); | 232 exceptionState.throwIfNeeded(); |
| 233 return; | 233 return; |
| 234 } | 234 } |
| 235 V8TRYCATCH_VOID(SVGPointTearOff*, item, V8SVGPoint::hasInstance(info[0], inf
o.GetIsolate()) ? V8SVGPoint::toNative(v8::Handle<v8::Object>::Cast(info[0])) :
0); | 235 V8TRYCATCH_VOID(SVGPointTearOff*, item, V8SVGPoint::toNativeWithTypeCheck(in
fo.GetIsolate(), info[0])); |
| 236 V8TRYCATCH_EXCEPTION_VOID(unsigned, index, toUInt32(info[1], exceptionState)
, exceptionState); | 236 V8TRYCATCH_EXCEPTION_VOID(unsigned, index, toUInt32(info[1], exceptionState)
, exceptionState); |
| 237 RefPtr<SVGPointTearOff> result = imp->strictSVGPointMethod(item, index, exce
ptionState); | 237 RefPtr<SVGPointTearOff> result = imp->strictSVGPointMethod(item, index, exce
ptionState); |
| 238 if (exceptionState.throwIfNeeded()) | 238 if (exceptionState.throwIfNeeded()) |
| 239 return; | 239 return; |
| 240 v8SetReturnValue(info, result.release()); | 240 v8SetReturnValue(info, result.release()); |
| 241 } | 241 } |
| 242 | 242 |
| 243 static void strictSVGPointMethodMethodCallback(const v8::FunctionCallbackInfo<v8
::Value>& info) | 243 static void strictSVGPointMethodMethodCallback(const v8::FunctionCallbackInfo<v8
::Value>& info) |
| 244 { | 244 { |
| 245 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod"); | 245 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod"); |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 294 data->templateMap(currentWorldType).add(&wrapperTypeInfo, UnsafePersistent<v
8::FunctionTemplate>(isolate, templ)); | 294 data->templateMap(currentWorldType).add(&wrapperTypeInfo, UnsafePersistent<v
8::FunctionTemplate>(isolate, templ)); |
| 295 return handleScope.Escape(templ); | 295 return handleScope.Escape(templ); |
| 296 } | 296 } |
| 297 | 297 |
| 298 bool V8TestSVG::hasInstance(v8::Handle<v8::Value> jsValue, v8::Isolate* isolate) | 298 bool V8TestSVG::hasInstance(v8::Handle<v8::Value> jsValue, v8::Isolate* isolate) |
| 299 { | 299 { |
| 300 return V8PerIsolateData::from(isolate)->hasInstanceInMainWorld(&wrapperTypeI
nfo, jsValue) | 300 return V8PerIsolateData::from(isolate)->hasInstanceInMainWorld(&wrapperTypeI
nfo, jsValue) |
| 301 || V8PerIsolateData::from(isolate)->hasInstanceInNonMainWorld(&wrapperTy
peInfo, jsValue); | 301 || V8PerIsolateData::from(isolate)->hasInstanceInNonMainWorld(&wrapperTy
peInfo, jsValue); |
| 302 } | 302 } |
| 303 | 303 |
| 304 TestSVG* V8TestSVG::toNativeWithTypeCheck(v8::Isolate* isolate, v8::Handle<v8::V
alue> value) |
| 305 { |
| 306 return hasInstance(value, isolate) ? fromInternalPointer(v8::Handle<v8::Obje
ct>::Cast(value)->GetAlignedPointerFromInternalField(v8DOMWrapperObjectIndex)) :
0; |
| 307 } |
| 308 |
| 304 v8::Handle<v8::Object> V8TestSVG::createWrapper(PassRefPtr<TestSVG> impl, v8::Ha
ndle<v8::Object> creationContext, v8::Isolate* isolate) | 309 v8::Handle<v8::Object> V8TestSVG::createWrapper(PassRefPtr<TestSVG> impl, v8::Ha
ndle<v8::Object> creationContext, v8::Isolate* isolate) |
| 305 { | 310 { |
| 306 ASSERT(impl); | 311 ASSERT(impl); |
| 307 ASSERT(!DOMDataStore::containsWrapper<V8TestSVG>(impl.get(), isolate)); | 312 ASSERT(!DOMDataStore::containsWrapper<V8TestSVG>(impl.get(), isolate)); |
| 308 if (ScriptWrappable::wrapperCanBeStoredInObject(impl.get())) { | 313 if (ScriptWrappable::wrapperCanBeStoredInObject(impl.get())) { |
| 309 const WrapperTypeInfo* actualInfo = ScriptWrappable::getTypeInfoFromObje
ct(impl.get()); | 314 const WrapperTypeInfo* actualInfo = ScriptWrappable::getTypeInfoFromObje
ct(impl.get()); |
| 310 // Might be a XXXConstructor::wrapperTypeInfo instead of an XXX::wrapper
TypeInfo. These will both have | 315 // Might be a XXXConstructor::wrapperTypeInfo instead of an XXX::wrapper
TypeInfo. These will both have |
| 311 // the same object de-ref functions, though, so use that as the basis of
the check. | 316 // the same object de-ref functions, though, so use that as the basis of
the check. |
| 312 RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(actualInfo->derefObjectFunction
== wrapperTypeInfo.derefObjectFunction); | 317 RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(actualInfo->derefObjectFunction
== wrapperTypeInfo.derefObjectFunction); |
| 313 } | 318 } |
| (...skipping 12 matching lines...) Expand all Loading... |
| 326 fromInternalPointer(object)->deref(); | 331 fromInternalPointer(object)->deref(); |
| 327 } | 332 } |
| 328 | 333 |
| 329 template<> | 334 template<> |
| 330 v8::Handle<v8::Value> toV8NoInline(TestSVG* impl, v8::Handle<v8::Object> creatio
nContext, v8::Isolate* isolate) | 335 v8::Handle<v8::Value> toV8NoInline(TestSVG* impl, v8::Handle<v8::Object> creatio
nContext, v8::Isolate* isolate) |
| 331 { | 336 { |
| 332 return toV8(impl, creationContext, isolate); | 337 return toV8(impl, creationContext, isolate); |
| 333 } | 338 } |
| 334 | 339 |
| 335 } // namespace WebCore | 340 } // namespace WebCore |
| OLD | NEW |