| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 Google Inc. All rights reserved. |
| 3 * Copyright (C) 2012 Ericsson AB. All rights reserved. | 3 * Copyright (C) 2012 Ericsson AB. All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions are | 6 * modification, are permitted provided that the following conditions are |
| 7 * met: | 7 * met: |
| 8 * | 8 * |
| 9 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 30 */ | 30 */ |
| 31 | 31 |
| 32 #ifndef V8Binding_h | 32 #ifndef V8Binding_h |
| 33 #define V8Binding_h | 33 #define V8Binding_h |
| 34 | 34 |
| 35 #include "bindings/core/v8/DOMWrapperWorld.h" | 35 #include "bindings/core/v8/DOMWrapperWorld.h" |
| 36 #include "bindings/core/v8/ExceptionMessages.h" | 36 #include "bindings/core/v8/ExceptionMessages.h" |
| 37 #include "bindings/core/v8/ExceptionState.h" |
| 37 #include "bindings/core/v8/ScriptValue.h" | 38 #include "bindings/core/v8/ScriptValue.h" |
| 38 #include "bindings/core/v8/ScriptWrappable.h" | 39 #include "bindings/core/v8/ScriptWrappable.h" |
| 39 #include "bindings/core/v8/V8BindingMacros.h" | 40 #include "bindings/core/v8/V8BindingMacros.h" |
| 40 #include "bindings/core/v8/V8PerIsolateData.h" | 41 #include "bindings/core/v8/V8PerIsolateData.h" |
| 41 #include "bindings/core/v8/V8StringResource.h" | 42 #include "bindings/core/v8/V8StringResource.h" |
| 42 #include "bindings/core/v8/V8ThrowException.h" | 43 #include "bindings/core/v8/V8ThrowException.h" |
| 43 #include "bindings/core/v8/V8ValueCache.h" | 44 #include "bindings/core/v8/V8ValueCache.h" |
| 44 #include "platform/heap/Heap.h" | 45 #include "platform/heap/Heap.h" |
| 45 #include "wtf/GetPtr.h" | 46 #include "wtf/GetPtr.h" |
| 46 #include "wtf/MathExtras.h" | 47 #include "wtf/MathExtras.h" |
| (...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 528 | 529 |
| 529 // Convert a value to a single precision float, which might fail. | 530 // Convert a value to a single precision float, which might fail. |
| 530 float toFloat(v8::Handle<v8::Value>, ExceptionState&); | 531 float toFloat(v8::Handle<v8::Value>, ExceptionState&); |
| 531 | 532 |
| 532 // Convert a value to a single precision float assuming the conversion cannot fa
il. | 533 // Convert a value to a single precision float assuming the conversion cannot fa
il. |
| 533 inline float toFloat(v8::Local<v8::Value> value) | 534 inline float toFloat(v8::Local<v8::Value> value) |
| 534 { | 535 { |
| 535 return static_cast<float>(value->NumberValue()); | 536 return static_cast<float>(value->NumberValue()); |
| 536 } | 537 } |
| 537 | 538 |
| 539 bool toBoolean(v8::Handle<v8::Value>, ExceptionState&); |
| 540 double toDouble(v8::Handle<v8::Value>, ExceptionState&); |
| 541 |
| 538 // Converts a value to a String, throwing if any code unit is outside 0-255. | 542 // Converts a value to a String, throwing if any code unit is outside 0-255. |
| 539 String toByteString(v8::Handle<v8::Value>, ExceptionState&); | 543 String toByteString(v8::Handle<v8::Value>, ExceptionState&); |
| 540 | 544 |
| 541 // Converts a value to a String, replacing unmatched UTF-16 surrogates with repl
acement characters. | 545 // Converts a value to a String, replacing unmatched UTF-16 surrogates with repl
acement characters. |
| 542 String toScalarValueString(v8::Handle<v8::Value>, ExceptionState&); | 546 String toScalarValueString(v8::Handle<v8::Value>, ExceptionState&); |
| 543 | 547 |
| 544 inline v8::Handle<v8::Boolean> v8Boolean(bool value, v8::Isolate* isolate) | 548 inline v8::Handle<v8::Boolean> v8Boolean(bool value, v8::Isolate* isolate) |
| 545 { | 549 { |
| 546 return value ? v8::True(isolate) : v8::False(isolate); | 550 return value ? v8::True(isolate) : v8::False(isolate); |
| 547 } | 551 } |
| (...skipping 13 matching lines...) Expand all Loading... |
| 561 return v8::Date::New(isolate, std::isfinite(value) ? value : std::numeric_li
mits<double>::quiet_NaN()); | 565 return v8::Date::New(isolate, std::isfinite(value) ? value : std::numeric_li
mits<double>::quiet_NaN()); |
| 562 } | 566 } |
| 563 | 567 |
| 564 // FIXME: Remove the special casing for NodeFilter and XPathNSResolver. | 568 // FIXME: Remove the special casing for NodeFilter and XPathNSResolver. |
| 565 PassRefPtrWillBeRawPtr<NodeFilter> toNodeFilter(v8::Handle<v8::Value>, v8::Handl
e<v8::Object>, ScriptState*); | 569 PassRefPtrWillBeRawPtr<NodeFilter> toNodeFilter(v8::Handle<v8::Value>, v8::Handl
e<v8::Object>, ScriptState*); |
| 566 PassRefPtrWillBeRawPtr<XPathNSResolver> toXPathNSResolver(v8::Handle<v8::Value>,
v8::Isolate*); | 570 PassRefPtrWillBeRawPtr<XPathNSResolver> toXPathNSResolver(v8::Handle<v8::Value>,
v8::Isolate*); |
| 567 | 571 |
| 568 template<class T> struct NativeValueTraits; | 572 template<class T> struct NativeValueTraits; |
| 569 | 573 |
| 570 template<> | 574 template<> |
| 575 struct NativeValueTraits<bool> { |
| 576 static inline bool nativeValueMayFail(v8::Isolate* isolate, const v8::Handle
<v8::Value>& value, ExceptionState& exceptionState) |
| 577 { |
| 578 return toBoolean(value, exceptionState); |
| 579 } |
| 580 }; |
| 581 |
| 582 template<> |
| 571 struct NativeValueTraits<String> { | 583 struct NativeValueTraits<String> { |
| 572 static inline String nativeValue(const v8::Handle<v8::Value>& value, v8::Iso
late* isolate) | 584 static inline String nativeValue(const v8::Handle<v8::Value>& value, v8::Iso
late* isolate) |
| 573 { | 585 { |
| 574 TOSTRING_DEFAULT(V8StringResource<>, stringValue, value, String()); | 586 TOSTRING_DEFAULT(V8StringResource<>, stringValue, value, String()); |
| 575 return stringValue; | 587 return stringValue; |
| 576 } | 588 } |
| 589 static inline String nativeValueMayFail(v8::Isolate* isolate, const v8::Hand
le<v8::Value>& value, ExceptionState& exceptionState) |
| 590 { |
| 591 // FIXME: handle failure |
| 592 TOSTRING_DEFAULT(V8StringResource<>, stringValue, value, String()); |
| 593 return stringValue; |
| 594 } |
| 577 }; | 595 }; |
| 578 | 596 |
| 579 template<> | 597 template<> |
| 598 struct NativeValueTraits<AtomicString> { |
| 599 static inline AtomicString nativeValueMayFail(v8::Isolate* isolate, const v8
::Handle<v8::Value>& value, ExceptionState& exceptionState) |
| 600 { |
| 601 TOSTRING_DEFAULT(V8StringResource<>, stringValue, value, AtomicString())
; |
| 602 return stringValue; |
| 603 } |
| 604 }; |
| 605 |
| 606 template<> |
| 607 struct NativeValueTraits<int> { |
| 608 static inline int nativeValue(const v8::Handle<v8::Value>& value, v8::Isolat
e* isolate) |
| 609 { |
| 610 return toInt32(value); |
| 611 } |
| 612 static inline int nativeValueMayFail(v8::Isolate* isolate, const v8::Handle<
v8::Value>& value, ExceptionState& exceptionState) |
| 613 { |
| 614 return toInt32(value, NormalConversion, exceptionState); |
| 615 } |
| 616 }; |
| 617 |
| 618 template<> |
| 580 struct NativeValueTraits<unsigned> { | 619 struct NativeValueTraits<unsigned> { |
| 581 static inline unsigned nativeValue(const v8::Handle<v8::Value>& value, v8::I
solate* isolate) | 620 static inline unsigned nativeValue(const v8::Handle<v8::Value>& value, v8::I
solate* isolate) |
| 582 { | 621 { |
| 583 return toUInt32(value); | 622 return toUInt32(value); |
| 584 } | 623 } |
| 624 static inline unsigned nativeValueMayFail(v8::Isolate* isolate, const v8::Ha
ndle<v8::Value>& value, ExceptionState& exceptionState) |
| 625 { |
| 626 return toUInt32(value, NormalConversion, exceptionState); |
| 627 } |
| 585 }; | 628 }; |
| 586 | 629 |
| 587 template<> | 630 template<> |
| 631 struct NativeValueTraits<unsigned long> { |
| 632 static inline unsigned long nativeValue(const v8::Handle<v8::Value>& value,
v8::Isolate* isolate) |
| 633 { |
| 634 return toUInt32(value); |
| 635 } |
| 636 static inline unsigned long nativeValueMayFail(v8::Isolate* isolate, const v
8::Handle<v8::Value>& value, ExceptionState& exceptionState) |
| 637 { |
| 638 return toUInt32(value, NormalConversion, exceptionState); |
| 639 } |
| 640 }; |
| 641 |
| 642 template<> |
| 643 struct NativeValueTraits<unsigned long long> { |
| 644 static inline unsigned long long nativeValue(const v8::Handle<v8::Value>& va
lue, v8::Isolate* isolate) |
| 645 { |
| 646 return toUInt64(value); |
| 647 } |
| 648 static inline unsigned long long nativeValueMayFail(v8::Isolate* isolate, co
nst v8::Handle<v8::Value>& value, ExceptionState& exceptionState) |
| 649 { |
| 650 return toUInt64(value, NormalConversion, exceptionState); |
| 651 } |
| 652 }; |
| 653 |
| 654 template<> |
| 655 struct NativeValueTraits<short> { |
| 656 static inline short nativeValue(const v8::Handle<v8::Value>& value, v8::Isol
ate* isolate) |
| 657 { |
| 658 return toInt16(value); |
| 659 } |
| 660 static inline short nativeValueMayFail(v8::Isolate* isolate, const v8::Handl
e<v8::Value>& value, ExceptionState& exceptionState) |
| 661 { |
| 662 return toInt16(value, NormalConversion, exceptionState); |
| 663 } |
| 664 }; |
| 665 |
| 666 template<> |
| 667 struct NativeValueTraits<unsigned short> { |
| 668 static inline unsigned short nativeValue(const v8::Handle<v8::Value>& value,
v8::Isolate* isolate) |
| 669 { |
| 670 return toUInt16(value); |
| 671 } |
| 672 static inline unsigned short nativeValueMayFail(v8::Isolate* isolate, const
v8::Handle<v8::Value>& value, ExceptionState& exceptionState) |
| 673 { |
| 674 return toUInt16(value, NormalConversion, exceptionState); |
| 675 } |
| 676 }; |
| 677 |
| 678 template<> |
| 588 struct NativeValueTraits<float> { | 679 struct NativeValueTraits<float> { |
| 589 static inline float nativeValue(const v8::Handle<v8::Value>& value, v8::Isol
ate* isolate) | 680 static inline float nativeValue(const v8::Handle<v8::Value>& value, v8::Isol
ate* isolate) |
| 590 { | 681 { |
| 591 return static_cast<float>(value->NumberValue()); | 682 return static_cast<float>(value->NumberValue()); |
| 592 } | 683 } |
| 684 static inline float nativeValueMayFail(v8::Isolate* isolate, const v8::Handl
e<v8::Value>& value, ExceptionState& exceptionState) |
| 685 { |
| 686 return toFloat(value, exceptionState); |
| 687 } |
| 593 }; | 688 }; |
| 594 | 689 |
| 595 template<> | 690 template<> |
| 596 struct NativeValueTraits<double> { | 691 struct NativeValueTraits<double> { |
| 597 static inline double nativeValue(const v8::Handle<v8::Value>& value, v8::Iso
late* isolate) | 692 static inline double nativeValue(const v8::Handle<v8::Value>& value, v8::Iso
late* isolate) |
| 598 { | 693 { |
| 599 return static_cast<double>(value->NumberValue()); | 694 return static_cast<double>(value->NumberValue()); |
| 600 } | 695 } |
| 696 static inline double nativeValueMayFail(v8::Isolate* isolate, const v8::Hand
le<v8::Value>& value, ExceptionState& exceptionState) |
| 697 { |
| 698 return toDouble(value, exceptionState); |
| 699 } |
| 601 }; | 700 }; |
| 602 | 701 |
| 603 template<> | 702 template<> |
| 604 struct NativeValueTraits<v8::Handle<v8::Value> > { | 703 struct NativeValueTraits<v8::Handle<v8::Value> > { |
| 605 static inline v8::Handle<v8::Value> nativeValue(const v8::Handle<v8::Value>&
value, v8::Isolate* isolate) | 704 static inline v8::Handle<v8::Value> nativeValue(const v8::Handle<v8::Value>&
value, v8::Isolate* isolate) |
| 606 { | 705 { |
| 607 return value; | 706 return value; |
| 608 } | 707 } |
| 609 }; | 708 }; |
| 610 | 709 |
| 611 template<> | 710 template<> |
| 612 struct NativeValueTraits<ScriptValue> { | 711 struct NativeValueTraits<ScriptValue> { |
| 613 static inline ScriptValue nativeValue(const v8::Handle<v8::Value>& value, v8
::Isolate* isolate) | 712 static inline ScriptValue nativeValue(const v8::Handle<v8::Value>& value, v8
::Isolate* isolate) |
| 614 { | 713 { |
| 615 return ScriptValue(ScriptState::current(isolate), value); | 714 return ScriptValue(ScriptState::current(isolate), value); |
| 616 } | 715 } |
| 716 static inline ScriptValue nativeValueMayFail(v8::Isolate* isolate, const v8:
:Handle<v8::Value>& value, ExceptionState& exceptionState) |
| 717 { |
| 718 return ScriptValue(ScriptState::current(isolate), value); |
| 719 } |
| 617 }; | 720 }; |
| 618 | 721 |
| 619 v8::Handle<v8::Value> toV8Sequence(v8::Handle<v8::Value>, uint32_t& length, v8::
Isolate*); | 722 v8::Handle<v8::Value> toV8Sequence(v8::Handle<v8::Value>, uint32_t& length, v8::
Isolate*); |
| 620 | 723 |
| 621 // Converts a JavaScript value to an array as per the Web IDL specification: | 724 // Converts a JavaScript value to an array as per the Web IDL specification: |
| 622 // http://www.w3.org/TR/2012/CR-WebIDL-20120419/#es-array | 725 // http://www.w3.org/TR/2012/CR-WebIDL-20120419/#es-array |
| 623 template <class T, class V8T> | 726 template <class T, class V8T> |
| 624 Vector<RefPtr<T> > toRefPtrNativeArrayUnchecked(v8::Local<v8::Value> v8Value, ui
nt32_t length, v8::Isolate* isolate, bool* success = 0) | 727 Vector<RefPtr<T> > toRefPtrNativeArrayUnchecked(v8::Local<v8::Value> v8Value, ui
nt32_t length, v8::Isolate* isolate, bool* success = 0) |
| 625 { | 728 { |
| 626 Vector<RefPtr<T> > result; | 729 Vector<RefPtr<T> > result; |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 669 if (value->IsArray()) { | 772 if (value->IsArray()) { |
| 670 length = v8::Local<v8::Array>::Cast(v8Value)->Length(); | 773 length = v8::Local<v8::Array>::Cast(v8Value)->Length(); |
| 671 } else if (toV8Sequence(value, length, isolate).IsEmpty()) { | 774 } else if (toV8Sequence(value, length, isolate).IsEmpty()) { |
| 672 V8ThrowException::throwTypeError(ExceptionMessages::notASequenceTypeProp
erty(propertyName), isolate); | 775 V8ThrowException::throwTypeError(ExceptionMessages::notASequenceTypeProp
erty(propertyName), isolate); |
| 673 return Vector<RefPtr<T> >(); | 776 return Vector<RefPtr<T> >(); |
| 674 } | 777 } |
| 675 return toRefPtrNativeArrayUnchecked<T, V8T>(v8Value, length, isolate, succes
s); | 778 return toRefPtrNativeArrayUnchecked<T, V8T>(v8Value, length, isolate, succes
s); |
| 676 } | 779 } |
| 677 | 780 |
| 678 template <class T, class V8T> | 781 template <class T, class V8T> |
| 679 WillBeHeapVector<RefPtrWillBeMember<T> > toRefPtrWillBeMemberNativeArray(v8::Han
dle<v8::Value> value, int argumentIndex, v8::Isolate* isolate, bool* success = 0
) | 782 WillBeHeapVector<RefPtrWillBeMember<T> > toRefPtrWillBeMemberNativeArray(v8::Han
dle<v8::Value> value, int argumentIndex, v8::Isolate* isolate, ExceptionState* e
xceptionState = 0) |
| 680 { | 783 { |
| 681 if (success) | |
| 682 *success = true; | |
| 683 | |
| 684 v8::Local<v8::Value> v8Value(v8::Local<v8::Value>::New(isolate, value)); | 784 v8::Local<v8::Value> v8Value(v8::Local<v8::Value>::New(isolate, value)); |
| 685 uint32_t length = 0; | 785 uint32_t length = 0; |
| 686 if (value->IsArray()) { | 786 if (value->IsArray()) { |
| 687 length = v8::Local<v8::Array>::Cast(v8Value)->Length(); | 787 length = v8::Local<v8::Array>::Cast(v8Value)->Length(); |
| 688 } else if (toV8Sequence(value, length, isolate).IsEmpty()) { | 788 } else if (toV8Sequence(value, length, isolate).IsEmpty()) { |
| 689 V8ThrowException::throwTypeError(ExceptionMessages::notAnArrayTypeArgume
ntOrValue(argumentIndex), isolate); | 789 if (exceptionState) |
| 790 exceptionState->throwTypeError(ExceptionMessages::notAnArrayTypeArgu
mentOrValue(argumentIndex)); |
| 791 else |
| 792 V8ThrowException::throwTypeError(ExceptionMessages::notAnArrayTypeAr
gumentOrValue(argumentIndex), isolate); |
| 690 return WillBeHeapVector<RefPtrWillBeMember<T> >(); | 793 return WillBeHeapVector<RefPtrWillBeMember<T> >(); |
| 691 } | 794 } |
| 692 | 795 |
| 693 WillBeHeapVector<RefPtrWillBeMember<T> > result; | 796 WillBeHeapVector<RefPtrWillBeMember<T> > result; |
| 694 result.reserveInitialCapacity(length); | 797 result.reserveInitialCapacity(length); |
| 695 v8::Local<v8::Object> object = v8::Local<v8::Object>::Cast(v8Value); | 798 v8::Local<v8::Object> object = v8::Local<v8::Object>::Cast(v8Value); |
| 696 for (uint32_t i = 0; i < length; ++i) { | 799 for (uint32_t i = 0; i < length; ++i) { |
| 697 v8::Handle<v8::Value> element = object->Get(i); | 800 v8::Handle<v8::Value> element = object->Get(i); |
| 698 if (V8T::hasInstance(element, isolate)) { | 801 if (V8T::hasInstance(element, isolate)) { |
| 699 v8::Handle<v8::Object> elementObject = v8::Handle<v8::Object>::Cast(
element); | 802 v8::Handle<v8::Object> elementObject = v8::Handle<v8::Object>::Cast(
element); |
| 700 result.uncheckedAppend(V8T::toImpl(elementObject)); | 803 result.uncheckedAppend(V8T::toImpl(elementObject)); |
| 701 } else { | 804 } else { |
| 702 if (success) | 805 if (exceptionState) |
| 703 *success = false; | 806 exceptionState->throwTypeError("Invalid Array element type"); |
| 704 V8ThrowException::throwTypeError("Invalid Array element type", isola
te); | 807 else |
| 808 V8ThrowException::throwTypeError("Invalid Array element type", i
solate); |
| 705 return WillBeHeapVector<RefPtrWillBeMember<T> >(); | 809 return WillBeHeapVector<RefPtrWillBeMember<T> >(); |
| 706 } | 810 } |
| 707 } | 811 } |
| 708 return result; | 812 return result; |
| 709 } | 813 } |
| 710 | 814 |
| 711 template <class T, class V8T> | 815 template <class T, class V8T> |
| 712 WillBeHeapVector<RefPtrWillBeMember<T> > toRefPtrWillBeMemberNativeArray(v8::Han
dle<v8::Value> value, const String& propertyName, v8::Isolate* isolate, bool* su
ccess = 0) | 816 WillBeHeapVector<RefPtrWillBeMember<T> > toRefPtrWillBeMemberNativeArray(v8::Han
dle<v8::Value> value, const String& propertyName, v8::Isolate* isolate, Exceptio
nState* exceptionState = 0) |
| 713 { | 817 { |
| 714 if (success) | |
| 715 *success = true; | |
| 716 | |
| 717 v8::Local<v8::Value> v8Value(v8::Local<v8::Value>::New(isolate, value)); | 818 v8::Local<v8::Value> v8Value(v8::Local<v8::Value>::New(isolate, value)); |
| 718 uint32_t length = 0; | 819 uint32_t length = 0; |
| 719 if (value->IsArray()) { | 820 if (value->IsArray()) { |
| 720 length = v8::Local<v8::Array>::Cast(v8Value)->Length(); | 821 length = v8::Local<v8::Array>::Cast(v8Value)->Length(); |
| 721 } else if (toV8Sequence(value, length, isolate).IsEmpty()) { | 822 } else if (toV8Sequence(value, length, isolate).IsEmpty()) { |
| 722 V8ThrowException::throwTypeError(ExceptionMessages::notASequenceTypeProp
erty(propertyName), isolate); | 823 if (exceptionState) |
| 824 exceptionState->throwTypeError(ExceptionMessages::notASequenceTypePr
operty(propertyName)); |
| 825 else |
| 826 V8ThrowException::throwTypeError(ExceptionMessages::notASequenceType
Property(propertyName), isolate); |
| 723 return WillBeHeapVector<RefPtrWillBeMember<T> >(); | 827 return WillBeHeapVector<RefPtrWillBeMember<T> >(); |
| 724 } | 828 } |
| 725 | 829 |
| 726 WillBeHeapVector<RefPtrWillBeMember<T> > result; | 830 WillBeHeapVector<RefPtrWillBeMember<T> > result; |
| 727 result.reserveInitialCapacity(length); | 831 result.reserveInitialCapacity(length); |
| 728 v8::Local<v8::Object> object = v8::Local<v8::Object>::Cast(v8Value); | 832 v8::Local<v8::Object> object = v8::Local<v8::Object>::Cast(v8Value); |
| 729 for (uint32_t i = 0; i < length; ++i) { | 833 for (uint32_t i = 0; i < length; ++i) { |
| 730 v8::Handle<v8::Value> element = object->Get(i); | 834 v8::Handle<v8::Value> element = object->Get(i); |
| 731 if (V8T::hasInstance(element, isolate)) { | 835 if (V8T::hasInstance(element, isolate)) { |
| 732 v8::Handle<v8::Object> elementObject = v8::Handle<v8::Object>::Cast(
element); | 836 v8::Handle<v8::Object> elementObject = v8::Handle<v8::Object>::Cast(
element); |
| 733 result.uncheckedAppend(V8T::toImpl(elementObject)); | 837 result.uncheckedAppend(V8T::toImpl(elementObject)); |
| 734 } else { | 838 } else { |
| 735 if (success) | 839 if (exceptionState) |
| 736 *success = false; | 840 exceptionState->throwTypeError("Invalid Array element type"); |
| 737 V8ThrowException::throwTypeError("Invalid Array element type", isola
te); | 841 else |
| 842 V8ThrowException::throwTypeError("Invalid Array element type", i
solate); |
| 738 return WillBeHeapVector<RefPtrWillBeMember<T> >(); | 843 return WillBeHeapVector<RefPtrWillBeMember<T> >(); |
| 739 } | 844 } |
| 740 } | 845 } |
| 741 return result; | 846 return result; |
| 742 } | 847 } |
| 743 | 848 |
| 744 template <class T, class V8T> | 849 template <class T, class V8T> |
| 745 HeapVector<Member<T> > toMemberNativeArray(v8::Handle<v8::Value> value, int argu
mentIndex, v8::Isolate* isolate, bool* success = 0) | 850 HeapVector<Member<T> > toMemberNativeArray(v8::Handle<v8::Value> value, int argu
mentIndex, v8::Isolate* isolate, bool* success = 0) |
| 746 { | 851 { |
| 747 if (success) | 852 if (success) |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 971 v8::Local<v8::Value> v8IteratorResult(v8::Isolate*, v8::Handle<v8::Value>); | 1076 v8::Local<v8::Value> v8IteratorResult(v8::Isolate*, v8::Handle<v8::Value>); |
| 972 template <typename T> | 1077 template <typename T> |
| 973 v8::Local<v8::Value> v8IteratorResult(ScriptState* scriptState, const T& value) | 1078 v8::Local<v8::Value> v8IteratorResult(ScriptState* scriptState, const T& value) |
| 974 { | 1079 { |
| 975 return v8IteratorResult(scriptState->isolate(), V8ValueTraits<T>::toV8Value(
value, scriptState->context()->Global(), scriptState->isolate())); | 1080 return v8IteratorResult(scriptState->isolate(), V8ValueTraits<T>::toV8Value(
value, scriptState->context()->Global(), scriptState->isolate())); |
| 976 } | 1081 } |
| 977 | 1082 |
| 978 } // namespace blink | 1083 } // namespace blink |
| 979 | 1084 |
| 980 #endif // V8Binding_h | 1085 #endif // V8Binding_h |
| OLD | NEW |