Commit f62c7ec1 authored by Jeremy Roman's avatar Jeremy Roman Committed by Commit Bot

Remove remaining uses of V8CallBoolean.

Bug: 670615
Change-Id: Ifd560c15fe8440d6501935753afb5f6eff6cd176
Reviewed-on: https://chromium-review.googlesource.com/c/1299735
Commit-Queue: Jeremy Roman <jbroman@chromium.org>
Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Reviewed-by: default avatarHitoshi Yoshida <peria@chromium.org>
Reviewed-by: default avatarYuki Shiino <yukishiino@chromium.org>
Cr-Commit-Position: refs/heads/master@{#603173}
parent 010d0755
......@@ -64,13 +64,15 @@ void GetScriptableObjectProperty(
if (instance.IsEmpty())
return;
v8::Local<v8::String> v8_name = V8String(info.GetIsolate(), name);
if (!V8CallBoolean(instance->HasOwnProperty(state->GetContext(), v8_name)))
return;
v8::Local<v8::String> v8_name = V8AtomicString(info.GetIsolate(), name);
bool has_own_property;
v8::Local<v8::Value> value;
if (!instance->Get(state->GetContext(), v8_name).ToLocal(&value))
if (!instance->HasOwnProperty(state->GetContext(), v8_name)
.To(&has_own_property) ||
!has_own_property ||
!instance->Get(state->GetContext(), v8_name).ToLocal(&value)) {
return;
}
V8SetReturnValue(info, value);
}
......@@ -94,9 +96,13 @@ void SetScriptableObjectProperty(
return;
// Don't intercept any of the properties of the HTMLPluginElement.
v8::Local<v8::String> v8_name = V8String(info.GetIsolate(), name);
if (!V8CallBoolean(instance->HasOwnProperty(state->GetContext(), v8_name)) &&
V8CallBoolean(info.Holder()->Has(state->GetContext(), v8_name))) {
v8::Local<v8::String> v8_name = V8AtomicString(info.GetIsolate(), name);
v8::Local<v8::Context> context = state->GetContext();
bool instance_has_property;
bool holder_has_property;
if (!instance->HasOwnProperty(context, v8_name).To(&instance_has_property) ||
!info.Holder()->Has(context, v8_name).To(&holder_has_property) ||
(!instance_has_property && holder_has_property)) {
return;
}
......@@ -109,8 +115,10 @@ void SetScriptableObjectProperty(
// DOM element will also be set. For plugin's that don't intercept the call
// (all except gTalk) this makes no difference at all. For gTalk the fact
// that the property on the DOM element also gets set is inconsequential.
V8CallBoolean(
instance->CreateDataProperty(state->GetContext(), v8_name, value));
bool created;
if (!instance->CreateDataProperty(context, v8_name, value).To(&created))
return;
V8SetReturnValue(info, value);
}
......
......@@ -93,11 +93,14 @@ bool V0CustomElementConstructorBuilder::ValidateOptions(
script_state_->PerContextData()->PrototypeForType(
&V8HTMLElement::wrapperTypeInfo);
if (!base_prototype.IsEmpty()) {
if (!V8CallBoolean(prototype_->SetPrototype(script_state_->GetContext(),
base_prototype)))
bool set_prototype;
if (!prototype_->SetPrototype(script_state_->GetContext(), base_prototype)
.To(&set_prototype) ||
!set_prototype) {
return false;
}
}
}
AtomicString namespace_uri = HTMLNames::xhtmlNamespaceURI;
if (HasValidPrototypeChainFor(&V8SVGElement::wrapperTypeInfo))
......@@ -216,38 +219,63 @@ bool V0CustomElementConstructorBuilder::CreateConstructor(
: v8_type.As<v8::String>());
v8::Local<v8::String> prototype_key = V8AtomicString(isolate, "prototype");
if (!V8CallBoolean(constructor_->HasOwnProperty(context, prototype_key)))
bool has_own_property;
if (!constructor_->HasOwnProperty(context, prototype_key)
.To(&has_own_property) ||
!has_own_property) {
return false;
}
// This sets the property *value*; calling Set is safe because
// "prototype" is a non-configurable data property so there can be
// no side effects.
if (!V8CallBoolean(constructor_->Set(context, prototype_key, prototype_)))
bool set_prototype_key;
if (!constructor_->Set(context, prototype_key, prototype_)
.To(&set_prototype_key) ||
!set_prototype_key) {
return false;
}
// This *configures* the property. DefineOwnProperty of a function's
// "prototype" does not affect the value, but can reconfigure the
// property.
if (!V8CallBoolean(constructor_->DefineOwnProperty(
bool configured_prototype;
if (!constructor_
->DefineOwnProperty(
context, prototype_key, prototype_,
v8::PropertyAttribute(v8::ReadOnly | v8::DontEnum | v8::DontDelete))))
v8::PropertyAttribute(v8::ReadOnly | v8::DontEnum |
v8::DontDelete))
.To(&configured_prototype) ||
!configured_prototype) {
return false;
}
v8::Local<v8::String> constructor_key =
V8AtomicString(isolate, "constructor");
v8::Local<v8::Value> constructor_prototype;
if (!prototype_->Get(context, constructor_key)
.ToLocal(&constructor_prototype))
.ToLocal(&constructor_prototype)) {
return false;
}
if (!V8CallBoolean(
constructor_->SetPrototype(context, constructor_prototype)))
bool set_prototype;
if (!constructor_->SetPrototype(context, constructor_prototype)
.To(&set_prototype) ||
!set_prototype) {
return false;
}
V8PrivateProperty::GetCustomElementIsInterfacePrototypeObject(isolate).Set(
prototype_, v8::True(isolate));
if (!V8CallBoolean(prototype_->DefineOwnProperty(
context, V8AtomicString(isolate, "constructor"), constructor_,
v8::DontEnum)))
bool configured_constructor;
if (!prototype_
->DefineOwnProperty(context, constructor_key, constructor_,
v8::DontEnum)
.To(&configured_constructor) ||
!configured_constructor) {
return false;
}
return true;
}
......
......@@ -168,10 +168,12 @@ void V8V0CustomElementLifecycleCallbacks::Created(Element* element) {
// Swizzle the prototype of the wrapper.
v8::Local<v8::Object> prototype = prototype_.NewLocal(isolate);
if (prototype.IsEmpty())
return;
if (!V8CallBoolean(receiver->SetPrototype(context, prototype)))
bool set_prototype;
if (prototype.IsEmpty() ||
!receiver->SetPrototype(context, prototype).To(&set_prototype) ||
!set_prototype) {
return;
}
v8::Local<v8::Function> callback = created_.NewLocal(isolate);
if (callback.IsEmpty())
......
......@@ -239,15 +239,20 @@ inline v8::Local<v8::Value> ToV8(const Vector<std::pair<String, T>>& value,
v8::Context::Scope context_scope(creation_context->CreationContext());
object = v8::Object::New(isolate);
}
v8::Local<v8::Context> context = isolate->GetCurrentContext();
for (unsigned i = 0; i < value.size(); ++i) {
v8::Local<v8::Value> v8_value = ToV8(value[i].second, object, isolate);
if (v8_value.IsEmpty())
v8_value = v8::Undefined(isolate);
if (!V8CallBoolean(object->CreateDataProperty(
isolate->GetCurrentContext(), V8String(isolate, value[i].first),
v8_value)))
bool created_property;
if (!object
->CreateDataProperty(
context, V8AtomicString(isolate, value[i].first), v8_value)
.To(&created_property) ||
!created_property) {
return v8::Local<v8::Value>();
}
}
return object;
}
......@@ -260,15 +265,20 @@ inline v8::Local<v8::Value> ToV8(const HeapVector<std::pair<String, T>>& value,
v8::Context::Scope context_scope(creation_context->CreationContext());
object = v8::Object::New(isolate);
}
v8::Local<v8::Context> context = isolate->GetCurrentContext();
for (unsigned i = 0; i < value.size(); ++i) {
v8::Local<v8::Value> v8_value = ToV8(value[i].second, object, isolate);
if (v8_value.IsEmpty())
v8_value = v8::Undefined(isolate);
if (!V8CallBoolean(object->CreateDataProperty(
isolate->GetCurrentContext(), V8String(isolate, value[i].first),
v8_value)))
bool created_property;
if (!object
->CreateDataProperty(
context, V8AtomicString(isolate, value[i].first), v8_value)
.To(&created_property) ||
!created_property) {
return v8::Local<v8::Value>();
}
}
return object;
}
......@@ -284,6 +294,7 @@ inline v8::Local<v8::Value> ToV8SequenceInternal(
v8::Context::Scope context_scope(creation_context->CreationContext());
array = v8::Array::New(isolate, sequence.size());
}
v8::Local<v8::Context> context = isolate->GetCurrentContext();
uint32_t index = 0;
typename Sequence::const_iterator end = sequence.end();
for (typename Sequence::const_iterator iter = sequence.begin(); iter != end;
......@@ -291,10 +302,13 @@ inline v8::Local<v8::Value> ToV8SequenceInternal(
v8::Local<v8::Value> value = ToV8(*iter, array, isolate);
if (value.IsEmpty())
value = v8::Undefined(isolate);
if (!V8CallBoolean(array->CreateDataProperty(isolate->GetCurrentContext(),
index++, value)))
bool created_property;
if (!array->CreateDataProperty(context, index++, value)
.To(&created_property) ||
!created_property) {
return v8::Local<v8::Value>();
}
}
return array;
}
......
......@@ -59,12 +59,6 @@ namespace blink {
? alloca(value.As<v8::ArrayBufferView>()->ByteLength()) \
: nullptr)
// DEPRECATED
inline bool V8CallBoolean(v8::Maybe<bool> maybe) {
bool result;
return maybe.To(&result) && result;
}
} // namespace blink
#endif // THIRD_PARTY_BLINK_RENDERER_PLATFORM_BINDINGS_V8_BINDING_MACROS_H_
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment