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( ...@@ -64,13 +64,15 @@ void GetScriptableObjectProperty(
if (instance.IsEmpty()) if (instance.IsEmpty())
return; return;
v8::Local<v8::String> v8_name = V8String(info.GetIsolate(), name); v8::Local<v8::String> v8_name = V8AtomicString(info.GetIsolate(), name);
if (!V8CallBoolean(instance->HasOwnProperty(state->GetContext(), v8_name))) bool has_own_property;
return;
v8::Local<v8::Value> value; 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; return;
}
V8SetReturnValue(info, value); V8SetReturnValue(info, value);
} }
...@@ -94,9 +96,13 @@ void SetScriptableObjectProperty( ...@@ -94,9 +96,13 @@ void SetScriptableObjectProperty(
return; return;
// Don't intercept any of the properties of the HTMLPluginElement. // Don't intercept any of the properties of the HTMLPluginElement.
v8::Local<v8::String> v8_name = V8String(info.GetIsolate(), name); v8::Local<v8::String> v8_name = V8AtomicString(info.GetIsolate(), name);
if (!V8CallBoolean(instance->HasOwnProperty(state->GetContext(), v8_name)) && v8::Local<v8::Context> context = state->GetContext();
V8CallBoolean(info.Holder()->Has(state->GetContext(), v8_name))) { 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; return;
} }
...@@ -109,8 +115,10 @@ void SetScriptableObjectProperty( ...@@ -109,8 +115,10 @@ void SetScriptableObjectProperty(
// DOM element will also be set. For plugin's that don't intercept the call // 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 // (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. // that the property on the DOM element also gets set is inconsequential.
V8CallBoolean( bool created;
instance->CreateDataProperty(state->GetContext(), v8_name, value)); if (!instance->CreateDataProperty(context, v8_name, value).To(&created))
return;
V8SetReturnValue(info, value); V8SetReturnValue(info, value);
} }
......
...@@ -93,9 +93,12 @@ bool V0CustomElementConstructorBuilder::ValidateOptions( ...@@ -93,9 +93,12 @@ bool V0CustomElementConstructorBuilder::ValidateOptions(
script_state_->PerContextData()->PrototypeForType( script_state_->PerContextData()->PrototypeForType(
&V8HTMLElement::wrapperTypeInfo); &V8HTMLElement::wrapperTypeInfo);
if (!base_prototype.IsEmpty()) { if (!base_prototype.IsEmpty()) {
if (!V8CallBoolean(prototype_->SetPrototype(script_state_->GetContext(), bool set_prototype;
base_prototype))) if (!prototype_->SetPrototype(script_state_->GetContext(), base_prototype)
.To(&set_prototype) ||
!set_prototype) {
return false; return false;
}
} }
} }
...@@ -216,38 +219,63 @@ bool V0CustomElementConstructorBuilder::CreateConstructor( ...@@ -216,38 +219,63 @@ bool V0CustomElementConstructorBuilder::CreateConstructor(
: v8_type.As<v8::String>()); : v8_type.As<v8::String>());
v8::Local<v8::String> prototype_key = V8AtomicString(isolate, "prototype"); 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; return false;
}
// This sets the property *value*; calling Set is safe because // This sets the property *value*; calling Set is safe because
// "prototype" is a non-configurable data property so there can be // "prototype" is a non-configurable data property so there can be
// no side effects. // 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; return false;
}
// This *configures* the property. DefineOwnProperty of a function's // This *configures* the property. DefineOwnProperty of a function's
// "prototype" does not affect the value, but can reconfigure the // "prototype" does not affect the value, but can reconfigure the
// property. // property.
if (!V8CallBoolean(constructor_->DefineOwnProperty( bool configured_prototype;
context, prototype_key, prototype_, if (!constructor_
v8::PropertyAttribute(v8::ReadOnly | v8::DontEnum | v8::DontDelete)))) ->DefineOwnProperty(
context, prototype_key, prototype_,
v8::PropertyAttribute(v8::ReadOnly | v8::DontEnum |
v8::DontDelete))
.To(&configured_prototype) ||
!configured_prototype) {
return false; return false;
}
v8::Local<v8::String> constructor_key = v8::Local<v8::String> constructor_key =
V8AtomicString(isolate, "constructor"); V8AtomicString(isolate, "constructor");
v8::Local<v8::Value> constructor_prototype; v8::Local<v8::Value> constructor_prototype;
if (!prototype_->Get(context, constructor_key) if (!prototype_->Get(context, constructor_key)
.ToLocal(&constructor_prototype)) .ToLocal(&constructor_prototype)) {
return false; return false;
}
if (!V8CallBoolean( bool set_prototype;
constructor_->SetPrototype(context, constructor_prototype))) if (!constructor_->SetPrototype(context, constructor_prototype)
.To(&set_prototype) ||
!set_prototype) {
return false; return false;
}
V8PrivateProperty::GetCustomElementIsInterfacePrototypeObject(isolate).Set( V8PrivateProperty::GetCustomElementIsInterfacePrototypeObject(isolate).Set(
prototype_, v8::True(isolate)); prototype_, v8::True(isolate));
if (!V8CallBoolean(prototype_->DefineOwnProperty(
context, V8AtomicString(isolate, "constructor"), constructor_, bool configured_constructor;
v8::DontEnum))) if (!prototype_
->DefineOwnProperty(context, constructor_key, constructor_,
v8::DontEnum)
.To(&configured_constructor) ||
!configured_constructor) {
return false; return false;
}
return true; return true;
} }
......
...@@ -168,10 +168,12 @@ void V8V0CustomElementLifecycleCallbacks::Created(Element* element) { ...@@ -168,10 +168,12 @@ void V8V0CustomElementLifecycleCallbacks::Created(Element* element) {
// Swizzle the prototype of the wrapper. // Swizzle the prototype of the wrapper.
v8::Local<v8::Object> prototype = prototype_.NewLocal(isolate); v8::Local<v8::Object> prototype = prototype_.NewLocal(isolate);
if (prototype.IsEmpty()) bool set_prototype;
return; if (prototype.IsEmpty() ||
if (!V8CallBoolean(receiver->SetPrototype(context, prototype))) !receiver->SetPrototype(context, prototype).To(&set_prototype) ||
!set_prototype) {
return; return;
}
v8::Local<v8::Function> callback = created_.NewLocal(isolate); v8::Local<v8::Function> callback = created_.NewLocal(isolate);
if (callback.IsEmpty()) if (callback.IsEmpty())
......
...@@ -239,14 +239,19 @@ inline v8::Local<v8::Value> ToV8(const Vector<std::pair<String, T>>& value, ...@@ -239,14 +239,19 @@ inline v8::Local<v8::Value> ToV8(const Vector<std::pair<String, T>>& value,
v8::Context::Scope context_scope(creation_context->CreationContext()); v8::Context::Scope context_scope(creation_context->CreationContext());
object = v8::Object::New(isolate); object = v8::Object::New(isolate);
} }
v8::Local<v8::Context> context = isolate->GetCurrentContext();
for (unsigned i = 0; i < value.size(); ++i) { for (unsigned i = 0; i < value.size(); ++i) {
v8::Local<v8::Value> v8_value = ToV8(value[i].second, object, isolate); v8::Local<v8::Value> v8_value = ToV8(value[i].second, object, isolate);
if (v8_value.IsEmpty()) if (v8_value.IsEmpty())
v8_value = v8::Undefined(isolate); v8_value = v8::Undefined(isolate);
if (!V8CallBoolean(object->CreateDataProperty( bool created_property;
isolate->GetCurrentContext(), V8String(isolate, value[i].first), if (!object
v8_value))) ->CreateDataProperty(
context, V8AtomicString(isolate, value[i].first), v8_value)
.To(&created_property) ||
!created_property) {
return v8::Local<v8::Value>(); return v8::Local<v8::Value>();
}
} }
return object; return object;
} }
...@@ -260,14 +265,19 @@ inline v8::Local<v8::Value> ToV8(const HeapVector<std::pair<String, T>>& value, ...@@ -260,14 +265,19 @@ inline v8::Local<v8::Value> ToV8(const HeapVector<std::pair<String, T>>& value,
v8::Context::Scope context_scope(creation_context->CreationContext()); v8::Context::Scope context_scope(creation_context->CreationContext());
object = v8::Object::New(isolate); object = v8::Object::New(isolate);
} }
v8::Local<v8::Context> context = isolate->GetCurrentContext();
for (unsigned i = 0; i < value.size(); ++i) { for (unsigned i = 0; i < value.size(); ++i) {
v8::Local<v8::Value> v8_value = ToV8(value[i].second, object, isolate); v8::Local<v8::Value> v8_value = ToV8(value[i].second, object, isolate);
if (v8_value.IsEmpty()) if (v8_value.IsEmpty())
v8_value = v8::Undefined(isolate); v8_value = v8::Undefined(isolate);
if (!V8CallBoolean(object->CreateDataProperty( bool created_property;
isolate->GetCurrentContext(), V8String(isolate, value[i].first), if (!object
v8_value))) ->CreateDataProperty(
context, V8AtomicString(isolate, value[i].first), v8_value)
.To(&created_property) ||
!created_property) {
return v8::Local<v8::Value>(); return v8::Local<v8::Value>();
}
} }
return object; return object;
} }
...@@ -284,6 +294,7 @@ inline v8::Local<v8::Value> ToV8SequenceInternal( ...@@ -284,6 +294,7 @@ inline v8::Local<v8::Value> ToV8SequenceInternal(
v8::Context::Scope context_scope(creation_context->CreationContext()); v8::Context::Scope context_scope(creation_context->CreationContext());
array = v8::Array::New(isolate, sequence.size()); array = v8::Array::New(isolate, sequence.size());
} }
v8::Local<v8::Context> context = isolate->GetCurrentContext();
uint32_t index = 0; uint32_t index = 0;
typename Sequence::const_iterator end = sequence.end(); typename Sequence::const_iterator end = sequence.end();
for (typename Sequence::const_iterator iter = sequence.begin(); iter != end; for (typename Sequence::const_iterator iter = sequence.begin(); iter != end;
...@@ -291,9 +302,12 @@ inline v8::Local<v8::Value> ToV8SequenceInternal( ...@@ -291,9 +302,12 @@ inline v8::Local<v8::Value> ToV8SequenceInternal(
v8::Local<v8::Value> value = ToV8(*iter, array, isolate); v8::Local<v8::Value> value = ToV8(*iter, array, isolate);
if (value.IsEmpty()) if (value.IsEmpty())
value = v8::Undefined(isolate); value = v8::Undefined(isolate);
if (!V8CallBoolean(array->CreateDataProperty(isolate->GetCurrentContext(), bool created_property;
index++, value))) if (!array->CreateDataProperty(context, index++, value)
.To(&created_property) ||
!created_property) {
return v8::Local<v8::Value>(); return v8::Local<v8::Value>();
}
} }
return array; return array;
} }
......
...@@ -59,12 +59,6 @@ namespace blink { ...@@ -59,12 +59,6 @@ namespace blink {
? alloca(value.As<v8::ArrayBufferView>()->ByteLength()) \ ? alloca(value.As<v8::ArrayBufferView>()->ByteLength()) \
: nullptr) : nullptr)
// DEPRECATED
inline bool V8CallBoolean(v8::Maybe<bool> maybe) {
bool result;
return maybe.To(&result) && result;
}
} // namespace blink } // namespace blink
#endif // THIRD_PARTY_BLINK_RENDERER_PLATFORM_BINDINGS_V8_BINDING_MACROS_H_ #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