Use type XFA_ResolveNodeMask more consistently.
Missed a few cases while converting the other day.
-- use constexpr and kNamingStyle where appropriate.
Change-Id: I664da6e9acf6dcbd603e2c07701f5ca8a8bd4e37
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/80995
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
diff --git a/fxjs/xfa/cfxjse_formcalc_context.cpp b/fxjs/xfa/cfxjse_formcalc_context.cpp
index 3acf137..4c21178 100644
--- a/fxjs/xfa/cfxjse_formcalc_context.cpp
+++ b/fxjs/xfa/cfxjse_formcalc_context.cpp
@@ -1552,12 +1552,13 @@
return v8::Local<v8::Value>();
CFXJSE_Engine* pScriptContext = pDoc->GetScriptContext();
- uint32_t dwFlags = XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Properties |
- XFA_RESOLVENODE_Siblings | XFA_RESOLVENODE_Parent;
+ constexpr XFA_ResolveNodeMask kFlags =
+ XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Properties |
+ XFA_RESOLVENODE_Siblings | XFA_RESOLVENODE_Parent;
Optional<CFXJSE_Engine::ResolveResult> maybeResult =
pScriptContext->ResolveObjects(
pScriptContext->GetThisObject(),
- WideString::FromUTF8(bsAccessorName).AsStringView(), dwFlags);
+ WideString::FromUTF8(bsAccessorName).AsStringView(), kFlags);
if (!maybeResult.has_value() ||
maybeResult.value().type != CFXJSE_Engine::ResolveResult::Type::kNodes ||
maybeResult.value().objects.empty()) {
@@ -1581,11 +1582,11 @@
WideString wsSomExpression = WideString::FromUTF8(bsSomExp);
CFXJSE_Engine* pScriptContext = pDoc->GetScriptContext();
CXFA_Object* pNode = nullptr;
- uint32_t dFlags = 0UL;
+ XFA_ResolveNodeMask dwFlags = 0;
if (bDotAccessor) {
if (fxv8::IsNull(pRefValue)) {
pNode = pScriptContext->GetThisObject();
- dFlags = XFA_RESOLVENODE_Siblings | XFA_RESOLVENODE_Parent;
+ dwFlags = XFA_RESOLVENODE_Siblings | XFA_RESOLVENODE_Parent;
} else {
pNode = CFXJSE_Engine::ToObject(pIsolate, pRefValue);
if (!pNode)
@@ -1603,20 +1604,20 @@
wsName = L"#" + WideString::FromASCII(pNode->GetClassName());
wsSomExpression = wsName + wsSomExpression;
- dFlags = XFA_RESOLVENODE_Siblings;
+ dwFlags = XFA_RESOLVENODE_Siblings;
} else {
- dFlags = (bsSomExp == "*")
- ? (XFA_RESOLVENODE_Children)
- : (XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Attributes |
- XFA_RESOLVENODE_Properties);
+ dwFlags = (bsSomExp == "*")
+ ? (XFA_RESOLVENODE_Children)
+ : (XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Attributes |
+ XFA_RESOLVENODE_Properties);
}
}
} else {
pNode = CFXJSE_Engine::ToObject(pIsolate, pRefValue);
- dFlags = XFA_RESOLVENODE_AnyChild;
+ dwFlags = XFA_RESOLVENODE_AnyChild;
}
return pScriptContext->ResolveObjects(pNode, wsSomExpression.AsStringView(),
- dFlags);
+ dwFlags);
}
std::vector<v8::Local<v8::Value>> ParseResolveResult(
diff --git a/fxjs/xfa/cjx_hostpseudomodel.cpp b/fxjs/xfa/cjx_hostpseudomodel.cpp
index e063901..51daeec 100644
--- a/fxjs/xfa/cjx_hostpseudomodel.cpp
+++ b/fxjs/xfa/cjx_hostpseudomodel.cpp
@@ -292,11 +292,12 @@
if (!pObject)
return CJS_Result::Success();
- uint32_t dwFlag = XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Parent |
- XFA_RESOLVENODE_Siblings;
+ constexpr XFA_ResolveNodeMask kFlags = XFA_RESOLVENODE_Children |
+ XFA_RESOLVENODE_Parent |
+ XFA_RESOLVENODE_Siblings;
Optional<CFXJSE_Engine::ResolveResult> maybeResult =
pScriptContext->ResolveObjects(
- pObject, runtime->ToWideString(params[0]).AsStringView(), dwFlag);
+ pObject, runtime->ToWideString(params[0]).AsStringView(), kFlags);
if (!maybeResult.has_value() ||
!maybeResult.value().objects.front()->IsNode()) {
return CJS_Result::Success();
@@ -377,10 +378,11 @@
if (!pObject)
return CJS_Result::Success();
- uint32_t dwFlag = XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Parent |
- XFA_RESOLVENODE_Siblings;
+ constexpr XFA_ResolveNodeMask kFlags = XFA_RESOLVENODE_Children |
+ XFA_RESOLVENODE_Parent |
+ XFA_RESOLVENODE_Siblings;
Optional<CFXJSE_Engine::ResolveResult> maybeResult =
- pScriptContext->ResolveObjects(pObject, wsName.AsStringView(), dwFlag);
+ pScriptContext->ResolveObjects(pObject, wsName.AsStringView(), kFlags);
if (!maybeResult.has_value() ||
!maybeResult.value().objects.front()->IsNode())
continue;
@@ -439,11 +441,12 @@
if (!pObject)
return CJS_Result::Success();
- uint32_t dwFlag = XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Parent |
- XFA_RESOLVENODE_Siblings;
+ constexpr XFA_ResolveNodeMask kFlags = XFA_RESOLVENODE_Children |
+ XFA_RESOLVENODE_Parent |
+ XFA_RESOLVENODE_Siblings;
Optional<CFXJSE_Engine::ResolveResult> maybeResult =
pScriptContext->ResolveObjects(
- pObject, runtime->ToWideString(params[0]).AsStringView(), dwFlag);
+ pObject, runtime->ToWideString(params[0]).AsStringView(), kFlags);
if (!maybeResult.has_value() ||
!maybeResult.value().objects.front()->IsNode()) {
return CJS_Result::Success();
diff --git a/fxjs/xfa/cjx_object.cpp b/fxjs/xfa/cjx_object.cpp
index 8a39e4f..a82382b 100644
--- a/fxjs/xfa/cjx_object.cpp
+++ b/fxjs/xfa/cjx_object.cpp
@@ -1003,13 +1003,13 @@
CXFA_Node* pProtoNode = nullptr;
if (!wsSOM.IsEmpty()) {
- constexpr uint32_t dwFlag =
+ constexpr XFA_ResolveNodeMask kFlags =
XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Attributes |
XFA_RESOLVENODE_Properties | XFA_RESOLVENODE_Parent |
XFA_RESOLVENODE_Siblings;
Optional<CFXJSE_Engine::ResolveResult> maybeResult =
GetDocument()->GetScriptContext()->ResolveObjects(
- pProtoRoot, wsSOM.AsStringView(), dwFlag);
+ pProtoRoot, wsSOM.AsStringView(), kFlags);
if (maybeResult.has_value() &&
maybeResult.value().objects.front()->IsNode()) {
pProtoNode = maybeResult.value().objects.front()->AsNode();
diff --git a/fxjs/xfa/cjx_tree.cpp b/fxjs/xfa/cjx_tree.cpp
index 477374a..f876081 100644
--- a/fxjs/xfa/cjx_tree.cpp
+++ b/fxjs/xfa/cjx_tree.cpp
@@ -41,18 +41,19 @@
if (params.size() != 1)
return CJS_Result::Failure(JSMessage::kParamError);
- WideString expression = runtime->ToWideString(params[0]);
+ WideString wsExpression = runtime->ToWideString(params[0]);
CFXJSE_Engine* pScriptContext = GetDocument()->GetScriptContext();
- CXFA_Object* refNode = GetXFAObject();
- if (refNode->GetElementType() == XFA_Element::Xfa)
- refNode = pScriptContext->GetThisObject();
+ CXFA_Object* pRefNode = GetXFAObject();
+ if (pRefNode->GetElementType() == XFA_Element::Xfa)
+ pRefNode = pScriptContext->GetThisObject();
- uint32_t dwFlag = XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Attributes |
- XFA_RESOLVENODE_Properties | XFA_RESOLVENODE_Parent |
- XFA_RESOLVENODE_Siblings;
+ constexpr XFA_ResolveNodeMask kFlags =
+ XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Attributes |
+ XFA_RESOLVENODE_Properties | XFA_RESOLVENODE_Parent |
+ XFA_RESOLVENODE_Siblings;
Optional<CFXJSE_Engine::ResolveResult> maybeResult =
- pScriptContext->ResolveObjects(ToNode(refNode), expression.AsStringView(),
- dwFlag);
+ pScriptContext->ResolveObjects(ToNode(pRefNode),
+ wsExpression.AsStringView(), kFlags);
if (!maybeResult.has_value())
return CJS_Result::Success(runtime->NewNull());
@@ -87,13 +88,13 @@
refNode = GetDocument()->GetScriptContext()->GetThisObject();
CFXJSE_Engine* pScriptContext = GetDocument()->GetScriptContext();
+ constexpr XFA_ResolveNodeMask kFlags =
+ 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]),
- XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Attributes |
- XFA_RESOLVENODE_Properties | XFA_RESOLVENODE_Parent |
- XFA_RESOLVENODE_Siblings,
- ToNode(refNode));
+ runtime->ToWideString(params[0]), kFlags, ToNode(refNode));
return CJS_Result::Success(pValue);
}
@@ -105,10 +106,10 @@
ThrowInvalidPropertyException();
return;
}
-
- uint32_t dwFlag = XFA_RESOLVENODE_Siblings | XFA_RESOLVENODE_ALL;
+ constexpr XFA_ResolveNodeMask kFlags =
+ XFA_RESOLVENODE_Siblings | XFA_RESOLVENODE_ALL;
WideString wsExpression = GetAttributeByEnum(XFA_Attribute::Name) + L"[*]";
- ResolveNodeList(pIsolate, pValue, wsExpression, dwFlag, nullptr);
+ ResolveNodeList(pIsolate, pValue, wsExpression, kFlags, nullptr);
}
void CJX_Tree::classAll(v8::Isolate* pIsolate,
@@ -119,11 +120,11 @@
ThrowInvalidPropertyException();
return;
}
-
+ constexpr XFA_ResolveNodeMask kFlags =
+ XFA_RESOLVENODE_Siblings | XFA_RESOLVENODE_ALL;
WideString wsExpression =
L"#" + WideString::FromASCII(GetXFAObject()->GetClassName()) + L"[*]";
- ResolveNodeList(pIsolate, pValue, wsExpression,
- XFA_RESOLVENODE_Siblings | XFA_RESOLVENODE_ALL, nullptr);
+ ResolveNodeList(pIsolate, pValue, wsExpression, kFlags, nullptr);
}
void CJX_Tree::nodes(v8::Isolate* pIsolate,
@@ -209,7 +210,7 @@
void CJX_Tree::ResolveNodeList(v8::Isolate* pIsolate,
v8::Local<v8::Value>* pValue,
WideString wsExpression,
- uint32_t dwFlag,
+ XFA_ResolveNodeMask dwFlag,
CXFA_Node* refNode) {
if (!refNode)
refNode = GetXFANode();
diff --git a/fxjs/xfa/cjx_tree.h b/fxjs/xfa/cjx_tree.h
index d155cb7..dcc80d6 100644
--- a/fxjs/xfa/cjx_tree.h
+++ b/fxjs/xfa/cjx_tree.h
@@ -7,6 +7,7 @@
#ifndef FXJS_XFA_CJX_TREE_H_
#define FXJS_XFA_CJX_TREE_H_
+#include "fxjs/xfa/cfxjse_engine.h"
#include "fxjs/xfa/cjx_object.h"
#include "fxjs/xfa/jse_define.h"
@@ -46,7 +47,7 @@
void ResolveNodeList(v8::Isolate* pIsolate,
v8::Local<v8::Value>* pValue,
WideString wsExpression,
- uint32_t dwFlag,
+ XFA_ResolveNodeMask dwFlag,
CXFA_Node* refNode);
};
diff --git a/xfa/fxfa/cxfa_ffdocview.cpp b/xfa/fxfa/cxfa_ffdocview.cpp
index 53770b3..56401f3 100644
--- a/xfa/fxfa/cxfa_ffdocview.cpp
+++ b/xfa/fxfa/cxfa_ffdocview.cpp
@@ -436,13 +436,12 @@
pRefNode = node->IsWidgetReady() ? node : nullptr;
}
WideString wsExpression = (!pRefNode ? L"$form." : L"") + wsName;
-
- constexpr uint32_t kStyle = XFA_RESOLVENODE_Children |
- XFA_RESOLVENODE_Properties |
- XFA_RESOLVENODE_Siblings | XFA_RESOLVENODE_Parent;
+ constexpr XFA_ResolveNodeMask kFlags =
+ XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Properties |
+ XFA_RESOLVENODE_Siblings | XFA_RESOLVENODE_Parent;
Optional<CFXJSE_Engine::ResolveResult> maybeResult =
pScriptContext->ResolveObjects(pRefNode, wsExpression.AsStringView(),
- kStyle);
+ kFlags);
if (!maybeResult.has_value())
return nullptr;
@@ -637,12 +636,12 @@
CFXJSE_Engine* pScriptContext =
pWidgetNode->GetDocument()->GetScriptContext();
WideString wsRef = item->GetRef();
- constexpr uint32_t kStyle =
+ constexpr XFA_ResolveNodeMask kFlags =
XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Properties |
XFA_RESOLVENODE_Siblings | XFA_RESOLVENODE_Parent | XFA_RESOLVENODE_ALL;
Optional<CFXJSE_Engine::ResolveResult> maybeRS =
pScriptContext->ResolveObjects(pWidgetNode, wsRef.AsStringView(),
- kStyle);
+ kFlags);
pWidgetNode->DeleteItem(-1, false, false);
if (!maybeRS.has_value() ||
maybeRS.value().type != CFXJSE_Engine::ResolveResult::Type::kNodes ||
diff --git a/xfa/fxfa/layout/cxfa_viewlayoutprocessor.cpp b/xfa/fxfa/layout/cxfa_viewlayoutprocessor.cpp
index 8e0b9c2..17fd7fa 100644
--- a/xfa/fxfa/layout/cxfa_viewlayoutprocessor.cpp
+++ b/xfa/fxfa/layout/cxfa_viewlayoutprocessor.cpp
@@ -209,16 +209,17 @@
if (wsExpr.First(4).EqualsASCII("som(") && wsExpr.Back() == L')')
wsProcessedTarget = wsExpr.Substr(4, wsExpr.GetLength() - 5);
- constexpr uint32_t dwFlag =
+ constexpr XFA_ResolveNodeMask kFlags =
XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Properties |
XFA_RESOLVENODE_Attributes | XFA_RESOLVENODE_Siblings |
XFA_RESOLVENODE_Parent;
Optional<CFXJSE_Engine::ResolveResult> maybeResult =
pDocument->GetScriptContext()->ResolveObjects(
- pPageSetRoot, wsProcessedTarget.AsStringView(), dwFlag);
+ pPageSetRoot, wsProcessedTarget.AsStringView(), kFlags);
if (maybeResult.has_value() &&
- maybeResult.value().objects.front()->IsNode())
+ maybeResult.value().objects.front()->IsNode()) {
return maybeResult.value().objects.front()->AsNode();
+ }
}
iSplitIndex = iSplitNextIndex.value();
}
diff --git a/xfa/fxfa/parser/cxfa_document.cpp b/xfa/fxfa/parser/cxfa_document.cpp
index ba5bd02..4ec94e9 100644
--- a/xfa/fxfa/parser/cxfa_document.cpp
+++ b/xfa/fxfa/parser/cxfa_document.cpp
@@ -347,13 +347,14 @@
CXFA_Node* pTemplateNode,
bool bForceBind,
bool bUpLevel) {
- uint32_t dFlags = XFA_RESOLVENODE_Children | XFA_RESOLVENODE_BindNew;
+ XFA_ResolveNodeMask dwFlags =
+ XFA_RESOLVENODE_Children | XFA_RESOLVENODE_BindNew;
if (bUpLevel || !wsRef.EqualsASCII("name"))
- dFlags |= (XFA_RESOLVENODE_Parent | XFA_RESOLVENODE_Siblings);
+ dwFlags |= (XFA_RESOLVENODE_Parent | XFA_RESOLVENODE_Siblings);
Optional<CFXJSE_Engine::ResolveResult> maybeResult =
pDocument->GetScriptContext()->ResolveObjectsWithBindNode(
- pDataScope, wsRef.AsStringView(), dFlags, pTemplateNode);
+ pDataScope, wsRef.AsStringView(), dwFlags, pTemplateNode);
if (!maybeResult.has_value())
return nullptr;
@@ -1198,11 +1199,11 @@
pTemplateNodeBind
? pTemplateNodeBind->JSObject()->GetCData(XFA_Attribute::Ref)
: WideString();
- uint32_t dFlags =
+ constexpr XFA_ResolveNodeMask kFlags =
XFA_RESOLVENODE_Children | XFA_RESOLVENODE_CreateNode;
Optional<CFXJSE_Engine::ResolveResult> maybeResult =
pDocument->GetScriptContext()->ResolveObjectsWithBindNode(
- pDataScope, wsRef.AsStringView(), dFlags, pTemplateNode);
+ pDataScope, wsRef.AsStringView(), kFlags, pTemplateNode);
CXFA_Object* pObject =
maybeResult.has_value() && !maybeResult.value().objects.empty()
? maybeResult.value().objects.front().Get()