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

Unified Diff: Source/bindings/core/v8/ScriptValueSerializer.cpp

Issue 1153613007: bindings: Use CreateDataProperty() instead of ForceSet() (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fix uninitialized error Created 5 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: Source/bindings/core/v8/ScriptValueSerializer.cpp
diff --git a/Source/bindings/core/v8/ScriptValueSerializer.cpp b/Source/bindings/core/v8/ScriptValueSerializer.cpp
index 11fb2d37d51ae2af107bfe62c812cfd6931397ac..04c93047f1140907d04f4be642eae1909d9f0753 100644
--- a/Source/bindings/core/v8/ScriptValueSerializer.cpp
+++ b/Source/bindings/core/v8/ScriptValueSerializer.cpp
@@ -1825,13 +1825,11 @@ bool ScriptValueDeserializer::completeDenseArray(uint32_t numProperties, uint32_
return false;
if (length > stackDepth())
return false;
- v8::Isolate* isolate = m_reader.scriptState()->isolate();
v8::Local<v8::Context> context = m_reader.scriptState()->context();
for (unsigned i = 0, stackPos = stackDepth() - length; i < length; i++, stackPos++) {
v8::Local<v8::Value> elem = element(stackPos);
if (!elem->IsUndefined()) {
- // TODO(jsbell): Use DefineOwnProperty when exposed by v8. http://crbug.com/475206
- if (!v8CallBoolean(array->ForceSet(context, v8::Integer::New(isolate, i), elem)))
+ if (!v8CallBoolean(array->CreateDataProperty(context, i, elem)))
return false;
}
}
@@ -1897,8 +1895,14 @@ bool ScriptValueDeserializer::initializeObject(v8::Local<v8::Object> object, uin
for (unsigned i = stackDepth() - length; i < stackDepth(); i += 2) {
v8::Local<v8::Value> propertyName = element(i);
v8::Local<v8::Value> propertyValue = element(i + 1);
- // TODO(jsbell): Use DefineOwnProperty when exposed by v8. http://crbug.com/475206
- if (!v8CallBoolean(object->ForceSet(context, propertyName, propertyValue)))
+ bool result = false;
+ if (propertyName->IsString())
+ result = v8CallBoolean(object->CreateDataProperty(context, propertyName.As<v8::String>(), propertyValue));
+ else if (propertyName->IsUint32())
+ result = v8CallBoolean(object->CreateDataProperty(context, propertyName.As<v8::Uint32>()->Value(), propertyValue));
+ else
+ ASSERT_NOT_REACHED();
+ if (!result)
return false;
}
pop(length);
« no previous file with comments | « Source/bindings/core/v8/CustomElementConstructorBuilder.cpp ('k') | Source/bindings/core/v8/V8LazyEventListener.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698