diff options
author | Dan Sinclair <dsinclair@chromium.org> | 2018-05-25 16:18:40 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2018-05-25 16:18:40 +0000 |
commit | cbf1550e48e300142a53f635daba3c1d8910add9 (patch) | |
tree | 71dca5ce8b3b5ac8a9f8ed6930601f3f0a272e0b /fxjs/xfa | |
parent | 4ba76201df61467928bba429ea1d8115e292072e (diff) | |
download | pdfium-cbf1550e48e300142a53f635daba3c1d8910add9.tar.xz |
[xfa] Generate CXFA_EventParam.newText dynamically
When an xfa.event is sent it is possible to change the selStart, selEnd
and change values of the event. This should cause the value of newText
to be changed as needed.
This CL removes m_wsNewText from CXFA_EventParam and instead generates
the new text based on the previous text, the selection and the change.
Bug: 1066
Change-Id: I35d126fad9771c8980654a8af64d2b98989bff3f
Reviewed-on: https://pdfium-review.googlesource.com/32970
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Diffstat (limited to 'fxjs/xfa')
-rw-r--r-- | fxjs/xfa/cjx_eventpseudomodel.cpp | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/fxjs/xfa/cjx_eventpseudomodel.cpp b/fxjs/xfa/cjx_eventpseudomodel.cpp index 82b76fce12..d2364c8f32 100644 --- a/fxjs/xfa/cjx_eventpseudomodel.cpp +++ b/fxjs/xfa/cjx_eventpseudomodel.cpp @@ -101,7 +101,18 @@ void CJX_EventPseudoModel::newContentType(CFXJSE_Value* pValue, void CJX_EventPseudoModel::newText(CFXJSE_Value* pValue, bool bSetting, XFA_Attribute eAttribute) { - Property(pValue, XFA_Event::NewText, bSetting); + if (bSetting) + return; + + CFXJSE_Engine* pScriptContext = GetDocument()->GetScriptContext(); + if (!pScriptContext) + return; + + CXFA_EventParam* pEventParam = pScriptContext->GetEventParam(); + if (!pEventParam) + return; + + pValue->SetString(pEventParam->GetNewText().UTF8Encode().AsStringView()); } void CJX_EventPseudoModel::prevContentType(CFXJSE_Value* pValue, @@ -237,7 +248,7 @@ void CJX_EventPseudoModel::Property(CFXJSE_Value* pValue, StringProperty(pValue, &pEventParam->m_wsNewContentType, bSetting); break; case XFA_Event::NewText: - StringProperty(pValue, &pEventParam->m_wsNewText, bSetting); + NOTREACHED(); break; case XFA_Event::PreviousContentType: StringProperty(pValue, &pEventParam->m_wsPrevContentType, bSetting); |