diff options
author | Dan Sinclair <dsinclair@chromium.org> | 2017-12-04 19:12:16 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-12-04 19:12:16 +0000 |
commit | 33beb4e4d34547a4de43f4dee4b2b0483c526b5e (patch) | |
tree | 725d0e866857680a0a391ead73bf3e5c88132773 /fxjs | |
parent | 47a90adb7da175cfefe99a3dc40f88521d99b879 (diff) | |
download | pdfium-33beb4e4d34547a4de43f4dee4b2b0483c526b5e.tar.xz |
Remove SetResultCreateNode
This CL removes the SetResultCreateNode method and inlines into the one
caller. The XFA_RESOLVENODE_RSTYPE enum is also renamed
XFA_ResolveNode_RSType to make it easier to find XFA_RESOLVENODE_RS
objects.
Change-Id: I937b612be062c5b7b05fd8d2822cd12cb882ba06
Reviewed-on: https://pdfium-review.googlesource.com/20370
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Commit-Queue: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'fxjs')
-rw-r--r-- | fxjs/cfxjse_engine.cpp | 26 | ||||
-rw-r--r-- | fxjs/cfxjse_formcalc_context.cpp | 4 | ||||
-rw-r--r-- | fxjs/cfxjse_resolveprocessor.cpp | 20 | ||||
-rw-r--r-- | fxjs/cfxjse_resolveprocessor.h | 4 | ||||
-rw-r--r-- | fxjs/cjx_node.cpp | 4 |
5 files changed, 25 insertions, 33 deletions
diff --git a/fxjs/cfxjse_engine.cpp b/fxjs/cfxjse_engine.cpp index a2bebdb7f9..821b8da70f 100644 --- a/fxjs/cfxjse_engine.cpp +++ b/fxjs/cfxjse_engine.cpp @@ -175,11 +175,11 @@ bool CFXJSE_Engine::QueryNodeByFlag(CXFA_Node* refNode, XFA_RESOLVENODE_RS resolveRs; if (!ResolveObjects(refNode, propname, &resolveRs, dwFlag, nullptr)) return false; - if (resolveRs.dwFlags == XFA_RESOLVENODE_RSTYPE_Nodes) { + if (resolveRs.dwFlags == XFA_ResolveNode_RSType_Nodes) { pValue->Assign(GetJSValueFromMap(resolveRs.objects.front())); return true; } - if (resolveRs.dwFlags == XFA_RESOLVENODE_RSTYPE_Attribute) { + if (resolveRs.dwFlags == XFA_ResolveNode_RSType_Attribute) { const XFA_SCRIPTATTRIBUTEINFO* lpAttributeInfo = resolveRs.pScriptAttribute; if (lpAttributeInfo) { CJX_Object* jsObject = resolveRs.objects.front()->JSObject(); @@ -641,11 +641,11 @@ bool CFXJSE_Engine::ResolveObjects(CXFA_Object* refObject, } rndFind.m_CurObject = findObjects[i++]; rndFind.m_nLevel = nLevel; - rndFind.m_dwFlag = XFA_RESOLVENODE_RSTYPE_Nodes; + rndFind.m_dwFlag = XFA_ResolveNode_RSType_Nodes; if (!m_ResolveProcessor->Resolve(rndFind)) continue; - if (rndFind.m_dwFlag == XFA_RESOLVENODE_RSTYPE_Attribute && + if (rndFind.m_dwFlag == XFA_ResolveNode_RSType_Attribute && rndFind.m_pScriptAttribute && nStart < pdfium::base::checked_cast<int32_t>(wsExpression.GetLength())) { @@ -701,17 +701,27 @@ bool CFXJSE_Engine::ResolveObjects(CXFA_Object* refObject, resolveNodeRS->objects.insert(resolveNodeRS->objects.end(), findObjects.begin(), findObjects.end()); } - if (rndFind.m_dwFlag == XFA_RESOLVENODE_RSTYPE_Attribute) { + if (rndFind.m_dwFlag == XFA_ResolveNode_RSType_Attribute) { resolveNodeRS->pScriptAttribute = rndFind.m_pScriptAttribute; return 1; } } if (dwStyles & (XFA_RESOLVENODE_CreateNode | XFA_RESOLVENODE_Bind | XFA_RESOLVENODE_BindNew)) { - m_ResolveProcessor->SetResultCreateNode(resolveNodeRS, - rndFind.m_wsCondition); + CXFA_NodeHelper* helper = m_ResolveProcessor->GetNodeHelper(); + if (helper->m_pCreateParent) + resolveNodeRS->objects.push_back(helper->m_pCreateParent); + else + helper->CreateNode_ForCondition(rndFind.m_wsCondition); + + resolveNodeRS->dwFlags = helper->m_iCreateFlag; + if (resolveNodeRS->dwFlags == XFA_ResolveNode_RSType_CreateNodeOne) { + if (helper->m_iCurAllStart != -1) + resolveNodeRS->dwFlags = XFA_ResolveNode_RSType_CreateNodeMidAll; + } + if (!bNextCreate && (dwStyles & XFA_RESOLVENODE_CreateNode)) - resolveNodeRS->dwFlags = XFA_RESOLVENODE_RSTYPE_ExistNodes; + resolveNodeRS->dwFlags = XFA_ResolveNode_RSType_ExistNodes; return !resolveNodeRS->objects.empty(); } diff --git a/fxjs/cfxjse_formcalc_context.cpp b/fxjs/cfxjse_formcalc_context.cpp index e7d44d179f..e565c42e46 100644 --- a/fxjs/cfxjse_formcalc_context.cpp +++ b/fxjs/cfxjse_formcalc_context.cpp @@ -5918,7 +5918,7 @@ bool CFXJSE_FormCalcContext::GetObjectForName( pScriptContext->GetThisObject(), WideString::FromUTF8(szAccessorName).AsStringView(), &resolveNodeRS, dwFlags, nullptr); - if (iRet && resolveNodeRS.dwFlags == XFA_RESOLVENODE_RSTYPE_Nodes) { + if (iRet && resolveNodeRS.dwFlags == XFA_ResolveNode_RSType_Nodes) { accessorValue->Assign( pScriptContext->GetJSValueFromMap(resolveNodeRS.objects.front())); return true; @@ -5990,7 +5990,7 @@ void CFXJSE_FormCalcContext::ParseResolveResult( CFXJSE_FormCalcContext* pContext = ToJSContext(pThis, nullptr); v8::Isolate* pIsolate = pContext->GetScriptRuntime(); - if (resolveNodeRS.dwFlags == XFA_RESOLVENODE_RSTYPE_Nodes) { + if (resolveNodeRS.dwFlags == XFA_ResolveNode_RSType_Nodes) { *bAttribute = false; CFXJSE_Engine* pScriptContext = pContext->GetDocument()->GetScriptContext(); for (CXFA_Object* pObject : resolveNodeRS.objects) { diff --git a/fxjs/cfxjse_resolveprocessor.cpp b/fxjs/cfxjse_resolveprocessor.cpp index eeeeefcf08..8e0c6fba1e 100644 --- a/fxjs/cfxjse_resolveprocessor.cpp +++ b/fxjs/cfxjse_resolveprocessor.cpp @@ -207,7 +207,7 @@ bool CFXJSE_ResolveProcessor::ResolveForAttributeRs( rnd.m_pScriptAttribute = lpScriptAttribute; rnd.m_Objects.push_back(curNode); - rnd.m_dwFlag = XFA_RESOLVENODE_RSTYPE_Attribute; + rnd.m_dwFlag = XFA_ResolveNode_RSType_Attribute; return true; } @@ -713,22 +713,6 @@ void CFXJSE_ResolveProcessor::SetStylesForChild(uint32_t dwParentStyles, rnd.m_dwStyles = dwSubStyles; } -int32_t CFXJSE_ResolveProcessor::SetResultCreateNode( - XFA_RESOLVENODE_RS* resolveNodeRS, - WideString& wsLastCondition) { - if (m_pNodeHelper->m_pCreateParent) - resolveNodeRS->objects.push_back(m_pNodeHelper->m_pCreateParent); - else - m_pNodeHelper->CreateNode_ForCondition(wsLastCondition); - - resolveNodeRS->dwFlags = m_pNodeHelper->m_iCreateFlag; - if (resolveNodeRS->dwFlags == XFA_RESOLVENODE_RSTYPE_CreateNodeOne) { - if (m_pNodeHelper->m_iCurAllStart != -1) - resolveNodeRS->dwFlags = XFA_RESOLVENODE_RSTYPE_CreateNodeMidAll; - } - return pdfium::CollectionSize<int32_t>(resolveNodeRS->objects); -} - void CFXJSE_ResolveProcessor::SetIndexDataBind(WideString& wsNextCondition, int32_t& iIndex, int32_t iCount) { @@ -753,6 +737,6 @@ CFXJSE_ResolveNodeData::CFXJSE_ResolveNodeData(CFXJSE_Engine* pSC) m_Objects(), m_dwStyles(XFA_RESOLVENODE_Children), m_pScriptAttribute(nullptr), - m_dwFlag(XFA_RESOLVENODE_RSTYPE_Nodes) {} + m_dwFlag(XFA_ResolveNode_RSType_Nodes) {} CFXJSE_ResolveNodeData::~CFXJSE_ResolveNodeData() {} diff --git a/fxjs/cfxjse_resolveprocessor.h b/fxjs/cfxjse_resolveprocessor.h index 23ecd52d1a..71aba6efa8 100644 --- a/fxjs/cfxjse_resolveprocessor.h +++ b/fxjs/cfxjse_resolveprocessor.h @@ -29,7 +29,7 @@ class CFXJSE_ResolveNodeData { std::vector<CXFA_Object*> m_Objects; // Not owned. uint32_t m_dwStyles; const XFA_SCRIPTATTRIBUTEINFO* m_pScriptAttribute; - XFA_RESOLVENODE_RSTYPE m_dwFlag; + XFA_ResolveNode_RSType m_dwFlag; }; class CFXJSE_ResolveProcessor { @@ -41,8 +41,6 @@ class CFXJSE_ResolveProcessor { int32_t GetFilter(const WideStringView& wsExpression, int32_t nStart, CFXJSE_ResolveNodeData& rnd); - int32_t SetResultCreateNode(XFA_RESOLVENODE_RS* resolveNodeRS, - WideString& wsLastCondition); void SetIndexDataBind(WideString& wsNextCondition, int32_t& iIndex, int32_t iCount); diff --git a/fxjs/cjx_node.cpp b/fxjs/cjx_node.cpp index 9f0a0de998..aaff83ecb1 100644 --- a/fxjs/cjx_node.cpp +++ b/fxjs/cjx_node.cpp @@ -416,7 +416,7 @@ void CJX_Node::Script_TreeClass_ResolveNode(CFXJSE_Arguments* pArguments) { pArguments->GetReturnValue()->SetNull(); return; } - if (resolveNodeRS.dwFlags == XFA_RESOLVENODE_RSTYPE_Nodes) { + if (resolveNodeRS.dwFlags == XFA_ResolveNode_RSType_Nodes) { CXFA_Object* pObject = resolveNodeRS.objects.front(); pArguments->GetReturnValue()->Assign( pScriptContext->GetJSValueFromMap(pObject)); @@ -475,7 +475,7 @@ void CJX_Node::ResolveNodeList(CFXJSE_Value* pValue, pScriptContext->ResolveObjects(refNode, wsExpression.AsStringView(), &resolveNodeRS, dwFlag, nullptr); CXFA_ArrayNodeList* pNodeList = new CXFA_ArrayNodeList(GetDocument()); - if (resolveNodeRS.dwFlags == XFA_RESOLVENODE_RSTYPE_Nodes) { + if (resolveNodeRS.dwFlags == XFA_ResolveNode_RSType_Nodes) { for (CXFA_Object* pObject : resolveNodeRS.objects) { if (pObject->IsNode()) pNodeList->Append(pObject->AsNode()); |