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

Side by Side Diff: third_party/WebKit/Source/bindings/core/v8/V8Binding.cpp

Issue 1938943002: Use v8::Object::CreateDataProperty() for object construction (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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
OLDNEW
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 844 matching lines...) Expand 10 before | Expand all | Expand 10 after
855 bool addHiddenValueToArray(v8::Isolate* isolate, v8::Local<v8::Object> object, v 8::Local<v8::Value> value, int arrayIndex) 855 bool addHiddenValueToArray(v8::Isolate* isolate, v8::Local<v8::Object> object, v 8::Local<v8::Value> value, int arrayIndex)
856 { 856 {
857 ASSERT(!value.IsEmpty()); 857 ASSERT(!value.IsEmpty());
858 v8::Local<v8::Value> arrayValue = object->GetInternalField(arrayIndex); 858 v8::Local<v8::Value> arrayValue = object->GetInternalField(arrayIndex);
859 if (arrayValue->IsNull() || arrayValue->IsUndefined()) { 859 if (arrayValue->IsNull() || arrayValue->IsUndefined()) {
860 arrayValue = v8::Array::New(isolate); 860 arrayValue = v8::Array::New(isolate);
861 object->SetInternalField(arrayIndex, arrayValue); 861 object->SetInternalField(arrayIndex, arrayValue);
862 } 862 }
863 863
864 v8::Local<v8::Array> array = v8::Local<v8::Array>::Cast(arrayValue); 864 v8::Local<v8::Array> array = v8::Local<v8::Array>::Cast(arrayValue);
865 return v8CallBoolean(array->Set(isolate->GetCurrentContext(), v8::Integer::N ew(isolate, array->Length()), value)); 865 return v8CallBoolean(array->CreateDataProperty(isolate->GetCurrentContext(), array->Length(), value));
866 } 866 }
867 867
868 void removeHiddenValueFromArray(v8::Isolate* isolate, v8::Local<v8::Object> obje ct, v8::Local<v8::Value> value, int arrayIndex) 868 void removeHiddenValueFromArray(v8::Isolate* isolate, v8::Local<v8::Object> obje ct, v8::Local<v8::Value> value, int arrayIndex)
869 { 869 {
870 v8::Local<v8::Value> arrayValue = object->GetInternalField(arrayIndex); 870 v8::Local<v8::Value> arrayValue = object->GetInternalField(arrayIndex);
871 if (!arrayValue->IsArray()) 871 if (!arrayValue->IsArray())
872 return; 872 return;
873 v8::Local<v8::Array> array = v8::Local<v8::Array>::Cast(arrayValue); 873 v8::Local<v8::Array> array = v8::Local<v8::Array>::Cast(arrayValue);
874 for (int i = array->Length() - 1; i >= 0; --i) { 874 for (int i = array->Length() - 1; i >= 0; --i) {
875 v8::Local<v8::Value> item; 875 v8::Local<v8::Value> item;
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
920 v8SetReturnValue(info, perContextData->constructorForType(WrapperTypeInfo::u nwrap(data))); 920 v8SetReturnValue(info, perContextData->constructorForType(WrapperTypeInfo::u nwrap(data)));
921 } 921 }
922 922
923 v8::Local<v8::Value> freezeV8Object(v8::Local<v8::Value> value, v8::Isolate* iso late) 923 v8::Local<v8::Value> freezeV8Object(v8::Local<v8::Value> value, v8::Isolate* iso late)
924 { 924 {
925 v8CallOrCrash(value.As<v8::Object>()->SetIntegrityLevel(isolate->GetCurrentC ontext(), v8::IntegrityLevel::kFrozen)); 925 v8CallOrCrash(value.As<v8::Object>()->SetIntegrityLevel(isolate->GetCurrentC ontext(), v8::IntegrityLevel::kFrozen));
926 return value; 926 return value;
927 } 927 }
928 928
929 } // namespace blink 929 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698