Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(51)

Side by Side Diff: Source/bindings/tests/results/V8TestSVG.cpp

Issue 125043004: Remove world type from hasInstance() (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 static void animatedReflectedAttributeAttributeGetterCallback(v8::Local<v8::Stri ng>, const v8::PropertyCallbackInfo<v8::Value>& info) 88 static void animatedReflectedAttributeAttributeGetterCallback(v8::Local<v8::Stri ng>, const v8::PropertyCallbackInfo<v8::Value>& info)
89 { 89 {
90 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter"); 90 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter");
91 TestSVGV8Internal::animatedReflectedAttributeAttributeGetter(info); 91 TestSVGV8Internal::animatedReflectedAttributeAttributeGetter(info);
92 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); 92 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
93 } 93 }
94 94
95 static void animatedReflectedAttributeAttributeSetter(v8::Local<v8::Value> jsVal ue, const v8::PropertyCallbackInfo<void>& info) 95 static void animatedReflectedAttributeAttributeSetter(v8::Local<v8::Value> jsVal ue, const v8::PropertyCallbackInfo<void>& info)
96 { 96 {
97 TestSVG* imp = V8TestSVG::toNative(info.Holder()); 97 TestSVG* imp = V8TestSVG::toNative(info.Holder());
98 V8TRYCATCH_VOID(SVGAnimatedString*, cppValue, V8SVGAnimatedString::hasInstan ce(jsValue, info.GetIsolate(), worldType(info.GetIsolate())) ? V8SVGAnimatedStri ng::toNative(v8::Handle<v8::Object>::Cast(jsValue)) : 0); 98 V8TRYCATCH_VOID(SVGAnimatedString*, cppValue, V8SVGAnimatedString::hasInstan ce(jsValue, info.GetIsolate()) ? V8SVGAnimatedString::toNative(v8::Handle<v8::Ob ject>::Cast(jsValue)) : 0);
99 CustomElementCallbackDispatcher::CallbackDeliveryScope deliveryScope; 99 CustomElementCallbackDispatcher::CallbackDeliveryScope deliveryScope;
100 imp->setAttribute(HTMLNames::animatedreflectedattributeAttr, WTF::getPtr(cpp Value)); 100 imp->setAttribute(HTMLNames::animatedreflectedattributeAttr, WTF::getPtr(cpp Value));
101 } 101 }
102 102
103 static void animatedReflectedAttributeAttributeSetterCallback(v8::Local<v8::Stri ng>, v8::Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<void>& info) 103 static void animatedReflectedAttributeAttributeSetterCallback(v8::Local<v8::Stri ng>, v8::Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<void>& info)
104 { 104 {
105 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMSetter"); 105 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMSetter");
106 CustomElementCallbackDispatcher::CallbackDeliveryScope deliveryScope; 106 CustomElementCallbackDispatcher::CallbackDeliveryScope deliveryScope;
107 TestSVGV8Internal::animatedReflectedAttributeAttributeSetter(jsValue, info); 107 TestSVGV8Internal::animatedReflectedAttributeAttributeSetter(jsValue, info);
108 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); 108 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
109 } 109 }
110 110
111 static void mutablePointAttributeGetter(const v8::PropertyCallbackInfo<v8::Value >& info) 111 static void mutablePointAttributeGetter(const v8::PropertyCallbackInfo<v8::Value >& info)
112 { 112 {
113 TestSVG* imp = V8TestSVG::toNative(info.Holder()); 113 TestSVG* imp = V8TestSVG::toNative(info.Holder());
114 v8SetReturnValueFast(info, WTF::getPtr(SVGStaticPropertyTearOff<TestSVG, SVG Point>::create(imp, imp->mutablePoint(), &TestSVG::updateMutablePoint)), imp); 114 v8SetReturnValueFast(info, WTF::getPtr(SVGStaticPropertyTearOff<TestSVG, SVG Point>::create(imp, imp->mutablePoint(), &TestSVG::updateMutablePoint)), imp);
115 } 115 }
116 116
117 static void mutablePointAttributeGetterCallback(v8::Local<v8::String>, const v8: :PropertyCallbackInfo<v8::Value>& info) 117 static void mutablePointAttributeGetterCallback(v8::Local<v8::String>, const v8: :PropertyCallbackInfo<v8::Value>& info)
118 { 118 {
119 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter"); 119 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter");
120 TestSVGV8Internal::mutablePointAttributeGetter(info); 120 TestSVGV8Internal::mutablePointAttributeGetter(info);
121 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); 121 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
122 } 122 }
123 123
124 static void mutablePointAttributeSetter(v8::Local<v8::Value> jsValue, const v8:: PropertyCallbackInfo<void>& info) 124 static void mutablePointAttributeSetter(v8::Local<v8::Value> jsValue, const v8:: PropertyCallbackInfo<void>& info)
125 { 125 {
126 ExceptionState exceptionState(ExceptionState::SetterContext, "mutablePoint", "TestSVG", info.Holder(), info.GetIsolate()); 126 ExceptionState exceptionState(ExceptionState::SetterContext, "mutablePoint", "TestSVG", info.Holder(), info.GetIsolate());
127 TestSVG* imp = V8TestSVG::toNative(info.Holder()); 127 TestSVG* imp = V8TestSVG::toNative(info.Holder());
128 V8TRYCATCH_VOID(RefPtr<SVGPropertyTearOff<SVGPoint> >, cppValue, V8SVGPoint: :hasInstance(jsValue, info.GetIsolate(), worldType(info.GetIsolate())) ? V8SVGPo int::toNative(v8::Handle<v8::Object>::Cast(jsValue)) : 0); 128 V8TRYCATCH_VOID(RefPtr<SVGPropertyTearOff<SVGPoint> >, cppValue, V8SVGPoint: :hasInstance(jsValue, info.GetIsolate()) ? V8SVGPoint::toNative(v8::Handle<v8::O bject>::Cast(jsValue)) : 0);
129 if (!WTF::getPtr(cppValue)) { 129 if (!WTF::getPtr(cppValue)) {
130 exceptionState.throwTypeError("The provided value is not of type 'SVGPoi nt'."); 130 exceptionState.throwTypeError("The provided value is not of type 'SVGPoi nt'.");
131 exceptionState.throwIfNeeded(); 131 exceptionState.throwIfNeeded();
132 return; 132 return;
133 } 133 }
134 imp->setMutablePoint(WTF::getPtr(cppValue)->propertyReference()); 134 imp->setMutablePoint(WTF::getPtr(cppValue)->propertyReference());
135 } 135 }
136 136
137 static void mutablePointAttributeSetterCallback(v8::Local<v8::String>, v8::Local <v8::Value> jsValue, const v8::PropertyCallbackInfo<void>& info) 137 static void mutablePointAttributeSetterCallback(v8::Local<v8::String>, v8::Local <v8::Value> jsValue, const v8::PropertyCallbackInfo<void>& info)
138 { 138 {
(...skipping 12 matching lines...) Expand all
151 { 151 {
152 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter"); 152 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter");
153 TestSVGV8Internal::immutablePointAttributeGetter(info); 153 TestSVGV8Internal::immutablePointAttributeGetter(info);
154 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); 154 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
155 } 155 }
156 156
157 static void immutablePointAttributeSetter(v8::Local<v8::Value> jsValue, const v8 ::PropertyCallbackInfo<void>& info) 157 static void immutablePointAttributeSetter(v8::Local<v8::Value> jsValue, const v8 ::PropertyCallbackInfo<void>& info)
158 { 158 {
159 ExceptionState exceptionState(ExceptionState::SetterContext, "immutablePoint ", "TestSVG", info.Holder(), info.GetIsolate()); 159 ExceptionState exceptionState(ExceptionState::SetterContext, "immutablePoint ", "TestSVG", info.Holder(), info.GetIsolate());
160 TestSVG* imp = V8TestSVG::toNative(info.Holder()); 160 TestSVG* imp = V8TestSVG::toNative(info.Holder());
161 V8TRYCATCH_VOID(RefPtr<SVGPropertyTearOff<SVGPoint> >, cppValue, V8SVGPoint: :hasInstance(jsValue, info.GetIsolate(), worldType(info.GetIsolate())) ? V8SVGPo int::toNative(v8::Handle<v8::Object>::Cast(jsValue)) : 0); 161 V8TRYCATCH_VOID(RefPtr<SVGPropertyTearOff<SVGPoint> >, cppValue, V8SVGPoint: :hasInstance(jsValue, info.GetIsolate()) ? V8SVGPoint::toNative(v8::Handle<v8::O bject>::Cast(jsValue)) : 0);
162 if (!WTF::getPtr(cppValue)) { 162 if (!WTF::getPtr(cppValue)) {
163 exceptionState.throwTypeError("The provided value is not of type 'SVGPoi nt'."); 163 exceptionState.throwTypeError("The provided value is not of type 'SVGPoi nt'.");
164 exceptionState.throwIfNeeded(); 164 exceptionState.throwIfNeeded();
165 return; 165 return;
166 } 166 }
167 imp->setImmutablePoint(WTF::getPtr(cppValue)->propertyReference()); 167 imp->setImmutablePoint(WTF::getPtr(cppValue)->propertyReference());
168 } 168 }
169 169
170 static void immutablePointAttributeSetterCallback(v8::Local<v8::String>, v8::Loc al<v8::Value> jsValue, const v8::PropertyCallbackInfo<void>& info) 170 static void immutablePointAttributeSetterCallback(v8::Local<v8::String>, v8::Loc al<v8::Value> jsValue, const v8::PropertyCallbackInfo<void>& info)
171 { 171 {
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 237
238 static void svgPointMethodMethod(const v8::FunctionCallbackInfo<v8::Value>& info ) 238 static void svgPointMethodMethod(const v8::FunctionCallbackInfo<v8::Value>& info )
239 { 239 {
240 ExceptionState exceptionState(ExceptionState::ExecutionContext, "svgPointMet hod", "TestSVG", info.Holder(), info.GetIsolate()); 240 ExceptionState exceptionState(ExceptionState::ExecutionContext, "svgPointMet hod", "TestSVG", info.Holder(), info.GetIsolate());
241 if (UNLIKELY(info.Length() < 2)) { 241 if (UNLIKELY(info.Length() < 2)) {
242 exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments(2, i nfo.Length())); 242 exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments(2, i nfo.Length()));
243 exceptionState.throwIfNeeded(); 243 exceptionState.throwIfNeeded();
244 return; 244 return;
245 } 245 }
246 TestSVG* imp = V8TestSVG::toNative(info.Holder()); 246 TestSVG* imp = V8TestSVG::toNative(info.Holder());
247 V8TRYCATCH_VOID(RefPtr<SVGPropertyTearOff<SVGPoint> >, item, V8SVGPoint::has Instance(info[0], info.GetIsolate(), worldType(info.GetIsolate())) ? V8SVGPoint: :toNative(v8::Handle<v8::Object>::Cast(info[0])) : 0); 247 V8TRYCATCH_VOID(RefPtr<SVGPropertyTearOff<SVGPoint> >, item, V8SVGPoint::has Instance(info[0], info.GetIsolate()) ? V8SVGPoint::toNative(v8::Handle<v8::Objec t>::Cast(info[0])) : 0);
248 V8TRYCATCH_EXCEPTION_VOID(unsigned, index, toUInt32(info[1], exceptionState) , exceptionState); 248 V8TRYCATCH_EXCEPTION_VOID(unsigned, index, toUInt32(info[1], exceptionState) , exceptionState);
249 if (!item) { 249 if (!item) {
250 exceptionState.throwTypeError("parameter 1 is not of type 'SVGPoint'."); 250 exceptionState.throwTypeError("parameter 1 is not of type 'SVGPoint'.");
251 exceptionState.throwIfNeeded(); 251 exceptionState.throwIfNeeded();
252 return; 252 return;
253 } 253 }
254 v8SetReturnValue(info, WTF::getPtr(SVGPropertyTearOff<SVGPoint>::create(imp- >svgPointMethod(item->propertyReference(), index)))); 254 v8SetReturnValue(info, WTF::getPtr(SVGPropertyTearOff<SVGPoint>::create(imp- >svgPointMethod(item->propertyReference(), index))));
255 } 255 }
256 256
257 static void svgPointMethodMethodCallback(const v8::FunctionCallbackInfo<v8::Valu e>& info) 257 static void svgPointMethodMethodCallback(const v8::FunctionCallbackInfo<v8::Valu e>& info)
258 { 258 {
259 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod"); 259 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod");
260 TestSVGV8Internal::svgPointMethodMethod(info); 260 TestSVGV8Internal::svgPointMethodMethod(info);
261 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); 261 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
262 } 262 }
263 263
264 static void strictSVGPointMethodMethod(const v8::FunctionCallbackInfo<v8::Value> & info) 264 static void strictSVGPointMethodMethod(const v8::FunctionCallbackInfo<v8::Value> & info)
265 { 265 {
266 ExceptionState exceptionState(ExceptionState::ExecutionContext, "strictSVGPo intMethod", "TestSVG", info.Holder(), info.GetIsolate()); 266 ExceptionState exceptionState(ExceptionState::ExecutionContext, "strictSVGPo intMethod", "TestSVG", info.Holder(), info.GetIsolate());
267 if (UNLIKELY(info.Length() < 2)) { 267 if (UNLIKELY(info.Length() < 2)) {
268 exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments(2, i nfo.Length())); 268 exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments(2, i nfo.Length()));
269 exceptionState.throwIfNeeded(); 269 exceptionState.throwIfNeeded();
270 return; 270 return;
271 } 271 }
272 TestSVG* imp = V8TestSVG::toNative(info.Holder()); 272 TestSVG* imp = V8TestSVG::toNative(info.Holder());
273 if (info.Length() > 0 && !info[0]->IsUndefined() && !V8SVGPoint::hasInstance (info[0], info.GetIsolate(), worldType(info.GetIsolate()))) { 273 if (info.Length() > 0 && !info[0]->IsUndefined() && !V8SVGPoint::hasInstance (info[0], info.GetIsolate())) {
274 exceptionState.throwTypeError("parameter 1 is not of type 'SVGPoint'."); 274 exceptionState.throwTypeError("parameter 1 is not of type 'SVGPoint'.");
275 exceptionState.throwIfNeeded(); 275 exceptionState.throwIfNeeded();
276 return; 276 return;
277 } 277 }
278 V8TRYCATCH_VOID(RefPtr<SVGPropertyTearOff<SVGPoint> >, item, V8SVGPoint::has Instance(info[0], info.GetIsolate(), worldType(info.GetIsolate())) ? V8SVGPoint: :toNative(v8::Handle<v8::Object>::Cast(info[0])) : 0); 278 V8TRYCATCH_VOID(RefPtr<SVGPropertyTearOff<SVGPoint> >, item, V8SVGPoint::has Instance(info[0], info.GetIsolate()) ? V8SVGPoint::toNative(v8::Handle<v8::Objec t>::Cast(info[0])) : 0);
279 V8TRYCATCH_EXCEPTION_VOID(unsigned, index, toUInt32(info[1], exceptionState) , exceptionState); 279 V8TRYCATCH_EXCEPTION_VOID(unsigned, index, toUInt32(info[1], exceptionState) , exceptionState);
280 if (!item) { 280 if (!item) {
281 exceptionState.throwTypeError("parameter 1 is not of type 'SVGPoint'."); 281 exceptionState.throwTypeError("parameter 1 is not of type 'SVGPoint'.");
282 exceptionState.throwIfNeeded(); 282 exceptionState.throwIfNeeded();
283 return; 283 return;
284 } 284 }
285 SVGPoint result = imp->strictSVGPointMethod(item->propertyReference(), index , exceptionState); 285 SVGPoint result = imp->strictSVGPointMethod(item->propertyReference(), index , exceptionState);
286 if (exceptionState.throwIfNeeded()) 286 if (exceptionState.throwIfNeeded())
287 return; 287 return;
288 v8SetReturnValue(info, WTF::getPtr(SVGPropertyTearOff<SVGPoint>::create(resu lt))); 288 v8SetReturnValue(info, WTF::getPtr(SVGPropertyTearOff<SVGPoint>::create(resu lt)));
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 return result->value.newLocal(isolate); 337 return result->value.newLocal(isolate);
338 338
339 TRACE_EVENT_SCOPED_SAMPLING_STATE("Blink", "BuildDOMTemplate"); 339 TRACE_EVENT_SCOPED_SAMPLING_STATE("Blink", "BuildDOMTemplate");
340 v8::EscapableHandleScope handleScope(isolate); 340 v8::EscapableHandleScope handleScope(isolate);
341 v8::Local<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(isolate, V 8ObjectConstructor::isValidConstructorMode); 341 v8::Local<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(isolate, V 8ObjectConstructor::isValidConstructorMode);
342 configureV8TestSVGTemplate(templ, isolate, currentWorldType); 342 configureV8TestSVGTemplate(templ, isolate, currentWorldType);
343 data->templateMap(currentWorldType).add(&wrapperTypeInfo, UnsafePersistent<v 8::FunctionTemplate>(isolate, templ)); 343 data->templateMap(currentWorldType).add(&wrapperTypeInfo, UnsafePersistent<v 8::FunctionTemplate>(isolate, templ));
344 return handleScope.Escape(templ); 344 return handleScope.Escape(templ);
345 } 345 }
346 346
347 bool V8TestSVG::hasInstance(v8::Handle<v8::Value> jsValue, v8::Isolate* isolate, WrapperWorldType currentWorldType) 347 bool V8TestSVG::hasInstance(v8::Handle<v8::Value> jsValue, v8::Isolate* isolate)
348 { 348 {
349 return V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, jsValu e, currentWorldType); 349 return V8PerIsolateData::from(isolate)->hasInstanceInMainWorld(&wrapperTypeI nfo, jsValue)
350 } 350 || V8PerIsolateData::from(isolate)->hasInstanceInNonMainWorld(&wrapperTy peInfo, jsValue);
351
352 bool V8TestSVG::hasInstanceInAnyWorld(v8::Handle<v8::Value> jsValue, v8::Isolate * isolate)
353 {
354 return V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, jsValu e, MainWorld)
355 || V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, jsValu e, IsolatedWorld)
356 || V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, jsValu e, WorkerWorld);
357 } 351 }
358 352
359 v8::Handle<v8::Object> V8TestSVG::createWrapper(PassRefPtr<TestSVG> impl, v8::Ha ndle<v8::Object> creationContext, v8::Isolate* isolate) 353 v8::Handle<v8::Object> V8TestSVG::createWrapper(PassRefPtr<TestSVG> impl, v8::Ha ndle<v8::Object> creationContext, v8::Isolate* isolate)
360 { 354 {
361 ASSERT(impl); 355 ASSERT(impl);
362 ASSERT(!DOMDataStore::containsWrapper<V8TestSVG>(impl.get(), isolate)); 356 ASSERT(!DOMDataStore::containsWrapper<V8TestSVG>(impl.get(), isolate));
363 if (ScriptWrappable::wrapperCanBeStoredInObject(impl.get())) { 357 if (ScriptWrappable::wrapperCanBeStoredInObject(impl.get())) {
364 const WrapperTypeInfo* actualInfo = ScriptWrappable::getTypeInfoFromObje ct(impl.get()); 358 const WrapperTypeInfo* actualInfo = ScriptWrappable::getTypeInfoFromObje ct(impl.get());
365 // Might be a XXXConstructor::wrapperTypeInfo instead of an XXX::wrapper TypeInfo. These will both have 359 // Might be a XXXConstructor::wrapperTypeInfo instead of an XXX::wrapper TypeInfo. These will both have
366 // the same object de-ref functions, though, so use that as the basis of the check. 360 // the same object de-ref functions, though, so use that as the basis of the check.
(...skipping 14 matching lines...) Expand all
381 fromInternalPointer(object)->deref(); 375 fromInternalPointer(object)->deref();
382 } 376 }
383 377
384 template<> 378 template<>
385 v8::Handle<v8::Value> toV8NoInline(TestSVG* impl, v8::Handle<v8::Object> creatio nContext, v8::Isolate* isolate) 379 v8::Handle<v8::Value> toV8NoInline(TestSVG* impl, v8::Handle<v8::Object> creatio nContext, v8::Isolate* isolate)
386 { 380 {
387 return toV8(impl, creationContext, isolate); 381 return toV8(impl, creationContext, isolate);
388 } 382 }
389 383
390 } // namespace WebCore 384 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/bindings/tests/results/V8TestSVG.h ('k') | Source/bindings/tests/results/V8TestTypedefs.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698