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( ...@@ -114,15 +114,8 @@ void V8MessageEvent::InitMessageEventMethodCustom(
MessageEvent* event = V8MessageEvent::ToImpl(info.Holder()); MessageEvent* event = V8MessageEvent::ToImpl(info.Holder());
TOSTRING_VOID(V8StringResource<>, type_arg, info[0]); TOSTRING_VOID(V8StringResource<>, type_arg, info[0]);
bool bubbles_arg = false; bool bubbles_arg = info[1]->BooleanValue(info.GetIsolate());
bool cancelable_arg = false; bool cancelable_arg = info[2]->BooleanValue(info.GetIsolate());
if (!info[1]
->BooleanValue(info.GetIsolate()->GetCurrentContext())
.To(&bubbles_arg) ||
!info[2]
->BooleanValue(info.GetIsolate()->GetCurrentContext())
.To(&cancelable_arg))
return;
v8::Local<v8::Value> data_arg = info[3]; v8::Local<v8::Value> data_arg = info[3];
TOSTRING_VOID(V8StringResource<>, origin_arg, info[4]); TOSTRING_VOID(V8StringResource<>, origin_arg, info[4]);
TOSTRING_VOID(V8StringResource<>, last_event_id_arg, info[5]); TOSTRING_VOID(V8StringResource<>, last_event_id_arg, info[5]);
......
...@@ -61,7 +61,8 @@ CORE_EXPORT bool DictionaryHelper::Get(const Dictionary& dictionary, ...@@ -61,7 +61,8 @@ CORE_EXPORT bool DictionaryHelper::Get(const Dictionary& dictionary,
if (!dictionary.Get(key, v8_value)) if (!dictionary.Get(key, v8_value))
return false; return false;
return v8_value->BooleanValue(dictionary.V8Context()).To(&value); value = v8_value->BooleanValue(dictionary.GetIsolate());
return true;
} }
template <> template <>
......
...@@ -519,12 +519,7 @@ struct NativeValueTraits<IDLSequence<T>> ...@@ -519,12 +519,7 @@ struct NativeValueTraits<IDLSequence<T>>
exception_state.RethrowV8Exception(block.Exception()); exception_state.RethrowV8Exception(block.Exception());
return; return;
} }
bool done_boolean; if (done->BooleanValue(isolate))
if (!done->BooleanValue(context).To(&done_boolean)) {
exception_state.RethrowV8Exception(block.Exception());
return;
}
if (done_boolean)
break; break;
result.emplace_back( result.emplace_back(
NativeValueTraits<T>::NativeValue(isolate, element, exception_state)); NativeValueTraits<T>::NativeValue(isolate, element, exception_state));
...@@ -619,7 +614,7 @@ struct NativeValueTraits<IDLRecord<K, V>> ...@@ -619,7 +614,7 @@ struct NativeValueTraits<IDLRecord<K, V>>
v8::Local<v8::Object>::Cast(desc) v8::Local<v8::Object>::Cast(desc)
->Get(context, V8String(isolate, "enumerable")) ->Get(context, V8String(isolate, "enumerable"))
.ToLocalChecked(); .ToLocalChecked();
if (!enumerable->BooleanValue(context).ToChecked()) if (!enumerable->BooleanValue(isolate))
continue; continue;
// "4.2.1. Let typedKey be key converted to an IDL value of type K." // "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, ...@@ -72,16 +72,14 @@ bool ScriptIterator::Next(ExecutionContext* execution_context,
} }
v8::Local<v8::Value> done; v8::Local<v8::Value> done;
v8::Local<v8::Boolean> done_boolean; if (!result_object->Get(context, done_key_).ToLocal(&done)) {
if (!result_object->Get(context, done_key_).ToLocal(&done) ||
!done->ToBoolean(context).ToLocal(&done_boolean)) {
CHECK(!try_catch.Exception().IsEmpty()); CHECK(!try_catch.Exception().IsEmpty());
exception_state.RethrowV8Exception(try_catch.Exception()); exception_state.RethrowV8Exception(try_catch.Exception());
done_ = true; done_ = true;
return false; return false;
} }
done_ = done_boolean->Value(); done_ = done->BooleanValue(isolate_);
return !done_; return !done_;
} }
......
...@@ -89,17 +89,6 @@ void V8SetReturnValue(const v8::PropertyCallbackInfo<v8::Value>& info, ...@@ -89,17 +89,6 @@ void V8SetReturnValue(const v8::PropertyCallbackInfo<v8::Value>& info,
.V8Value()); .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 kMaxInt32 = 0x7fffffff;
const int32_t kMinInt32 = -kMaxInt32 - 1; const int32_t kMinInt32 = -kMaxInt32 - 1;
const uint32_t kMaxUInt32 = 0xffffffff; const uint32_t kMaxUInt32 = 0xffffffff;
......
...@@ -191,15 +191,12 @@ enum IntegerConversionConfiguration { ...@@ -191,15 +191,12 @@ enum IntegerConversionConfiguration {
}; };
// Convert a value to a boolean. // Convert a value to a boolean.
CORE_EXPORT bool ToBooleanSlow(v8::Isolate*,
v8::Local<v8::Value>,
ExceptionState&);
inline bool ToBoolean(v8::Isolate* isolate, inline bool ToBoolean(v8::Isolate* isolate,
v8::Local<v8::Value> value, v8::Local<v8::Value> value,
ExceptionState& exception_state) { ExceptionState& exception_state) {
if (LIKELY(value->IsBoolean())) if (LIKELY(value->IsBoolean()))
return value.As<v8::Boolean>()->Value(); 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 // 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, ...@@ -31,10 +31,10 @@ v8::MaybeLocal<v8::Value> V8UnpackIteratorResult(ScriptState* script_state,
if (!result if (!result
->Get(script_state->GetContext(), ->Get(script_state->GetContext(),
V8AtomicString(script_state->GetIsolate(), "done")) V8AtomicString(script_state->GetIsolate(), "done"))
.ToLocal(&done_value) || .ToLocal(&done_value)) {
!done_value->BooleanValue(script_state->GetContext()).To(done)) {
return v8::MaybeLocal<v8::Value>(); return v8::MaybeLocal<v8::Value>();
} }
*done = done_value->BooleanValue(script_state->GetIsolate());
return maybe_value; 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