Initialize more fwl classes in header.
Provide initializers for scalars even if we think they will be changed
before use. Tidy/pack while at it, prefer scalars with initializers
before classes which initialize themselves.
Change-Id: If766cbc3445222e0eeb1676be73e6ca88282974c
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/65012
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
diff --git a/fxbarcode/BC_Library.h b/fxbarcode/BC_Library.h
index af38a81..5f1af4d 100644
--- a/fxbarcode/BC_Library.h
+++ b/fxbarcode/BC_Library.h
@@ -7,7 +7,9 @@
#ifndef FXBARCODE_BC_LIBRARY_H_
#define FXBARCODE_BC_LIBRARY_H_
-enum BC_TEXT_LOC {
+#include <stdint.h>
+
+enum BC_TEXT_LOC : uint8_t {
BC_TEXT_LOC_NONE = 0,
BC_TEXT_LOC_ABOVE,
BC_TEXT_LOC_BELOW,
@@ -15,9 +17,12 @@
BC_TEXT_LOC_BELOWEMBED
};
-enum BC_CHAR_ENCODING { CHAR_ENCODING_UTF8 = 0, CHAR_ENCODING_UNICODE };
+enum BC_CHAR_ENCODING : uint8_t {
+ CHAR_ENCODING_UTF8 = 0,
+ CHAR_ENCODING_UNICODE
+};
-enum BC_TYPE {
+enum BC_TYPE : int8_t {
BC_UNKNOWN = -1,
BC_CODE39 = 0,
BC_CODABAR,
diff --git a/xfa/fwl/cfwl_barcode.h b/xfa/fwl/cfwl_barcode.h
index 64a21d3..d2cd716 100644
--- a/xfa/fwl/cfwl_barcode.h
+++ b/xfa/fwl/cfwl_barcode.h
@@ -69,21 +69,21 @@
void GenerateBarcodeImageCache();
void CreateBarcodeEngine();
- std::unique_ptr<CFX_Barcode> m_pBarcodeEngine;
- Status m_eStatus = Status::kNormal;
BC_TYPE m_type = BC_UNKNOWN;
- BC_CHAR_ENCODING m_eCharEncoding;
- int32_t m_nModuleHeight;
- int32_t m_nModuleWidth;
- int32_t m_nDataLength;
- bool m_bCalChecksum;
- bool m_bPrintChecksum;
- BC_TEXT_LOC m_eTextLocation;
- int8_t m_nWideNarrowRatio;
- char m_cStartChar;
- char m_cEndChar;
- int32_t m_nECLevel;
+ BC_CHAR_ENCODING m_eCharEncoding = CHAR_ENCODING_UTF8;
+ BC_TEXT_LOC m_eTextLocation = BC_TEXT_LOC_NONE;
+ Status m_eStatus = Status::kNormal;
+ bool m_bCalChecksum = false;
+ bool m_bPrintChecksum = false;
+ char m_cStartChar = 0;
+ char m_cEndChar = 0;
+ int8_t m_nWideNarrowRatio = 1;
+ int32_t m_nModuleHeight = -1;
+ int32_t m_nModuleWidth = -1;
+ int32_t m_nDataLength = 0;
+ int32_t m_nECLevel = 0;
uint32_t m_dwAttributeMask = 0;
+ std::unique_ptr<CFX_Barcode> m_pBarcodeEngine;
};
#endif // XFA_FWL_CFWL_BARCODE_H_
diff --git a/xfa/fwl/cfwl_combolist.cpp b/xfa/fwl/cfwl_combolist.cpp
index 7c30bdf..d25f312 100644
--- a/xfa/fwl/cfwl_combolist.cpp
+++ b/xfa/fwl/cfwl_combolist.cpp
@@ -21,7 +21,7 @@
const CFWL_App* app,
std::unique_ptr<CFWL_WidgetProperties> properties,
CFWL_Widget* pOuter)
- : CFWL_ListBox(app, std::move(properties), pOuter), m_bNotifyOwner(true) {
+ : CFWL_ListBox(app, std::move(properties), pOuter) {
ASSERT(pOuter);
}
diff --git a/xfa/fwl/cfwl_combolist.h b/xfa/fwl/cfwl_combolist.h
index 24a1012..c275c72 100644
--- a/xfa/fwl/cfwl_combolist.h
+++ b/xfa/fwl/cfwl_combolist.h
@@ -35,7 +35,7 @@
bool OnDropListKey(CFWL_MessageKey* pKey);
void OnDropListKeyDown(CFWL_MessageKey* pKey);
- bool m_bNotifyOwner;
+ bool m_bNotifyOwner = true;
};
#endif // XFA_FWL_CFWL_COMBOLIST_H_
diff --git a/xfa/fwl/cfwl_eventmouse.h b/xfa/fwl/cfwl_eventmouse.h
index 273856f..e7982fb 100644
--- a/xfa/fwl/cfwl_eventmouse.h
+++ b/xfa/fwl/cfwl_eventmouse.h
@@ -16,7 +16,7 @@
CFWL_EventMouse(CFWL_Widget* pSrcTarget, CFWL_Widget* pDstTarget);
~CFWL_EventMouse() override;
- FWL_MouseCommand m_dwCmd;
+ FWL_MouseCommand m_dwCmd = FWL_MouseCommand::LeftButtonDown;
};
#endif // XFA_FWL_CFWL_EVENTMOUSE_H_
diff --git a/xfa/fwl/cfwl_eventscroll.h b/xfa/fwl/cfwl_eventscroll.h
index 0491ad7..78960c8 100644
--- a/xfa/fwl/cfwl_eventscroll.h
+++ b/xfa/fwl/cfwl_eventscroll.h
@@ -27,8 +27,8 @@
explicit CFWL_EventScroll(CFWL_Widget* pSrcTarget);
~CFWL_EventScroll() override;
- Code m_iScrollCode;
- float m_fPos;
+ Code m_iScrollCode = Code::None;
+ float m_fPos = 0.0f;
};
#endif // XFA_FWL_CFWL_EVENTSCROLL_H_
diff --git a/xfa/fwl/cfwl_eventselectchanged.h b/xfa/fwl/cfwl_eventselectchanged.h
index 176cb87..d4b68b3 100644
--- a/xfa/fwl/cfwl_eventselectchanged.h
+++ b/xfa/fwl/cfwl_eventselectchanged.h
@@ -15,12 +15,12 @@
~CFWL_EventSelectChanged() override;
// Used by ComboBox.
- bool bLButtonUp;
+ bool bLButtonUp = false;
// Used by DateTimePIcker
- int32_t iYear;
- int32_t iMonth;
- int32_t iDay;
+ int32_t iYear = -1;
+ int32_t iMonth = -1;
+ int32_t iDay = -1;
};
#endif // XFA_FWL_CFWL_EVENTSELECTCHANGED_H_
diff --git a/xfa/fwl/cfwl_eventtarget.cpp b/xfa/fwl/cfwl_eventtarget.cpp
index d6a717d..4b3d87c 100644
--- a/xfa/fwl/cfwl_eventtarget.cpp
+++ b/xfa/fwl/cfwl_eventtarget.cpp
@@ -10,7 +10,7 @@
#include "xfa/fwl/ifwl_widgetdelegate.h"
CFWL_EventTarget::CFWL_EventTarget(CFWL_Widget* pListener)
- : m_pListener(pListener), m_bValid(true) {}
+ : m_pListener(pListener) {}
CFWL_EventTarget::~CFWL_EventTarget() {}
diff --git a/xfa/fwl/cfwl_eventtarget.h b/xfa/fwl/cfwl_eventtarget.h
index b5a8bdb..f614319 100644
--- a/xfa/fwl/cfwl_eventtarget.h
+++ b/xfa/fwl/cfwl_eventtarget.h
@@ -26,9 +26,9 @@
void FlagInvalid() { m_bValid = false; }
private:
+ bool m_bValid = true;
+ CFWL_Widget* const m_pListener;
std::set<CFWL_Widget*> m_widgets;
- CFWL_Widget* m_pListener;
- bool m_bValid;
};
#endif // XFA_FWL_CFWL_EVENTTARGET_H_
diff --git a/xfa/fwl/cfwl_eventvalidate.h b/xfa/fwl/cfwl_eventvalidate.h
index 7d88b97..26e3c7f 100644
--- a/xfa/fwl/cfwl_eventvalidate.h
+++ b/xfa/fwl/cfwl_eventvalidate.h
@@ -14,8 +14,8 @@
explicit CFWL_EventValidate(CFWL_Widget* pSrcTarget);
~CFWL_EventValidate() override;
+ bool bValidate = false;
WideString wsInsert;
- bool bValidate;
};
#endif // XFA_FWL_CFWL_EVENTVALIDATE_H_
diff --git a/xfa/fwl/cfwl_messagekey.h b/xfa/fwl/cfwl_messagekey.h
index 3b46531..b122647 100644
--- a/xfa/fwl/cfwl_messagekey.h
+++ b/xfa/fwl/cfwl_messagekey.h
@@ -21,9 +21,9 @@
uint32_t keycode);
~CFWL_MessageKey() override;
- FWL_KeyCommand m_dwCmd;
- uint32_t m_dwFlags;
- uint32_t m_dwKeyCode;
+ const FWL_KeyCommand m_dwCmd;
+ const uint32_t m_dwFlags;
+ const uint32_t m_dwKeyCode;
};
#endif // XFA_FWL_CFWL_MESSAGEKEY_H_
diff --git a/xfa/fwl/cfwl_messagemouse.h b/xfa/fwl/cfwl_messagemouse.h
index b0cea2a..10c298a 100644
--- a/xfa/fwl/cfwl_messagemouse.h
+++ b/xfa/fwl/cfwl_messagemouse.h
@@ -34,7 +34,7 @@
CFX_PointF pos);
~CFWL_MessageMouse() override;
- FWL_MouseCommand m_dwCmd;
+ const FWL_MouseCommand m_dwCmd;
uint32_t m_dwFlags = 0;
CFX_PointF m_pos;
};
diff --git a/xfa/fwl/cfwl_messagemousewheel.h b/xfa/fwl/cfwl_messagemousewheel.h
index 8eb4be7..9908951 100644
--- a/xfa/fwl/cfwl_messagemousewheel.h
+++ b/xfa/fwl/cfwl_messagemousewheel.h
@@ -20,7 +20,7 @@
CFX_PointF delta);
~CFWL_MessageMouseWheel() override;
- uint32_t m_dwFlags;
+ const uint32_t m_dwFlags;
CFX_PointF m_pos;
CFX_PointF m_delta;
};
diff --git a/xfa/fwl/cfwl_pushbutton.cpp b/xfa/fwl/cfwl_pushbutton.cpp
index 980a89d..7806399 100644
--- a/xfa/fwl/cfwl_pushbutton.cpp
+++ b/xfa/fwl/cfwl_pushbutton.cpp
@@ -22,8 +22,7 @@
#include "xfa/fwl/ifwl_themeprovider.h"
CFWL_PushButton::CFWL_PushButton(const CFWL_App* app)
- : CFWL_Widget(app, pdfium::MakeUnique<CFWL_WidgetProperties>(), nullptr),
- m_bBtnDown(false) {}
+ : CFWL_Widget(app, pdfium::MakeUnique<CFWL_WidgetProperties>(), nullptr) {}
CFWL_PushButton::~CFWL_PushButton() {}
diff --git a/xfa/fwl/cfwl_pushbutton.h b/xfa/fwl/cfwl_pushbutton.h
index 7c68017..925dbb6 100644
--- a/xfa/fwl/cfwl_pushbutton.h
+++ b/xfa/fwl/cfwl_pushbutton.h
@@ -44,9 +44,9 @@
void OnMouseLeave(CFWL_MessageMouse* pMsg);
void OnKeyDown(CFWL_MessageKey* pMsg);
+ bool m_bBtnDown = false;
CFX_RectF m_rtClient;
CFX_RectF m_rtCaption;
- bool m_bBtnDown;
};
#endif // XFA_FWL_CFWL_PUSHBUTTON_H_
diff --git a/xfa/fwl/cfwl_themetext.h b/xfa/fwl/cfwl_themetext.h
index a63b8bf..f0cfaa7 100644
--- a/xfa/fwl/cfwl_themetext.h
+++ b/xfa/fwl/cfwl_themetext.h
@@ -13,12 +13,12 @@
class CFWL_ThemeText final : public CFWL_ThemePart {
public:
- CFWL_ThemeText() : m_pGraphics(nullptr) {}
+ CFWL_ThemeText() = default;
+ FDE_TextAlignment m_iTTOAlign = FDE_TextAlignment::kTopLeft;
+ CXFA_Graphics* m_pGraphics = nullptr;
WideString m_wsText;
FDE_TextStyle m_dwTTOStyles;
- FDE_TextAlignment m_iTTOAlign;
- CXFA_Graphics* m_pGraphics;
};
#endif // XFA_FWL_CFWL_THEMETEXT_H_
diff --git a/xfa/fwl/cfwl_widgetproperties.h b/xfa/fwl/cfwl_widgetproperties.h
index 5e9cf24..4148833 100644
--- a/xfa/fwl/cfwl_widgetproperties.h
+++ b/xfa/fwl/cfwl_widgetproperties.h
@@ -20,10 +20,10 @@
CFWL_WidgetProperties();
~CFWL_WidgetProperties();
- CFX_RectF m_rtWidget;
uint32_t m_dwStyles = FWL_WGTSTYLE_Child;
uint32_t m_dwStyleExes = 0;
uint32_t m_dwStates = 0;
+ CFX_RectF m_rtWidget;
UnownedPtr<IFWL_ThemeProvider> m_pThemeProvider;
CFWL_Widget* m_pParent = nullptr; // Raw, this class owned by node in tree.
};