Initialize various class members in the headers.
Then change ctors to "= default" when possible.
Also reorder members in CPWL_EditImpl to consolidate POD members.
Bug: pdfium:1669
Change-Id: I07f4ab634ee888e9a01756cf835285d29a0fced2
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/79570
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
diff --git a/core/fxcodec/jbig2/JBig2_Segment.cpp b/core/fxcodec/jbig2/JBig2_Segment.cpp
index 35cad7d..edc39eb 100644
--- a/core/fxcodec/jbig2/JBig2_Segment.cpp
+++ b/core/fxcodec/jbig2/JBig2_Segment.cpp
@@ -6,17 +6,6 @@
#include "core/fxcodec/jbig2/JBig2_Segment.h"
-CJBig2_Segment::CJBig2_Segment()
- : m_dwNumber(0),
- m_nReferred_to_segment_count(0),
- m_dwPage_association(0),
- m_dwData_length(0),
- m_dwHeader_Length(0),
- m_dwObjNum(0),
- m_dwDataOffset(0),
- m_State(JBIG2_SEGMENT_HEADER_UNPARSED),
- m_nResultType(JBIG2_VOID_POINTER) {
- m_cFlags.c = 0;
-}
+CJBig2_Segment::CJBig2_Segment() = default;
CJBig2_Segment::~CJBig2_Segment() = default;
diff --git a/core/fxcodec/jbig2/JBig2_Segment.h b/core/fxcodec/jbig2/JBig2_Segment.h
index 45e2a3d..8cf5e31 100644
--- a/core/fxcodec/jbig2/JBig2_Segment.h
+++ b/core/fxcodec/jbig2/JBig2_Segment.h
@@ -36,25 +36,24 @@
CJBig2_Segment();
~CJBig2_Segment();
- uint32_t m_dwNumber;
+ uint32_t m_dwNumber = 0;
union {
struct {
uint8_t type : 6;
uint8_t page_association_size : 1;
uint8_t deferred_non_retain : 1;
} s;
- uint8_t c;
+ uint8_t c = 0;
} m_cFlags;
- int32_t m_nReferred_to_segment_count;
+ int32_t m_nReferred_to_segment_count = 0;
std::vector<uint32_t> m_Referred_to_segment_numbers;
- uint32_t m_dwPage_association;
- uint32_t m_dwData_length;
-
- uint32_t m_dwHeader_Length;
- uint32_t m_dwObjNum;
- uint32_t m_dwDataOffset;
- JBig2_SegmentState m_State;
- JBig2_ResultType m_nResultType;
+ uint32_t m_dwPage_association = 0;
+ uint32_t m_dwData_length = 0;
+ uint32_t m_dwHeader_Length = 0;
+ uint32_t m_dwObjNum = 0;
+ uint32_t m_dwDataOffset = 0;
+ JBig2_SegmentState m_State = JBIG2_SEGMENT_HEADER_UNPARSED;
+ JBig2_ResultType m_nResultType = JBIG2_VOID_POINTER;
std::unique_ptr<CJBig2_SymbolDict> m_SymbolDict;
std::unique_ptr<CJBig2_PatternDict> m_PatternDict;
std::unique_ptr<CJBig2_Image> m_Image;
diff --git a/fpdfsdk/formfiller/cffl_button.cpp b/fpdfsdk/formfiller/cffl_button.cpp
index 233bf49..f7da69b 100644
--- a/fpdfsdk/formfiller/cffl_button.cpp
+++ b/fpdfsdk/formfiller/cffl_button.cpp
@@ -11,9 +11,7 @@
CFFL_Button::CFFL_Button(CPDFSDK_FormFillEnvironment* pFormFillEnv,
CPDFSDK_Widget* pWidget)
- : CFFL_FormFiller(pFormFillEnv, pWidget),
- m_bMouseIn(false),
- m_bMouseDown(false) {}
+ : CFFL_FormFiller(pFormFillEnv, pWidget) {}
CFFL_Button::~CFFL_Button() = default;
diff --git a/fpdfsdk/formfiller/cffl_button.h b/fpdfsdk/formfiller/cffl_button.h
index 768c144..d55b231 100644
--- a/fpdfsdk/formfiller/cffl_button.h
+++ b/fpdfsdk/formfiller/cffl_button.h
@@ -47,8 +47,8 @@
const CFX_Matrix& mtUser2Device) override;
private:
- bool m_bMouseIn;
- bool m_bMouseDown;
+ bool m_bMouseIn = false;
+ bool m_bMouseDown = false;
};
#endif // FPDFSDK_FORMFILLER_CFFL_BUTTON_H_
diff --git a/fpdfsdk/pwl/cpwl_edit_impl.cpp b/fpdfsdk/pwl/cpwl_edit_impl.cpp
index 54cd32f..69620a2 100644
--- a/fpdfsdk/pwl/cpwl_edit_impl.cpp
+++ b/fpdfsdk/pwl/cpwl_edit_impl.cpp
@@ -161,8 +161,7 @@
m_RefreshRects.emplace_back(CFX_FloatRect(new_rect));
}
-CPWL_EditImpl_Undo::CPWL_EditImpl_Undo()
- : m_nCurUndoPos(0), m_bWorking(false) {}
+CPWL_EditImpl_Undo::CPWL_EditImpl_Undo() = default;
CPWL_EditImpl_Undo::~CPWL_EditImpl_Undo() = default;
@@ -535,14 +534,7 @@
}
}
-CPWL_EditImpl::CPWL_EditImpl()
- : m_pVT(std::make_unique<CPDF_VariableText>()),
- m_bEnableScroll(false),
- m_nAlignment(0),
- m_bNotifyFlag(false),
- m_bEnableOverflow(false),
- m_bEnableRefresh(true),
- m_bEnableUndo(true) {}
+CPWL_EditImpl::CPWL_EditImpl() : m_pVT(std::make_unique<CPDF_VariableText>()) {}
CPWL_EditImpl::~CPWL_EditImpl() = default;
diff --git a/fpdfsdk/pwl/cpwl_edit_impl.h b/fpdfsdk/pwl/cpwl_edit_impl.h
index 4098af1..f8e5771 100644
--- a/fpdfsdk/pwl/cpwl_edit_impl.h
+++ b/fpdfsdk/pwl/cpwl_edit_impl.h
@@ -86,8 +86,8 @@
void RemoveTails();
std::deque<std::unique_ptr<IFX_Edit_UndoItem>> m_UndoItemStack;
- size_t m_nCurUndoPos;
- bool m_bWorking;
+ size_t m_nCurUndoPos = 0;
+ bool m_bWorking = false;
};
class IFX_Edit_UndoItem {
@@ -390,6 +390,12 @@
void AddEditUndoItem(std::unique_ptr<IFX_Edit_UndoItem> pEditUndoItem);
+ bool m_bEnableScroll = false;
+ bool m_bNotifyFlag = false;
+ bool m_bEnableOverflow = false;
+ bool m_bEnableRefresh = true;
+ bool m_bEnableUndo = true;
+ int32_t m_nAlignment = 0;
std::unique_ptr<CPWL_EditImpl_Provider> m_pVTProvider;
std::unique_ptr<CPDF_VariableText> m_pVT; // Must outlive |m_pVTProvider|.
UnownedPtr<CPWL_Edit> m_pNotify;
@@ -398,17 +404,11 @@
CPWL_EditImpl_Select m_SelState;
CFX_PointF m_ptScrollPos;
CFX_PointF m_ptRefreshScrollPos;
- bool m_bEnableScroll;
std::unique_ptr<CPWL_EditImpl_Iterator> m_pIterator;
CPWL_EditImpl_Refresh m_Refresh;
CFX_PointF m_ptCaret;
CPWL_EditImpl_Undo m_Undo;
- int32_t m_nAlignment;
- bool m_bNotifyFlag;
- bool m_bEnableOverflow;
- bool m_bEnableRefresh;
CFX_FloatRect m_rcOldContent;
- bool m_bEnableUndo;
};
class CPWL_EditImpl_Iterator {
diff --git a/xfa/fgas/layout/cfgas_txtbreak.cpp b/xfa/fgas/layout/cfgas_txtbreak.cpp
index 9b670f6..426e512 100644
--- a/xfa/fgas/layout/cfgas_txtbreak.cpp
+++ b/xfa/fgas/layout/cfgas_txtbreak.cpp
@@ -29,10 +29,7 @@
} // namespace
-CFGAS_TxtBreak::CFGAS_TxtBreak()
- : CFGAS_Break(FX_LAYOUTSTYLE_None),
- m_iAlignment(CFX_TxtLineAlignment_Left),
- m_iCombWidth(360000) {}
+CFGAS_TxtBreak::CFGAS_TxtBreak() : CFGAS_Break(FX_LAYOUTSTYLE_None) {}
CFGAS_TxtBreak::~CFGAS_TxtBreak() = default;
diff --git a/xfa/fgas/layout/cfgas_txtbreak.h b/xfa/fgas/layout/cfgas_txtbreak.h
index 7c10f29..0437d0d 100644
--- a/xfa/fgas/layout/cfgas_txtbreak.h
+++ b/xfa/fgas/layout/cfgas_txtbreak.h
@@ -98,8 +98,8 @@
CFGAS_BreakLine* pNextLine,
bool bAllChars);
- int32_t m_iAlignment;
- int32_t m_iCombWidth;
+ int32_t m_iAlignment = CFX_TxtLineAlignment_Left;
+ int32_t m_iCombWidth = 360000;
};
#endif // XFA_FGAS_LAYOUT_CFGAS_TXTBREAK_H_