| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006, 2007, 2008, 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2006, 2007, 2008, 2009 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 887 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 898 } | 898 } |
| 899 return true; | 899 return true; |
| 900 } | 900 } |
| 901 | 901 |
| 902 v8::Local<v8::Function> getBoundFunction(v8::Local<v8::Function> function) | 902 v8::Local<v8::Function> getBoundFunction(v8::Local<v8::Function> function) |
| 903 { | 903 { |
| 904 v8::Local<v8::Value> boundFunction = function->GetBoundFunction(); | 904 v8::Local<v8::Value> boundFunction = function->GetBoundFunction(); |
| 905 return boundFunction->IsFunction() ? v8::Local<v8::Function>::Cast(boundFunc
tion) : function; | 905 return boundFunction->IsFunction() ? v8::Local<v8::Function>::Cast(boundFunc
tion) : function; |
| 906 } | 906 } |
| 907 | 907 |
| 908 v8::MaybeLocal<v8::Object> getEsIterator(v8::Isolate* isolate, v8::Local<v8::Obj
ect> object, ExceptionState& exceptionState) |
| 909 { |
| 910 v8::Local<v8::Context> context = isolate->GetCurrentContext(); |
| 911 v8::Local<v8::Value> iteratorGetter; |
| 912 if (!object->Get(context, v8::Symbol::GetIterator(isolate)).ToLocal(&iterato
rGetter)) |
| 913 return v8::MaybeLocal<v8::Object>(); |
| 914 if (!iteratorGetter->IsFunction()) { |
| 915 exceptionState.throwTypeError("Iterator getter is not callable."); |
| 916 return v8::MaybeLocal<v8::Object>(); |
| 917 } |
| 918 |
| 919 v8::Local<v8::Function> getterFunction = iteratorGetter.As<v8::Function>(); |
| 920 v8::Local<v8::Value> iterator; |
| 921 if (!V8ScriptRunner::callFunction(getterFunction, toExecutionContext(context
), object, 0, nullptr, isolate).ToLocal(&iterator)) |
| 922 return v8::MaybeLocal<v8::Object>(); |
| 923 if (!iterator->IsObject()) { |
| 924 exceptionState.throwTypeError("Iterator is not an object."); |
| 925 return v8::MaybeLocal<v8::Object>(); |
| 926 } |
| 927 return v8::MaybeLocal<v8::Object>(iterator.As<v8::Object>()); |
| 928 } |
| 929 |
| 908 bool addHiddenValueToArray(v8::Isolate* isolate, v8::Local<v8::Object> object, v
8::Local<v8::Value> value, int arrayIndex) | 930 bool addHiddenValueToArray(v8::Isolate* isolate, v8::Local<v8::Object> object, v
8::Local<v8::Value> value, int arrayIndex) |
| 909 { | 931 { |
| 910 ASSERT(!value.IsEmpty()); | 932 ASSERT(!value.IsEmpty()); |
| 911 v8::Local<v8::Value> arrayValue = object->GetInternalField(arrayIndex); | 933 v8::Local<v8::Value> arrayValue = object->GetInternalField(arrayIndex); |
| 912 if (arrayValue->IsNull() || arrayValue->IsUndefined()) { | 934 if (arrayValue->IsNull() || arrayValue->IsUndefined()) { |
| 913 arrayValue = v8::Array::New(isolate); | 935 arrayValue = v8::Array::New(isolate); |
| 914 object->SetInternalField(arrayIndex, arrayValue); | 936 object->SetInternalField(arrayIndex, arrayValue); |
| 915 } | 937 } |
| 916 | 938 |
| 917 v8::Local<v8::Array> array = v8::Local<v8::Array>::Cast(arrayValue); | 939 v8::Local<v8::Array> array = v8::Local<v8::Array>::Cast(arrayValue); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 963 return frame->script().isolate(); | 985 return frame->script().isolate(); |
| 964 } | 986 } |
| 965 | 987 |
| 966 v8::Local<v8::Value> freezeV8Object(v8::Local<v8::Value> value, v8::Isolate* iso
late) | 988 v8::Local<v8::Value> freezeV8Object(v8::Local<v8::Value> value, v8::Isolate* iso
late) |
| 967 { | 989 { |
| 968 value.As<v8::Object>()->SetIntegrityLevel(isolate->GetCurrentContext(), v8::
IntegrityLevel::kFrozen).ToChecked(); | 990 value.As<v8::Object>()->SetIntegrityLevel(isolate->GetCurrentContext(), v8::
IntegrityLevel::kFrozen).ToChecked(); |
| 969 return value; | 991 return value; |
| 970 } | 992 } |
| 971 | 993 |
| 972 } // namespace blink | 994 } // namespace blink |
| OLD | NEW |