Remove out parameter from CJX_Tree::ResolveNodeList()
Re-order a few statements to make clearer.
Change-Id: I6eed933f9daf58a87e79b4a74ed29de1a5b98c5c
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/81010
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
diff --git a/fxjs/xfa/cjx_tree.cpp b/fxjs/xfa/cjx_tree.cpp
index f876081..17d18b6 100644
--- a/fxjs/xfa/cjx_tree.cpp
+++ b/fxjs/xfa/cjx_tree.cpp
@@ -92,10 +92,9 @@
XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Attributes |
XFA_RESOLVENODE_Properties | XFA_RESOLVENODE_Parent |
XFA_RESOLVENODE_Siblings;
- v8::Local<v8::Value> pValue;
- ResolveNodeList(pScriptContext->GetIsolate(), &pValue,
- runtime->ToWideString(params[0]), kFlags, ToNode(refNode));
- return CJS_Result::Success(pValue);
+ return CJS_Result::Success(ResolveNodeList(pScriptContext->GetIsolate(),
+ runtime->ToWideString(params[0]),
+ kFlags, ToNode(refNode)));
}
void CJX_Tree::all(v8::Isolate* pIsolate,
@@ -109,7 +108,7 @@
constexpr XFA_ResolveNodeMask kFlags =
XFA_RESOLVENODE_Siblings | XFA_RESOLVENODE_ALL;
WideString wsExpression = GetAttributeByEnum(XFA_Attribute::Name) + L"[*]";
- ResolveNodeList(pIsolate, pValue, wsExpression, kFlags, nullptr);
+ *pValue = ResolveNodeList(pIsolate, wsExpression, kFlags, nullptr);
}
void CJX_Tree::classAll(v8::Isolate* pIsolate,
@@ -124,7 +123,7 @@
XFA_RESOLVENODE_Siblings | XFA_RESOLVENODE_ALL;
WideString wsExpression =
L"#" + WideString::FromASCII(GetXFAObject()->GetClassName()) + L"[*]";
- ResolveNodeList(pIsolate, pValue, wsExpression, kFlags, nullptr);
+ *pValue = ResolveNodeList(pIsolate, wsExpression, kFlags, nullptr);
}
void CJX_Tree::nodes(v8::Isolate* pIsolate,
@@ -207,24 +206,23 @@
*pValue = fxv8::NewStringHelper(pIsolate, bsSOMExpression.AsStringView());
}
-void CJX_Tree::ResolveNodeList(v8::Isolate* pIsolate,
- v8::Local<v8::Value>* pValue,
- WideString wsExpression,
- XFA_ResolveNodeMask dwFlag,
- CXFA_Node* refNode) {
+v8::Local<v8::Value> CJX_Tree::ResolveNodeList(v8::Isolate* pIsolate,
+ WideString wsExpression,
+ XFA_ResolveNodeMask dwFlag,
+ CXFA_Node* refNode) {
if (!refNode)
refNode = GetXFANode();
CXFA_Document* pDoc = GetDocument();
+ auto* pNodeList = cppgc::MakeGarbageCollected<CXFA_ArrayNodeList>(
+ pDoc->GetHeap()->GetAllocationHandle(), pDoc);
+ pDoc->GetNodeOwner()->PersistList(pNodeList);
+
CFXJSE_Engine* pScriptContext = pDoc->GetScriptContext();
Optional<CFXJSE_Engine::ResolveResult> maybeResult =
pScriptContext->ResolveObjects(refNode, wsExpression.AsStringView(),
dwFlag);
- auto* pNodeList = cppgc::MakeGarbageCollected<CXFA_ArrayNodeList>(
- pDoc->GetHeap()->GetAllocationHandle(), pDoc);
- pDoc->GetNodeOwner()->PersistList(pNodeList);
-
if (maybeResult.has_value()) {
if (maybeResult.value().type ==
CFXJSE_Engine::ResolveResult::Type::kNodes) {
@@ -250,6 +248,6 @@
}
}
}
- *pValue = pNodeList->JSObject()->NewBoundV8Object(
+ return pNodeList->JSObject()->NewBoundV8Object(
pIsolate, pScriptContext->GetJseNormalClass()->GetTemplate(pIsolate));
}
diff --git a/fxjs/xfa/cjx_tree.h b/fxjs/xfa/cjx_tree.h
index dcc80d6..271558e 100644
--- a/fxjs/xfa/cjx_tree.h
+++ b/fxjs/xfa/cjx_tree.h
@@ -44,11 +44,10 @@
static const TypeTag static_type__ = TypeTag::Tree;
static const CJX_MethodSpec MethodSpecs[];
- void ResolveNodeList(v8::Isolate* pIsolate,
- v8::Local<v8::Value>* pValue,
- WideString wsExpression,
- XFA_ResolveNodeMask dwFlag,
- CXFA_Node* refNode);
+ v8::Local<v8::Value> ResolveNodeList(v8::Isolate* pIsolate,
+ WideString wsExpression,
+ XFA_ResolveNodeMask dwFlag,
+ CXFA_Node* refNode);
};
#endif // FXJS_XFA_CJX_TREE_H_