Commit eb07a5e0 authored by Bartek Nowierski's avatar Bartek Nowierski Committed by Commit Bot

Convert NULL to nullptr or shorten to bool-like expression

https://google.github.io/styleguide/cppguide.html#0_and_nullptr/NULL
says:
"For pointers (address values), use nullptr, as this provides
type-safety."
Furthermore, NULL/0 won't compile if we change |SomeClass*| to
|CheckedPtr<SomeClass>|. See go/miracleptr for more details.

!! is used in situations where the pointer is assigned to or returned
as bool, otherwise CheckedPtr's more costly implicit T* cast operator
would kick in. !! isn't needed in boolean expressions. Examples here:
https://chromium-review.googlesource.com/c/chromium/src/+/2226003

Bug: 1080832
Change-Id: I449817c8949d85bd99a1f7d5043cd189f109303c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2227936
Auto-Submit: Bartek Nowierski <bartekn@chromium.org>
Commit-Queue: Kentaro Hara <haraken@chromium.org>
Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Cr-Commit-Position: refs/heads/master@{#774523}
parent 033d852c
......@@ -70,7 +70,7 @@ using content::OpenURLParams;
using content::WebContents;
// If non-null there is a drag underway.
static TabDragController* g_tab_drag_controller = NULL;
static TabDragController* g_tab_drag_controller = nullptr;
namespace {
......@@ -408,7 +408,7 @@ TabDragController::TabDragController()
TabDragController::~TabDragController() {
if (g_tab_drag_controller == this)
g_tab_drag_controller = NULL;
g_tab_drag_controller = nullptr;
if (move_loop_widget_)
move_loop_widget_->RemoveObserver(this);
......@@ -1320,7 +1320,7 @@ void TabDragController::Detach(ReleaseCapture release_capture) {
ClearTabDraggingInfo();
attached_context_->DraggedTabsDetached();
attached_context_ = NULL;
attached_context_ = nullptr;
attached_views_.clear();
}
......@@ -1441,7 +1441,7 @@ void TabDragController::RunMoveLoop(const gfx::Vector2d& drag_offset) {
// Activate may trigger a focus loss, destroying us.
if (!ref)
return;
tab_strip_to_attach_to_after_exit_ = NULL;
tab_strip_to_attach_to_after_exit_ = nullptr;
} else if (current_state_ == DragState::kWaitingToStop) {
EndDrag(result == views::Widget::MOVE_LOOP_CANCELED ? END_DRAG_CANCEL
: END_DRAG_COMPLETE);
......
......@@ -530,7 +530,7 @@ void OutputController::StopCloseAndClearStream() {
stream_->Close();
stats_tracker_.reset();
stream_ = NULL;
stream_ = nullptr;
}
state_ = kEmpty;
......
......@@ -53,7 +53,7 @@ bool IsNonClientLocation(Window* target, const gfx::Point& location) {
}
Window* ConsumerToWindow(ui::GestureConsumer* consumer) {
return consumer ? static_cast<Window*>(consumer) : NULL;
return consumer ? static_cast<Window*>(consumer) : nullptr;
}
bool IsEventCandidateForHold(const ui::Event& event) {
......@@ -150,7 +150,7 @@ void WindowEventDispatcher::DispatchCancelModeEvent() {
ui::CancelModeEvent event;
Window* focused_window = client::GetFocusClient(window())->GetFocusedWindow();
if (focused_window && !window()->Contains(focused_window))
focused_window = NULL;
focused_window = nullptr;
DispatchDetails details =
DispatchEvent(focused_window ? focused_window : window(), &event);
if (details.dispatcher_destroyed)
......@@ -246,8 +246,8 @@ gfx::Point WindowEventDispatcher::GetLastMouseLocationInRoot() const {
}
void WindowEventDispatcher::OnHostLostMouseGrab() {
mouse_pressed_handler_ = NULL;
mouse_moved_handler_ = NULL;
mouse_pressed_handler_ = nullptr;
mouse_moved_handler_ = nullptr;
}
void WindowEventDispatcher::OnCursorMovedToRootLocation(
......@@ -358,9 +358,9 @@ void WindowEventDispatcher::OnWindowHidden(Window* invisible,
// If the window the mouse was pressed in becomes invisible, it should no
// longer receive mouse events.
if (invisible->Contains(mouse_pressed_handler_))
mouse_pressed_handler_ = NULL;
mouse_pressed_handler_ = nullptr;
if (invisible->Contains(mouse_moved_handler_))
mouse_moved_handler_ = NULL;
mouse_moved_handler_ = nullptr;
if (invisible->Contains(touchpad_pinch_handler_))
touchpad_pinch_handler_ = nullptr;
......@@ -369,7 +369,7 @@ void WindowEventDispatcher::OnWindowHidden(Window* invisible,
// dispatching events in the inner loop, then reset the target for the outer
// loop.
if (invisible->Contains(old_dispatch_target_))
old_dispatch_target_ = NULL;
old_dispatch_target_ = nullptr;
invisible->CleanupGestureState();
......@@ -384,10 +384,10 @@ void WindowEventDispatcher::OnWindowHidden(Window* invisible,
client::CaptureClient* capture_client =
client::GetCaptureClient(host_->window());
Window* capture_window =
capture_client ? capture_client->GetCaptureWindow() : NULL;
capture_client ? capture_client->GetCaptureWindow() : nullptr;
if (invisible->Contains(event_dispatch_target_))
event_dispatch_target_ = NULL;
event_dispatch_target_ = nullptr;
// If the ancestor of the capture window is hidden, release the capture.
// Note that this may delete the window so do not use capture_window
......@@ -411,7 +411,7 @@ void WindowEventDispatcher::UpdateCapture(Window* old_capture,
// (see below). Clear it here to ensure we don't end up referencing a stale
// Window.
if (mouse_moved_handler_ && !window()->Contains(mouse_moved_handler_))
mouse_moved_handler_ = NULL;
mouse_moved_handler_ = nullptr;
if (old_capture && old_capture->GetRootWindow() == window() &&
old_capture->delegate()) {
......@@ -439,7 +439,7 @@ void WindowEventDispatcher::UpdateCapture(Window* old_capture,
if (details.dispatcher_destroyed)
return;
}
mouse_pressed_handler_ = NULL;
mouse_pressed_handler_ = nullptr;
}
void WindowEventDispatcher::OnOtherRootGotCapture() {
......@@ -461,8 +461,8 @@ void WindowEventDispatcher::OnOtherRootGotCapture() {
}
#endif
mouse_moved_handler_ = NULL;
mouse_pressed_handler_ = NULL;
mouse_moved_handler_ = nullptr;
mouse_pressed_handler_ = nullptr;
}
void WindowEventDispatcher::SetNativeCapture() {
......@@ -559,7 +559,7 @@ ui::EventDispatchDetails WindowEventDispatcher::PostDispatchEvent(
if (!target || target != event_dispatch_target_)
details.target_destroyed = true;
event_dispatch_target_ = old_dispatch_target_;
old_dispatch_target_ = NULL;
old_dispatch_target_ = nullptr;
#ifndef NDEBUG
DCHECK(!event_dispatch_target_ || window()->Contains(event_dispatch_target_));
#endif
......@@ -921,7 +921,7 @@ DispatchDetails WindowEventDispatcher::PreDispatchMouseEvent(
event->SetHandled();
return details;
}
mouse_moved_handler_ = NULL;
mouse_moved_handler_ = nullptr;
}
break;
case ui::ET_MOUSE_MOVED:
......@@ -950,7 +950,7 @@ DispatchDetails WindowEventDispatcher::PreDispatchMouseEvent(
return target_details;
}
if (details.target_destroyed || target_details.target_destroyed) {
mouse_moved_handler_ = NULL;
mouse_moved_handler_ = nullptr;
event->SetHandled();
return target_details;
}
......@@ -974,7 +974,7 @@ DispatchDetails WindowEventDispatcher::PreDispatchMouseEvent(
mouse_pressed_handler_ = target;
break;
case ui::ET_MOUSE_RELEASED:
mouse_pressed_handler_ = NULL;
mouse_pressed_handler_ = nullptr;
break;
default:
break;
......
......@@ -32,9 +32,8 @@
? function(running_anim.sequence()) \
: false)
#define SAFE_INVOKE_PTR(function, running_anim) \
((running_anim.is_sequence_alive()) \
? function(running_anim.sequence()) \
: NULL)
((running_anim.is_sequence_alive()) ? function(running_anim.sequence()) \
: nullptr)
namespace ui {
......@@ -66,7 +65,7 @@ LayerAnimator::~LayerAnimator() {
running_animations_[i].sequence()->OnAnimatorDestroyed();
}
ClearAnimationsInternal();
delegate_ = NULL;
delegate_ = nullptr;
DCHECK(!animation_->animation_timeline());
}
......@@ -660,7 +659,7 @@ LayerAnimator::RunningAnimation* LayerAnimator::GetRunningAnimation(
if ((*iter).sequence()->properties() & property)
return &(*iter);
}
return NULL;
return nullptr;
}
void LayerAnimator::AddToQueueIfNotPresent(LayerAnimationSequence* animation) {
......@@ -735,7 +734,7 @@ void LayerAnimator::ImmediatelySetNewTarget(LayerAnimationSequence* sequence) {
return;
LayerAnimationSequence* removed = RemoveAnimation(sequence);
DCHECK(removed == NULL || removed == sequence);
DCHECK(removed == nullptr || removed == sequence);
if (!weak_sequence_ptr.get())
return;
......@@ -950,7 +949,7 @@ void LayerAnimator::PurgeDeletedAnimations() {
}
LayerAnimatorCollection* LayerAnimator::GetLayerAnimatorCollection() {
return delegate_ ? delegate_->GetLayerAnimatorCollection() : NULL;
return delegate_ ? delegate_->GetLayerAnimatorCollection() : nullptr;
}
void LayerAnimator::NotifyAnimationStarted(base::TimeTicks monotonic_time,
......
......@@ -100,7 +100,7 @@ class GESTURE_DETECTION_EXPORT GestureDetector {
// Note: The listener must never be changed while |is_double_tapping| is true.
void SetDoubleTapListener(DoubleTapListener* double_tap_listener);
bool has_doubletap_listener() const { return double_tap_listener_ != NULL; }
bool has_doubletap_listener() const { return !!double_tap_listener_; }
bool is_double_tapping() const { return is_double_tapping_; }
......
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