From 95bb9748c9292d282e2425d4500f15f5c48c2b34 Mon Sep 17 00:00:00 2001 From: Dan Sinclair Date: Tue, 9 Jan 2018 10:02:55 -0500 Subject: More Execute* methods to CXFA_Node This Cl moves the two Execute* methods from CXFA_WidgetAcc to CXFA_Node. Change-Id: I4e1d6cd2159028800b855558273ca80aad365570 Reviewed-on: https://pdfium-review.googlesource.com/22550 Reviewed-by: Ryan Harrison Commit-Queue: dsinclair --- xfa/fxfa/cxfa_widgetacc.cpp | 90 +-------------------------------------------- 1 file changed, 1 insertion(+), 89 deletions(-) (limited to 'xfa/fxfa/cxfa_widgetacc.cpp') diff --git a/xfa/fxfa/cxfa_widgetacc.cpp b/xfa/fxfa/cxfa_widgetacc.cpp index bbed5b3245..870dc53ff9 100644 --- a/xfa/fxfa/cxfa_widgetacc.cpp +++ b/xfa/fxfa/cxfa_widgetacc.cpp @@ -357,8 +357,7 @@ std::pair CreateUIChild(CXFA_Node* pNode) { } // namespace CXFA_WidgetAcc::CXFA_WidgetAcc(CXFA_Node* pNode) - : m_nRecursionDepth(0), - m_bIsNull(true), + : m_bIsNull(true), m_bPreNull(true), m_pUiChildNode(nullptr), m_eUIType(XFA_Element::Unknown), @@ -464,93 +463,6 @@ void CXFA_WidgetAcc::SetImageEdit(const WideString& wsContentType, } } -int32_t CXFA_WidgetAcc::ExecuteScript(CXFA_FFDocView* docView, - CXFA_Script* script, - CXFA_EventParam* pEventParam) { - bool bRet; - int32_t iRet; - std::tie(iRet, bRet) = ExecuteBoolScript(docView, script, pEventParam); - return iRet; -} - -std::pair CXFA_WidgetAcc::ExecuteBoolScript( - CXFA_FFDocView* docView, - CXFA_Script* script, - CXFA_EventParam* pEventParam) { - static const uint32_t MAX_RECURSION_DEPTH = 2; - if (m_nRecursionDepth > MAX_RECURSION_DEPTH) - return {XFA_EVENTERROR_Success, false}; - - ASSERT(pEventParam); - if (!script) - return {XFA_EVENTERROR_NotExist, false}; - if (script->GetRunAt() == XFA_AttributeEnum::Server) - return {XFA_EVENTERROR_Disabled, false}; - - WideString wsExpression = script->GetExpression(); - if (wsExpression.IsEmpty()) - return {XFA_EVENTERROR_NotExist, false}; - - CXFA_Script::Type eScriptType = script->GetContentType(); - if (eScriptType == CXFA_Script::Type::Unknown) - return {XFA_EVENTERROR_Success, false}; - - CXFA_FFDoc* pDoc = docView->GetDoc(); - CFXJSE_Engine* pContext = pDoc->GetXFADoc()->GetScriptContext(); - pContext->SetEventParam(*pEventParam); - pContext->SetRunAtType(script->GetRunAt()); - - std::vector refNodes; - if (pEventParam->m_eType == XFA_EVENT_InitCalculate || - pEventParam->m_eType == XFA_EVENT_Calculate) { - pContext->SetNodesOfRunScript(&refNodes); - } - - auto pTmpRetValue = pdfium::MakeUnique(pContext->GetIsolate()); - ++m_nRecursionDepth; - bool bRet = pContext->RunScript(eScriptType, wsExpression.AsStringView(), - pTmpRetValue.get(), m_pNode); - --m_nRecursionDepth; - int32_t iRet = XFA_EVENTERROR_Error; - if (bRet) { - iRet = XFA_EVENTERROR_Success; - if (pEventParam->m_eType == XFA_EVENT_Calculate || - pEventParam->m_eType == XFA_EVENT_InitCalculate) { - if (!pTmpRetValue->IsUndefined()) { - if (!pTmpRetValue->IsNull()) - pEventParam->m_wsResult = pTmpRetValue->ToWideString(); - - iRet = XFA_EVENTERROR_Success; - } else { - iRet = XFA_EVENTERROR_Error; - } - if (pEventParam->m_eType == XFA_EVENT_InitCalculate) { - if ((iRet == XFA_EVENTERROR_Success) && - (m_pNode->GetRawValue() != pEventParam->m_wsResult)) { - SetValue(XFA_VALUEPICTURE_Raw, pEventParam->m_wsResult); - docView->AddValidateWidget(this); - } - } - for (CXFA_Node* pRefNode : refNodes) { - if (pRefNode->GetWidgetAcc() == this) - continue; - - CXFA_CalcData* pGlobalData = pRefNode->JSObject()->GetCalcData(); - if (!pGlobalData) { - pRefNode->JSObject()->SetCalcData( - pdfium::MakeUnique()); - pGlobalData = pRefNode->JSObject()->GetCalcData(); - } - if (!pdfium::ContainsValue(pGlobalData->m_Globals, GetNode())) - pGlobalData->m_Globals.push_back(GetNode()); - } - } - } - pContext->SetNodesOfRunScript(nullptr); - - return {iRet, pTmpRetValue->IsBoolean() ? pTmpRetValue->ToBoolean() : false}; -} - CXFA_FFWidget* CXFA_WidgetAcc::GetNextWidget(CXFA_FFWidget* pWidget) { return static_cast(pWidget->GetNext()); } -- cgit v1.2.3