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