Refactoring: use C++11 class member variable initialization

This commit is contained in:
Milan Burda 2018-05-22 00:18:38 +02:00
parent ee57c95aa6
commit 2337237d58
94 changed files with 218 additions and 377 deletions

View file

@ -42,7 +42,6 @@ class GtkMessageBox : public NativeWindowObserver {
const std::string& checkbox_label,
bool checkbox_checked)
: cancel_id_(cancel_id),
checkbox_checked_(false),
parent_(static_cast<NativeWindow*>(parent_window)) {
// Create dialog.
dialog_ =
@ -160,9 +159,9 @@ class GtkMessageBox : public NativeWindowObserver {
atom::UnresponsiveSuppressor unresponsive_suppressor_;
// The id to return when the dialog is closed without pressing buttons.
int cancel_id_;
int cancel_id_ = 0;
bool checkbox_checked_;
bool checkbox_checked_ = false;
NativeWindow* parent_;
GtkWidget* dialog_;

View file

@ -46,7 +46,7 @@ class TrayIconCocoa : public TrayIcon, public AtomMenuModel::Observer {
base::scoped_nsobject<AtomMenuController> menu_;
// Used for unregistering observer.
AtomMenuModel* menu_model_; // weak ref.
AtomMenuModel* menu_model_ = nullptr; // weak ref.
DISALLOW_COPY_AND_ASSIGN(TrayIconCocoa);
};

View file

@ -291,7 +291,8 @@ const CGFloat kVerticalTitleMargin = 2;
// If we are ignoring double click events, we should ignore the `clickCount`
// value and immediately emit a click event.
BOOL shouldBeHandledAsASingleClick = (event.clickCount == 1) || ignoreDoubleClickEvents_;
BOOL shouldBeHandledAsASingleClick =
(event.clickCount == 1) || ignoreDoubleClickEvents_;
if (shouldBeHandledAsASingleClick)
trayIcon_->NotifyClicked(
gfx::ScreenRectFromNSRect(event.window.frame),
@ -299,7 +300,8 @@ const CGFloat kVerticalTitleMargin = 2;
ui::EventFlagsFromModifiers([event modifierFlags]));
// Double click event.
BOOL shouldBeHandledAsADoubleClick = (event.clickCount == 2) && !ignoreDoubleClickEvents_;
BOOL shouldBeHandledAsADoubleClick =
(event.clickCount == 2) && !ignoreDoubleClickEvents_;
if (shouldBeHandledAsADoubleClick)
trayIcon_->NotifyDoubleClicked(
gfx::ScreenRectFromNSRect(event.window.frame),
@ -417,7 +419,7 @@ const CGFloat kVerticalTitleMargin = 2;
namespace atom {
TrayIconCocoa::TrayIconCocoa() : menu_model_(nullptr) {}
TrayIconCocoa::TrayIconCocoa() {}
TrayIconCocoa::~TrayIconCocoa() {
[status_item_view_ removeItem];

View file

@ -25,12 +25,7 @@ void AutofillPopupChildView::GetAccessibleNodeData(ui::AXNodeData* node_data) {
AutofillPopupView::AutofillPopupView(AutofillPopup* popup,
views::Widget* parent_widget)
: popup_(popup),
parent_widget_(parent_widget),
#if defined(ENABLE_OSR)
view_proxy_(nullptr),
#endif
weak_ptr_factory_(this) {
: popup_(popup), parent_widget_(parent_widget), weak_ptr_factory_(this) {
CreateChildViews();
SetFocusBehavior(FocusBehavior::ALWAYS);
set_drag_controller(this);

View file

@ -22,7 +22,7 @@ const int kResizeAreaCornerSize = 16;
// static
const char FramelessView::kViewClassName[] = "FramelessView";
FramelessView::FramelessView() : window_(NULL), frame_(NULL) {}
FramelessView::FramelessView() {}
FramelessView::~FramelessView() {}

View file

@ -45,8 +45,8 @@ class FramelessView : public views::NonClientFrameView {
const char* GetClassName() const override;
// Not owned.
NativeWindowViews* window_;
views::Widget* frame_;
NativeWindowViews* window_ = nullptr;
views::Widget* frame_ = nullptr;
private:
DISALLOW_COPY_AND_ASSIGN(FramelessView);

View file

@ -181,8 +181,7 @@ std::string GetMenuModelStatus(AtomMenuModel* model) {
GlobalMenuBarX11::GlobalMenuBarX11(NativeWindowViews* window)
: window_(window),
xid_(window_->GetNativeWindow()->GetHost()->GetAcceleratedWidget()),
server_(NULL) {
xid_(window_->GetNativeWindow()->GetHost()->GetAcceleratedWidget()) {
EnsureMethodsLoaded();
if (server_new)
InitServer(xid_);

View file

@ -71,7 +71,7 @@ class GlobalMenuBarX11 {
NativeWindowViews* window_;
gfx::AcceleratedWidget xid_;
DbusmenuServer* server_;
DbusmenuServer* server_ = nullptr;
DISALLOW_COPY_AND_ASSIGN(GlobalMenuBarX11);
};

View file

@ -26,7 +26,7 @@ const SkColor kDefaultColor = SkColorSetARGB(255, 233, 233, 233);
const char MenuBar::kViewClassName[] = "ElectronMenuBar";
MenuBar::MenuBar(views::View* window)
: background_color_(kDefaultColor), window_(window), menu_model_(NULL) {
: background_color_(kDefaultColor), window_(window) {
RefreshColorCache();
UpdateViewColors();
SetLayoutManager(new views::BoxLayout(views::BoxLayout::kHorizontal));

View file

@ -72,8 +72,8 @@ class MenuBar : public views::View,
SkColor disabled_color_;
#endif
views::View* window_;
AtomMenuModel* menu_model_;
views::View* window_ = nullptr;
AtomMenuModel* menu_model_ = nullptr;
View* FindAccelChild(base::char16 key);

View file

@ -22,13 +22,6 @@ SubmenuButton::SubmenuButton(const base::string16& title,
: views::MenuButton(gfx::RemoveAcceleratorChar(title, '&', NULL, NULL),
menu_button_listener,
false),
accelerator_(0),
show_underline_(false),
underline_start_(0),
underline_end_(0),
text_width_(0),
text_height_(0),
underline_color_(SK_ColorBLACK),
background_color_(background_color) {
#if defined(OS_LINUX)
// Dont' use native style border.

View file

@ -39,15 +39,15 @@ class SubmenuButton : public views::MenuButton {
int index,
int* pos) const;
base::char16 accelerator_;
base::char16 accelerator_ = 0;
bool show_underline_;
bool show_underline_ = false;
int underline_start_;
int underline_end_;
int text_width_;
int text_height_;
SkColor underline_color_;
int underline_start_ = 0;
int underline_end_ = 0;
int text_width_ = 0;
int text_height_ = 0;
SkColor underline_color_ = SK_ColorBLACK;
SkColor background_color_;
DISALLOW_COPY_AND_ASSIGN(SubmenuButton);

View file

@ -56,7 +56,7 @@ void PopulateStreamInfo(base::DictionaryValue* stream_info,
} // namespace
PdfViewerHandler::PdfViewerHandler(const std::string& src)
: stream_(nullptr), original_url_(src) {}
: original_url_(src) {}
PdfViewerHandler::~PdfViewerHandler() {
RemoveObserver();

View file

@ -53,7 +53,7 @@ class PdfViewerHandler : public content::WebUIMessageHandler,
void AddObserver();
void RemoveObserver();
std::unique_ptr<base::Value> initialize_callback_id_;
content::StreamInfo* stream_;
content::StreamInfo* stream_ = nullptr;
std::string original_url_;
DISALLOW_COPY_AND_ASSIGN(PdfViewerHandler);

View file

@ -19,11 +19,7 @@
namespace atom {
NotifyIcon::NotifyIcon(NotifyIconHost* host, UINT id, HWND window, UINT message)
: host_(host),
icon_id_(id),
window_(window),
message_id_(message),
menu_model_(NULL) {
: host_(host), icon_id_(id), window_(window), message_id_(message) {
NOTIFYICONDATA icon_data;
InitIconData(&icon_data);
icon_data.uFlags |= NIF_MESSAGE;

View file

@ -79,7 +79,7 @@ class NotifyIcon : public TrayIcon {
base::win::ScopedHICON icon_;
// The context menu.
AtomMenuModel* menu_model_;
AtomMenuModel* menu_model_ = nullptr;
// Context menu associated with this icon (if any).
std::unique_ptr<views::MenuRunner> menu_runner_;

View file

@ -47,8 +47,7 @@ int GetKeyboardModifers() {
} // namespace
NotifyIconHost::NotifyIconHost()
: next_icon_id_(1), atom_(0), instance_(NULL), window_(NULL) {
NotifyIconHost::NotifyIconHost() {
// Register our window class
WNDCLASSEX window_class;
base::win::InitializeWindowClass(

View file

@ -40,23 +40,23 @@ class NotifyIconHost {
UINT NextIconId();
// The unique icon ID we will assign to the next icon.
UINT next_icon_id_;
UINT next_icon_id_ = 1;
// List containing all active NotifyIcons.
NotifyIcons notify_icons_;
// The window class of |window_|.
ATOM atom_;
ATOM atom_ = 0;
// The handle of the module that contains the window procedure of |window_|.
HMODULE instance_;
HMODULE instance_ = nullptr;
// The window used for processing events.
HWND window_;
HWND window_ = nullptr;
// The message ID of the "TaskbarCreated" message, sent to us when we need to
// reset our status icons.
UINT taskbar_created_message_;
UINT taskbar_created_message_ = 0;
DISALLOW_COPY_AND_ASSIGN(NotifyIconHost);
};

View file

@ -50,7 +50,7 @@ bool GetThumbarButtonFlags(const std::vector<std::string>& flags,
} // namespace
TaskbarHost::TaskbarHost() : thumbar_buttons_added_(false) {}
TaskbarHost::TaskbarHost() {}
TaskbarHost::~TaskbarHost() {}

View file

@ -69,7 +69,7 @@ class TaskbarHost {
base::win::ScopedComPtr<ITaskbarList3> taskbar_;
// Whether we have already added the buttons to thumbar.
bool thumbar_buttons_added_;
bool thumbar_buttons_added_ = false;
DISALLOW_COPY_AND_ASSIGN(TaskbarHost);
};

View file

@ -12,10 +12,7 @@
namespace atom {
WindowStateWatcher::WindowStateWatcher(NativeWindowViews* window)
: window_(window),
widget_(window->GetAcceleratedWidget()),
was_minimized_(false),
was_maximized_(false) {
: window_(window), widget_(window->GetAcceleratedWidget()) {
ui::PlatformEventSource::GetInstance()->AddPlatformEventObserver(this);
}

View file

@ -27,8 +27,8 @@ class WindowStateWatcher : public ui::PlatformEventObserver {
NativeWindowViews* window_;
gfx::AcceleratedWidget widget_;
bool was_minimized_;
bool was_maximized_;
bool was_minimized_ = false;
bool was_maximized_ = false;
DISALLOW_COPY_AND_ASSIGN(WindowStateWatcher);
};