Tidy CXFA_EventParam
- Initialize in header and pack more tightly
- Declare copy-assign and move-assign operators.
- Use assignment of default object in place of Reset(), since this
avoids having to keep Reset() in sync with constructors.
Change-Id: I3542c891551bd9e087192442cf0b701acb13198e
Reviewed-on: https://pdfium-review.googlesource.com/c/48391
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
diff --git a/fxjs/xfa/cjx_eventpseudomodel.cpp b/fxjs/xfa/cjx_eventpseudomodel.cpp
index 4fa58ed..b8ef6ea 100644
--- a/fxjs/xfa/cjx_eventpseudomodel.cpp
+++ b/fxjs/xfa/cjx_eventpseudomodel.cpp
@@ -201,7 +201,7 @@
CXFA_EventParam* pEventParam = pScriptContext->GetEventParam();
if (pEventParam)
- pEventParam->Reset();
+ *pEventParam = CXFA_EventParam();
return CJS_Result::Success();
}
diff --git a/xfa/fxfa/cxfa_eventparam.cpp b/xfa/fxfa/cxfa_eventparam.cpp
index 4746a6a..e6eab2c 100644
--- a/xfa/fxfa/cxfa_eventparam.cpp
+++ b/xfa/fxfa/cxfa_eventparam.cpp
@@ -8,41 +8,16 @@
#include "xfa/fxfa/fxfa.h"
-CXFA_EventParam::CXFA_EventParam()
- : m_pTarget(nullptr),
- m_eType(XFA_EVENT_Unknown),
- m_bCancelAction(false),
- m_iCommitKey(0),
- m_bKeyDown(false),
- m_bModifier(false),
- m_bReenter(false),
- m_iSelEnd(0),
- m_iSelStart(0),
- m_bShift(false),
- m_bIsFormReady(false) {}
-
-CXFA_EventParam::~CXFA_EventParam() = default;
+CXFA_EventParam::CXFA_EventParam() = default;
CXFA_EventParam::CXFA_EventParam(const CXFA_EventParam& other) = default;
-void CXFA_EventParam::Reset() {
- m_wsChange.clear();
- m_bCancelAction = false;
- m_iCommitKey = 0;
- m_wsFullText.clear();
- m_bKeyDown = false;
- m_bModifier = false;
- m_wsNewContentType.clear();
- m_wsPrevContentType.clear();
- m_wsPrevText.clear();
- m_bReenter = false;
- m_iSelEnd = 0;
- m_iSelStart = 0;
- m_bShift = false;
- m_wsSoapFaultCode.clear();
- m_wsSoapFaultString.clear();
- m_bIsFormReady = false;
-}
+CXFA_EventParam::~CXFA_EventParam() = default;
+
+CXFA_EventParam& CXFA_EventParam::operator=(const CXFA_EventParam& other) =
+ default;
+
+CXFA_EventParam& CXFA_EventParam::operator=(CXFA_EventParam&& other) = default;
WideString CXFA_EventParam::GetNewText() const {
return m_wsPrevText.Left(m_iSelStart) + m_wsChange +
diff --git a/xfa/fxfa/cxfa_eventparam.h b/xfa/fxfa/cxfa_eventparam.h
index 82134f6..a670263 100644
--- a/xfa/fxfa/cxfa_eventparam.h
+++ b/xfa/fxfa/cxfa_eventparam.h
@@ -50,23 +50,26 @@
class CXFA_EventParam {
public:
CXFA_EventParam();
- ~CXFA_EventParam();
CXFA_EventParam(const CXFA_EventParam& other);
+ ~CXFA_EventParam();
- void Reset();
+ CXFA_EventParam& operator=(const CXFA_EventParam& other);
+ CXFA_EventParam& operator=(CXFA_EventParam&& other);
+
WideString GetNewText() const;
+ XFA_EVENTTYPE m_eType = XFA_EVENT_Unknown;
+ bool m_bCancelAction = false;
+ bool m_bKeyDown = false;
+ bool m_bModifier = false;
+ bool m_bReenter = false;
+ bool m_bShift = false;
+ bool m_bIsFormReady = false;
+ int32_t m_iCommitKey = 0;
+ int32_t m_iSelEnd = 0;
+ int32_t m_iSelStart = 0;
UnownedPtr<CXFA_Node> m_pTarget;
- XFA_EVENTTYPE m_eType;
WideString m_wsResult;
- bool m_bCancelAction;
- int32_t m_iCommitKey;
- bool m_bKeyDown;
- bool m_bModifier;
- bool m_bReenter;
- int32_t m_iSelEnd;
- int32_t m_iSelStart;
- bool m_bShift;
WideString m_wsChange;
WideString m_wsFullText;
WideString m_wsNewContentType;
@@ -74,7 +77,6 @@
WideString m_wsPrevText;
WideString m_wsSoapFaultCode;
WideString m_wsSoapFaultString;
- bool m_bIsFormReady;
};
#endif // XFA_FXFA_CXFA_EVENTPARAM_H_