From 8946aec4c3e727aae806f9858c2329ce368dd517 Mon Sep 17 00:00:00 2001 From: Dan Sinclair Date: Thu, 2 Nov 2017 19:15:03 +0000 Subject: Remove default values from CJX_Node::TryContent This CL removes the default values from TryContent and inlines into the call sites. Change-Id: I2d3f41f77364a0b923931479a60e07eae98dd5a9 Reviewed-on: https://pdfium-review.googlesource.com/17550 Commit-Queue: dsinclair Reviewed-by: Tom Sepez --- fxjs/cjx_node.cpp | 4 ++-- fxjs/cjx_node.h | 4 +--- xfa/fxfa/cxfa_ffdoc.cpp | 4 +++- xfa/fxfa/parser/cxfa_bind.cpp | 2 +- xfa/fxfa/parser/cxfa_document.cpp | 2 +- xfa/fxfa/parser/cxfa_image.cpp | 2 +- xfa/fxfa/parser/cxfa_layoutpagemgr.cpp | 2 +- xfa/fxfa/parser/cxfa_script.cpp | 2 +- xfa/fxfa/parser/cxfa_text.cpp | 2 +- xfa/fxfa/parser/cxfa_tooltip.cpp | 2 +- xfa/fxfa/parser/cxfa_validate.cpp | 4 ++-- xfa/fxfa/parser/cxfa_value.cpp | 2 +- xfa/fxfa/parser/cxfa_widgetdata.cpp | 30 +++++++++++++------------ xfa/fxfa/parser/xfa_document_datamerger_imp.cpp | 8 +++---- 14 files changed, 36 insertions(+), 34 deletions(-) diff --git a/fxjs/cjx_node.cpp b/fxjs/cjx_node.cpp index 1724881c55..b4f480e537 100644 --- a/fxjs/cjx_node.cpp +++ b/fxjs/cjx_node.cpp @@ -959,7 +959,7 @@ void CJX_Node::Script_NodeClass_IsNull(CFXJSE_Value* pValue, return; } WideString strValue; - pValue->SetBoolean(!TryContent(strValue) || strValue.IsEmpty()); + pValue->SetBoolean(!TryContent(strValue, false, true) || strValue.IsEmpty()); } void CJX_Node::Script_NodeClass_OneOfChild(CFXJSE_Value* pValue, @@ -3508,7 +3508,7 @@ bool CJX_Node::SetContent(const WideString& wsContent, WideString CJX_Node::GetScriptContent(bool bScriptModify) { WideString wsContent; - return TryContent(wsContent, bScriptModify) ? wsContent : WideString(); + return TryContent(wsContent, bScriptModify, true) ? wsContent : WideString(); } WideString CJX_Node::GetContent() { diff --git a/fxjs/cjx_node.h b/fxjs/cjx_node.h index 7df789df50..7256e31c19 100644 --- a/fxjs/cjx_node.h +++ b/fxjs/cjx_node.h @@ -92,9 +92,7 @@ class CJX_Node : public CJX_Object { bool bScriptModify); WideStringView GetCData(XFA_ATTRIBUTE eAttr); - bool TryContent(WideString& wsContent, - bool bScriptModify = false, - bool bProto = true); + bool TryContent(WideString& wsContent, bool bScriptModify, bool bProto); bool TryEnum(XFA_ATTRIBUTE eAttr, XFA_ATTRIBUTEENUM& eValue, diff --git a/xfa/fxfa/cxfa_ffdoc.cpp b/xfa/fxfa/cxfa_ffdoc.cpp index 5b00d5a579..244e243273 100644 --- a/xfa/fxfa/cxfa_ffdoc.cpp +++ b/xfa/fxfa/cxfa_ffdoc.cpp @@ -264,8 +264,10 @@ void CXFA_FFDoc::StopLoad() { return; WideString wsType; - if (pDynamicRender->JSNode()->TryContent(wsType) && wsType == L"required") + if (pDynamicRender->JSNode()->TryContent(wsType, false, true) && + wsType == L"required") { m_FormType = FormType::kXFAFull; + } } CXFA_FFDocView* CXFA_FFDoc::CreateDocView() { diff --git a/xfa/fxfa/parser/cxfa_bind.cpp b/xfa/fxfa/parser/cxfa_bind.cpp index 3c16661364..a3764d0eaf 100644 --- a/xfa/fxfa/parser/cxfa_bind.cpp +++ b/xfa/fxfa/parser/cxfa_bind.cpp @@ -12,5 +12,5 @@ CXFA_Bind::CXFA_Bind(CXFA_Node* pNode) : CXFA_Data(pNode) {} void CXFA_Bind::GetPicture(WideString& wsPicture) { if (CXFA_Node* pPicture = m_pNode->GetChild(0, XFA_Element::Picture)) - pPicture->JSNode()->TryContent(wsPicture); + pPicture->JSNode()->TryContent(wsPicture, false, true); } diff --git a/xfa/fxfa/parser/cxfa_document.cpp b/xfa/fxfa/parser/cxfa_document.cpp index d2c2da814d..3d263132d4 100644 --- a/xfa/fxfa/parser/cxfa_document.cpp +++ b/xfa/fxfa/parser/cxfa_document.cpp @@ -267,7 +267,7 @@ bool CXFA_Document::IsInteractive() { CXFA_Node* pFormFiller = pPDF->GetChild(0, XFA_Element::Interactive); if (pFormFiller) { m_dwDocFlags |= XFA_DOCFLAG_HasInteractive; - if (pFormFiller->JSNode()->TryContent(wsInteractive) && + if (pFormFiller->JSNode()->TryContent(wsInteractive, false, true) && wsInteractive == L"1") { m_dwDocFlags |= XFA_DOCFLAG_Interactive; return true; diff --git a/xfa/fxfa/parser/cxfa_image.cpp b/xfa/fxfa/parser/cxfa_image.cpp index 08a10884f4..0e23cb1b38 100644 --- a/xfa/fxfa/parser/cxfa_image.cpp +++ b/xfa/fxfa/parser/cxfa_image.cpp @@ -33,7 +33,7 @@ int32_t CXFA_Image::GetTransferEncoding() { } bool CXFA_Image::GetContent(WideString& wsText) { - return m_pNode->JSNode()->TryContent(wsText); + return m_pNode->JSNode()->TryContent(wsText, false, true); } bool CXFA_Image::SetContentType(const WideString& wsContentType) { diff --git a/xfa/fxfa/parser/cxfa_layoutpagemgr.cpp b/xfa/fxfa/parser/cxfa_layoutpagemgr.cpp index 2c1e6e4fd3..2def914529 100644 --- a/xfa/fxfa/parser/cxfa_layoutpagemgr.cpp +++ b/xfa/fxfa/parser/cxfa_layoutpagemgr.cpp @@ -480,7 +480,7 @@ float CXFA_LayoutPageMgr::GetAvailHeight() { bool XFA_LayoutPageMgr_RunBreakTestScript(CXFA_Node* pTestScript) { WideString wsExpression; - pTestScript->JSNode()->TryContent(wsExpression); + pTestScript->JSNode()->TryContent(wsExpression, false, true); if (wsExpression.IsEmpty()) return true; return pTestScript->GetDocument()->GetNotify()->RunScript( diff --git a/xfa/fxfa/parser/cxfa_script.cpp b/xfa/fxfa/parser/cxfa_script.cpp index c548dea394..fcb0f95af1 100644 --- a/xfa/fxfa/parser/cxfa_script.cpp +++ b/xfa/fxfa/parser/cxfa_script.cpp @@ -27,5 +27,5 @@ int32_t CXFA_Script::GetRunAt() { } void CXFA_Script::GetExpression(WideString& wsExpression) { - m_pNode->JSNode()->TryContent(wsExpression); + m_pNode->JSNode()->TryContent(wsExpression, false, true); } diff --git a/xfa/fxfa/parser/cxfa_text.cpp b/xfa/fxfa/parser/cxfa_text.cpp index 9d743fa518..7abca0a92f 100644 --- a/xfa/fxfa/parser/cxfa_text.cpp +++ b/xfa/fxfa/parser/cxfa_text.cpp @@ -11,5 +11,5 @@ CXFA_Text::CXFA_Text(CXFA_Node* pNode) : CXFA_Data(pNode) {} void CXFA_Text::GetContent(WideString& wsText) { - m_pNode->JSNode()->TryContent(wsText); + m_pNode->JSNode()->TryContent(wsText, false, true); } diff --git a/xfa/fxfa/parser/cxfa_tooltip.cpp b/xfa/fxfa/parser/cxfa_tooltip.cpp index fed28d0f32..7e56c669d5 100644 --- a/xfa/fxfa/parser/cxfa_tooltip.cpp +++ b/xfa/fxfa/parser/cxfa_tooltip.cpp @@ -11,5 +11,5 @@ CXFA_ToolTip::CXFA_ToolTip(CXFA_Node* pNode) : CXFA_Data(pNode) {} bool CXFA_ToolTip::GetTip(WideString& wsTip) { - return m_pNode->JSNode()->TryContent(wsTip); + return m_pNode->JSNode()->TryContent(wsTip, false, true); } diff --git a/xfa/fxfa/parser/cxfa_validate.cpp b/xfa/fxfa/parser/cxfa_validate.cpp index 60837161d7..513d6b45c1 100644 --- a/xfa/fxfa/parser/cxfa_validate.cpp +++ b/xfa/fxfa/parser/cxfa_validate.cpp @@ -56,7 +56,7 @@ void CXFA_Validate::GetMessageText(WideString& wsMessage, WideStringView wsName; pItemNode->JSNode()->TryCData(XFA_ATTRIBUTE_Name, wsName, true); if (wsName.IsEmpty() || wsName == wsMessageType) { - pItemNode->JSNode()->TryContent(wsMessage); + pItemNode->JSNode()->TryContent(wsMessage, false, true); return; } } @@ -115,7 +115,7 @@ void CXFA_Validate::SetScriptMessageText(WideString wsMessage) { void CXFA_Validate::GetPicture(WideString& wsPicture) { if (CXFA_Node* pNode = m_pNode->GetChild(0, XFA_Element::Picture)) - pNode->JSNode()->TryContent(wsPicture); + pNode->JSNode()->TryContent(wsPicture, false, true); } CXFA_Script CXFA_Validate::GetScript() { diff --git a/xfa/fxfa/parser/cxfa_value.cpp b/xfa/fxfa/parser/cxfa_value.cpp index 2b32e9d25e..f2bdf64805 100644 --- a/xfa/fxfa/parser/cxfa_value.cpp +++ b/xfa/fxfa/parser/cxfa_value.cpp @@ -20,7 +20,7 @@ bool CXFA_Value::GetChildValueContent(WideString& wsContent) { if (!m_pNode) return false; if (CXFA_Node* pNode = m_pNode->GetNodeItem(XFA_NODEITEM_FirstChild)) - return pNode->JSNode()->TryContent(wsContent); + return pNode->JSNode()->TryContent(wsContent, false, true); return false; } diff --git a/xfa/fxfa/parser/cxfa_widgetdata.cpp b/xfa/fxfa/parser/cxfa_widgetdata.cpp index 1d6ea33859..53ab6b4bfe 100644 --- a/xfa/fxfa/parser/cxfa_widgetdata.cpp +++ b/xfa/fxfa/parser/cxfa_widgetdata.cpp @@ -447,7 +447,7 @@ bool CXFA_WidgetData::GetButtonRollover(WideString& wsRollover, WideStringView wsName; pText->JSNode()->TryCData(XFA_ATTRIBUTE_Name, wsName, true); if (wsName == L"rollover") { - pText->JSNode()->TryContent(wsRollover); + pText->JSNode()->TryContent(wsRollover, false, true); bRichText = pText->GetElementType() == XFA_Element::ExData; return !wsRollover.IsEmpty(); } @@ -464,7 +464,7 @@ bool CXFA_WidgetData::GetButtonDown(WideString& wsDown, bool& bRichText) { WideStringView wsName; pText->JSNode()->TryCData(XFA_ATTRIBUTE_Name, wsName, true); if (wsName == L"down") { - pText->JSNode()->TryContent(wsDown); + pText->JSNode()->TryContent(wsDown, false, true); bRichText = pText->GetElementType() == XFA_Element::ExData; return !wsDown.IsEmpty(); } @@ -525,8 +525,10 @@ XFA_CHECKSTATE CXFA_WidgetData::GetCheckState() { int32_t i = 0; while (pText) { WideString wsContent; - if (pText->JSNode()->TryContent(wsContent) && (wsContent == wsValue)) + if (pText->JSNode()->TryContent(wsContent, false, true) && + (wsContent == wsValue)) { return (XFA_CHECKSTATE)i; + } i++; pText = pText->GetNodeItem(XFA_NODEITEM_NextSibling); @@ -543,7 +545,7 @@ void CXFA_WidgetData::SetCheckState(XFA_CHECKSTATE eCheckState, bool bNotify) { if (CXFA_Node* pItems = m_pNode->GetChild(0, XFA_Element::Items)) { CXFA_Node* pText = pItems->GetNodeItem(XFA_NODEITEM_FirstChild); if (pText) - pText->JSNode()->TryContent(wsValue); + pText->JSNode()->TryContent(wsValue, false, true); } } CXFA_Node* pChild = @@ -584,7 +586,7 @@ void CXFA_WidgetData::SetCheckState(XFA_CHECKSTATE eCheckState, bool bNotify) { while (pText) { i++; if (i == eCheckState) { - pText->JSNode()->TryContent(wsContent); + pText->JSNode()->TryContent(wsContent, false, true); break; } pText = pText->GetNodeItem(XFA_NODEITEM_NextSibling); @@ -782,7 +784,7 @@ bool CXFA_WidgetData::GetChoiceListItem(WideString& wsText, if (pItems) { CXFA_Node* pItem = pItems->GetChild(nIndex, XFA_Element::Unknown); if (pItem) { - pItem->JSNode()->TryContent(wsText); + pItem->JSNode()->TryContent(wsText, false, true); return true; } } @@ -812,7 +814,7 @@ std::vector CXFA_WidgetData::GetChoiceListItems(bool bSaveValue) { for (CXFA_Node* pNode = pItem->GetNodeItem(XFA_NODEITEM_FirstChild); pNode; pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { wsTextArray.emplace_back(); - pNode->JSNode()->TryContent(wsTextArray.back()); + pNode->JSNode()->TryContent(wsTextArray.back(), false, true); } return wsTextArray; } @@ -1014,7 +1016,7 @@ void CXFA_WidgetData::InsertItem(const WideString& wsLabel, int32_t i = 0; while (pListNode) { WideString wsOldValue; - pListNode->JSNode()->TryContent(wsOldValue); + pListNode->JSNode()->TryContent(wsOldValue, false, true); InsertListTextItem(pSaveItems, wsOldValue, i); i++; pListNode = pListNode->GetNodeItem(XFA_NODEITEM_NextSibling); @@ -1058,7 +1060,7 @@ void CXFA_WidgetData::GetItemLabel(const WideStringView& wsValue, CXFA_Node* pChildItem = pSaveItems->GetNodeItem(XFA_NODEITEM_FirstChild); for (; pChildItem; pChildItem = pChildItem->GetNodeItem(XFA_NODEITEM_NextSibling)) { - pChildItem->JSNode()->TryContent(wsContent); + pChildItem->JSNode()->TryContent(wsContent, false, true); if (wsContent == wsValue) { iSearch = iCount; break; @@ -1069,7 +1071,7 @@ void CXFA_WidgetData::GetItemLabel(const WideStringView& wsValue, return; if (CXFA_Node* pText = pLabelItems->GetChild(iSearch, XFA_Element::Unknown)) { - pText->JSNode()->TryContent(wsLabel); + pText->JSNode()->TryContent(wsLabel, false, true); } } } @@ -1103,7 +1105,7 @@ void CXFA_WidgetData::GetItemValue(const WideStringView& wsLabel, CXFA_Node* pChildItem = pLabelItems->GetNodeItem(XFA_NODEITEM_FirstChild); for (; pChildItem; pChildItem = pChildItem->GetNodeItem(XFA_NODEITEM_NextSibling)) { - pChildItem->JSNode()->TryContent(wsContent); + pChildItem->JSNode()->TryContent(wsContent, false, true); if (wsContent == wsLabel) { iSearch = iCount; break; @@ -1113,7 +1115,7 @@ void CXFA_WidgetData::GetItemValue(const WideStringView& wsLabel, if (iSearch < 0) return; if (CXFA_Node* pText = pSaveItems->GetChild(iSearch, XFA_Element::Unknown)) - pText->JSNode()->TryContent(wsValue); + pText->JSNode()->TryContent(wsValue, false, true); } } @@ -1500,7 +1502,7 @@ bool CXFA_WidgetData::GetPictureContent(WideString& wsPicture, case XFA_VALUEPICTURE_Display: { if (CXFA_Node* pFormat = m_pNode->GetChild(0, XFA_Element::Format)) { if (CXFA_Node* pPicture = pFormat->GetChild(0, XFA_Element::Picture)) { - if (pPicture->JSNode()->TryContent(wsPicture)) + if (pPicture->JSNode()->TryContent(wsPicture, false, true)) return true; } } @@ -1537,7 +1539,7 @@ bool CXFA_WidgetData::GetPictureContent(WideString& wsPicture, CXFA_Node* pUI = m_pNode->GetChild(0, XFA_Element::Ui); if (pUI) { if (CXFA_Node* pPicture = pUI->GetChild(0, XFA_Element::Picture)) { - if (pPicture->JSNode()->TryContent(wsPicture)) + if (pPicture->JSNode()->TryContent(wsPicture, false, true)) return true; } } diff --git a/xfa/fxfa/parser/xfa_document_datamerger_imp.cpp b/xfa/fxfa/parser/xfa_document_datamerger_imp.cpp index ee9e78f0e3..478a1783f6 100644 --- a/xfa/fxfa/parser/xfa_document_datamerger_imp.cpp +++ b/xfa/fxfa/parser/xfa_document_datamerger_imp.cpp @@ -221,7 +221,7 @@ void CreateDataBinding(CXFA_Node* pFormNode, continue; WideString wsContent; - if (pText->JSNode()->TryContent(wsContent) && + if (pText->JSNode()->TryContent(wsContent, false, true) && (wsContent == wsValue)) { pChecked = pChild; wsFormattedValue = wsValue; @@ -252,7 +252,7 @@ void CreateDataBinding(CXFA_Node* pFormNode, WideString wsContent; if (pText) - pText->JSNode()->TryContent(wsContent); + pText->JSNode()->TryContent(wsContent, false, true); FormValueNode_SetChildContent(pValue, wsContent, XFA_Element::Text); } @@ -288,7 +288,7 @@ void CreateDataBinding(CXFA_Node* pFormNode, } WideString wsXMLValue; - pDataNode->JSNode()->TryContent(wsXMLValue); + pDataNode->JSNode()->TryContent(wsXMLValue, false, true); WideString wsNormalizeValue; pWidgetData->GetNormalizeDataValue(wsXMLValue, wsNormalizeValue); pDataNode->JSNode()->SetAttributeValue(wsNormalizeValue, wsXMLValue, false, @@ -325,7 +325,7 @@ void CreateDataBinding(CXFA_Node* pFormNode, wsNormalizeValue.clear(); WideString wsItem; for (CXFA_Node* pNode : items) { - pNode->JSNode()->TryContent(wsItem); + pNode->JSNode()->TryContent(wsItem, false, true); wsItem = single ? wsItem : wsItem + L"\n"; wsNormalizeValue += wsItem; } -- cgit v1.2.3