From 3d8131535e6b127c7ededdbd2e76662688997272 Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Thu, 21 Jun 2018 17:28:24 +0000 Subject: 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 Commit-Queue: Tom Sepez --- fpdfsdk/cpdfsdk_actionhandler.cpp | 18 ++++++++++-------- fpdfsdk/cpdfsdk_interform.cpp | 4 ++-- 2 files changed, 12 insertions(+), 10 deletions(-) (limited to 'fpdfsdk') diff --git a/fpdfsdk/cpdfsdk_actionhandler.cpp b/fpdfsdk/cpdfsdk_actionhandler.cpp index 5b72082104..64d82b93ba 100644 --- a/fpdfsdk/cpdfsdk_actionhandler.cpp +++ b/fpdfsdk/cpdfsdk_actionhandler.cpp @@ -422,22 +422,24 @@ void CPDFSDK_ActionHandler::RunFieldJavaScript( break; case CPDF_AAction::GetFocus: context->OnField_Focus(data->bModifier, data->bShift, pFormField, - data->sValue); + &data->sValue); break; case CPDF_AAction::LoseFocus: context->OnField_Blur(data->bModifier, data->bShift, pFormField, - data->sValue); + &data->sValue); break; case CPDF_AAction::KeyStroke: context->OnField_Keystroke( - data->sChange, data->sChangeEx, data->bKeyDown, data->bModifier, - data->nSelEnd, data->nSelStart, data->bShift, pFormField, - data->sValue, data->bWillCommit, data->bFieldFull, data->bRC); + &data->sChange, data->sChangeEx, data->bKeyDown, + data->bModifier, &data->nSelEnd, &data->nSelStart, data->bShift, + pFormField, &data->sValue, data->bWillCommit, data->bFieldFull, + &data->bRC); break; case CPDF_AAction::Validate: - context->OnField_Validate( - data->sChange, data->sChangeEx, data->bKeyDown, data->bModifier, - data->bShift, pFormField, data->sValue, data->bRC); + context->OnField_Validate(&data->sChange, data->sChangeEx, + data->bKeyDown, data->bModifier, + data->bShift, pFormField, &data->sValue, + &data->bRC); break; default: NOTREACHED(); diff --git a/fpdfsdk/cpdfsdk_interform.cpp b/fpdfsdk/cpdfsdk_interform.cpp index 751a889b68..9d646b6574 100644 --- a/fpdfsdk/cpdfsdk_interform.cpp +++ b/fpdfsdk/cpdfsdk_interform.cpp @@ -290,7 +290,7 @@ void CPDFSDK_InterForm::OnCalculate(CPDF_FormField* pFormField) { WideString sValue = sOldValue; bool bRC = true; IJS_Runtime::ScopedEventContext pContext(pRuntime); - pContext->OnField_Calculate(pFormField, pField, sValue, bRC); + pContext->OnField_Calculate(pFormField, pField, &sValue, &bRC); Optional err = pContext->RunScript(csJS); if (!err && bRC && sValue.Compare(sOldValue) != 0) @@ -324,7 +324,7 @@ WideString CPDFSDK_InterForm::OnFormat(CPDF_FormField* pFormField, if (!script.IsEmpty()) { WideString Value = sValue; IJS_Runtime::ScopedEventContext pContext(pRuntime); - pContext->OnField_Format(pFormField, Value, true); + pContext->OnField_Format(pFormField, &Value, true); Optional err = pContext->RunScript(script); if (!err) { sValue = std::move(Value); -- cgit v1.2.3