From cd6e3d720f536d4accfa4f2d8479be2523634591 Mon Sep 17 00:00:00 2001 From: "trop[bot]" <37223003+trop[bot]@users.noreply.github.com> Date: Tue, 26 Nov 2024 22:18:00 -0600 Subject: [PATCH] refactor: fix modernize-return-braced-init-list warnings (#44857) * refactor: avoid repeating the return type from the declaration; use a braced initializer list instead [modernize-return-braced-init-list] Co-authored-by: Charles Kerr * refactor: avoid repeating the return type from the declaration; use a braced initializer list instead [modernize-return-braced-init-list] NB: using the braced-initializer list uncovered an error here: the float returned by std::floor() can't be implicitly cast to an int. This is solved by using base::ClampFloor() instead. std::floor() Co-authored-by: Charles Kerr --------- Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: Charles Kerr --- shell/browser/api/electron_api_app.cc | 4 ++-- shell/browser/api/electron_api_cookies.cc | 2 +- shell/browser/api/electron_api_crash_reporter.cc | 2 +- shell/browser/api/electron_api_net_log.cc | 11 +++++------ shell/browser/api/electron_api_safe_storage.cc | 6 +++--- shell/browser/api/electron_api_screen.cc | 2 +- shell/browser/api/electron_api_tray.cc | 10 +++++----- shell/browser/api/electron_api_view.cc | 2 +- shell/browser/api/electron_api_web_contents.cc | 8 ++++---- shell/browser/api/electron_api_web_frame_main.cc | 4 ++-- shell/browser/browser_linux.cc | 4 ++-- shell/browser/electron_browser_client.cc | 6 +++--- shell/browser/electron_browser_main_parts.cc | 2 +- shell/browser/electron_permission_manager.cc | 3 +-- .../electron_extensions_browser_client.cc | 6 +++--- shell/browser/javascript_environment.cc | 14 ++++++++------ shell/browser/native_window.cc | 4 ++-- shell/browser/osr/osr_render_widget_host_view.cc | 7 ++++--- shell/browser/plugins/plugin_utils.cc | 2 +- shell/browser/printing/printing_utils.cc | 2 +- shell/browser/ui/autofill_popup.cc | 7 +++---- .../ui/electron_desktop_window_tree_host_linux.cc | 4 ++-- shell/browser/ui/tray_icon.cc | 2 +- shell/browser/ui/views/client_frame_view_linux.cc | 6 +++--- shell/browser/ui/views/opaque_frame_view.cc | 2 +- shell/browser/web_contents_permission_helper.cc | 3 +-- shell/common/api/electron_api_clipboard.cc | 4 ++-- shell/common/api/electron_api_native_image.cc | 12 ++++++------ .../extensions/electron_extensions_client.cc | 4 ++-- shell/common/gin_helper/wrappable.cc | 7 +++---- shell/common/node_util.cc | 2 +- shell/renderer/api/electron_api_web_frame.cc | 4 ++-- .../printing/print_render_frame_helper_delegate.cc | 2 +- 33 files changed, 79 insertions(+), 81 deletions(-) diff --git a/shell/browser/api/electron_api_app.cc b/shell/browser/api/electron_api_app.cc index ba00dd1e4f82..64fc4a7beb15 100644 --- a/shell/browser/api/electron_api_app.cc +++ b/shell/browser/api/electron_api_app.cc @@ -775,7 +775,7 @@ base::OnceClosure App::SelectClientCertificate( std::move((*shared_identities)[0]), base::BindRepeating(&GotPrivateKey, shared_delegate, std::move(cert))); } - return base::OnceClosure(); + return {}; } void App::OnGpuInfoUpdate() { @@ -943,7 +943,7 @@ std::string App::GetSystemLocale(gin_helper::ErrorThrower thrower) const { thrower.ThrowError( "app.getSystemLocale() can only be called " "after app is ready"); - return std::string(); + return {}; } return static_cast(g_browser_process)->GetSystemLocale(); } diff --git a/shell/browser/api/electron_api_cookies.cc b/shell/browser/api/electron_api_cookies.cc index 8870355084bd..4ec26e9539a3 100644 --- a/shell/browser/api/electron_api_cookies.cc +++ b/shell/browser/api/electron_api_cookies.cc @@ -168,7 +168,7 @@ void FilterCookieWithStatuses( // Parse dictionary property to CanonicalCookie time correctly. base::Time ParseTimeProperty(const std::optional& value) { if (!value) // empty time means ignoring the parameter - return base::Time(); + return {}; if (*value == 0) // FromSecondsSinceUnixEpoch would convert 0 to empty Time return base::Time::UnixEpoch(); return base::Time::FromSecondsSinceUnixEpoch(*value); diff --git a/shell/browser/api/electron_api_crash_reporter.cc b/shell/browser/api/electron_api_crash_reporter.cc index 1b2f54cb719e..2d5457cef3f0 100644 --- a/shell/browser/api/electron_api_crash_reporter.cc +++ b/shell/browser/api/electron_api_crash_reporter.cc @@ -99,7 +99,7 @@ std::string ReadClientId() { if (GetClientIdPath(&client_id_path) && (!base::ReadFileToStringWithMaxSize(client_id_path, &client_id, 36) || client_id.size() != 36)) - return std::string(); + return {}; return client_id; } diff --git a/shell/browser/api/electron_api_net_log.cc b/shell/browser/api/electron_api_net_log.cc index 394d45b54849..f42101390d64 100644 --- a/shell/browser/api/electron_api_net_log.cc +++ b/shell/browser/api/electron_api_net_log.cc @@ -63,8 +63,7 @@ scoped_refptr CreateFileTaskRunner() { } base::File OpenFileForWriting(base::FilePath path) { - return base::File(path, - base::File::FLAG_CREATE_ALWAYS | base::File::FLAG_WRITE); + return {path, base::File::FLAG_CREATE_ALWAYS | base::File::FLAG_WRITE}; } void ResolvePromiseWithNetError(gin_helper::Promise promise, @@ -93,7 +92,7 @@ v8::Local NetLog::StartLogging(base::FilePath log_path, gin::Arguments* args) { if (log_path.empty()) { args->ThrowTypeError("The first parameter must be a valid string"); - return v8::Local(); + return {}; } net::NetLogCaptureMode capture_mode = net::NetLogCaptureMode::kDefault; @@ -106,7 +105,7 @@ v8::Local NetLog::StartLogging(base::FilePath log_path, if (!gin::ConvertFromV8(args->isolate(), capture_mode_v8, &capture_mode)) { args->ThrowTypeError("Invalid value for captureMode"); - return v8::Local(); + return {}; } } v8::Local max_file_size_v8; @@ -114,14 +113,14 @@ v8::Local NetLog::StartLogging(base::FilePath log_path, if (!gin::ConvertFromV8(args->isolate(), max_file_size_v8, &max_file_size)) { args->ThrowTypeError("Invalid value for maxFileSize"); - return v8::Local(); + return {}; } } } if (net_log_exporter_) { args->ThrowTypeError("There is already a net log running"); - return v8::Local(); + return {}; } pending_start_promise_ = diff --git a/shell/browser/api/electron_api_safe_storage.cc b/shell/browser/api/electron_api_safe_storage.cc index a8c63ec718f7..f9ecdd0734fb 100644 --- a/shell/browser/api/electron_api_safe_storage.cc +++ b/shell/browser/api/electron_api_safe_storage.cc @@ -53,13 +53,13 @@ v8::Local EncryptString(v8::Isolate* isolate, if (!electron::Browser::Get()->is_ready()) { gin_helper::ErrorThrower(isolate).ThrowError( "safeStorage cannot be used before app is ready"); - return v8::Local(); + return {}; } gin_helper::ErrorThrower(isolate).ThrowError( "Error while encrypting the text provided to " "safeStorage.encryptString. " "Encryption is not available."); - return v8::Local(); + return {}; } std::string ciphertext; @@ -69,7 +69,7 @@ v8::Local EncryptString(v8::Isolate* isolate, gin_helper::ErrorThrower(isolate).ThrowError( "Error while encrypting the text provided to " "safeStorage.encryptString."); - return v8::Local(); + return {}; } return node::Buffer::Copy(isolate, ciphertext.c_str(), ciphertext.size()) diff --git a/shell/browser/api/electron_api_screen.cc b/shell/browser/api/electron_api_screen.cc index 93a2eaa321cf..1f8fa4828f75 100644 --- a/shell/browser/api/electron_api_screen.cc +++ b/shell/browser/api/electron_api_screen.cc @@ -82,7 +82,7 @@ gfx::Point Screen::GetCursorScreenPoint(v8::Isolate* isolate) { thrower.ThrowError( "screen.getCursorScreenPoint() cannot be called before a window has " "been created."); - return gfx::Point(); + return {}; } #endif return screen_->GetCursorScreenPoint(); diff --git a/shell/browser/api/electron_api_tray.cc b/shell/browser/api/electron_api_tray.cc index 2b285ed5bea8..1d69d848858e 100644 --- a/shell/browser/api/electron_api_tray.cc +++ b/shell/browser/api/electron_api_tray.cc @@ -67,13 +67,13 @@ gin::Handle Tray::New(gin_helper::ErrorThrower thrower, gin::Arguments* args) { if (!Browser::Get()->is_ready()) { thrower.ThrowError("Cannot create Tray before app is ready"); - return gin::Handle(); + return {}; } #if BUILDFLAG(IS_WIN) if (!guid.has_value() && args->Length() > 1) { thrower.ThrowError("Invalid GUID format"); - return gin::Handle(); + return {}; } #endif @@ -85,7 +85,7 @@ gin::Handle Tray::New(gin_helper::ErrorThrower thrower, if (try_catch.HasCaught()) { delete tray; try_catch.ReThrow(); - return gin::Handle(); + return {}; } auto handle = gin::CreateHandle(args->isolate(), tray); @@ -264,7 +264,7 @@ void Tray::SetTitle(const std::string& title, std::string Tray::GetTitle() { if (!CheckAlive()) - return std::string(); + return {}; #if BUILDFLAG(IS_MAC) return tray_icon_->GetTitle(); #else @@ -388,7 +388,7 @@ void Tray::SetContextMenu(gin_helper::ErrorThrower thrower, gfx::Rect Tray::GetBounds() { if (!CheckAlive()) - return gfx::Rect(); + return {}; return tray_icon_->GetBounds(); } diff --git a/shell/browser/api/electron_api_view.cc b/shell/browser/api/electron_api_view.cc index 1f337426a055..cd9337641996 100644 --- a/shell/browser/api/electron_api_view.cc +++ b/shell/browser/api/electron_api_view.cc @@ -282,7 +282,7 @@ void View::SetBounds(const gfx::Rect& bounds) { gfx::Rect View::GetBounds() { if (!view_) - return gfx::Rect(); + return {}; return view_->bounds(); } diff --git a/shell/browser/api/electron_api_web_contents.cc b/shell/browser/api/electron_api_web_contents.cc index c9dfbe8f6010..bb2ad030161e 100644 --- a/shell/browser/api/electron_api_web_contents.cc +++ b/shell/browser/api/electron_api_web_contents.cc @@ -2628,7 +2628,7 @@ std::string WebContents::GetMediaSourceID( content::WebContents* request_web_contents) { auto* frame_host = web_contents()->GetPrimaryMainFrame(); if (!frame_host) - return std::string(); + return {}; content::DesktopMediaID media_id( content::DesktopMediaID::TYPE_WEB_CONTENTS, @@ -2638,7 +2638,7 @@ std::string WebContents::GetMediaSourceID( auto* request_frame_host = request_web_contents->GetPrimaryMainFrame(); if (!request_frame_host) - return std::string(); + return {}; std::string id = content::DesktopStreamsRegistry::GetInstance()->RegisterStream( @@ -2760,7 +2760,7 @@ bool WebContents::IsDevToolsOpened() { std::u16string WebContents::GetDevToolsTitle() { if (type_ == Type::kRemote) - return std::u16string(); + return {}; DCHECK(inspectable_web_contents_); return inspectable_web_contents_->GetDevToolsTitle(); @@ -3640,7 +3640,7 @@ gfx::Size WebContents::GetSizeForNewRenderView(content::WebContents* wc) { } } - return gfx::Size(); + return {}; } void WebContents::SetZoomLevel(double level) { diff --git a/shell/browser/api/electron_api_web_frame_main.cc b/shell/browser/api/electron_api_web_frame_main.cc index 80ec117244e9..ac9653a76239 100644 --- a/shell/browser/api/electron_api_web_frame_main.cc +++ b/shell/browser/api/electron_api_web_frame_main.cc @@ -344,7 +344,7 @@ content::FrameTreeNodeId WebFrameMain::FrameTreeNodeID() const { std::string WebFrameMain::Name() const { if (!CheckRenderFrame()) - return std::string(); + return {}; return render_frame_->GetFrameName(); } @@ -376,7 +376,7 @@ GURL WebFrameMain::URL() const { std::string WebFrameMain::Origin() const { if (!CheckRenderFrame()) - return std::string(); + return {}; return render_frame_->GetLastCommittedOrigin().Serialize(); } diff --git a/shell/browser/browser_linux.cc b/shell/browser/browser_linux.cc index b61a4a4340ab..99804abe3786 100644 --- a/shell/browser/browser_linux.cc +++ b/shell/browser/browser_linux.cc @@ -66,9 +66,9 @@ std::optional GetXdgAppOutput( &success_code); if (!ran_ok || success_code != EXIT_SUCCESS) - return std::optional(); + return {}; - return std::make_optional(reply); + return reply; } bool SetDefaultWebClient(const std::string& protocol) { diff --git a/shell/browser/electron_browser_client.cc b/shell/browser/electron_browser_client.cc index 24391f8732aa..b00ff9721c4c 100644 --- a/shell/browser/electron_browser_client.cc +++ b/shell/browser/electron_browser_client.cc @@ -595,7 +595,7 @@ ElectronBrowserClient::GetGeneratedCodeCacheSettings( // If we pass 0 for size, disk_cache will pick a default size using the // heuristics based on available disk size. These are implemented in // disk_cache::PreferredCacheSize in net/disk_cache/cache_util.cc. - return content::GeneratedCodeCacheSettings(true, 0, cache_path); + return {true, 0, cache_path}; } void ElectronBrowserClient::AllowCertificateError( @@ -628,7 +628,7 @@ base::OnceClosure ElectronBrowserClient::SelectClientCertificate( std::move(client_certs), std::move(delegate)); } - return base::OnceClosure(); + return {}; } bool ElectronBrowserClient::CanCreateWindow( @@ -983,7 +983,7 @@ base::FilePath ElectronBrowserClient::GetDefaultDownloadDirectory() { base::FilePath download_path; if (base::PathService::Get(chrome::DIR_DEFAULT_DOWNLOADS, &download_path)) return download_path; - return base::FilePath(); + return {}; } scoped_refptr diff --git a/shell/browser/electron_browser_main_parts.cc b/shell/browser/electron_browser_main_parts.cc index f8f87353b8be..4b3a61ec4b66 100644 --- a/shell/browser/electron_browser_main_parts.cc +++ b/shell/browser/electron_browser_main_parts.cc @@ -163,7 +163,7 @@ std::u16string MediaStringProvider(media::MessageId id) { return u"Communications"; #endif default: - return std::u16string(); + return {}; } } diff --git a/shell/browser/electron_permission_manager.cc b/shell/browser/electron_permission_manager.cc index 62e687cab4f6..af5b852853cf 100644 --- a/shell/browser/electron_permission_manager.cc +++ b/shell/browser/electron_permission_manager.cc @@ -278,8 +278,7 @@ ElectronPermissionManager::GetPermissionResultForOriginWithoutContext( const url::Origin& embedding_origin) { blink::mojom::PermissionStatus status = GetPermissionStatus( permission, requesting_origin.GetURL(), embedding_origin.GetURL()); - return content::PermissionResult( - status, content::PermissionStatusSource::UNSPECIFIED); + return {status, content::PermissionStatusSource::UNSPECIFIED}; } void ElectronPermissionManager::CheckBluetoothDevicePair( diff --git a/shell/browser/extensions/electron_extensions_browser_client.cc b/shell/browser/extensions/electron_extensions_browser_client.cc index fe9b7e1248e8..2fb2baaf9e2b 100644 --- a/shell/browser/extensions/electron_extensions_browser_client.cc +++ b/shell/browser/extensions/electron_extensions_browser_client.cc @@ -168,14 +168,14 @@ base::FilePath ElectronExtensionsBrowserClient::GetBundleResourcePath( *resource_id = 0; base::FilePath chrome_resources_path; if (!base::PathService::Get(chrome::DIR_RESOURCES, &chrome_resources_path)) - return base::FilePath(); + return {}; // Since component extension resources are included in // component_extension_resources.pak file in |chrome_resources_path|, // calculate the extension |request_relative_path| against // |chrome_resources_path|. if (!chrome_resources_path.IsParent(extension_resources_path)) - return base::FilePath(); + return {}; base::FilePath request_relative_path = extensions::file_util::ExtensionURLToRelativeFilePath(request.url); @@ -183,7 +183,7 @@ base::FilePath ElectronExtensionsBrowserClient::GetBundleResourcePath( ->GetComponentExtensionResourceManager() ->IsComponentExtensionResource(extension_resources_path, request_relative_path, resource_id)) { - return base::FilePath(); + return {}; } DCHECK_NE(0, *resource_id); diff --git a/shell/browser/javascript_environment.cc b/shell/browser/javascript_environment.cc index 3a1043c9dea5..f5e93fe9d249 100644 --- a/shell/browser/javascript_environment.cc +++ b/shell/browser/javascript_environment.cc @@ -41,12 +41,14 @@ gin::IsolateHolder CreateIsolateHolder(v8::Isolate* isolate) { // This is necessary for important aspects of Node.js // including heap and cpu profilers to function properly. - return gin::IsolateHolder(base::SingleThreadTaskRunner::GetCurrentDefault(), - gin::IsolateHolder::kSingleThread, - gin::IsolateHolder::IsolateType::kUtility, - std::move(create_params), - gin::IsolateHolder::IsolateCreationMode::kNormal, - nullptr, nullptr, isolate); + return {base::SingleThreadTaskRunner::GetCurrentDefault(), + gin::IsolateHolder::kSingleThread, + gin::IsolateHolder::IsolateType::kUtility, + std::move(create_params), + gin::IsolateHolder::IsolateCreationMode::kNormal, + nullptr, + nullptr, + isolate}; } } // namespace diff --git a/shell/browser/native_window.cc b/shell/browser/native_window.cc index 418783b4cfee..e0217f41b5e0 100644 --- a/shell/browser/native_window.cc +++ b/shell/browser/native_window.cc @@ -334,7 +334,7 @@ extensions::SizeConstraints NativeWindow::GetSizeConstraints() const { if (size_constraints_) return *size_constraints_; if (!content_size_constraints_) - return extensions::SizeConstraints(); + return {}; // Convert content size constraints to window size constraints. extensions::SizeConstraints constraints; if (content_size_constraints_->HasMaximumSize()) { @@ -368,7 +368,7 @@ extensions::SizeConstraints NativeWindow::GetContentSizeConstraints() const { if (content_size_constraints_) return *content_size_constraints_; if (!size_constraints_) - return extensions::SizeConstraints(); + return {}; // Convert window size constraints to content size constraints. // Note that we are not caching the results, because Chromium reccalculates // window frame size everytime when min/max sizes are passed, and we must diff --git a/shell/browser/osr/osr_render_widget_host_view.cc b/shell/browser/osr/osr_render_widget_host_view.cc index 7ac417f0dbd7..8f339bdf0d84 100644 --- a/shell/browser/osr/osr_render_widget_host_view.cc +++ b/shell/browser/osr/osr_render_widget_host_view.cc @@ -14,6 +14,7 @@ #include "base/location.h" #include "base/memory/ptr_util.h" #include "base/memory/raw_ptr.h" +#include "base/numerics/safe_conversions.h" #include "base/task/single_thread_task_runner.h" #include "base/time/time.h" #include "components/input/cursor_manager.h" @@ -115,9 +116,9 @@ ui::MouseEvent UiMouseEventFromWebMouseEvent(blink::WebMouseEvent event) { ui::MouseWheelEvent UiMouseWheelEventFromWebMouseEvent( blink::WebMouseWheelEvent event) { - return ui::MouseWheelEvent(UiMouseEventFromWebMouseEvent(event), - std::floor(event.delta_x), - std::floor(event.delta_y)); + return {UiMouseEventFromWebMouseEvent(event), + base::ClampFloor(event.delta_x), + base::ClampFloor(event.delta_y)}; } } // namespace diff --git a/shell/browser/plugins/plugin_utils.cc b/shell/browser/plugins/plugin_utils.cc index c14167337afa..68173a72e83b 100644 --- a/shell/browser/plugins/plugin_utils.cc +++ b/shell/browser/plugins/plugin_utils.cc @@ -28,7 +28,7 @@ std::string PluginUtils::GetExtensionIdForMimeType( auto it = map.find(mime_type); if (it != map.end()) return it->second; - return std::string(); + return {}; } base::flat_map diff --git a/shell/browser/printing/printing_utils.cc b/shell/browser/printing/printing_utils.cc index 52534ee31fdb..5f1d4fb549b0 100644 --- a/shell/browser/printing/printing_utils.cc +++ b/shell/browser/printing/printing_utils.cc @@ -59,7 +59,7 @@ gfx::Size GetDefaultPrinterDPI(const std::u16string& device_name) { GtkPrintSettings* print_settings = gtk_print_settings_new(); int dpi = gtk_print_settings_get_resolution(print_settings); g_object_unref(print_settings); - return gfx::Size(dpi, dpi); + return {dpi, dpi}; #endif } diff --git a/shell/browser/ui/autofill_popup.cc b/shell/browser/ui/autofill_popup.cc index d63b33459c5a..2c266f84277d 100644 --- a/shell/browser/ui/autofill_popup.cc +++ b/shell/browser/ui/autofill_popup.cc @@ -245,7 +245,7 @@ gfx::Rect AutofillPopup::popup_bounds_in_view() { gfx::Point origin(popup_bounds_.origin()); views::View::ConvertPointFromScreen(parent_, &origin); - return gfx::Rect(origin, popup_bounds_.size()); + return {origin, popup_bounds_.size()}; } void AutofillPopup::OnViewBoundsChanged(views::View* view) { @@ -280,9 +280,8 @@ int AutofillPopup::GetDesiredPopupWidth() { gfx::Rect AutofillPopup::GetRowBounds(int index) { int top = kPopupBorderThickness + index * kRowHeight; - return gfx::Rect(kPopupBorderThickness, top, - popup_bounds_.width() - 2 * kPopupBorderThickness, - kRowHeight); + return {kPopupBorderThickness, top, + popup_bounds_.width() - 2 * kPopupBorderThickness, kRowHeight}; } const gfx::FontList& AutofillPopup::GetValueFontListForRow(int index) const { diff --git a/shell/browser/ui/electron_desktop_window_tree_host_linux.cc b/shell/browser/ui/electron_desktop_window_tree_host_linux.cc index eb2999311ef0..e19d7480ddab 100644 --- a/shell/browser/ui/electron_desktop_window_tree_host_linux.cc +++ b/shell/browser/ui/electron_desktop_window_tree_host_linux.cc @@ -50,12 +50,12 @@ gfx::Insets ElectronDesktopWindowTreeHostLinux::CalculateInsetsInDIP( ui::PlatformWindowState window_state) const { // If we are not showing frame, the insets should be zero. if (native_window_view_->IsFullscreen()) { - return gfx::Insets(); + return {}; } if (!native_window_view_->has_frame() || !native_window_view_->has_client_frame()) { - return gfx::Insets(); + return {}; } auto* view = static_cast( diff --git a/shell/browser/ui/tray_icon.cc b/shell/browser/ui/tray_icon.cc index bda7208896fd..22de23fb65c5 100644 --- a/shell/browser/ui/tray_icon.cc +++ b/shell/browser/ui/tray_icon.cc @@ -13,7 +13,7 @@ TrayIcon::TrayIcon() = default; TrayIcon::~TrayIcon() = default; gfx::Rect TrayIcon::GetBounds() { - return gfx::Rect(); + return {}; } void TrayIcon::NotifyClicked(const gfx::Rect& bounds, diff --git a/shell/browser/ui/views/client_frame_view_linux.cc b/shell/browser/ui/views/client_frame_view_linux.cc index 8ade35e4258c..8482131a3dc9 100644 --- a/shell/browser/ui/views/client_frame_view_linux.cc +++ b/shell/browser/ui/views/client_frame_view_linux.cc @@ -154,8 +154,8 @@ gfx::Insets ClientFrameViewLinux::GetBorderDecorationInsets() const { } gfx::Insets ClientFrameViewLinux::GetInputInsets() const { - return gfx::Insets( - host_supports_client_frame_shadow_ ? -kResizeOutsideBorderSize : 0); + return gfx::Insets{ + host_supports_client_frame_shadow_ ? -kResizeOutsideBorderSize : 0}; } gfx::Rect ClientFrameViewLinux::GetWindowContentBounds() const { @@ -457,7 +457,7 @@ void ClientFrameViewLinux::LayoutButtonsOnSide( gfx::Rect ClientFrameViewLinux::GetTitlebarBounds() const { if (frame_->IsFullscreen()) { - return gfx::Rect(); + return {}; } int font_height = gfx::FontList().GetHeight(); diff --git a/shell/browser/ui/views/opaque_frame_view.cc b/shell/browser/ui/views/opaque_frame_view.cc index c30f37e9a06b..6aef44bdeedf 100644 --- a/shell/browser/ui/views/opaque_frame_view.cc +++ b/shell/browser/ui/views/opaque_frame_view.cc @@ -338,7 +338,7 @@ bool OpaqueFrameView::IsFrameCondensed() const { } gfx::Insets OpaqueFrameView::RestoredFrameBorderInsets() const { - return gfx::Insets(); + return {}; } gfx::Insets OpaqueFrameView::RestoredFrameEdgeInsets() const { diff --git a/shell/browser/web_contents_permission_helper.cc b/shell/browser/web_contents_permission_helper.cc index 9a369660004d..92992ebfa294 100644 --- a/shell/browser/web_contents_permission_helper.cc +++ b/shell/browser/web_contents_permission_helper.cc @@ -53,8 +53,7 @@ namespace { // If the device id wasn't specified then this is a screen capture request // (i.e. chooseDesktopMedia() API wasn't used to generate device id). - return content::DesktopMediaID(content::DesktopMediaID::TYPE_SCREEN, - -1 /* kFullDesktopScreenId */); + return {content::DesktopMediaID::TYPE_SCREEN, -1 /* kFullDesktopScreenId */}; } #if BUILDFLAG(IS_MAC) diff --git a/shell/common/api/electron_api_clipboard.cc b/shell/common/api/electron_api_clipboard.cc index 11bccb10b2d2..d5bddc60dbed 100644 --- a/shell/common/api/electron_api_clipboard.cc +++ b/shell/common/api/electron_api_clipboard.cc @@ -231,7 +231,7 @@ gfx::Image Clipboard::ReadImage(gin_helper::Arguments* args) { args->ThrowError( "clipboard.readImage is available only after app ready in the main " "process"); - return gfx::Image(); + return {}; } ui::Clipboard* clipboard = ui::Clipboard::GetForCurrentThread(); @@ -272,7 +272,7 @@ void Clipboard::WriteImage(const gfx::Image& image, #if !BUILDFLAG(IS_MAC) void Clipboard::WriteFindText(const std::u16string& text) {} std::u16string Clipboard::ReadFindText() { - return std::u16string(); + return {}; } #endif diff --git a/shell/common/api/electron_api_native_image.cc b/shell/common/api/electron_api_native_image.cc index 6b88419f90ce..da6761c5aeb8 100644 --- a/shell/common/api/electron_api_native_image.cc +++ b/shell/common/api/electron_api_native_image.cc @@ -321,7 +321,7 @@ gfx::Size NativeImage::GetSize(const std::optional scale_factor) { float sf = scale_factor.value_or(1.0f); gfx::ImageSkiaRep image_rep = image_.AsImageSkia().GetRepresentation(sf); - return gfx::Size(image_rep.GetWidth(), image_rep.GetHeight()); + return {image_rep.GetWidth(), image_rep.GetHeight()}; } std::vector NativeImage::GetScaleFactors() { @@ -487,7 +487,7 @@ gin::Handle NativeImage::CreateFromBitmap( const gin_helper::Dictionary& options) { if (!node::Buffer::HasInstance(buffer)) { thrower.ThrowError("buffer must be a node Buffer"); - return gin::Handle(); + return {}; } int width = 0; @@ -495,12 +495,12 @@ gin::Handle NativeImage::CreateFromBitmap( if (!options.Get("width", &width)) { thrower.ThrowError("width is required"); - return gin::Handle(); + return {}; } if (!options.Get("height", &height)) { thrower.ThrowError("height is required"); - return gin::Handle(); + return {}; } if (width <= 0 || height <= 0) @@ -512,7 +512,7 @@ gin::Handle NativeImage::CreateFromBitmap( const auto buffer_data = electron::util::as_byte_span(buffer); if (size_bytes != buffer_data.size()) { thrower.ThrowError("invalid buffer size"); - return gin::Handle(); + return {}; } SkBitmap bitmap; @@ -534,7 +534,7 @@ gin::Handle NativeImage::CreateFromBuffer( gin::Arguments* args) { if (!node::Buffer::HasInstance(buffer)) { thrower.ThrowError("buffer must be a node Buffer"); - return gin::Handle(); + return {}; } int width = 0; diff --git a/shell/common/extensions/electron_extensions_client.cc b/shell/common/extensions/electron_extensions_client.cc index 627e8ad54b73..97ba0580edef 100644 --- a/shell/common/extensions/electron_extensions_client.cc +++ b/shell/common/extensions/electron_extensions_client.cc @@ -56,7 +56,7 @@ class ElectronPermissionMessageProvider [[nodiscard]] extensions::PermissionIDSet GetAllPermissionIDs( const extensions::PermissionSet& permissions, extensions::Manifest::Type extension_type) const override { - return extensions::PermissionIDSet(); + return {}; } }; @@ -114,7 +114,7 @@ extensions::URLPatternSet ElectronExtensionsClient::GetPermittedChromeSchemeHosts( const extensions::Extension* extension, const extensions::APIPermissionSet& api_permissions) const { - return extensions::URLPatternSet(); + return {}; } bool ElectronExtensionsClient::IsScriptableURL(const GURL& url, diff --git a/shell/common/gin_helper/wrappable.cc b/shell/common/gin_helper/wrappable.cc index 8f4e8a87dfbe..22a3cd57f031 100644 --- a/shell/common/gin_helper/wrappable.cc +++ b/shell/common/gin_helper/wrappable.cc @@ -26,16 +26,15 @@ v8::Local WrappableBase::GetWrapper() const { if (!wrapper_.IsEmpty()) return v8::Local::New(isolate_, wrapper_); else - return v8::Local(); + return {}; } v8::MaybeLocal WrappableBase::GetWrapper( v8::Isolate* isolate) const { if (!wrapper_.IsEmpty()) - return v8::MaybeLocal( - v8::Local::New(isolate, wrapper_)); + return {v8::Local::New(isolate, wrapper_)}; else - return v8::MaybeLocal(); + return {}; } void WrappableBase::InitWithArgs(gin::Arguments* args) { diff --git a/shell/common/node_util.cc b/shell/common/node_util.cc index da5b605e4dc7..89f2316216ec 100644 --- a/shell/common/node_util.cc +++ b/shell/common/node_util.cc @@ -27,7 +27,7 @@ v8::MaybeLocal CompileAndCall( context, id, parameters, node::Realm::GetCurrent(context)); if (compiled.IsEmpty()) - return v8::MaybeLocal(); + return {}; v8::Local fn = compiled.ToLocalChecked().As(); v8::MaybeLocal ret = fn->Call( diff --git a/shell/renderer/api/electron_api_web_frame.cc b/shell/renderer/api/electron_api_web_frame.cc index 35861aa941e5..86679ea2922c 100644 --- a/shell/renderer/api/electron_api_web_frame.cc +++ b/shell/renderer/api/electron_api_web_frame.cc @@ -592,7 +592,7 @@ class WebFrameRenderer final : public gin::Wrappable, content::RenderFrame* render_frame; if (!MaybeGetRenderFrame(isolate, "insertCSS", &render_frame)) - return std::u16string(); + return {}; blink::WebFrame* web_frame = render_frame->GetWebFrame(); if (web_frame->IsWebLocalFrame()) { @@ -602,7 +602,7 @@ class WebFrameRenderer final : public gin::Wrappable, css_origin) .Utf16(); } - return std::u16string(); + return {}; } void RemoveInsertedCSS(v8::Isolate* isolate, const std::u16string& key) { diff --git a/shell/renderer/printing/print_render_frame_helper_delegate.cc b/shell/renderer/printing/print_render_frame_helper_delegate.cc index 3407a91caa56..c827f67e65a8 100644 --- a/shell/renderer/printing/print_render_frame_helper_delegate.cc +++ b/shell/renderer/printing/print_render_frame_helper_delegate.cc @@ -34,7 +34,7 @@ blink::WebElement PrintRenderFrameHelperDelegate::GetPdfElement( return plugin_element; } #endif // BUILDFLAG(ENABLE_ELECTRON_EXTENSIONS) - return blink::WebElement(); + return {}; } bool PrintRenderFrameHelperDelegate::IsPrintPreviewEnabled() {