summaryrefslogtreecommitdiff
path: root/fxjs/cjs_eventhandler.cpp
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2018-06-21 17:28:24 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-06-21 17:28:24 +0000
commit3d8131535e6b127c7ededdbd2e76662688997272 (patch)
tree656faaadbaf0139f8a299b672f6530e7a004b6bb /fxjs/cjs_eventhandler.cpp
parenta964f2a5ab09dc01d09fad78f940ee8e0e5c0c04 (diff)
downloadpdfium-3d8131535e6b127c7ededdbd2e76662688997272.tar.xz
Pass output parameters as pointers in ijs_event_context
It is hard to tell if there is some unsavory stuff going on with references otherwise. Avoids some const_casts in the process. Add some UnownedPtrs along the way to check caller's storage duration. Change-Id: Ic8d85802083f0b27e07993ea25f8f1c15fca1712 Reviewed-on: https://pdfium-review.googlesource.com/35750 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'fxjs/cjs_eventhandler.cpp')
-rw-r--r--fxjs/cjs_eventhandler.cpp58
1 files changed, 32 insertions, 26 deletions
diff --git a/fxjs/cjs_eventhandler.cpp b/fxjs/cjs_eventhandler.cpp
index 43605d985b..884651a77b 100644
--- a/fxjs/cjs_eventhandler.cpp
+++ b/fxjs/cjs_eventhandler.cpp
@@ -127,97 +127,103 @@ void CJS_EventHandler::OnField_MouseUp(bool bModifier,
void CJS_EventHandler::OnField_Focus(bool bModifier,
bool bShift,
CPDF_FormField* pTarget,
- const WideString& Value) {
+ WideString* pValue) {
+ ASSERT(pValue);
Initialize(JET_FIELD_FOCUS);
m_bModifier = bModifier;
m_bShift = bShift;
m_strTargetName = pTarget->GetFullName();
- m_pValue = const_cast<WideString*>(&Value);
+ m_pValue = pValue;
}
void CJS_EventHandler::OnField_Blur(bool bModifier,
bool bShift,
CPDF_FormField* pTarget,
- const WideString& Value) {
+ WideString* pValue) {
+ ASSERT(pValue);
Initialize(JET_FIELD_BLUR);
m_bModifier = bModifier;
m_bShift = bShift;
m_strTargetName = pTarget->GetFullName();
- m_pValue = const_cast<WideString*>(&Value);
+ m_pValue = pValue;
}
-void CJS_EventHandler::OnField_Keystroke(WideString& strChange,
+void CJS_EventHandler::OnField_Keystroke(WideString* strChange,
const WideString& strChangeEx,
bool KeyDown,
bool bModifier,
- int& nSelEnd,
- int& nSelStart,
+ int* pSelEnd,
+ int* pSelStart,
bool bShift,
CPDF_FormField* pTarget,
- WideString& Value,
+ WideString* pValue,
bool bWillCommit,
bool bFieldFull,
- bool& bRc) {
+ bool* pbRc) {
+ ASSERT(pValue && pbRc && pSelEnd && pSelStart);
Initialize(JET_FIELD_KEYSTROKE);
m_nCommitKey = 0;
- m_pWideStrChange = &strChange;
+ m_pWideStrChange = strChange;
m_WideStrChangeEx = strChangeEx;
m_bKeyDown = KeyDown;
m_bModifier = bModifier;
- m_pISelEnd = &nSelEnd;
- m_pISelStart = &nSelStart;
+ m_pISelEnd = pSelEnd;
+ m_pISelStart = pSelStart;
m_bShift = bShift;
m_strTargetName = pTarget->GetFullName();
- m_pValue = &Value;
+ m_pValue = pValue;
m_bWillCommit = bWillCommit;
- m_pbRc = &bRc;
+ m_pbRc = pbRc;
m_bFieldFull = bFieldFull;
}
-void CJS_EventHandler::OnField_Validate(WideString& strChange,
+void CJS_EventHandler::OnField_Validate(WideString* strChange,
const WideString& strChangeEx,
bool bKeyDown,
bool bModifier,
bool bShift,
CPDF_FormField* pTarget,
- WideString& Value,
- bool& bRc) {
+ WideString* pValue,
+ bool* pbRc) {
+ ASSERT(pValue && pbRc);
Initialize(JET_FIELD_VALIDATE);
- m_pWideStrChange = &strChange;
+ m_pWideStrChange = strChange;
m_WideStrChangeEx = strChangeEx;
m_bKeyDown = bKeyDown;
m_bModifier = bModifier;
m_bShift = bShift;
m_strTargetName = pTarget->GetFullName();
- m_pValue = &Value;
- m_pbRc = &bRc;
+ m_pValue = pValue;
+ m_pbRc = pbRc;
}
void CJS_EventHandler::OnField_Calculate(CPDF_FormField* pSource,
CPDF_FormField* pTarget,
- WideString& Value,
- bool& bRc) {
+ WideString* pValue,
+ bool* pRc) {
+ ASSERT(pValue && pRc);
Initialize(JET_FIELD_CALCULATE);
if (pSource)
m_strSourceName = pSource->GetFullName();
m_strTargetName = pTarget->GetFullName();
- m_pValue = &Value;
- m_pbRc = &bRc;
+ m_pValue = pValue;
+ m_pbRc = pRc;
}
void CJS_EventHandler::OnField_Format(CPDF_FormField* pTarget,
- WideString& Value,
+ WideString* pValue,
bool bWillCommit) {
+ ASSERT(pValue);
Initialize(JET_FIELD_FORMAT);
m_nCommitKey = 0;
m_strTargetName = pTarget->GetFullName();
- m_pValue = &Value;
+ m_pValue = pValue;
m_bWillCommit = bWillCommit;
}