Skip to content

Commit

Permalink
Run clang-tidy modernize-use-nullptr on //ui/views
Browse files Browse the repository at this point in the history
This is a run of
run-clang-tidy.py -checks="-*,modernize-use-nullptr" -header-filter=ui/views/* \\src\\ui\\views\\

BUG=940732
This CL was uploaded by git cl split.

TBR=sadrul@chromium.org

Change-Id: Ie9e8876a0053b1fbded992be9aef15ad3d11a3df
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1529881
Reviewed-by: Robert Liao <robliao@chromium.org>
Reviewed-by: Sadrul Chowdhury <sadrul@chromium.org>
Commit-Queue: Robert Liao <robliao@chromium.org>
Auto-Submit: Robert Liao <robliao@chromium.org>
Cr-Commit-Position: refs/heads/master@{#642032}
  • Loading branch information
Robert Liao authored and Commit Bot committed Mar 19, 2019
1 parent e0775cd commit 3888a7d
Show file tree
Hide file tree
Showing 89 changed files with 652 additions and 676 deletions.
5 changes: 2 additions & 3 deletions ui/views/button_drag_utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,8 @@ void SetDragImage(const GURL& url,
const views::Widget& widget,
ui::OSExchangeData* data) {
// Create a button to render the drag image for us.
views::LabelButton button(NULL,
title.empty() ? base::UTF8ToUTF16(url.spec())
: title);
views::LabelButton button(
nullptr, title.empty() ? base::UTF8ToUTF16(url.spec()) : title);
button.SetTextSubpixelRenderingEnabled(false);
const ui::NativeTheme* theme = widget.GetNativeTheme();
button.SetTextColor(views::Button::STATE_NORMAL,
Expand Down
2 changes: 1 addition & 1 deletion ui/views/controls/button/image_button.cc
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ void ImageButton::SetImage(ButtonState for_state, const gfx::ImageSkia& image) {
void ImageButton::SetBackgroundImage(SkColor color,
const gfx::ImageSkia* image,
const gfx::ImageSkia* mask) {
if (image == NULL || mask == NULL) {
if (image == nullptr || mask == nullptr) {
background_image_ = gfx::ImageSkia();
return;
}
Expand Down
12 changes: 6 additions & 6 deletions ui/views/controls/button/image_button_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ const ImageButton::VerticalAlignment kDefaultVerticalAlignment =
typedef ViewsTestBase ImageButtonTest;

TEST_F(ImageButtonTest, Basics) {
ImageButton button(NULL);
ImageButton button(nullptr);

// Our image to paint starts empty.
EXPECT_TRUE(button.GetImageToPaint().isNull());
Expand Down Expand Up @@ -97,7 +97,7 @@ TEST_F(ImageButtonTest, Basics) {
}

TEST_F(ImageButtonTest, SetAndGetImage) {
ImageButton button(NULL);
ImageButton button(nullptr);

// Images start as null.
EXPECT_TRUE(button.GetImage(Button::STATE_NORMAL).isNull());
Expand All @@ -118,12 +118,12 @@ TEST_F(ImageButtonTest, SetAndGetImage) {
EXPECT_TRUE(button.GetImage(Button::STATE_DISABLED).isNull());

// ImageButton supports NULL image pointers.
button.SetImage(Button::STATE_NORMAL, NULL);
button.SetImage(Button::STATE_NORMAL, nullptr);
EXPECT_TRUE(button.GetImage(Button::STATE_NORMAL).isNull());
}

TEST_F(ImageButtonTest, ImagePositionWithBorder) {
ImageButton button(NULL);
ImageButton button(nullptr);
gfx::ImageSkia image = CreateTestImage(20, 30);
button.SetImage(Button::STATE_NORMAL, &image);

Expand Down Expand Up @@ -172,7 +172,7 @@ TEST_F(ImageButtonTest, ImagePositionWithBorder) {
}

TEST_F(ImageButtonTest, LeftAlignedMirrored) {
ImageButton button(NULL);
ImageButton button(nullptr);
gfx::ImageSkia image = CreateTestImage(20, 30);
button.SetImage(Button::STATE_NORMAL, &image);
button.SetBounds(0, 0, 50, 30);
Expand All @@ -190,7 +190,7 @@ TEST_F(ImageButtonTest, LeftAlignedMirrored) {
}

TEST_F(ImageButtonTest, RightAlignedMirrored) {
ImageButton button(NULL);
ImageButton button(nullptr);
gfx::ImageSkia image = CreateTestImage(20, 30);
button.SetImage(Button::STATE_NORMAL, &image);
button.SetBounds(0, 0, 50, 30);
Expand Down
4 changes: 2 additions & 2 deletions ui/views/controls/button/radio_button.cc
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@ View* RadioButton::GetSelectedViewForGroup(int group) {
Views views;
GetViewsInGroupFromParent(group, &views);
if (views.empty())
return NULL;
return nullptr;

for (Views::const_iterator i(views.begin()); i != views.end(); ++i) {
// REVIEW: why don't we check the runtime type like is done above?
RadioButton* radio_button = static_cast<RadioButton*>(*i);
if (radio_button->checked())
return radio_button;
}
return NULL;
return nullptr;
}

bool RadioButton::IsGroupFocusTraversable() const {
Expand Down
2 changes: 1 addition & 1 deletion ui/views/controls/link.cc
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ void Link::SetUnderline(bool underline) {
}

void Link::Init() {
listener_ = NULL;
listener_ = nullptr;
pressed_ = false;
underline_ = GetDefaultFocusStyle() != FocusStyle::UNDERLINE;
RecalculateFont();
Expand Down
2 changes: 1 addition & 1 deletion ui/views/controls/menu/display_change_listener_aura.cc
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ void AuraDisplayChangeListener::OnWindowBoundsChanged(
void AuraDisplayChangeListener::OnWindowDestroying(aura::Window* window) {
DCHECK_EQ(window, root_window_);
root_window_->RemoveObserver(this);
root_window_ = NULL;
root_window_ = nullptr;
}

// static
Expand Down
54 changes: 27 additions & 27 deletions ui/views/controls/menu/menu_controller.cc
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ bool TitleMatchesMnemonic(MenuItemView* menu, base::char16 key) {
// Returns the first descendant of |view| that is hot tracked.
Button* GetFirstHotTrackedView(View* view) {
if (!view)
return NULL;
return nullptr;
Button* button = Button::AsButton(view);
if (button && button->IsHotTracked())
return button;
Expand All @@ -125,7 +125,7 @@ Button* GetFirstHotTrackedView(View* view) {
if (hot_view)
return hot_view;
}
return NULL;
return nullptr;
}

// Recurses through the child views of |view| returning the first view starting
Expand Down Expand Up @@ -224,8 +224,8 @@ static void RepostEventImpl(const ui::LocatedEvent* event,
if (event->IsMouseEvent()) {
HWND source_window = HWNDForNativeView(native_view);
if (!target_window || !source_window ||
GetWindowThreadProcessId(source_window, NULL) !=
GetWindowThreadProcessId(target_window, NULL)) {
GetWindowThreadProcessId(source_window, nullptr) !=
GetWindowThreadProcessId(target_window, nullptr)) {
// Even though we have mouse capture, windows generates a mouse event if
// the other window is in a separate thread. Only repost an event if
// |target_window| and |source_window| were created on the same thread,
Expand Down Expand Up @@ -306,7 +306,7 @@ static void RepostEventImpl(const ui::LocatedEvent* event,

class MenuController::MenuScrollTask {
public:
MenuScrollTask() : submenu_(NULL), is_scrolling_up_(false), start_y_(0) {
MenuScrollTask() : submenu_(nullptr), is_scrolling_up_(false), start_y_(0) {
pixels_per_second_ = MenuItemView::pref_menu_height() * 20;
}

Expand Down Expand Up @@ -336,7 +336,7 @@ class MenuController::MenuScrollTask {
void StopScrolling() {
if (scrolling_timer_.IsRunning()) {
scrolling_timer_.Stop();
submenu_ = NULL;
submenu_ = nullptr;
}
}

Expand Down Expand Up @@ -418,7 +418,7 @@ MenuController::State::~State() {}
// MenuController ------------------------------------------------------------

// static
MenuController* MenuController::active_instance_ = NULL;
MenuController* MenuController::active_instance_ = nullptr;

// static
MenuController* MenuController::GetActiveInstance() {
Expand Down Expand Up @@ -538,7 +538,7 @@ void MenuController::Cancel(ExitType type) {
SendMouseCaptureLostToActiveView();

// Hide windows immediately.
SetSelection(NULL, SELECTION_UPDATE_IMMEDIATELY | SELECTION_EXIT);
SetSelection(nullptr, SELECTION_UPDATE_IMMEDIATELY | SELECTION_EXIT);

if (for_drop_) {
// If we didn't block the caller we need to notify the menu, which
Expand Down Expand Up @@ -661,7 +661,7 @@ bool MenuController::OnMouseDragged(SubmenuView* source,
StartDrag(source, press_pt_);
return true;
}
MenuItemView* mouse_menu = NULL;
MenuItemView* mouse_menu = nullptr;
if (part.type == MenuPart::MENU_ITEM) {
// If there is no menu target, but a submenu target, then we are interacting
// with an empty menu item within a submenu. These cannot become selection
Expand Down Expand Up @@ -720,12 +720,12 @@ void MenuController::OnMouseReleased(SubmenuView* source,
MenuItemView* menu = part.menu;
// |menu| is NULL means this event is from an empty menu or a separator.
// If it is from an empty menu, use parent context menu instead of that.
if (menu == NULL && part.submenu->child_count() == 1 &&
if (menu == nullptr && part.submenu->child_count() == 1 &&
part.submenu->child_at(0)->id() == MenuItemView::kEmptyMenuItemViewID) {
menu = part.parent;
}

if (menu != NULL) {
if (menu != nullptr) {
gfx::Point screen_location(event.location());
View::ConvertPointToScreen(source->GetScrollViewContainer(),
&screen_location);
Expand Down Expand Up @@ -1022,7 +1022,7 @@ int MenuController::OnDragUpdated(SubmenuView* source,

if (drop_position == MenuDelegate::DROP_NONE ||
drop_operation == ui::DragDropTypes::DRAG_NONE)
menu_item = NULL;
menu_item = nullptr;
} else {
SetSelection(source->GetMenuItem(), SELECTION_OPEN_SUBMENU);
}
Expand All @@ -1036,7 +1036,7 @@ void MenuController::OnDragExited(SubmenuView* source) {

if (drop_target_) {
StopShowTimer();
SetDropMenuItem(NULL, MenuDelegate::DROP_NONE);
SetDropMenuItem(nullptr, MenuDelegate::DROP_NONE);
}
}

Expand All @@ -1053,7 +1053,7 @@ int MenuController::OnPerformDrop(SubmenuView* source,
MenuDelegate::DropPosition drop_position = drop_position_;

// Close all menus, including any nested menus.
SetSelection(NULL, SELECTION_UPDATE_IMMEDIATELY | SELECTION_EXIT);
SetSelection(nullptr, SELECTION_UPDATE_IMMEDIATELY | SELECTION_EXIT);
CloseAllNestedMenus();

// Set state such that we exit.
Expand Down Expand Up @@ -1091,7 +1091,7 @@ void MenuController::OnDragEnteredScrollButton(SubmenuView* source,

void MenuController::OnDragExitedScrollButton(SubmenuView* source) {
StartCancelAllTimer();
SetDropMenuItem(NULL, MenuDelegate::DROP_NONE);
SetDropMenuItem(nullptr, MenuDelegate::DROP_NONE);
StopScrolling();
}

Expand Down Expand Up @@ -1223,7 +1223,7 @@ void MenuController::UpdateSubmenuSelection(SubmenuView* submenu) {
void MenuController::OnWidgetDestroying(Widget* widget) {
DCHECK_EQ(owner_, widget);
owner_->RemoveObserver(this);
owner_ = NULL;
owner_ = nullptr;
}

bool MenuController::IsCancelAllTimerRunningForTest() {
Expand Down Expand Up @@ -1283,7 +1283,7 @@ void MenuController::SetSelection(MenuItemView* menu_item,

// Notify the old path it isn't selected.
MenuDelegate* current_delegate =
current_path.empty() ? NULL : current_path.front()->GetDelegate();
current_path.empty() ? nullptr : current_path.front()->GetDelegate();
for (size_t i = paths_differ_at; i < current_size; ++i) {
if (current_delegate &&
(current_path[i]->GetType() == MenuItemView::SUBMENU ||
Expand Down Expand Up @@ -1407,7 +1407,7 @@ void MenuController::StartDrag(SubmenuView* source,
did_initiate_drag_ = true;
base::WeakPtr<MenuController> this_ref = AsWeakPtr();
// TODO(varunjain): Properly determine and send DRAG_EVENT_SOURCE below.
item->GetWidget()->RunShellDrag(NULL, data, widget_loc, drag_ops,
item->GetWidget()->RunShellDrag(nullptr, data, widget_loc, drag_ops,
ui::DragDropTypes::DRAG_EVENT_SOURCE_MOUSE);
// MenuController may have been deleted so check before accessing member
// variables.
Expand Down Expand Up @@ -1567,7 +1567,7 @@ MenuController::~MenuController() {
if (owner_)
owner_->RemoveObserver(this);
if (active_instance_ == this)
active_instance_ = NULL;
active_instance_ = nullptr;
StopShowTimer();
StopCancelAllTimer();
}
Expand Down Expand Up @@ -1675,7 +1675,7 @@ bool MenuController::ShowSiblingMenu(SubmenuView* source,
View::ConvertPointToScreen(source_view, &screen_point);
MenuAnchorPosition anchor;
bool has_mnemonics;
MenuButton* button = NULL;
MenuButton* button = nullptr;
MenuItemView* alt_menu = source->GetMenuItem()->GetDelegate()->GetSiblingMenu(
source->GetMenuItem()->GetRootMenuItem(), screen_point, &anchor,
&has_mnemonics, &button);
Expand Down Expand Up @@ -1756,7 +1756,7 @@ MenuItemView* MenuController::GetMenuItemAt(View* source, int x, int y) {
child_under_mouse->id() == MenuItemView::kMenuItemViewID) {
return static_cast<MenuItemView*>(child_under_mouse);
}
return NULL;
return nullptr;
}

MenuItemView* MenuController::GetEmptyMenuItemAt(View* source, int x, int y) {
Expand All @@ -1765,7 +1765,7 @@ MenuItemView* MenuController::GetEmptyMenuItemAt(View* source, int x, int y) {
child_under_mouse->id() == MenuItemView::kEmptyMenuItemViewID) {
return static_cast<MenuItemView*>(child_under_mouse);
}
return NULL;
return nullptr;
}

bool MenuController::IsScrollButtonAt(SubmenuView* source,
Expand Down Expand Up @@ -2628,7 +2628,7 @@ void MenuController::OpenSubmenuChangeSelectionIfCan() {
MenuItemView* item = pending_state_.item;
if (!item->HasSubmenu() || !item->enabled())
return;
MenuItemView* to_select = NULL;
MenuItemView* to_select = nullptr;
if (item->GetSubmenu()->GetMenuItemCount() > 0)
to_select = FindInitialSelectableMenuItem(item, INCREMENT_SELECTION_DOWN);
if (to_select) {
Expand Down Expand Up @@ -2812,7 +2812,7 @@ void MenuController::SetDropMenuItem(MenuItemView* new_target,

if (drop_target_) {
drop_target_->GetParentMenuItem()->GetSubmenu()->SetDropMenuItem(
NULL, MenuDelegate::DROP_NONE);
nullptr, MenuDelegate::DROP_NONE);
}
drop_target_ = new_target;
drop_position_ = new_position;
Expand All @@ -2832,13 +2832,13 @@ void MenuController::UpdateScrolling(const MenuPart& part) {
}

void MenuController::StopScrolling() {
scroll_task_.reset(NULL);
scroll_task_.reset(nullptr);
}

void MenuController::UpdateActiveMouseView(SubmenuView* event_source,
const ui::MouseEvent& event,
View* target_menu) {
View* target = NULL;
View* target = nullptr;
gfx::Point target_menu_loc(event.location());
if (target_menu && target_menu->has_children()) {
// Locate the deepest child view to send events to. This code assumes we
Expand All @@ -2850,7 +2850,7 @@ void MenuController::UpdateActiveMouseView(SubmenuView* event_source,
View::ConvertPointFromScreen(target_menu, &target_menu_loc);
target = target_menu->GetEventHandlerForPoint(target_menu_loc);
if (target == target_menu || !target->enabled())
target = NULL;
target = nullptr;
}
View* active_mouse_view = active_mouse_view_tracker_->view();
if (target != active_mouse_view) {
Expand Down
2 changes: 1 addition & 1 deletion ui/views/controls/menu/menu_delegate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ MenuItemView* MenuDelegate::GetSiblingMenu(MenuItemView* menu,
MenuAnchorPosition* anchor,
bool* has_mnemonics,
MenuButton** button) {
return NULL;
return nullptr;
}

int MenuDelegate::GetMaxWidthForMenu(MenuItemView* menu) {
Expand Down
2 changes: 1 addition & 1 deletion ui/views/controls/menu/menu_host_root_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ void MenuHostRootView::OnEventProcessingFinished(ui::Event* event) {
}

MenuController* MenuHostRootView::GetMenuController() {
return submenu_ ? submenu_->GetMenuItem()->GetMenuController() : NULL;
return submenu_ ? submenu_->GetMenuItem()->GetMenuController() : nullptr;
}

MenuController* MenuHostRootView::GetMenuControllerForInputEvents() {
Expand Down
2 changes: 1 addition & 1 deletion ui/views/controls/menu/menu_host_root_view.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class MenuHostRootView : public internal::RootView {
public:
MenuHostRootView(Widget* widget, SubmenuView* submenu);

void ClearSubmenu() { submenu_ = NULL; }
void ClearSubmenu() { submenu_ = nullptr; }

// Overridden from View:
bool OnMousePressed(const ui::MouseEvent& event) override;
Expand Down
Loading

0 comments on commit 3888a7d

Please sign in to comment.