Commit 76cd3c26 authored by Dan Elphick's avatar Dan Elphick Committed by Commit Bot

[cleanup] Fix use of deprecated BooleanValue in bindings/core

Since BooleanValue cannot actually throw, the Maybe version of the
function is now deprecated.

Bug: v8:7279, v8:8238
Change-Id: Ic7fc9ff21d4cee2fe65de19cb800e76bce3d10bf
Reviewed-on: https://chromium-review.googlesource.com/c/1350916Reviewed-by: default avatarMichael Lippautz <mlippautz@chromium.org>
Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Commit-Queue: Dan Elphick <delphick@chromium.org>
Cr-Commit-Position: refs/heads/master@{#611053}
parent d2b35f5b
......@@ -114,15 +114,8 @@ void V8MessageEvent::InitMessageEventMethodCustom(
MessageEvent* event = V8MessageEvent::ToImpl(info.Holder());
TOSTRING_VOID(V8StringResource<>, type_arg, info[0]);
bool bubbles_arg = false;
bool cancelable_arg = false;
if (!info[1]
->BooleanValue(info.GetIsolate()->GetCurrentContext())
.To(&bubbles_arg) ||
!info[2]
->BooleanValue(info.GetIsolate()->GetCurrentContext())
.To(&cancelable_arg))
return;
bool bubbles_arg = info[1]->BooleanValue(info.GetIsolate());
bool cancelable_arg = info[2]->BooleanValue(info.GetIsolate());
v8::Local<v8::Value> data_arg = info[3];
TOSTRING_VOID(V8StringResource<>, origin_arg, info[4]);
TOSTRING_VOID(V8StringResource<>, last_event_id_arg, info[5]);
......
......@@ -61,7 +61,8 @@ CORE_EXPORT bool DictionaryHelper::Get(const Dictionary& dictionary,
if (!dictionary.Get(key, v8_value))
return false;
return v8_value->BooleanValue(dictionary.V8Context()).To(&value);
value = v8_value->BooleanValue(dictionary.GetIsolate());
return true;
}
template <>
......
......@@ -519,12 +519,7 @@ struct NativeValueTraits<IDLSequence<T>>
exception_state.RethrowV8Exception(block.Exception());
return;
}
bool done_boolean;
if (!done->BooleanValue(context).To(&done_boolean)) {
exception_state.RethrowV8Exception(block.Exception());
return;
}
if (done_boolean)
if (done->BooleanValue(isolate))
break;
result.emplace_back(
NativeValueTraits<T>::NativeValue(isolate, element, exception_state));
......@@ -619,7 +614,7 @@ struct NativeValueTraits<IDLRecord<K, V>>
v8::Local<v8::Object>::Cast(desc)
->Get(context, V8String(isolate, "enumerable"))
.ToLocalChecked();
if (!enumerable->BooleanValue(context).ToChecked())
if (!enumerable->BooleanValue(isolate))
continue;
// "4.2.1. Let typedKey be key converted to an IDL value of type K."
......
......@@ -72,16 +72,14 @@ bool ScriptIterator::Next(ExecutionContext* execution_context,
}
v8::Local<v8::Value> done;
v8::Local<v8::Boolean> done_boolean;
if (!result_object->Get(context, done_key_).ToLocal(&done) ||
!done->ToBoolean(context).ToLocal(&done_boolean)) {
if (!result_object->Get(context, done_key_).ToLocal(&done)) {
CHECK(!try_catch.Exception().IsEmpty());
exception_state.RethrowV8Exception(try_catch.Exception());
done_ = true;
return false;
}
done_ = done_boolean->Value();
done_ = done->BooleanValue(isolate_);
return !done_;
}
......
......@@ -89,17 +89,6 @@ void V8SetReturnValue(const v8::PropertyCallbackInfo<v8::Value>& info,
.V8Value());
}
bool ToBooleanSlow(v8::Isolate* isolate,
v8::Local<v8::Value> value,
ExceptionState& exception_state) {
DCHECK(!value->IsBoolean());
v8::TryCatch block(isolate);
bool result = false;
if (!value->BooleanValue(isolate->GetCurrentContext()).To(&result))
exception_state.RethrowV8Exception(block.Exception());
return result;
}
const int32_t kMaxInt32 = 0x7fffffff;
const int32_t kMinInt32 = -kMaxInt32 - 1;
const uint32_t kMaxUInt32 = 0xffffffff;
......
......@@ -191,15 +191,12 @@ enum IntegerConversionConfiguration {
};
// Convert a value to a boolean.
CORE_EXPORT bool ToBooleanSlow(v8::Isolate*,
v8::Local<v8::Value>,
ExceptionState&);
inline bool ToBoolean(v8::Isolate* isolate,
v8::Local<v8::Value> value,
ExceptionState& exception_state) {
if (LIKELY(value->IsBoolean()))
return value.As<v8::Boolean>()->Value();
return ToBooleanSlow(isolate, value, exception_state);
return value->BooleanValue(isolate);
}
// Convert a value to a 8-bit signed integer. The conversion fails if the
......
......@@ -31,10 +31,10 @@ v8::MaybeLocal<v8::Value> V8UnpackIteratorResult(ScriptState* script_state,
if (!result
->Get(script_state->GetContext(),
V8AtomicString(script_state->GetIsolate(), "done"))
.ToLocal(&done_value) ||
!done_value->BooleanValue(script_state->GetContext()).To(done)) {
.ToLocal(&done_value)) {
return v8::MaybeLocal<v8::Value>();
}
*done = done_value->BooleanValue(script_state->GetIsolate());
return maybe_value;
}
......
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