diff --git a/shell/common/api/electron_api_v8_util.cc b/shell/common/api/electron_api_v8_util.cc index a0133ec52584..3c45f1a23542 100644 --- a/shell/common/api/electron_api_v8_util.cc +++ b/shell/common/api/electron_api_v8_util.cc @@ -38,7 +38,7 @@ struct Converter> { if (!val->IsArray()) return false; - v8::Local array(v8::Local::Cast(val)); + v8::Local array = val.As(); if (array->Length() != 2) return false; diff --git a/shell/common/gin_converters/net_converter.cc b/shell/common/gin_converters/net_converter.cc index c92c99e25816..b5f776d40642 100644 --- a/shell/common/gin_converters/net_converter.cc +++ b/shell/common/gin_converters/net_converter.cc @@ -191,7 +191,7 @@ bool Converter::FromV8( }; auto context = isolate->GetCurrentContext(); - auto headers = v8::Local::Cast(val); + auto headers = val.As(); auto keys = headers->GetOwnPropertyNames(context).ToLocalChecked(); for (uint32_t i = 0; i < keys->Length(); i++) { v8::Local keyVal; @@ -203,7 +203,7 @@ bool Converter::FromV8( auto localVal = headers->Get(context, keyVal).ToLocalChecked(); if (localVal->IsArray()) { - auto values = v8::Local::Cast(localVal); + auto values = localVal.As(); for (uint32_t j = 0; j < values->Length(); j++) { if (!addHeaderFromValue(key, values->Get(context, j).ToLocalChecked())) { diff --git a/shell/common/gin_converters/std_converter.h b/shell/common/gin_converters/std_converter.h index fef3cd26fa67..1230334e6f10 100644 --- a/shell/common/gin_converters/std_converter.h +++ b/shell/common/gin_converters/std_converter.h @@ -86,7 +86,7 @@ struct Converter> { v8::Local* out) { if (!val->IsArray()) return false; - *out = v8::Local::Cast(val); + *out = val.As(); return true; } }; @@ -102,7 +102,7 @@ struct Converter> { v8::Local* out) { if (!val->IsString()) return false; - *out = v8::Local::Cast(val); + *out = val.As(); return true; } }; @@ -128,7 +128,7 @@ struct Converter> { auto context = isolate->GetCurrentContext(); std::set result; - v8::Local array(v8::Local::Cast(val)); + v8::Local array = val.As(); uint32_t length = array->Length(); for (uint32_t i = 0; i < length; ++i) { T item; diff --git a/shell/common/gin_helper/callback.cc b/shell/common/gin_helper/callback.cc index 52761fa5efbb..a02333323b56 100644 --- a/shell/common/gin_helper/callback.cc +++ b/shell/common/gin_helper/callback.cc @@ -86,7 +86,7 @@ class RefCountedGlobal : public base::RefCountedThreadSafe, DeleteOnUIThread> { public: RefCountedGlobal(v8::Isolate* isolate, v8::Local value) - : handle_(isolate, v8::Local::Cast(value)) {} + : handle_(isolate, value.As()) {} bool IsAlive() const { return !handle_.IsEmpty(); } @@ -147,8 +147,7 @@ v8::Local BindFunctionWith(v8::Isolate* isolate, v8::MaybeLocal bind = func->Get(context, gin::StringToV8(isolate, "bind")); CHECK(!bind.IsEmpty()); - v8::Local bind_func = - v8::Local::Cast(bind.ToLocalChecked()); + v8::Local bind_func = bind.ToLocalChecked().As(); v8::Local converted[] = {func, arg1, arg2}; return bind_func->Call(context, func, base::size(converted), converted) .ToLocalChecked(); diff --git a/shell/common/gin_helper/event_emitter.cc b/shell/common/gin_helper/event_emitter.cc index 710147b54f15..737305911fc5 100644 --- a/shell/common/gin_helper/event_emitter.cc +++ b/shell/common/gin_helper/event_emitter.cc @@ -59,7 +59,7 @@ v8::Local CreateNativeEvent( if (frame && callback) { gin::Handle native_event = Event::Create(isolate); native_event->SetCallback(std::move(callback)); - event = v8::Local::Cast(native_event.ToV8()); + event = native_event.ToV8().As(); } else { // No need to create native event if we do not need to send reply. event = CreateEvent(isolate); diff --git a/shell/common/gin_helper/persistent_dictionary.h b/shell/common/gin_helper/persistent_dictionary.h index f7b049583dce..e73da7ab259f 100644 --- a/shell/common/gin_helper/persistent_dictionary.h +++ b/shell/common/gin_helper/persistent_dictionary.h @@ -53,8 +53,7 @@ struct Converter { gin_helper::PersistentDictionary* out) { if (!val->IsObject()) return false; - *out = gin_helper::PersistentDictionary(isolate, - v8::Local::Cast(val)); + *out = gin_helper::PersistentDictionary(isolate, val.As()); return true; } }; diff --git a/shell/common/gin_helper/promise.h b/shell/common/gin_helper/promise.h index 329756ad231d..0da188fe4117 100644 --- a/shell/common/gin_helper/promise.h +++ b/shell/common/gin_helper/promise.h @@ -133,7 +133,7 @@ class Promise : public PromiseBase { v8::Context::Scope context_scope(GetContext()); v8::Local value = gin::ConvertToV8(isolate(), std::move(cb)); - v8::Local handler = v8::Local::Cast(value); + v8::Local handler = value.As(); return GetHandle()->Then(GetContext(), handler); } diff --git a/shell/common/gin_helper/wrappable.cc b/shell/common/gin_helper/wrappable.cc index e5fe390e15eb..4b68957c2df6 100644 --- a/shell/common/gin_helper/wrappable.cc +++ b/shell/common/gin_helper/wrappable.cc @@ -84,7 +84,7 @@ namespace internal { void* FromV8Impl(v8::Isolate* isolate, v8::Local val) { if (!val->IsObject()) return nullptr; - v8::Local obj = v8::Local::Cast(val); + v8::Local obj = val.As(); if (obj->InternalFieldCount() != 1) return nullptr; return obj->GetAlignedPointerFromInternalField(0); diff --git a/shell/common/v8_value_converter.cc b/shell/common/v8_value_converter.cc index 9bc691f0a1f7..43a7ddc2013b 100644 --- a/shell/common/v8_value_converter.cc +++ b/shell/common/v8_value_converter.cc @@ -282,7 +282,7 @@ v8::Local V8ValueConverter::ToArrayBuffer( } v8::Local args[] = {array_buffer}; - auto func = v8::Local::Cast(from_value); + auto func = from_value.As(); auto result = func->Call(context, v8::Null(isolate), 1, args); if (!result.IsEmpty()) { return result.ToLocalChecked(); diff --git a/shell/renderer/api/context_bridge/object_cache.cc b/shell/renderer/api/context_bridge/object_cache.cc index 72ab60d24e99..cb672d29c777 100644 --- a/shell/renderer/api/context_bridge/object_cache.cc +++ b/shell/renderer/api/context_bridge/object_cache.cc @@ -20,7 +20,7 @@ ObjectCache::~ObjectCache() = default; void ObjectCache::CacheProxiedObject(v8::Local from, v8::Local proxy_value) { if (from->IsObject() && !from->IsNullOrUndefined()) { - auto obj = v8::Local::Cast(from); + auto obj = from.As(); int hash = obj->GetIdentityHash(); proxy_map_[hash].push_front(std::make_pair(from, proxy_value)); @@ -32,7 +32,7 @@ v8::MaybeLocal ObjectCache::GetCachedProxiedObject( if (!from->IsObject() || from->IsNullOrUndefined()) return v8::MaybeLocal(); - auto obj = v8::Local::Cast(from); + auto obj = from.As(); int hash = obj->GetIdentityHash(); auto iter = proxy_map_.find(hash); if (iter == proxy_map_.end()) diff --git a/shell/renderer/api/electron_api_context_bridge.cc b/shell/renderer/api/electron_api_context_bridge.cc index 82eee560b706..d6e93ffb496d 100644 --- a/shell/renderer/api/electron_api_context_bridge.cc +++ b/shell/renderer/api/electron_api_context_bridge.cc @@ -83,7 +83,7 @@ bool DeepFreeze(const v8::Local& object, object->Get(context, property_names->Get(context, i).ToLocalChecked()) .ToLocalChecked(); if (child->IsObject() && !child->IsTypedArray()) { - if (!DeepFreeze(v8::Local::Cast(child), context, frozen)) + if (!DeepFreeze(child.As(), context, frozen)) return false; } } @@ -181,7 +181,7 @@ v8::MaybeLocal PassValueToOtherContext( // Proxy functions and monitor the lifetime in the new context to release // the global handle at the right time. if (value->IsFunction()) { - auto func = v8::Local::Cast(value); + auto func = value.As(); v8::MaybeLocal maybe_original_fn = GetPrivate( source_context, func, context_bridge::kOriginalFunctionPrivateKey); @@ -224,7 +224,7 @@ v8::MaybeLocal PassValueToOtherContext( // Proxy promises as they have a safe and guaranteed memory lifecycle if (value->IsPromise()) { v8::Context::Scope destination_scope(destination_context); - auto source_promise = v8::Local::Cast(value); + auto source_promise = value.As(); // Make the promise a shared_ptr so that when the original promise is // freed the proxy promise is correctly freed as well instead of being // left dangling @@ -290,10 +290,10 @@ v8::MaybeLocal PassValueToOtherContext( ignore_result(source_promise->Then( source_context, - v8::Local::Cast( - gin::ConvertToV8(destination_context->GetIsolate(), then_cb)), - v8::Local::Cast( - gin::ConvertToV8(destination_context->GetIsolate(), catch_cb)))); + gin::ConvertToV8(destination_context->GetIsolate(), then_cb) + .As(), + gin::ConvertToV8(destination_context->GetIsolate(), catch_cb) + .As())); object_cache->CacheProxiedObject(value, proxied_promise_handle); return v8::MaybeLocal(proxied_promise_handle); @@ -325,7 +325,7 @@ v8::MaybeLocal PassValueToOtherContext( // promises are proxied correctly. if (IsPlainArray(value)) { v8::Context::Scope destination_context_scope(destination_context); - v8::Local arr = v8::Local::Cast(value); + v8::Local arr = value.As(); size_t length = arr->Length(); v8::Local cloned_arr = v8::Array::New(destination_context->GetIsolate(), length); @@ -356,7 +356,7 @@ v8::MaybeLocal PassValueToOtherContext( // Proxy all objects if (IsPlainObject(value)) { - auto object_value = v8::Local::Cast(value); + auto object_value = value.As(); auto passed_value = CreateProxyForAPI( object_value, source_context, destination_context, object_cache, support_dynamic_properties, recursion_depth + 1); @@ -408,7 +408,7 @@ void ProxyFunctionWrapper(const v8::FunctionCallbackInfo& info) { !maybe_func.ToLocal(&func_value)) return; - v8::Local func = v8::Local::Cast(func_value); + v8::Local func = func_value.As(); v8::Local func_owning_context = func->CreationContext(); { @@ -507,7 +507,7 @@ v8::MaybeLocal CreateProxyForAPI( if (support_dynamic_properties) { v8::Context::Scope source_context_scope(source_context); auto maybe_desc = api.GetHandle()->GetOwnPropertyDescriptor( - source_context, v8::Local::Cast(key)); + source_context, key.As()); v8::Local desc_value; if (!maybe_desc.ToLocal(&desc_value) || !desc_value->IsObject()) continue; @@ -600,7 +600,7 @@ void ExposeAPIInMainWorld(v8::Isolate* isolate, } if (proxy->IsObject() && !proxy->IsTypedArray() && - !DeepFreeze(v8::Local::Cast(proxy), main_context)) + !DeepFreeze(proxy.As(), main_context)) return; global.SetReadOnlyNonConfigurable(key, proxy); diff --git a/shell/renderer/api/electron_api_web_frame.cc b/shell/renderer/api/electron_api_web_frame.cc index 4353d5355be5..839a53c5de61 100644 --- a/shell/renderer/api/electron_api_web_frame.cc +++ b/shell/renderer/api/electron_api_web_frame.cc @@ -102,9 +102,8 @@ namespace api { namespace { -content::RenderFrame* GetRenderFrame(v8::Local value) { - v8::Local context = - v8::Local::Cast(value)->CreationContext(); +content::RenderFrame* GetRenderFrame(v8::Local value) { + v8::Local context = value->CreationContext(); if (context.IsEmpty()) return nullptr; blink::WebLocalFrame* frame = blink::WebLocalFrame::FrameForContext(context); @@ -559,7 +558,7 @@ class WebFrameRenderer : public gin::Wrappable, nullptr); } - static int GetWebFrameId(v8::Local content_window) { + static int GetWebFrameId(v8::Local content_window) { // Get the WebLocalFrame before (possibly) executing any user-space JS while // getting the |params|. We track the status of the RenderFrame via an // observer in case it is deleted during user code execution. diff --git a/shell/renderer/electron_sandboxed_renderer_client.cc b/shell/renderer/electron_sandboxed_renderer_client.cc index ac497e19ab14..5a3ec0750459 100644 --- a/shell/renderer/electron_sandboxed_renderer_client.cc +++ b/shell/renderer/electron_sandboxed_renderer_client.cc @@ -114,7 +114,7 @@ void InvokeHiddenCallback(v8::Handle context, .ToLocalChecked(); auto callback_value = binding->Get(context, callback_key).ToLocalChecked(); DCHECK(callback_value->IsFunction()); // set by sandboxed_renderer/init.js - auto callback = v8::Handle::Cast(callback_value); + auto callback = callback_value.As(); ignore_result(callback->Call(context, binding, 0, nullptr)); }