diff options
author | Dan Sinclair <dsinclair@chromium.org> | 2017-12-11 22:31:58 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-12-11 22:31:58 +0000 |
commit | c002261326795102c4680c43ea447674dd4d6f3b (patch) | |
tree | d1793513d0e2dc1203d3806d7d734e3ddc9e2766 /fxjs/cjx_eventpseudomodel.cpp | |
parent | 07401bae6d9f95911b144e6fabb42f19e40def49 (diff) | |
download | pdfium-c002261326795102c4680c43ea447674dd4d6f3b.tar.xz |
[xfa] Move CJX code into fxjs/xfa
This CL moves the remaining CJX clases into fxjs/xfa so they co-exist
with the rest of the CJX classes.
Change-Id: I2b1e5504ac23f73df177f309967a04ab27fb61d1
Reviewed-on: https://pdfium-review.googlesource.com/20550
Commit-Queue: dsinclair <dsinclair@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
Diffstat (limited to 'fxjs/cjx_eventpseudomodel.cpp')
-rw-r--r-- | fxjs/cjx_eventpseudomodel.cpp | 257 |
1 files changed, 0 insertions, 257 deletions
diff --git a/fxjs/cjx_eventpseudomodel.cpp b/fxjs/cjx_eventpseudomodel.cpp deleted file mode 100644 index 092d39fa28..0000000000 --- a/fxjs/cjx_eventpseudomodel.cpp +++ /dev/null @@ -1,257 +0,0 @@ -// Copyright 2017 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com - -#include "fxjs/cjx_eventpseudomodel.h" - -#include <vector> - -#include "fxjs/cfxjse_engine.h" -#include "fxjs/cfxjse_value.h" -#include "xfa/fxfa/cxfa_eventparam.h" -#include "xfa/fxfa/cxfa_ffnotify.h" -#include "xfa/fxfa/cxfa_ffwidgethandler.h" -#include "xfa/fxfa/parser/cscript_eventpseudomodel.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 - -const CJX_MethodSpec CJX_EventPseudoModel::MethodSpecs[] = { - {"emit", emit_static}, - {"reset", reset_static}, - {"", nullptr}}; - -CJX_EventPseudoModel::CJX_EventPseudoModel(CScript_EventPseudoModel* model) - : CJX_Object(model) { - DefineMethods(MethodSpecs); -} - -CJX_EventPseudoModel::~CJX_EventPseudoModel() {} - -void CJX_EventPseudoModel::Change(CFXJSE_Value* pValue, - bool bSetting, - XFA_Attribute eAttribute) { - Property(pValue, XFA_Event::Change, bSetting); -} - -void CJX_EventPseudoModel::CommitKey(CFXJSE_Value* pValue, - bool bSetting, - XFA_Attribute eAttribute) { - Property(pValue, XFA_Event::CommitKey, bSetting); -} - -void CJX_EventPseudoModel::FullText(CFXJSE_Value* pValue, - bool bSetting, - XFA_Attribute eAttribute) { - Property(pValue, XFA_Event::FullText, bSetting); -} - -void CJX_EventPseudoModel::KeyDown(CFXJSE_Value* pValue, - bool bSetting, - XFA_Attribute eAttribute) { - Property(pValue, XFA_Event::Keydown, bSetting); -} - -void CJX_EventPseudoModel::Modifier(CFXJSE_Value* pValue, - bool bSetting, - XFA_Attribute eAttribute) { - Property(pValue, XFA_Event::Modifier, bSetting); -} - -void CJX_EventPseudoModel::NewContentType(CFXJSE_Value* pValue, - bool bSetting, - XFA_Attribute eAttribute) { - Property(pValue, XFA_Event::NewContentType, bSetting); -} - -void CJX_EventPseudoModel::NewText(CFXJSE_Value* pValue, - bool bSetting, - XFA_Attribute eAttribute) { - Property(pValue, XFA_Event::NewText, bSetting); -} - -void CJX_EventPseudoModel::PrevContentType(CFXJSE_Value* pValue, - bool bSetting, - XFA_Attribute eAttribute) { - Property(pValue, XFA_Event::PreviousContentType, bSetting); -} - -void CJX_EventPseudoModel::PrevText(CFXJSE_Value* pValue, - bool bSetting, - XFA_Attribute eAttribute) { - Property(pValue, XFA_Event::PreviousText, bSetting); -} - -void CJX_EventPseudoModel::Reenter(CFXJSE_Value* pValue, - bool bSetting, - XFA_Attribute eAttribute) { - Property(pValue, XFA_Event::Reenter, bSetting); -} - -void CJX_EventPseudoModel::SelEnd(CFXJSE_Value* pValue, - bool bSetting, - XFA_Attribute eAttribute) { - Property(pValue, XFA_Event::SelectionEnd, bSetting); -} - -void CJX_EventPseudoModel::SelStart(CFXJSE_Value* pValue, - bool bSetting, - XFA_Attribute eAttribute) { - Property(pValue, XFA_Event::SelectionStart, bSetting); -} - -void CJX_EventPseudoModel::Shift(CFXJSE_Value* pValue, - bool bSetting, - XFA_Attribute eAttribute) { - Property(pValue, XFA_Event::Shift, bSetting); -} - -void CJX_EventPseudoModel::SoapFaultCode(CFXJSE_Value* pValue, - bool bSetting, - XFA_Attribute eAttribute) { - Property(pValue, XFA_Event::SoapFaultCode, bSetting); -} - -void CJX_EventPseudoModel::SoapFaultString(CFXJSE_Value* pValue, - bool bSetting, - XFA_Attribute eAttribute) { - Property(pValue, XFA_Event::SoapFaultString, bSetting); -} - -void CJX_EventPseudoModel::Target(CFXJSE_Value* pValue, - bool bSetting, - XFA_Attribute eAttribute) { - Property(pValue, XFA_Event::Target, bSetting); -} - -CJS_Return CJX_EventPseudoModel::emit( - CJS_V8* runtime, - const std::vector<v8::Local<v8::Value>>& params) { - CFXJSE_Engine* pScriptContext = GetDocument()->GetScriptContext(); - if (!pScriptContext) - return CJS_Return(true); - - CXFA_EventParam* pEventParam = pScriptContext->GetEventParam(); - if (!pEventParam) - return CJS_Return(true); - - CXFA_FFNotify* pNotify = GetDocument()->GetNotify(); - if (!pNotify) - return CJS_Return(true); - - CXFA_FFWidgetHandler* pWidgetHandler = pNotify->GetWidgetHandler(); - if (!pWidgetHandler) - return CJS_Return(true); - - pWidgetHandler->ProcessEvent(pEventParam->m_pTarget, pEventParam); - return CJS_Return(true); -} - -CJS_Return CJX_EventPseudoModel::reset( - CJS_V8* runtime, - const std::vector<v8::Local<v8::Value>>& params) { - CFXJSE_Engine* pScriptContext = GetDocument()->GetScriptContext(); - if (!pScriptContext) - return CJS_Return(true); - - CXFA_EventParam* pEventParam = pScriptContext->GetEventParam(); - if (!pEventParam) - return CJS_Return(true); - - pEventParam->Reset(); - return CJS_Return(true); -} - -void CJX_EventPseudoModel::Property(CFXJSE_Value* pValue, - XFA_Event dwFlag, - bool bSetting) { - CFXJSE_Engine* pScriptContext = GetDocument()->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; - } -} |