OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 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 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 | 252 |
253 template <> | 253 template <> |
254 bool DictionaryHelper::get(const Dictionary& dictionary, const String& key, RefP
trWillBeMember<TrackBase>& value) | 254 bool DictionaryHelper::get(const Dictionary& dictionary, const String& key, RefP
trWillBeMember<TrackBase>& value) |
255 { | 255 { |
256 v8::Local<v8::Value> v8Value; | 256 v8::Local<v8::Value> v8Value; |
257 if (!dictionary.get(key, v8Value)) | 257 if (!dictionary.get(key, v8Value)) |
258 return false; | 258 return false; |
259 | 259 |
260 TrackBase* source = 0; | 260 TrackBase* source = 0; |
261 if (v8Value->IsObject()) { | 261 if (v8Value->IsObject()) { |
262 v8::Handle<v8::Object> wrapper = v8::Handle<v8::Object>::Cast(v8Value); | 262 v8::Local<v8::Object> wrapper = v8::Local<v8::Object>::Cast(v8Value); |
263 | 263 |
264 // FIXME: this will need to be changed so it can also return an AudioTra
ck or a VideoTrack once | 264 // FIXME: this will need to be changed so it can also return an AudioTra
ck or a VideoTrack once |
265 // we add them. | 265 // we add them. |
266 v8::Handle<v8::Object> track = V8TextTrack::findInstanceInPrototypeChain
(wrapper, dictionary.isolate()); | 266 v8::Local<v8::Object> track = V8TextTrack::findInstanceInPrototypeChain(
wrapper, dictionary.isolate()); |
267 if (!track.IsEmpty()) | 267 if (!track.IsEmpty()) |
268 source = V8TextTrack::toImpl(track); | 268 source = V8TextTrack::toImpl(track); |
269 } | 269 } |
270 value = source; | 270 value = source; |
271 return true; | 271 return true; |
272 } | 272 } |
273 | 273 |
274 template <> | 274 template <> |
275 bool DictionaryHelper::get(const Dictionary& dictionary, const String& key, RefP
trWillBeMember<EventTarget>& value) | 275 bool DictionaryHelper::get(const Dictionary& dictionary, const String& key, RefP
trWillBeMember<EventTarget>& value) |
276 { | 276 { |
277 v8::Local<v8::Value> v8Value; | 277 v8::Local<v8::Value> v8Value; |
278 if (!dictionary.get(key, v8Value)) | 278 if (!dictionary.get(key, v8Value)) |
279 return false; | 279 return false; |
280 | 280 |
281 value = nullptr; | 281 value = nullptr; |
282 // We need to handle a DOMWindow specially, because a DOMWindow wrapper | 282 // We need to handle a DOMWindow specially, because a DOMWindow wrapper |
283 // exists on a prototype chain of v8Value. | 283 // exists on a prototype chain of v8Value. |
284 if (v8Value->IsObject()) { | 284 if (v8Value->IsObject()) { |
285 v8::Handle<v8::Object> wrapper = v8::Handle<v8::Object>::Cast(v8Value); | 285 v8::Local<v8::Object> wrapper = v8::Local<v8::Object>::Cast(v8Value); |
286 v8::Handle<v8::Object> window = V8Window::findInstanceInPrototypeChain(w
rapper, dictionary.isolate()); | 286 v8::Local<v8::Object> window = V8Window::findInstanceInPrototypeChain(wr
apper, dictionary.isolate()); |
287 if (!window.IsEmpty()) { | 287 if (!window.IsEmpty()) { |
288 value = toWrapperTypeInfo(window)->toEventTarget(window); | 288 value = toWrapperTypeInfo(window)->toEventTarget(window); |
289 return true; | 289 return true; |
290 } | 290 } |
291 } | 291 } |
292 | 292 |
293 if (V8DOMWrapper::isWrapper(dictionary.isolate(), v8Value)) { | 293 if (V8DOMWrapper::isWrapper(dictionary.isolate(), v8Value)) { |
294 v8::Handle<v8::Object> wrapper = v8::Handle<v8::Object>::Cast(v8Value); | 294 v8::Local<v8::Object> wrapper = v8::Local<v8::Object>::Cast(v8Value); |
295 value = toWrapperTypeInfo(wrapper)->toEventTarget(wrapper); | 295 value = toWrapperTypeInfo(wrapper)->toEventTarget(wrapper); |
296 } | 296 } |
297 return true; | 297 return true; |
298 } | 298 } |
299 | 299 |
300 template <> | 300 template <> |
301 CORE_EXPORT bool DictionaryHelper::get(const Dictionary& dictionary, const Strin
g& key, Vector<String>& value) | 301 CORE_EXPORT bool DictionaryHelper::get(const Dictionary& dictionary, const Strin
g& key, Vector<String>& value) |
302 { | 302 { |
303 v8::Local<v8::Value> v8Value; | 303 v8::Local<v8::Value> v8Value; |
304 if (!dictionary.get(key, v8Value)) | 304 if (!dictionary.get(key, v8Value)) |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
400 } | 400 } |
401 | 401 |
402 template CORE_EXPORT bool DictionaryHelper::get(const Dictionary&, const String&
key, RefPtr<DOMUint8Array>& value); | 402 template CORE_EXPORT bool DictionaryHelper::get(const Dictionary&, const String&
key, RefPtr<DOMUint8Array>& value); |
403 | 403 |
404 template <typename T> | 404 template <typename T> |
405 struct IntegralTypeTraits { | 405 struct IntegralTypeTraits { |
406 }; | 406 }; |
407 | 407 |
408 template <> | 408 template <> |
409 struct IntegralTypeTraits<uint8_t> { | 409 struct IntegralTypeTraits<uint8_t> { |
410 static inline uint8_t toIntegral(v8::Isolate* isolate, v8::Handle<v8::Value>
value, IntegerConversionConfiguration configuration, ExceptionState& exceptionS
tate) | 410 static inline uint8_t toIntegral(v8::Isolate* isolate, v8::Local<v8::Value>
value, IntegerConversionConfiguration configuration, ExceptionState& exceptionSt
ate) |
411 { | 411 { |
412 return toUInt8(isolate, value, configuration, exceptionState); | 412 return toUInt8(isolate, value, configuration, exceptionState); |
413 } | 413 } |
414 static const String typeName() { return "UInt8"; } | 414 static const String typeName() { return "UInt8"; } |
415 }; | 415 }; |
416 | 416 |
417 template <> | 417 template <> |
418 struct IntegralTypeTraits<int8_t> { | 418 struct IntegralTypeTraits<int8_t> { |
419 static inline int8_t toIntegral(v8::Isolate* isolate, v8::Handle<v8::Value>
value, IntegerConversionConfiguration configuration, ExceptionState& exceptionSt
ate) | 419 static inline int8_t toIntegral(v8::Isolate* isolate, v8::Local<v8::Value> v
alue, IntegerConversionConfiguration configuration, ExceptionState& exceptionSta
te) |
420 { | 420 { |
421 return toInt8(isolate, value, configuration, exceptionState); | 421 return toInt8(isolate, value, configuration, exceptionState); |
422 } | 422 } |
423 static const String typeName() { return "Int8"; } | 423 static const String typeName() { return "Int8"; } |
424 }; | 424 }; |
425 | 425 |
426 template <> | 426 template <> |
427 struct IntegralTypeTraits<unsigned short> { | 427 struct IntegralTypeTraits<unsigned short> { |
428 static inline uint16_t toIntegral(v8::Isolate* isolate, v8::Handle<v8::Value
> value, IntegerConversionConfiguration configuration, ExceptionState& exception
State) | 428 static inline uint16_t toIntegral(v8::Isolate* isolate, v8::Local<v8::Value>
value, IntegerConversionConfiguration configuration, ExceptionState& exceptionS
tate) |
429 { | 429 { |
430 return toUInt16(isolate, value, configuration, exceptionState); | 430 return toUInt16(isolate, value, configuration, exceptionState); |
431 } | 431 } |
432 static const String typeName() { return "UInt16"; } | 432 static const String typeName() { return "UInt16"; } |
433 }; | 433 }; |
434 | 434 |
435 template <> | 435 template <> |
436 struct IntegralTypeTraits<short> { | 436 struct IntegralTypeTraits<short> { |
437 static inline int16_t toIntegral(v8::Isolate* isolate, v8::Handle<v8::Value>
value, IntegerConversionConfiguration configuration, ExceptionState& exceptionS
tate) | 437 static inline int16_t toIntegral(v8::Isolate* isolate, v8::Local<v8::Value>
value, IntegerConversionConfiguration configuration, ExceptionState& exceptionSt
ate) |
438 { | 438 { |
439 return toInt16(isolate, value, configuration, exceptionState); | 439 return toInt16(isolate, value, configuration, exceptionState); |
440 } | 440 } |
441 static const String typeName() { return "Int16"; } | 441 static const String typeName() { return "Int16"; } |
442 }; | 442 }; |
443 | 443 |
444 template <> | 444 template <> |
445 struct IntegralTypeTraits<unsigned> { | 445 struct IntegralTypeTraits<unsigned> { |
446 static inline uint32_t toIntegral(v8::Isolate* isolate, v8::Handle<v8::Value
> value, IntegerConversionConfiguration configuration, ExceptionState& exception
State) | 446 static inline uint32_t toIntegral(v8::Isolate* isolate, v8::Local<v8::Value>
value, IntegerConversionConfiguration configuration, ExceptionState& exceptionS
tate) |
447 { | 447 { |
448 return toUInt32(isolate, value, configuration, exceptionState); | 448 return toUInt32(isolate, value, configuration, exceptionState); |
449 } | 449 } |
450 static const String typeName() { return "UInt32"; } | 450 static const String typeName() { return "UInt32"; } |
451 }; | 451 }; |
452 | 452 |
453 template <> | 453 template <> |
454 struct IntegralTypeTraits<unsigned long> { | 454 struct IntegralTypeTraits<unsigned long> { |
455 static inline uint32_t toIntegral(v8::Isolate* isolate, v8::Handle<v8::Value
> value, IntegerConversionConfiguration configuration, ExceptionState& exception
State) | 455 static inline uint32_t toIntegral(v8::Isolate* isolate, v8::Local<v8::Value>
value, IntegerConversionConfiguration configuration, ExceptionState& exceptionS
tate) |
456 { | 456 { |
457 return toUInt32(isolate, value, configuration, exceptionState); | 457 return toUInt32(isolate, value, configuration, exceptionState); |
458 } | 458 } |
459 static const String typeName() { return "UInt32"; } | 459 static const String typeName() { return "UInt32"; } |
460 }; | 460 }; |
461 | 461 |
462 template <> | 462 template <> |
463 struct IntegralTypeTraits<int> { | 463 struct IntegralTypeTraits<int> { |
464 static inline int32_t toIntegral(v8::Isolate* isolate, v8::Handle<v8::Value>
value, IntegerConversionConfiguration configuration, ExceptionState& exceptionS
tate) | 464 static inline int32_t toIntegral(v8::Isolate* isolate, v8::Local<v8::Value>
value, IntegerConversionConfiguration configuration, ExceptionState& exceptionSt
ate) |
465 { | 465 { |
466 return toInt32(isolate, value, configuration, exceptionState); | 466 return toInt32(isolate, value, configuration, exceptionState); |
467 } | 467 } |
468 static const String typeName() { return "Int32"; } | 468 static const String typeName() { return "Int32"; } |
469 }; | 469 }; |
470 | 470 |
471 template <> | 471 template <> |
472 struct IntegralTypeTraits<long> { | 472 struct IntegralTypeTraits<long> { |
473 static inline int32_t toIntegral(v8::Isolate* isolate, v8::Handle<v8::Value>
value, IntegerConversionConfiguration configuration, ExceptionState& exceptionS
tate) | 473 static inline int32_t toIntegral(v8::Isolate* isolate, v8::Local<v8::Value>
value, IntegerConversionConfiguration configuration, ExceptionState& exceptionSt
ate) |
474 { | 474 { |
475 return toInt32(isolate, value, configuration, exceptionState); | 475 return toInt32(isolate, value, configuration, exceptionState); |
476 } | 476 } |
477 static const String typeName() { return "Int32"; } | 477 static const String typeName() { return "Int32"; } |
478 }; | 478 }; |
479 | 479 |
480 template <> | 480 template <> |
481 struct IntegralTypeTraits<unsigned long long> { | 481 struct IntegralTypeTraits<unsigned long long> { |
482 static inline unsigned long long toIntegral(v8::Isolate* isolate, v8::Handle
<v8::Value> value, IntegerConversionConfiguration configuration, ExceptionState&
exceptionState) | 482 static inline unsigned long long toIntegral(v8::Isolate* isolate, v8::Local<
v8::Value> value, IntegerConversionConfiguration configuration, ExceptionState&
exceptionState) |
483 { | 483 { |
484 return toUInt64(isolate, value, configuration, exceptionState); | 484 return toUInt64(isolate, value, configuration, exceptionState); |
485 } | 485 } |
486 static const String typeName() { return "UInt64"; } | 486 static const String typeName() { return "UInt64"; } |
487 }; | 487 }; |
488 | 488 |
489 template <> | 489 template <> |
490 struct IntegralTypeTraits<long long> { | 490 struct IntegralTypeTraits<long long> { |
491 static inline long long toIntegral(v8::Isolate* isolate, v8::Handle<v8::Valu
e> value, IntegerConversionConfiguration configuration, ExceptionState& exceptio
nState) | 491 static inline long long toIntegral(v8::Isolate* isolate, v8::Local<v8::Value
> value, IntegerConversionConfiguration configuration, ExceptionState& exception
State) |
492 { | 492 { |
493 return toInt64(isolate, value, configuration, exceptionState); | 493 return toInt64(isolate, value, configuration, exceptionState); |
494 } | 494 } |
495 static const String typeName() { return "Int64"; } | 495 static const String typeName() { return "Int64"; } |
496 }; | 496 }; |
497 | 497 |
498 template<typename T> | 498 template<typename T> |
499 bool DictionaryHelper::convert(const Dictionary& dictionary, Dictionary::Convers
ionContext& context, const String& key, T& value) | 499 bool DictionaryHelper::convert(const Dictionary& dictionary, Dictionary::Convers
ionContext& context, const String& key, T& value) |
500 { | 500 { |
501 Dictionary::ConversionContextScope scope(context); | 501 Dictionary::ConversionContextScope scope(context); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
541 | 541 |
542 value = toRefPtrWillBeMemberNativeArray<MessagePort, V8MessagePort>(v8Value,
key, dictionary.isolate(), context.exceptionState()); | 542 value = toRefPtrWillBeMemberNativeArray<MessagePort, V8MessagePort>(v8Value,
key, dictionary.isolate(), context.exceptionState()); |
543 | 543 |
544 if (context.exceptionState().throwIfNeeded()) | 544 if (context.exceptionState().throwIfNeeded()) |
545 return false; | 545 return false; |
546 | 546 |
547 return true; | 547 return true; |
548 } | 548 } |
549 | 549 |
550 } // namespace blink | 550 } // namespace blink |
OLD | NEW |