Simplify interface to CJX_Object::SetAttributeValue(). All public callers to CJX_Object::SetAttributeValue() pass in the same values for the 2 boolean paramters. So rename SetAttributeValue() to SetAttributeValueImpl(), mark SetAttributeValueImpl() as protected, and add a new public SetAttributeValue() with fewer parameters. Change-Id: I37ef5c8eb8a6c1ae6603fe9e34b53518eb5c5565 Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/74072 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
diff --git a/fxjs/xfa/cjx_object.cpp b/fxjs/xfa/cjx_object.cpp index a97c973..e0ae131 100644 --- a/fxjs/xfa/cjx_object.cpp +++ b/fxjs/xfa/cjx_object.cpp
@@ -494,9 +494,14 @@ } void CJX_Object::SetAttributeValue(const WideString& wsValue, - const WideString& wsXMLValue, - bool bNotify, - bool bScriptModify) { + const WideString& wsXMLValue) { + SetAttributeValueImpl(wsValue, wsXMLValue, false, false); +} + +void CJX_Object::SetAttributeValueImpl(const WideString& wsValue, + const WideString& wsXMLValue, + bool bNotify, + bool bScriptModify) { auto* xfaObj = GetXFANode(); void* pKey = GetMapKey_Element(xfaObj->GetElementType(), XFA_Attribute::Value); @@ -603,8 +608,8 @@ ASSERT(valueNodes.size() == wsSaveTextArray.size()); size_t i = 0; for (CXFA_Node* pValueNode : valueNodes) { - pValueNode->JSObject()->SetAttributeValue( - wsSaveTextArray[i], wsSaveTextArray[i], false, false); + pValueNode->JSObject()->SetAttributeValue(wsSaveTextArray[i], + wsSaveTextArray[i]); i++; } for (auto* pArrayNode : pBind->GetBindItemsCopy()) { @@ -701,7 +706,7 @@ if (!pNode) return; - SetAttributeValue(wsContent, wsXMLValue, bNotify, bScriptModify); + SetAttributeValueImpl(wsContent, wsXMLValue, bNotify, bScriptModify); if (pBindNode && bSyncData) { for (auto* pArrayNode : pBindNode->GetBindItemsCopy()) { pArrayNode->JSObject()->SetContent(wsContent, wsContent, bNotify,
diff --git a/fxjs/xfa/cjx_object.h b/fxjs/xfa/cjx_object.h index 9fccd50..7672926 100644 --- a/fxjs/xfa/cjx_object.h +++ b/fxjs/xfa/cjx_object.h
@@ -168,9 +168,7 @@ } void SetAttributeValue(const WideString& wsValue, - const WideString& wsXMLValue, - bool bNotify, - bool bScriptModify); + const WideString& wsXMLValue); // Not actual properties, but invoked as property handlers to cover // a broad range of underlying properties. @@ -235,6 +233,10 @@ protected: explicit CJX_Object(CXFA_Object* obj); + void SetAttributeValueImpl(const WideString& wsValue, + const WideString& wsXMLValue, + bool bNotify, + bool bScriptModify); void SetCDataImpl(XFA_Attribute eAttr, const WideString& wsValue, bool bNotify,
diff --git a/xfa/fxfa/parser/cxfa_document.cpp b/xfa/fxfa/parser/cxfa_document.cpp index 514949e..a01d8b0 100644 --- a/xfa/fxfa/parser/cxfa_document.cpp +++ b/xfa/fxfa/parser/cxfa_document.cpp
@@ -511,7 +511,7 @@ ToXMLElement(pDataNode->GetXMLMappingNode()); ASSERT(pXMLDataElement); pDataNode->JSObject()->SetAttributeValue( - wsValue, pFormNode->GetFormatDataValue(wsValue), false, false); + wsValue, pFormNode->GetFormatDataValue(wsValue)); pDataNode->JSObject()->SetCData(XFA_Attribute::ContentType, wsContentType); if (!wsHref.IsEmpty()) @@ -540,7 +540,7 @@ } } else if (!wsValue.IsEmpty()) { pDataNode->JSObject()->SetAttributeValue( - wsValue, pFormNode->GetFormatDataValue(wsValue), false, false); + wsValue, pFormNode->GetFormatDataValue(wsValue)); } break; case XFA_FFWidgetType::kCheckButton: @@ -549,7 +549,7 @@ break; pDataNode->JSObject()->SetAttributeValue( - wsValue, pFormNode->GetFormatDataValue(wsValue), false, false); + wsValue, pFormNode->GetFormatDataValue(wsValue)); break; case XFA_FFWidgetType::kExclGroup: { CXFA_Node* pChecked = nullptr; @@ -579,8 +579,7 @@ WideString wsContent = pText->JSObject()->GetContent(false); if (wsContent == wsValue) { pChecked = pChild; - pDataNode->JSObject()->SetAttributeValue(wsValue, wsValue, false, - false); + pDataNode->JSObject()->SetAttributeValue(wsValue, wsValue); pFormNode->JSObject()->SetCData(XFA_Attribute::Value, wsContent); break; } @@ -619,7 +618,7 @@ wsValue = pFormNode->NormalizeNumStr(wsValue); pDataNode->JSObject()->SetAttributeValue( - wsValue, pFormNode->GetFormatDataValue(wsValue), false, false); + wsValue, pFormNode->GetFormatDataValue(wsValue)); CXFA_Value* pValue = pFormNode->JSObject()->GetOrCreateProperty<CXFA_Value>( 0, XFA_Element::Value); @@ -632,7 +631,7 @@ break; pDataNode->JSObject()->SetAttributeValue( - wsValue, pFormNode->GetFormatDataValue(wsValue), false, false); + wsValue, pFormNode->GetFormatDataValue(wsValue)); break; } return; @@ -641,8 +640,7 @@ WideString wsXMLValue = pDataNode->JSObject()->GetContent(false); WideString wsNormalizeValue = pFormNode->GetNormalizeDataValue(wsXMLValue); - pDataNode->JSObject()->SetAttributeValue(wsNormalizeValue, wsXMLValue, false, - false); + pDataNode->JSObject()->SetAttributeValue(wsNormalizeValue, wsXMLValue); switch (pFormNode->GetFFWidgetType()) { case XFA_FFWidgetType::kImageEdit: { FormValueNode_SetChildContent(defValue, wsNormalizeValue,