chore: use auto to avoid repeating type (#26113)

This commit is contained in:
David Sanders 2020-10-26 11:56:31 -07:00 committed by GitHub
parent f714556a12
commit 4be10523e8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
25 changed files with 38 additions and 48 deletions

View file

@ -54,8 +54,7 @@ void Debugger::DispatchProtocolMessage(DevToolsAgentHost* agent_host,
base::JSON_REPLACE_INVALID_CHARACTERS);
if (!parsed_message || !parsed_message->is_dict())
return;
base::DictionaryValue* dict =
static_cast<base::DictionaryValue*>(parsed_message.get());
auto* dict = static_cast<base::DictionaryValue*>(parsed_message.get());
int id;
if (!dict->GetInteger("id", &id)) {
std::string method;

View file

@ -77,7 +77,7 @@ gin::WrapperInfo DownloadItem::kWrapperInfo = {gin::kEmbedderNativeGin};
DownloadItem* DownloadItem::FromDownloadItem(
download::DownloadItem* download_item) {
// ^- say that 7 times fast in a row
UserDataLink* data = static_cast<UserDataLink*>(
auto* data = static_cast<UserDataLink*>(
download_item->GetUserData(kElectronApiDownloadItemKey));
return data ? data->download_item.get() : nullptr;
}

View file

@ -58,7 +58,7 @@ LRESULT CALLBACK PowerMonitor::WndProcStatic(HWND hwnd,
UINT message,
WPARAM wparam,
LPARAM lparam) {
PowerMonitor* msg_wnd =
auto* msg_wnd =
reinterpret_cast<PowerMonitor*>(GetWindowLongPtr(hwnd, GWLP_USERDATA));
if (msg_wnd)
return msg_wnd->WndProc(hwnd, message, wparam, lparam);

View file

@ -1044,7 +1044,7 @@ bool Session::RemoveWordFromSpellCheckerDictionary(const std::string& word) {
// static
Session* Session::FromBrowserContext(content::BrowserContext* context) {
UserDataLink* data =
auto* data =
static_cast<UserDataLink*>(context->GetUserData(kElectronApiSessionKey));
return data ? data->session : nullptr;
}

View file

@ -218,7 +218,7 @@ LRESULT CALLBACK SystemPreferences::WndProcStatic(HWND hwnd,
UINT message,
WPARAM wparam,
LPARAM lparam) {
SystemPreferences* msg_wnd = reinterpret_cast<SystemPreferences*>(
auto* msg_wnd = reinterpret_cast<SystemPreferences*>(
GetWindowLongPtr(hwnd, GWLP_USERDATA));
if (msg_wnd)
return msg_wnd->WndProc(hwnd, message, wparam, lparam);

View file

@ -3081,7 +3081,7 @@ gin::Handle<WebContents> WebContents::CreateAndTake(
WebContents* WebContents::From(content::WebContents* web_contents) {
if (!web_contents)
return nullptr;
UserDataLink* data = static_cast<UserDataLink*>(
auto* data = static_cast<UserDataLink*>(
web_contents->GetUserData(kElectronApiWebContentsKey));
return data ? data->web_contents.get() : nullptr;
}

View file

@ -105,7 +105,7 @@ ProcessIntegrityLevel ProcessMetric::GetIntegrityLevel() const {
}
auto token_label_bytes = std::make_unique<char[]>(token_info_length);
TOKEN_MANDATORY_LABEL* token_label =
auto* token_label =
reinterpret_cast<TOKEN_MANDATORY_LABEL*>(token_label_bytes.get());
if (!::GetTokenInformation(token, TokenIntegrityLevel, token_label,
token_info_length, &token_info_length)) {

View file

@ -922,7 +922,7 @@ ElectronBrowserClient::CreateWindowForPictureInPicture(
#if defined(OS_WIN)
base::string16 app_user_model_id = Browser::Get()->GetAppUserModelID();
if (!app_user_model_id.empty()) {
OverlayWindowViews* overlay_window_view =
auto* overlay_window_view =
static_cast<OverlayWindowViews*>(overlay_window.get());
ui::win::SetAppIdForWindow(app_user_model_id,
overlay_window_view->GetNativeWindow()

View file

@ -153,8 +153,7 @@ void ElectronDownloadManagerDelegate::OnDownloadSaveDialogDone(
if (!canceled) {
if (result.Get("filePath", &path)) {
// Remember the last selected download directory.
ElectronBrowserContext* browser_context =
static_cast<ElectronBrowserContext*>(
auto* browser_context = static_cast<ElectronBrowserContext*>(
download_manager_->GetBrowserContext());
browser_context->prefs()->SetFilePath(prefs::kDownloadDefaultDirectory,
path.DirName());
@ -211,8 +210,7 @@ bool ElectronDownloadManagerDelegate::DetermineDownloadTarget(
return true;
}
ElectronBrowserContext* browser_context =
static_cast<ElectronBrowserContext*>(
auto* browser_context = static_cast<ElectronBrowserContext*>(
download_manager_->GetBrowserContext());
base::FilePath default_download_path =
browser_context->prefs()->GetFilePath(prefs::kDownloadDefaultDirectory);

View file

@ -1384,8 +1384,7 @@ void NativeWindowViews::OnWidgetBoundsChanged(views::Widget* changed_widget,
int width_delta = new_bounds.width() - widget_size_.width();
int height_delta = new_bounds.height() - widget_size_.height();
for (NativeBrowserView* item : browser_views()) {
NativeBrowserViewViews* native_view =
static_cast<NativeBrowserViewViews*>(item);
auto* native_view = static_cast<NativeBrowserViewViews*>(item);
native_view->SetAutoResizeProportions(widget_size_);
native_view->AutoResize(new_bounds, width_delta, height_delta);
}
@ -1453,7 +1452,7 @@ bool NativeWindowViews::ShouldDescendIntoChildForEventHandling(
// And the events on border for dragging resizable frameless window.
if (!has_frame() && CanResize()) {
FramelessView* frame =
auto* frame =
static_cast<FramelessView*>(widget()->non_client_view()->frame_view());
return frame->ResizingBorderHitTest(location) == HTNOWHERE;
}

View file

@ -397,7 +397,7 @@ LRESULT CALLBACK NativeWindowViews::SubclassProc(HWND hwnd,
LPARAM l_param,
UINT_PTR subclass_id,
DWORD_PTR ref_data) {
NativeWindowViews* window = reinterpret_cast<NativeWindowViews*>(ref_data);
auto* window = reinterpret_cast<NativeWindowViews*>(ref_data);
switch (msg) {
case WM_MOUSELEAVE: {
// When input is forwarded to underlying windows, this message is posted.

View file

@ -96,8 +96,7 @@ void PlatformNotificationService::DisplayNotification(
// See: https://notifications.spec.whatwg.org/#showing-a-notification
presenter->CloseNotificationWithId(notification_id);
NotificationDelegateImpl* delegate =
new NotificationDelegateImpl(notification_id);
auto* delegate = new NotificationDelegateImpl(notification_id);
auto notification = presenter->CreateNotification(delegate, notification_id);
if (notification) {

View file

@ -382,8 +382,7 @@ void OffScreenRenderWidgetHostView::TakeFallbackContentFrom(
content::RenderWidgetHostView* view) {
DCHECK(!static_cast<content::RenderWidgetHostViewBase*>(view)
->IsRenderWidgetHostViewChildFrame());
OffScreenRenderWidgetHostView* view_osr =
static_cast<OffScreenRenderWidgetHostView*>(view);
auto* view_osr = static_cast<OffScreenRenderWidgetHostView*>(view);
SetBackgroundColor(view_osr->background_color_);
if (GetDelegatedFrameHost() && view_osr->GetDelegatedFrameHost()) {
GetDelegatedFrameHost()->TakeFallbackContentFrom(

View file

@ -126,14 +126,12 @@ OffScreenWebContentsView::CreateViewForWidget(
content::RenderWidgetHostViewBase*
OffScreenWebContentsView::CreateViewForChildWidget(
content::RenderWidgetHost* render_widget_host) {
content::WebContentsImpl* web_contents_impl =
auto* web_contents_impl =
static_cast<content::WebContentsImpl*>(web_contents_);
OffScreenRenderWidgetHostView* view =
static_cast<OffScreenRenderWidgetHostView*>(
auto* view = static_cast<OffScreenRenderWidgetHostView*>(
web_contents_impl->GetOuterWebContents()
? web_contents_impl->GetOuterWebContents()
->GetRenderWidgetHostView()
? web_contents_impl->GetOuterWebContents()->GetRenderWidgetHostView()
: web_contents_impl->GetRenderWidgetHostView());
return new OffScreenRenderWidgetHostView(transparent_, painting_,

View file

@ -44,7 +44,7 @@ base::UnguessableToken DecodeToken(base::StringPiece input) {
return base::UnguessableToken();
}
const uint64_t* data = reinterpret_cast<const uint64_t*>(buffer.data());
const auto* data = reinterpret_cast<const uint64_t*>(buffer.data());
return base::UnguessableToken::Deserialize(data[0], data[1]);
}

View file

@ -73,7 +73,7 @@ void AutofillPopupView::Show() {
// The widget is destroyed by the corresponding NativeWidget, so we use
// a weak pointer to hold the reference and don't have to worry about
// deletion.
views::Widget* widget = new views::Widget;
auto* widget = new views::Widget;
views::Widget::InitParams params(views::Widget::InitParams::TYPE_POPUP);
params.delegate = this;
params.parent = parent_widget_->GetNativeView();

View file

@ -89,7 +89,7 @@ InspectableWebContentsViewViews::InspectableWebContentsViewViews(
title_(base::ASCIIToUTF16("Developer Tools")) {
if (!inspectable_web_contents_->IsGuest() &&
inspectable_web_contents_->GetWebContents()->GetNativeView()) {
views::WebView* contents_web_view = new views::WebView(nullptr);
auto* contents_web_view = new views::WebView(nullptr);
contents_web_view->SetWebContents(
inspectable_web_contents_->GetWebContents());
contents_web_view_ = contents_web_view;

View file

@ -272,7 +272,7 @@ void MenuBar::ButtonPressed(views::Button* source, const ui::Event& event) {
}
// Deleted in MenuDelegate::OnMenuClosed
MenuDelegate* menu_delegate = new MenuDelegate(this);
auto* menu_delegate = new MenuDelegate(this);
menu_delegate->RunMenu(
menu_model_->GetSubmenuModelAt(id), source,
event.IsKeyEvent() ? ui::MENU_SOURCE_KEYBOARD : ui::MENU_SOURCE_MOUSE);

View file

@ -39,7 +39,7 @@ void MenuDelegate::RunMenu(ElectronMenuModel* model,
id_ = button->tag();
adapter_ = std::make_unique<MenuModelAdapter>(model);
views::MenuItemView* item = new views::MenuItemView(this);
auto* item = new views::MenuItemView(this);
static_cast<MenuModelAdapter*>(adapter_.get())->BuildMenu(item);
menu_runner_ = std::make_unique<views::MenuRunner>(

View file

@ -89,7 +89,7 @@ NotifyIcon* NotifyIconHost::CreateNotifyIcon(base::Optional<UUID> guid) {
if (guid.has_value()) {
for (NotifyIcons::const_iterator i(notify_icons_.begin());
i != notify_icons_.end(); ++i) {
NotifyIcon* current_win_icon = static_cast<NotifyIcon*>(*i);
auto* current_win_icon = static_cast<NotifyIcon*>(*i);
if (current_win_icon->guid() == guid.value()) {
LOG(WARNING)
<< "Guid already in use. Existing tray entry will be replaced.";
@ -97,7 +97,7 @@ NotifyIcon* NotifyIconHost::CreateNotifyIcon(base::Optional<UUID> guid) {
}
}
NotifyIcon* notify_icon =
auto* notify_icon =
new NotifyIcon(this, NextIconId(), window_, kNotifyIconMessage,
guid.has_value() ? guid.value() : GUID_DEFAULT);
@ -121,7 +121,7 @@ LRESULT CALLBACK NotifyIconHost::WndProcStatic(HWND hwnd,
UINT message,
WPARAM wparam,
LPARAM lparam) {
NotifyIconHost* msg_wnd =
auto* msg_wnd =
reinterpret_cast<NotifyIconHost*>(GetWindowLongPtr(hwnd, GWLP_USERDATA));
if (msg_wnd)
return msg_wnd->WndProc(hwnd, message, wparam, lparam);
@ -137,7 +137,7 @@ LRESULT CALLBACK NotifyIconHost::WndProc(HWND hwnd,
// We need to reset all of our icons because the taskbar went away.
for (NotifyIcons::const_iterator i(notify_icons_.begin());
i != notify_icons_.end(); ++i) {
NotifyIcon* win_icon = static_cast<NotifyIcon*>(*i);
auto* win_icon = static_cast<NotifyIcon*>(*i);
win_icon->ResetIcon();
}
return TRUE;
@ -147,7 +147,7 @@ LRESULT CALLBACK NotifyIconHost::WndProc(HWND hwnd,
// Find the selected status icon.
for (NotifyIcons::const_iterator i(notify_icons_.begin());
i != notify_icons_.end(); ++i) {
NotifyIcon* current_win_icon = static_cast<NotifyIcon*>(*i);
auto* current_win_icon = static_cast<NotifyIcon*>(*i);
if (current_win_icon->icon_id() == wparam) {
win_icon = current_win_icon;
break;

View file

@ -108,7 +108,7 @@ void ElectronBindings::ActivateUVLoop(v8::Isolate* isolate) {
// static
void ElectronBindings::OnCallNextTick(uv_async_t* handle) {
ElectronBindings* self = static_cast<ElectronBindings*>(handle->data);
auto* self = static_cast<ElectronBindings*>(handle->data);
for (std::list<node::Environment*>::const_iterator it =
self->pending_next_ticks_.begin();
it != self->pending_next_ticks_.end(); ++it) {

View file

@ -55,7 +55,7 @@ void CallTranslater(v8::Local<v8::External> external,
}
}
TranslaterHolder* holder = static_cast<TranslaterHolder*>(external->Value());
auto* holder = static_cast<TranslaterHolder*>(external->Value());
holder->translater.Run(args);
// Free immediately for one-time callback.

View file

@ -64,8 +64,7 @@ void WrappableBase::InitWith(v8::Isolate* isolate,
// static
void WrappableBase::FirstWeakCallback(
const v8::WeakCallbackInfo<WrappableBase>& data) {
WrappableBase* wrappable =
static_cast<WrappableBase*>(data.GetInternalField(0));
auto* wrappable = static_cast<WrappableBase*>(data.GetInternalField(0));
if (wrappable) {
wrappable->wrapper_.Reset();
data.SetSecondPassCallback(SecondWeakCallback);
@ -75,8 +74,7 @@ void WrappableBase::FirstWeakCallback(
// static
void WrappableBase::SecondWeakCallback(
const v8::WeakCallbackInfo<WrappableBase>& data) {
WrappableBase* wrappable =
static_cast<WrappableBase*>(data.GetInternalField(0));
auto* wrappable = static_cast<WrappableBase*>(data.GetInternalField(0));
if (wrappable)
delete wrappable;
}

View file

@ -560,7 +560,7 @@ void NodeBindings::WakeupEmbedThread() {
// static
void NodeBindings::EmbedThreadRunner(void* arg) {
NodeBindings* self = static_cast<NodeBindings*>(arg);
auto* self = static_cast<NodeBindings*>(arg);
while (true) {
// Wait for the main loop to deal with events.

View file

@ -128,7 +128,7 @@ bool AddImageSkiaRepFromPath(gfx::ImageSkia* image,
return false;
}
const unsigned char* data =
const auto* data =
reinterpret_cast<const unsigned char*>(file_contents.data());
size_t size = file_contents.size();