From 4dd1b07b00842f33be3ebccdc8e4fd3219191c63 Mon Sep 17 00:00:00 2001 From: Dan Sinclair Date: Mon, 29 Jan 2018 20:49:26 +0000 Subject: Fold single caller methods into callsite This CL folds the GetNodeSameClassIndex, GetNodeSameNameIndex from CXFA_Node into the CJX_Tree callsites. Change-Id: Ia4f7750543e786ddd82abb4b6b4bde1bf1710f19 Reviewed-on: https://pdfium-review.googlesource.com/24471 Reviewed-by: Ryan Harrison Commit-Queue: dsinclair --- fxjs/xfa/cjx_tree.cpp | 17 +++++++++++++++-- xfa/fxfa/parser/cxfa_node.cpp | 16 ---------------- xfa/fxfa/parser/cxfa_node.h | 2 -- 3 files changed, 15 insertions(+), 20 deletions(-) diff --git a/fxjs/xfa/cjx_tree.cpp b/fxjs/xfa/cjx_tree.cpp index e20115b9bc..c11d77b125 100644 --- a/fxjs/xfa/cjx_tree.cpp +++ b/fxjs/xfa/cjx_tree.cpp @@ -175,7 +175,13 @@ void CJX_Tree::index(CFXJSE_Value* pValue, ThrowInvalidPropertyException(); return; } - pValue->SetInteger(ToNode(GetXFAObject())->GetNodeSameNameIndex()); + + CFXJSE_Engine* pScriptContext = GetDocument()->GetScriptContext(); + if (!pScriptContext) { + pValue->SetInteger(-1); + return; + } + pValue->SetInteger(pScriptContext->GetIndexByName(ToNode(GetXFAObject()))); } void CJX_Tree::classIndex(CFXJSE_Value* pValue, @@ -185,7 +191,14 @@ void CJX_Tree::classIndex(CFXJSE_Value* pValue, ThrowInvalidPropertyException(); return; } - pValue->SetInteger(ToNode(GetXFAObject())->GetNodeSameClassIndex()); + + CFXJSE_Engine* pScriptContext = GetDocument()->GetScriptContext(); + if (!pScriptContext) { + pValue->SetInteger(-1); + return; + } + pValue->SetInteger( + pScriptContext->GetIndexByClassName(ToNode(GetXFAObject()))); } void CJX_Tree::somExpression(CFXJSE_Value* pValue, diff --git a/xfa/fxfa/parser/cxfa_node.cpp b/xfa/fxfa/parser/cxfa_node.cpp index 2ccdd1d919..c97a0f3bfd 100644 --- a/xfa/fxfa/parser/cxfa_node.cpp +++ b/xfa/fxfa/parser/cxfa_node.cpp @@ -1331,22 +1331,6 @@ CXFA_Node* CXFA_Node::GetNextSameClassSiblingInternal(XFA_Element eType) const { return nullptr; } -int32_t CXFA_Node::GetNodeSameNameIndex() const { - CFXJSE_Engine* pScriptContext = m_pDocument->GetScriptContext(); - if (!pScriptContext) { - return -1; - } - return pScriptContext->GetIndexByName(const_cast(this)); -} - -int32_t CXFA_Node::GetNodeSameClassIndex() const { - CFXJSE_Engine* pScriptContext = m_pDocument->GetScriptContext(); - if (!pScriptContext) { - return -1; - } - return pScriptContext->GetIndexByClassName(const_cast(this)); -} - CXFA_Node* CXFA_Node::GetInstanceMgrOfSubform() { CXFA_Node* pInstanceMgr = nullptr; if (m_ePacket == XFA_PacketType::Form) { diff --git a/xfa/fxfa/parser/cxfa_node.h b/xfa/fxfa/parser/cxfa_node.h index 99b035dfc7..3c532b0dc8 100644 --- a/xfa/fxfa/parser/cxfa_node.h +++ b/xfa/fxfa/parser/cxfa_node.h @@ -235,8 +235,6 @@ class CXFA_Node : public CXFA_Object { return static_cast(GetNextSameClassSiblingInternal(eType)); } - int32_t GetNodeSameNameIndex() const; - int32_t GetNodeSameClassIndex() const; CXFA_Node* GetInstanceMgrOfSubform(); CXFA_Occur* GetOccurIfExists(); -- cgit v1.2.3