diff options
author | Dan Sinclair <dsinclair@chromium.org> | 2017-11-01 18:48:17 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-11-01 18:48:17 +0000 |
commit | 46ad7f84cfeef009a4f5e4bc13f8b3435f789f30 (patch) | |
tree | 12b2778ecd88257be897dbb8bce203f2e6d689de /xfa/fxfa/parser/cscript_eventpseudomodel.cpp | |
parent | 778f2feb328ac4321762b8dcf94ebc0a1bac79f5 (diff) | |
download | pdfium-46ad7f84cfeef009a4f5e4bc13f8b3435f789f30.tar.xz |
Convert CScript classes to have CJX objects
This CL moves the JS methods from the CScript classes into CJX
representations. The methods are proxied to the CJX versions.
Change-Id: Ic5f380228614a60238fbcf9e0d04d942fae395be
Reviewed-on: https://pdfium-review.googlesource.com/17313
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Commit-Queue: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'xfa/fxfa/parser/cscript_eventpseudomodel.cpp')
-rw-r--r-- | xfa/fxfa/parser/cscript_eventpseudomodel.cpp | 180 |
1 files changed, 36 insertions, 144 deletions
diff --git a/xfa/fxfa/parser/cscript_eventpseudomodel.cpp b/xfa/fxfa/parser/cscript_eventpseudomodel.cpp index 633ee9b7d2..806a318d8c 100644 --- a/xfa/fxfa/parser/cscript_eventpseudomodel.cpp +++ b/xfa/fxfa/parser/cscript_eventpseudomodel.cpp @@ -7,226 +7,118 @@ #include "xfa/fxfa/parser/cscript_eventpseudomodel.h" #include "fxjs/cfxjse_arguments.h" -#include "fxjs/cfxjse_engine.h" #include "fxjs/cjx_object.h" #include "third_party/base/ptr_util.h" -#include "xfa/fxfa/cxfa_eventparam.h" -#include "xfa/fxfa/cxfa_ffnotify.h" -#include "xfa/fxfa/cxfa_ffwidgethandler.h" -#include "xfa/fxfa/parser/cxfa_document.h" -#include "xfa/fxfa/parser/cxfa_localemgr.h" -#include "xfa/fxfa/parser/xfa_utils.h" - -namespace { - -void StringProperty(CFXJSE_Value* pValue, WideString& wsValue, bool bSetting) { - if (bSetting) { - wsValue = pValue->ToWideString(); - return; - } - pValue->SetString(wsValue.UTF8Encode().AsStringView()); -} - -void InterProperty(CFXJSE_Value* pValue, int32_t& iValue, bool bSetting) { - if (bSetting) { - iValue = pValue->ToInteger(); - return; - } - pValue->SetInteger(iValue); -} - -void BooleanProperty(CFXJSE_Value* pValue, bool& bValue, bool bSetting) { - if (bSetting) { - bValue = pValue->ToBoolean(); - return; - } - pValue->SetBoolean(bValue); -} - -} // namespace CScript_EventPseudoModel::CScript_EventPseudoModel(CXFA_Document* pDocument) : CXFA_Object(pDocument, XFA_ObjectType::Object, XFA_Element::EventPseudoModel, WideStringView(L"eventPseudoModel"), - pdfium::MakeUnique<CJX_Object>(this)) {} + pdfium::MakeUnique<CJX_EventPseudoModel>(this)) {} CScript_EventPseudoModel::~CScript_EventPseudoModel() {} -void CScript_EventPseudoModel::Property(CFXJSE_Value* pValue, - XFA_Event dwFlag, - bool bSetting) { - CFXJSE_Engine* pScriptContext = m_pDocument->GetScriptContext(); - if (!pScriptContext) - return; - - CXFA_EventParam* pEventParam = pScriptContext->GetEventParam(); - if (!pEventParam) - return; - - switch (dwFlag) { - case XFA_Event::CancelAction: - BooleanProperty(pValue, pEventParam->m_bCancelAction, bSetting); - break; - case XFA_Event::Change: - StringProperty(pValue, pEventParam->m_wsChange, bSetting); - break; - case XFA_Event::CommitKey: - InterProperty(pValue, pEventParam->m_iCommitKey, bSetting); - break; - case XFA_Event::FullText: - StringProperty(pValue, pEventParam->m_wsFullText, bSetting); - break; - case XFA_Event::Keydown: - BooleanProperty(pValue, pEventParam->m_bKeyDown, bSetting); - break; - case XFA_Event::Modifier: - BooleanProperty(pValue, pEventParam->m_bModifier, bSetting); - break; - case XFA_Event::NewContentType: - StringProperty(pValue, pEventParam->m_wsNewContentType, bSetting); - break; - case XFA_Event::NewText: - StringProperty(pValue, pEventParam->m_wsNewText, bSetting); - break; - case XFA_Event::PreviousContentType: - StringProperty(pValue, pEventParam->m_wsPrevContentType, bSetting); - break; - case XFA_Event::PreviousText: - StringProperty(pValue, pEventParam->m_wsPrevText, bSetting); - break; - case XFA_Event::Reenter: - BooleanProperty(pValue, pEventParam->m_bReenter, bSetting); - break; - case XFA_Event::SelectionEnd: - InterProperty(pValue, pEventParam->m_iSelEnd, bSetting); - break; - case XFA_Event::SelectionStart: - InterProperty(pValue, pEventParam->m_iSelStart, bSetting); - break; - case XFA_Event::Shift: - BooleanProperty(pValue, pEventParam->m_bShift, bSetting); - break; - case XFA_Event::SoapFaultCode: - StringProperty(pValue, pEventParam->m_wsSoapFaultCode, bSetting); - break; - case XFA_Event::SoapFaultString: - StringProperty(pValue, pEventParam->m_wsSoapFaultString, bSetting); - break; - case XFA_Event::Target: - break; - default: - break; - } -} void CScript_EventPseudoModel::Change(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute) { - Property(pValue, XFA_Event::Change, bSetting); + JSEventPseudoModel()->Change(pValue, bSetting, eAttribute); } + void CScript_EventPseudoModel::CommitKey(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute) { - Property(pValue, XFA_Event::CommitKey, bSetting); + JSEventPseudoModel()->CommitKey(pValue, bSetting, eAttribute); } + void CScript_EventPseudoModel::FullText(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute) { - Property(pValue, XFA_Event::FullText, bSetting); + JSEventPseudoModel()->FullText(pValue, bSetting, eAttribute); } + void CScript_EventPseudoModel::KeyDown(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute) { - Property(pValue, XFA_Event::Keydown, bSetting); + JSEventPseudoModel()->KeyDown(pValue, bSetting, eAttribute); } + void CScript_EventPseudoModel::Modifier(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute) { - Property(pValue, XFA_Event::Modifier, bSetting); + JSEventPseudoModel()->Modifier(pValue, bSetting, eAttribute); } + void CScript_EventPseudoModel::NewContentType(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute) { - Property(pValue, XFA_Event::NewContentType, bSetting); + JSEventPseudoModel()->NewContentType(pValue, bSetting, eAttribute); } + void CScript_EventPseudoModel::NewText(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute) { - Property(pValue, XFA_Event::NewText, bSetting); + JSEventPseudoModel()->NewText(pValue, bSetting, eAttribute); } + void CScript_EventPseudoModel::PrevContentType(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute) { - Property(pValue, XFA_Event::PreviousContentType, bSetting); + JSEventPseudoModel()->PrevContentType(pValue, bSetting, eAttribute); } + void CScript_EventPseudoModel::PrevText(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute) { - Property(pValue, XFA_Event::PreviousText, bSetting); + JSEventPseudoModel()->PrevText(pValue, bSetting, eAttribute); } + void CScript_EventPseudoModel::Reenter(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute) { - Property(pValue, XFA_Event::Reenter, bSetting); + JSEventPseudoModel()->Reenter(pValue, bSetting, eAttribute); } + void CScript_EventPseudoModel::SelEnd(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute) { - Property(pValue, XFA_Event::SelectionEnd, bSetting); + JSEventPseudoModel()->SelEnd(pValue, bSetting, eAttribute); } + void CScript_EventPseudoModel::SelStart(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute) { - Property(pValue, XFA_Event::SelectionStart, bSetting); + JSEventPseudoModel()->SelStart(pValue, bSetting, eAttribute); } + void CScript_EventPseudoModel::Shift(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute) { - Property(pValue, XFA_Event::Shift, bSetting); + JSEventPseudoModel()->Shift(pValue, bSetting, eAttribute); } + void CScript_EventPseudoModel::SoapFaultCode(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute) { - Property(pValue, XFA_Event::SoapFaultCode, bSetting); + JSEventPseudoModel()->SoapFaultString(pValue, bSetting, eAttribute); } + void CScript_EventPseudoModel::SoapFaultString(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute) { - Property(pValue, XFA_Event::SoapFaultString, bSetting); + JSEventPseudoModel()->SoapFaultString(pValue, bSetting, eAttribute); } + void CScript_EventPseudoModel::Target(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute) { - Property(pValue, XFA_Event::Target, bSetting); + JSEventPseudoModel()->Target(pValue, bSetting, eAttribute); } + void CScript_EventPseudoModel::Emit(CFXJSE_Arguments* pArguments) { - CFXJSE_Engine* pScriptContext = m_pDocument->GetScriptContext(); - if (!pScriptContext) { - return; - } - CXFA_EventParam* pEventParam = pScriptContext->GetEventParam(); - if (!pEventParam) { - return; - } - CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); - if (!pNotify) { - return; - } - CXFA_FFWidgetHandler* pWidgetHandler = pNotify->GetWidgetHandler(); - if (!pWidgetHandler) { - return; - } - pWidgetHandler->ProcessEvent(pEventParam->m_pTarget, pEventParam); + JSEventPseudoModel()->Emit(pArguments); } + void CScript_EventPseudoModel::Reset(CFXJSE_Arguments* pArguments) { - CFXJSE_Engine* pScriptContext = m_pDocument->GetScriptContext(); - if (!pScriptContext) { - return; - } - CXFA_EventParam* pEventParam = pScriptContext->GetEventParam(); - if (!pEventParam) { - return; - } - pEventParam->Reset(); + JSEventPseudoModel()->Reset(pArguments); } |