Commit e2d8e0c3 authored by Robert Liao's avatar Robert Liao Committed by Commit Bot

Clang-Tidy for //ui/views on Linux

This is a run of clang-tidy with the existing .clang-tidy config on
//ui/views including modernize-use-default-member-init and
readability-redundant-member-init.

BUG=940732
TBR=sky@chromium.org

Change-Id: I9f14648a041bbdb799b94642126483441cdf39c0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1542062Reviewed-by: default avatarRobert Liao <robliao@chromium.org>
Reviewed-by: default avatarScott Violet <sky@chromium.org>
Reviewed-by: default avatarThomas Anderson <thomasanderson@chromium.org>
Commit-Queue: Robert Liao <robliao@chromium.org>
Cr-Commit-Position: refs/heads/master@{#650446}
parent bc0f98a5
......@@ -85,10 +85,7 @@ MessageBoxView::InitParams::InitParams(const base::string16& message)
MessageBoxView::InitParams::~InitParams() = default;
MessageBoxView::MessageBoxView(const InitParams& params)
: prompt_field_(nullptr),
checkbox_(nullptr),
link_(nullptr),
message_width_(params.message_width) {
: message_width_(params.message_width) {
Init(params);
}
......
......@@ -123,12 +123,12 @@ class VIEWS_EXPORT MessageBoxView : public View {
// Link displayed at the bottom of the view.
Link* link_ = nullptr;
// Spacing between rows in the grid layout.
int inter_row_vertical_spacing_ = 0;
// Maximum width of the message label.
int message_width_;
// Spacing between rows in the grid layout.
int inter_row_vertical_spacing_;
DISALLOW_COPY_AND_ASSIGN(MessageBoxView);
};
......
......@@ -8,7 +8,7 @@ namespace views {
StatusIconLinux::Delegate::~Delegate() = default;
StatusIconLinux::StatusIconLinux() : delegate_(nullptr) {}
StatusIconLinux::StatusIconLinux() = default;
StatusIconLinux::~StatusIconLinux() = default;
......
......@@ -53,7 +53,7 @@ class VIEWS_EXPORT StatusIconLinux {
void set_delegate(Delegate* delegate) { delegate_ = delegate; }
private:
Delegate* delegate_;
Delegate* delegate_ = nullptr;
};
} // namespace views
......
......@@ -267,11 +267,11 @@ class DesktopDragDropClientAuraX11::X11DragContext
DesktopDragDropClientAuraX11* source_client_;
// The client we inform once we're done with requesting data.
DesktopDragDropClientAuraX11* drag_drop_client_;
DesktopDragDropClientAuraX11* drag_drop_client_ = nullptr;
// Whether we're blocking the handling of an XdndPosition message by waiting
// for |unfetched_targets_| to be fetched.
bool waiting_to_handle_position_;
bool waiting_to_handle_position_ = false;
// Where the cursor is on screen.
gfx::Point screen_point_;
......@@ -290,7 +290,7 @@ class DesktopDragDropClientAuraX11::X11DragContext
// XdndPosition messages have a suggested action. Qt applications exclusively
// use this, instead of the XdndActionList which is backed by |actions_|.
::Atom suggested_action_;
::Atom suggested_action_ = x11::None;
// Possible actions.
std::vector<::Atom> actions_;
......@@ -304,10 +304,7 @@ DesktopDragDropClientAuraX11::X11DragContext::X11DragContext(
: local_window_(local_window),
source_window_(event.data.l[0]),
source_client_(
DesktopDragDropClientAuraX11::GetForWindow(source_window_)),
drag_drop_client_(nullptr),
waiting_to_handle_position_(false),
suggested_action_(x11::None) {
DesktopDragDropClientAuraX11::GetForWindow(source_window_)) {
if (!source_client_) {
bool get_types_from_property = ((event.data.l[1] & 1) != 0);
......@@ -496,17 +493,7 @@ DesktopDragDropClientAuraX11::DesktopDragDropClientAuraX11(
: root_window_(root_window),
cursor_manager_(cursor_manager),
xdisplay_(xdisplay),
xwindow_(xwindow),
current_modifier_state_(ui::EF_NONE),
target_window_(nullptr),
waiting_on_status_(false),
status_received_since_enter_(false),
source_provider_(nullptr),
source_current_window_(x11::None),
source_state_(SOURCE_STATE_OTHER),
drag_operation_(0),
negotiated_operation_(ui::DragDropTypes::DRAG_NONE),
weak_ptr_factory_(this) {
xwindow_(xwindow) {
// Some tests change the DesktopDragDropClientAuraX11 associated with an
// |xwindow|.
g_live_client_map.Get()[xwindow] = this;
......
......@@ -17,6 +17,7 @@
#include "ui/aura/window_observer.h"
#include "ui/base/cursor/cursor.h"
#include "ui/base/dragdrop/drag_drop_types.h"
#include "ui/events/event_constants.h"
#include "ui/gfx/geometry/point.h"
#include "ui/gfx/geometry/size.h"
#include "ui/gfx/x/x11.h"
......@@ -218,14 +219,14 @@ class VIEWS_EXPORT DesktopDragDropClientAuraX11
std::unique_ptr<X11DragContext> target_current_context_;
// The modifier state for the most recent mouse move.
int current_modifier_state_;
int current_modifier_state_ = ui::EF_NONE;
// The Aura window that is currently under the cursor. We need to manually
// keep track of this because Windows will only call our drag enter method
// once when the user enters the associated X Window. But inside that X
// Window there could be multiple aura windows, so we need to generate drag
// enter events for them.
aura::Window* target_window_;
aura::Window* target_window_ = nullptr;
// Because Xdnd messages don't contain the position in messages other than
// the XdndPosition message, we must manually keep track of the last position
......@@ -235,7 +236,7 @@ class VIEWS_EXPORT DesktopDragDropClientAuraX11
// In the Xdnd protocol, we aren't supposed to send another XdndPosition
// message until we have received a confirming XdndStatus message.
bool waiting_on_status_;
bool waiting_on_status_ = false;
// If we would send an XdndPosition message while we're waiting for an
// XdndStatus response, we need to cache the latest details we'd send.
......@@ -249,12 +250,12 @@ class VIEWS_EXPORT DesktopDragDropClientAuraX11
// When the mouse is released, we need to wait for the last XdndStatus message
// only if we have previously received a status message from
// |source_current_window_|.
bool status_received_since_enter_;
bool status_received_since_enter_ = false;
// Source side information.
ui::OSExchangeDataProviderAuraX11 const* source_provider_;
::Window source_current_window_;
SourceState source_state_;
ui::OSExchangeDataProviderAuraX11 const* source_provider_ = nullptr;
::Window source_current_window_ = x11::None;
SourceState source_state_ = SOURCE_STATE_OTHER;
// The current drag-drop client that has an active operation. Since we have
// multiple root windows and multiple DesktopDragDropClientAuraX11 instances
......@@ -262,14 +263,15 @@ class VIEWS_EXPORT DesktopDragDropClientAuraX11
static DesktopDragDropClientAuraX11* g_current_drag_drop_client;
// The operation bitfield as requested by StartDragAndDrop.
int drag_operation_;
int drag_operation_ = 0;
// We offer the other window a list of possible operations,
// XdndActionsList. This is the requested action from the other window. This
// is DRAG_NONE if we haven't sent out an XdndPosition message yet, haven't
// yet received an XdndStatus or if the other window has told us that there's
// no action that we can agree on.
ui::DragDropTypes::DragOperation negotiated_operation_;
ui::DragDropTypes::DragOperation negotiated_operation_ =
ui::DragDropTypes::DRAG_NONE;
// Ends the move loop if the target is too slow to respond after the mouse is
// released.
......@@ -284,7 +286,7 @@ class VIEWS_EXPORT DesktopDragDropClientAuraX11
// The offset of |drag_widget_| relative to the mouse position.
gfx::Vector2d drag_widget_offset_;
base::WeakPtrFactory<DesktopDragDropClientAuraX11> weak_ptr_factory_;
base::WeakPtrFactory<DesktopDragDropClientAuraX11> weak_ptr_factory_{this};
DISALLOW_COPY_AND_ASSIGN(DesktopDragDropClientAuraX11);
};
......
......@@ -92,7 +92,7 @@ class TestMoveLoop : public X11MoveLoop {
// Ends the move loop.
base::OnceClosure quit_closure_;
bool is_running_;
bool is_running_ = false;
};
// Implementation of DesktopDragDropClientAuraX11 which short circuits
......@@ -118,10 +118,10 @@ class SimpleTestDragDropClient : public DesktopDragDropClientAuraX11 {
XID FindWindowFor(const gfx::Point& screen_point) override;
// The XID of the window which is simulated to be the topmost window.
XID target_xid_;
XID target_xid_ = x11::None;
// The move loop. Not owned.
TestMoveLoop* loop_;
TestMoveLoop* loop_ = nullptr;
DISALLOW_COPY_AND_ASSIGN(SimpleTestDragDropClient);
};
......@@ -216,9 +216,7 @@ void ClientMessageEventCollector::RecordEvent(
// TestMoveLoop
TestMoveLoop::TestMoveLoop(X11MoveLoopDelegate* delegate)
: delegate_(delegate),
is_running_(false) {
}
: delegate_(delegate) {}
TestMoveLoop::~TestMoveLoop() = default;
......@@ -256,9 +254,7 @@ SimpleTestDragDropClient::SimpleTestDragDropClient(
: DesktopDragDropClientAuraX11(window,
cursor_manager,
gfx::GetXDisplay(),
window->GetHost()->GetAcceleratedWidget()),
target_xid_(x11::None),
loop_(nullptr) {}
window->GetHost()->GetAcceleratedWidget()) {}
SimpleTestDragDropClient::~SimpleTestDragDropClient() = default;
......@@ -779,12 +775,7 @@ namespace {
// keeps track of the most recent drag-drop event.
class TestDragDropDelegate : public aura::client::DragDropDelegate {
public:
TestDragDropDelegate()
: num_enters_(0),
num_updates_(0),
num_exits_(0),
num_drops_(0),
last_event_flags_(0) {}
TestDragDropDelegate() = default;
~TestDragDropDelegate() override = default;
int num_enters() const { return num_enters_; }
......@@ -822,13 +813,13 @@ class TestDragDropDelegate : public aura::client::DragDropDelegate {
return ui::DragDropTypes::DRAG_COPY;
}
int num_enters_;
int num_updates_;
int num_exits_;
int num_drops_;
int num_enters_ = 0;
int num_updates_ = 0;
int num_exits_ = 0;
int num_drops_ = 0;
gfx::Point last_event_mouse_position_;
int last_event_flags_;
int last_event_flags_ = 0;
DISALLOW_COPY_AND_ASSIGN(TestDragDropDelegate);
};
......
......@@ -137,30 +137,9 @@ DesktopWindowTreeHostX11::DesktopWindowTreeHostX11(
internal::NativeWidgetDelegate* native_widget_delegate,
DesktopNativeWidgetAura* desktop_native_widget_aura)
: xdisplay_(gfx::GetXDisplay()),
xwindow_(0),
x_root_window_(DefaultRootWindow(xdisplay_)),
window_mapped_in_server_(false),
window_mapped_in_client_(false),
is_fullscreen_(false),
is_always_on_top_(false),
use_native_frame_(false),
should_maximize_after_map_(false),
use_argb_visual_(false),
drag_drop_client_(nullptr),
native_widget_delegate_(native_widget_delegate),
desktop_native_widget_aura_(desktop_native_widget_aura),
window_parent_(nullptr),
custom_window_shape_(false),
urgency_hint_set_(false),
has_pointer_grab_(false),
activatable_(true),
override_redirect_(false),
has_pointer_(false),
has_window_focus_(false),
has_pointer_focus_(false),
modal_dialog_counter_(0),
close_widget_factory_(this),
weak_factory_(this) {}
desktop_native_widget_aura_(desktop_native_widget_aura) {}
DesktopWindowTreeHostX11::~DesktopWindowTreeHostX11() {
window()->ClearProperty(kHostForRootWindow);
......
......@@ -308,7 +308,7 @@ class VIEWS_EXPORT DesktopWindowTreeHostX11
// X11 things
// The display and the native X window hosting the root window.
XDisplay* xdisplay_;
::Window xwindow_;
::Window xwindow_ = 0;
// Events selected on |xwindow_|.
std::unique_ptr<ui::XScopedEventSelector> xwindow_events_;
......@@ -317,10 +317,10 @@ class VIEWS_EXPORT DesktopWindowTreeHostX11
::Window x_root_window_;
// Whether the window is mapped with respect to the X server.
bool window_mapped_in_server_;
bool window_mapped_in_server_ = false;
// Whether the window is visible with respect to Aura.
bool window_mapped_in_client_;
bool window_mapped_in_client_ = false;
// The bounds of |xwindow_|.
gfx::Rect bounds_in_pixels_;
......@@ -351,21 +351,21 @@ class VIEWS_EXPORT DesktopWindowTreeHostX11
base::flat_set<XAtom> window_properties_;
// Whether |xwindow_| was requested to be fullscreen via SetFullscreen().
bool is_fullscreen_;
bool is_fullscreen_ = false;
// True if the window should stay on top of most other windows.
bool is_always_on_top_;
bool is_always_on_top_ = false;
// True if the window has title-bar / borders provided by the window manager.
bool use_native_frame_;
bool use_native_frame_ = false;
// True if a Maximize() call should be done after mapping the window.
bool should_maximize_after_map_;
bool should_maximize_after_map_ = false;
// Whether we used an ARGB visual for our window.
bool use_argb_visual_;
bool use_argb_visual_ = false;
DesktopDragDropClientAuraX11* drag_drop_client_;
DesktopDragDropClientAuraX11* drag_drop_client_ = nullptr;
std::unique_ptr<ui::EventHandler> x11_non_client_event_filter_;
std::unique_ptr<X11DesktopWindowMoveClient> x11_window_move_client_;
......@@ -378,7 +378,7 @@ class VIEWS_EXPORT DesktopWindowTreeHostX11
// We can optionally have a parent which can order us to close, or own
// children who we're responsible for closing when we CloseNow().
DesktopWindowTreeHostX11* window_parent_;
DesktopWindowTreeHostX11* window_parent_ = nullptr;
std::set<DesktopWindowTreeHostX11*> window_children_;
base::ObserverList<DesktopWindowTreeHostObserverX11>::Unchecked
......@@ -389,7 +389,7 @@ class VIEWS_EXPORT DesktopWindowTreeHostX11
window_shape_;
// Whether |window_shape_| was set via SetShape().
bool custom_window_shape_;
bool custom_window_shape_ = false;
// The size of the window manager provided borders (if any).
gfx::Insets native_window_frame_borders_in_pixels_;
......@@ -408,16 +408,16 @@ class VIEWS_EXPORT DesktopWindowTreeHostX11
// by setting the urgency hint with the window manager, which can draw
// attention to the window or completely ignore the hint. We stop flashing
// the frame when |xwindow_| gains focus or handles a mouse button event.
bool urgency_hint_set_;
bool urgency_hint_set_ = false;
// Does |xwindow_| have the pointer grab (XI2 or normal)?
bool has_pointer_grab_;
bool has_pointer_grab_ = false;
// Is this window able to receive focus?
bool activatable_;
bool activatable_ = true;
// Was this window initialized with the override_redirect window attribute?
bool override_redirect_;
bool override_redirect_ = false;
// The focus-tracking state variables are as described in
// gtk/docs/focus_tracking.txt
......@@ -427,27 +427,27 @@ class VIEWS_EXPORT DesktopWindowTreeHostX11
// !|ignore_keyboard_input_|
// Is the pointer in |xwindow_| or one of its children?
bool has_pointer_;
bool has_pointer_ = false;
// Is |xwindow_| or one of its children focused?
bool has_window_focus_;
bool has_window_focus_ = false;
// (An ancestor window or the PointerRoot is focused) && |has_pointer_|.
// |has_pointer_focus_| == true is the odd case where we will receive keyboard
// input when |has_window_focus_| == false. |has_window_focus_| and
// |has_pointer_focus_| are mutually exclusive.
bool has_pointer_focus_;
bool has_pointer_focus_ = false;
// X11 does not support defocusing windows; you can only focus a different
// window. If we would like to be defocused, we just ignore keyboard input we
// no longer care about.
bool ignore_keyboard_input_;
bool ignore_keyboard_input_ = false;
// Used for tracking activation state in {Before|After}ActivationStateChanged.
bool was_active_;
bool had_pointer_;
bool had_pointer_grab_;
bool had_window_focus_;
bool was_active_ = false;
bool had_pointer_ = false;
bool had_pointer_grab_ = false;
bool had_window_focus_ = false;
// Captures system key events when keyboard lock is requested.
std::unique_ptr<ui::KeyboardHook> keyboard_hook_;
......@@ -456,10 +456,10 @@ class VIEWS_EXPORT DesktopWindowTreeHostX11
std::unique_ptr<aura::ScopedWindowTargeter> targeter_for_modal_;
uint32_t modal_dialog_counter_;
uint32_t modal_dialog_counter_ = 0;
base::WeakPtrFactory<DesktopWindowTreeHostX11> close_widget_factory_;
base::WeakPtrFactory<DesktopWindowTreeHostX11> weak_factory_;
base::WeakPtrFactory<DesktopWindowTreeHostX11> close_widget_factory_{this};
base::WeakPtrFactory<DesktopWindowTreeHostX11> weak_factory_{this};
DISALLOW_COPY_AND_ASSIGN(DesktopWindowTreeHostX11);
};
......
......@@ -52,8 +52,7 @@ class ActivationWaiter : public X11PropertyChangeWaiter {
// An event handler which counts the number of mouse moves it has seen.
class MouseMoveCounterHandler : public ui::EventHandler {
public:
MouseMoveCounterHandler() : count_(0) {
}
MouseMoveCounterHandler() = default;
~MouseMoveCounterHandler() override = default;
// ui::EventHandler:
......@@ -67,7 +66,7 @@ class MouseMoveCounterHandler : public ui::EventHandler {
}
private:
int count_;
int count_ = 0;
DISALLOW_COPY_AND_ASSIGN(MouseMoveCounterHandler);
};
......
......@@ -24,7 +24,7 @@
namespace views {
WindowEventFilter::WindowEventFilter(DesktopWindowTreeHost* window_tree_host)
: window_tree_host_(window_tree_host), click_component_(HTNOWHERE) {}
: window_tree_host_(window_tree_host) {}
WindowEventFilter::~WindowEventFilter() = default;
......
......@@ -7,6 +7,7 @@
#include "base/compiler_specific.h"
#include "base/macros.h"
#include "ui/base/hit_test.h"
#include "ui/events/event_handler.h"
#include "ui/views/views_export.h"
......@@ -59,7 +60,7 @@ class VIEWS_EXPORT WindowEventFilter : public ui::EventHandler {
// ui::EF_IS_DOUBLE_CLICK event to no longer be the same as that of the
// initial click. Acting on a double click should only occur for matching
// components.
int click_component_;
int click_component_ = HTNOWHERE;
// A handler, which is used for interactive move/resize events if set and
// unless MaybeDispatchHostWindowDragMovement is overridden by a derived
......
......@@ -14,8 +14,7 @@
namespace views {
X11DesktopWindowMoveClient::X11DesktopWindowMoveClient()
: move_loop_(this), host_(nullptr) {}
X11DesktopWindowMoveClient::X11DesktopWindowMoveClient() = default;
X11DesktopWindowMoveClient::~X11DesktopWindowMoveClient() = default;
......
......@@ -42,11 +42,11 @@ class VIEWS_EXPORT X11DesktopWindowMoveClient
void EndMoveLoop() override;
private:
X11WholeScreenMoveLoop move_loop_;
X11WholeScreenMoveLoop move_loop_{this};
// We need to keep track of this so we can actually move it when reacting to
// mouse events.
aura::WindowTreeHost* host_;
aura::WindowTreeHost* host_ = nullptr;
// Our cursor offset from the top left window origin when the drag
// started. Used to calculate the window's new bounds relative to the current
......
......@@ -8,12 +8,11 @@
#include "ui/aura/client/screen_position_client.h"
#include "ui/aura/window.h"
#include "ui/gfx/x/x11.h"
#include "ui/views/widget/desktop_aura/desktop_window_tree_host_x11.h"
namespace views {
X11TopmostWindowFinder::X11TopmostWindowFinder() : toplevel_(x11::None) {}
X11TopmostWindowFinder::X11TopmostWindowFinder() = default;
X11TopmostWindowFinder::~X11TopmostWindowFinder() = default;
......
......@@ -10,6 +10,7 @@
#include "base/macros.h"
#include "ui/base/x/x11_util.h"
#include "ui/gfx/geometry/point.h"
#include "ui/gfx/x/x11.h"
#include "ui/views/views_export.h"
namespace aura {
......@@ -44,7 +45,7 @@ class VIEWS_EXPORT X11TopmostWindowFinder
gfx::Point screen_loc_in_pixels_;
std::set<aura::Window*> ignore_;
XID toplevel_;
XID toplevel_ = x11::None;
DISALLOW_COPY_AND_ASSIGN(X11TopmostWindowFinder);
};
......
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