diff options
author | Dan Sinclair <dsinclair@chromium.org> | 2018-02-13 21:44:33 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2018-02-13 21:44:33 +0000 |
commit | fa3765cce4da4c3923e525f0462afd794360d221 (patch) | |
tree | 2a246bc47d7584edf5d8dd2c124f6c21c26cd5c8 /xfa/fxfa | |
parent | 9c112f92d4c2046d5a4f8538f4d18b74a87649d4 (diff) | |
download | pdfium-fa3765cce4da4c3923e525f0462afd794360d221.tar.xz |
Cleanup CFX_XMLNode pointers
This CL cleans up hte CFX_XMLNode pointers. Each pointer has been
renamed to make the usage clearer, the NodeItems method has been removed
in favour of distinct accessors and the node pointers have been made
private.
Change-Id: I5459a77a0ae93b08741a0cd59266ef9c81ddad75
Reviewed-on: https://pdfium-review.googlesource.com/26550
Commit-Queue: dsinclair <dsinclair@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'xfa/fxfa')
-rw-r--r-- | xfa/fxfa/cxfa_ffdoc.cpp | 10 | ||||
-rw-r--r-- | xfa/fxfa/cxfa_textlayout.cpp | 24 | ||||
-rw-r--r-- | xfa/fxfa/cxfa_textparser.cpp | 7 | ||||
-rw-r--r-- | xfa/fxfa/cxfa_textprovider.cpp | 6 | ||||
-rw-r--r-- | xfa/fxfa/parser/cxfa_dataimporter.cpp | 2 | ||||
-rw-r--r-- | xfa/fxfa/parser/cxfa_node.cpp | 2 | ||||
-rw-r--r-- | xfa/fxfa/parser/cxfa_simple_parser.cpp | 75 | ||||
-rw-r--r-- | xfa/fxfa/parser/xfa_utils.cpp | 7 |
8 files changed, 50 insertions, 83 deletions
diff --git a/xfa/fxfa/cxfa_ffdoc.cpp b/xfa/fxfa/cxfa_ffdoc.cpp index 4dfa78edb1..52ad5f692d 100644 --- a/xfa/fxfa/cxfa_ffdoc.cpp +++ b/xfa/fxfa/cxfa_ffdoc.cpp @@ -175,9 +175,8 @@ bool XFA_GetPDFContentsFromPDFXML(CFX_XMLNode* pPDFElement, uint8_t*& pByteBuffer, int32_t& iBufferSize) { CFX_XMLElement* pDocumentElement = nullptr; - for (CFX_XMLNode* pXMLNode = - pPDFElement->GetNodeItem(CFX_XMLNode::FirstChild); - pXMLNode; pXMLNode = pXMLNode->GetNodeItem(CFX_XMLNode::NextSibling)) { + for (CFX_XMLNode* pXMLNode = pPDFElement->GetFirstChild(); pXMLNode; + pXMLNode = pXMLNode->GetNextSibling()) { if (pXMLNode->GetType() == FX_XMLNODE_Element) { CFX_XMLElement* pXMLElement = static_cast<CFX_XMLElement*>(pXMLNode); WideString wsTagName = pXMLElement->GetName(); @@ -191,9 +190,8 @@ bool XFA_GetPDFContentsFromPDFXML(CFX_XMLNode* pPDFElement, return false; } CFX_XMLElement* pChunkElement = nullptr; - for (CFX_XMLNode* pXMLNode = - pDocumentElement->GetNodeItem(CFX_XMLNode::FirstChild); - pXMLNode; pXMLNode = pXMLNode->GetNodeItem(CFX_XMLNode::NextSibling)) { + for (CFX_XMLNode* pXMLNode = pDocumentElement->GetFirstChild(); pXMLNode; + pXMLNode = pXMLNode->GetNextSibling()) { if (pXMLNode->GetType() == FX_XMLNODE_Element) { CFX_XMLElement* pXMLElement = static_cast<CFX_XMLElement*>(pXMLNode); WideString wsTagName = pXMLElement->GetName(); diff --git a/xfa/fxfa/cxfa_textlayout.cpp b/xfa/fxfa/cxfa_textlayout.cpp index ebb9e8aa2c..41d46f8824 100644 --- a/xfa/fxfa/cxfa_textlayout.cpp +++ b/xfa/fxfa/cxfa_textlayout.cpp @@ -78,9 +78,8 @@ CFX_XMLNode* CXFA_TextLayout::GetXMLContainerNode() { return nullptr; CFX_XMLNode* pXMLContainer = nullptr; - for (CFX_XMLNode* pXMLChild = pXMLRoot->GetNodeItem(CFX_XMLNode::FirstChild); - pXMLChild; - pXMLChild = pXMLChild->GetNodeItem(CFX_XMLNode::NextSibling)) { + for (CFX_XMLNode* pXMLChild = pXMLRoot->GetFirstChild(); pXMLChild; + pXMLChild = pXMLChild->GetNextSibling()) { if (pXMLChild->GetType() == FX_XMLNODE_Element) { CFX_XMLElement* pXMLElement = static_cast<CFX_XMLElement*>(pXMLChild); WideString wsTag = pXMLElement->GetLocalTagName(); @@ -463,15 +462,14 @@ bool CXFA_TextLayout::Layout(int32_t iBlock) { return true; CFX_XMLNode* pSaveXMLNode = m_pLoader->m_pXMLNode; - for (; pXMLNode; - pXMLNode = pXMLNode->GetNodeItem(CFX_XMLNode::NextSibling)) { + for (; pXMLNode; pXMLNode = pXMLNode->GetNextSibling()) { if (!LoadRichText(pXMLNode, szText.width, fLinePos, m_pLoader->m_pParentStyle, true, nullptr)) { break; } } while (!pXMLNode) { - pXMLNode = pSaveXMLNode->GetNodeItem(CFX_XMLNode::Parent); + pXMLNode = pSaveXMLNode->GetParent(); if (pXMLNode == pContainerNode) break; if (!LoadRichText(pXMLNode, szText.width, fLinePos, @@ -479,11 +477,10 @@ bool CXFA_TextLayout::Layout(int32_t iBlock) { break; } pSaveXMLNode = pXMLNode; - pXMLNode = pXMLNode->GetNodeItem(CFX_XMLNode::NextSibling); + pXMLNode = pXMLNode->GetNextSibling(); if (!pXMLNode) continue; - for (; pXMLNode; - pXMLNode = pXMLNode->GetNodeItem(CFX_XMLNode::NextSibling)) { + for (; pXMLNode; pXMLNode = pXMLNode->GetNextSibling()) { if (!LoadRichText(pXMLNode, szText.width, fLinePos, m_pLoader->m_pParentStyle, true, nullptr)) { break; @@ -824,10 +821,8 @@ bool CXFA_TextLayout::LoadRichText( } } - for (CFX_XMLNode* pChildNode = - pXMLNode->GetNodeItem(CFX_XMLNode::FirstChild); - pChildNode; - pChildNode = pChildNode->GetNodeItem(CFX_XMLNode::NextSibling)) { + for (CFX_XMLNode* pChildNode = pXMLNode->GetFirstChild(); pChildNode; + pChildNode = pChildNode->GetNextSibling()) { if (bCurOl) iLiCount++; @@ -861,8 +856,7 @@ bool CXFA_TextLayout::LoadRichText( } if (IsEnd(bSavePieces)) { if (m_pLoader && m_pLoader->m_iTotalLines > -1) { - m_pLoader->m_pXMLNode = - pXMLNode->GetNodeItem(CFX_XMLNode::NextSibling); + m_pLoader->m_pXMLNode = pXMLNode->GetNextSibling(); m_pLoader->m_pParentStyle = pParentStyle; } return false; diff --git a/xfa/fxfa/cxfa_textparser.cpp b/xfa/fxfa/cxfa_textparser.cpp index 07ba896843..bcadbea5c0 100644 --- a/xfa/fxfa/cxfa_textparser.cpp +++ b/xfa/fxfa/cxfa_textparser.cpp @@ -245,9 +245,8 @@ void CXFA_TextParser::ParseRichText(CFX_XMLNode* pXMLNode, m_mapXMLNodeToParseContext[pXMLNode] = std::move(pTextContext); } - for (CFX_XMLNode* pXMLChild = pXMLNode->GetNodeItem(CFX_XMLNode::FirstChild); - pXMLChild; - pXMLChild = pXMLChild->GetNodeItem(CFX_XMLNode::NextSibling)) { + for (CFX_XMLNode* pXMLChild = pXMLNode->GetFirstChild(); pXMLChild; + pXMLChild = pXMLChild->GetNextSibling()) { ParseRichText(pXMLChild, pNewStyle.Get()); } } @@ -382,7 +381,7 @@ int32_t CXFA_TextParser::GetHorScale(CXFA_TextProvider* pTextProvider, return wsValue.GetInteger(); } } - pXMLNode = pXMLNode->GetNodeItem(CFX_XMLNode::Parent); + pXMLNode = pXMLNode->GetParent(); } } diff --git a/xfa/fxfa/cxfa_textprovider.cpp b/xfa/fxfa/cxfa_textprovider.cpp index cbb01a9ea7..60c52942ed 100644 --- a/xfa/fxfa/cxfa_textprovider.cpp +++ b/xfa/fxfa/cxfa_textprovider.cpp @@ -62,10 +62,8 @@ CXFA_Node* CXFA_TextProvider::GetTextNode(bool& bRichText) { CXFA_Node* pBind = m_pNode->GetBindData(); CFX_XMLNode* pXMLNode = pBind->GetXMLMappingNode(); ASSERT(pXMLNode); - for (CFX_XMLNode* pXMLChild = - pXMLNode->GetNodeItem(CFX_XMLNode::FirstChild); - pXMLChild; - pXMLChild = pXMLChild->GetNodeItem(CFX_XMLNode::NextSibling)) { + for (CFX_XMLNode* pXMLChild = pXMLNode->GetFirstChild(); pXMLChild; + pXMLChild = pXMLChild->GetNextSibling()) { if (pXMLChild->GetType() == FX_XMLNODE_Element) { CFX_XMLElement* pElement = static_cast<CFX_XMLElement*>(pXMLChild); if (XFA_RecognizeRichText(pElement)) diff --git a/xfa/fxfa/parser/cxfa_dataimporter.cpp b/xfa/fxfa/parser/cxfa_dataimporter.cpp index 9171b00750..7c6e0ec12d 100644 --- a/xfa/fxfa/parser/cxfa_dataimporter.cpp +++ b/xfa/fxfa/parser/cxfa_dataimporter.cpp @@ -55,7 +55,7 @@ bool CXFA_DataImporter::ImportData( } } else { CFX_XMLNode* pXMLNode = pImportDataRoot->GetXMLMappingNode(); - CFX_XMLNode* pParentXMLNode = pXMLNode->GetNodeItem(CFX_XMLNode::Parent); + CFX_XMLNode* pParentXMLNode = pXMLNode->GetParent(); if (pParentXMLNode) pParentXMLNode->RemoveChildNode(pXMLNode); pDataModel->InsertChild(pImportDataRoot, nullptr); diff --git a/xfa/fxfa/parser/cxfa_node.cpp b/xfa/fxfa/parser/cxfa_node.cpp index 9159f020da..58b14cdf8a 100644 --- a/xfa/fxfa/parser/cxfa_node.cpp +++ b/xfa/fxfa/parser/cxfa_node.cpp @@ -1154,7 +1154,7 @@ void CXFA_Node::InsertChild(int32_t index, CXFA_Node* pNode) { if (!IsNeedSavingXMLNode() || !pNode->m_pXMLNode) return; - ASSERT(!pNode->m_pXMLNode->GetNodeItem(CFX_XMLNode::Parent)); + ASSERT(!pNode->m_pXMLNode->GetParent()); m_pXMLNode->InsertChildNode(pNode->m_pXMLNode, index); pNode->ClearFlag(XFA_NodeFlag_OwnXMLNode); diff --git a/xfa/fxfa/parser/cxfa_simple_parser.cpp b/xfa/fxfa/parser/cxfa_simple_parser.cpp index f21506d557..eee5cb3d83 100644 --- a/xfa/fxfa/parser/cxfa_simple_parser.cpp +++ b/xfa/fxfa/parser/cxfa_simple_parser.cpp @@ -106,19 +106,16 @@ CFX_XMLNode* GetDocumentNode(CFX_XMLDoc* pXMLDoc, if (!pXMLDoc) return nullptr; - for (CFX_XMLNode* pXMLNode = - pXMLDoc->GetRoot()->GetNodeItem(CFX_XMLNode::FirstChild); - pXMLNode; pXMLNode = pXMLNode->GetNodeItem(CFX_XMLNode::NextSibling)) { + for (CFX_XMLNode* pXMLNode = pXMLDoc->GetRoot()->GetFirstChild(); pXMLNode; + pXMLNode = pXMLNode->GetNextSibling()) { if (pXMLNode->GetType() != FX_XMLNODE_Element) continue; if (!bVerifyWellFormness) return pXMLNode; - for (CFX_XMLNode* pNextNode = - pXMLNode->GetNodeItem(CFX_XMLNode::NextSibling); - pNextNode; - pNextNode = pNextNode->GetNodeItem(CFX_XMLNode::NextSibling)) { + for (CFX_XMLNode* pNextNode = pXMLNode->GetNextSibling(); pNextNode; + pNextNode = pNextNode->GetNextSibling()) { if (pNextNode->GetType() == FX_XMLNODE_Element) return nullptr; } @@ -249,10 +246,8 @@ CFX_XMLNode* GetDataSetsFromXDP(CFX_XMLNode* pXMLDocumentNode) { return nullptr; } - for (CFX_XMLNode* pDatasetsNode = - pXMLDocumentNode->GetNodeItem(CFX_XMLNode::FirstChild); - pDatasetsNode; - pDatasetsNode = pDatasetsNode->GetNodeItem(CFX_XMLNode::NextSibling)) { + for (CFX_XMLNode* pDatasetsNode = pXMLDocumentNode->GetFirstChild(); + pDatasetsNode; pDatasetsNode = pDatasetsNode->GetNextSibling()) { if (MatchNodeName(pDatasetsNode, datasets_packet->name, datasets_packet->uri, datasets_packet->flags)) { return pDatasetsNode; @@ -267,10 +262,8 @@ bool IsStringAllWhitespace(WideString wsText) { } void ConvertXMLToPlainText(CFX_XMLElement* pRootXMLNode, WideString& wsOutput) { - for (CFX_XMLNode* pXMLChild = - pRootXMLNode->GetNodeItem(CFX_XMLNode::FirstChild); - pXMLChild; - pXMLChild = pXMLChild->GetNodeItem(CFX_XMLNode::NextSibling)) { + for (CFX_XMLNode* pXMLChild = pRootXMLNode->GetFirstChild(); pXMLChild; + pXMLChild = pXMLChild->GetNextSibling()) { switch (pXMLChild->GetType()) { case FX_XMLNODE_Element: { WideString wsTextData = @@ -328,9 +321,8 @@ WideString GetPlainTextFromRichText(CFX_XMLNode* pXMLNode) { default: break; } - for (CFX_XMLNode* pChildXML = pXMLNode->GetNodeItem(CFX_XMLNode::FirstChild); - pChildXML; - pChildXML = pChildXML->GetNodeItem(CFX_XMLNode::NextSibling)) { + for (CFX_XMLNode* pChildXML = pXMLNode->GetFirstChild(); pChildXML; + pChildXML = pChildXML->GetNextSibling()) { wsPlainText += GetPlainTextFromRichText(pChildXML); } @@ -423,10 +415,8 @@ void CXFA_SimpleParser::ConstructXFANode(CXFA_Node* pXFANode, XFA_PacketType ePacketID = pXFANode->GetPacketType(); if (ePacketID == XFA_PacketType::Datasets) { if (pXFANode->GetElementType() == XFA_Element::DataValue) { - for (CFX_XMLNode* pXMLChild = - pXMLNode->GetNodeItem(CFX_XMLNode::FirstChild); - pXMLChild; - pXMLChild = pXMLChild->GetNodeItem(CFX_XMLNode::NextSibling)) { + for (CFX_XMLNode* pXMLChild = pXMLNode->GetFirstChild(); pXMLChild; + pXMLChild = pXMLChild->GetNextSibling()) { FX_XMLNODETYPE eNodeType = pXMLChild->GetType(); if (eNodeType == FX_XMLNODE_Instruction) continue; @@ -526,10 +516,8 @@ CXFA_Node* CXFA_SimpleParser::ParseAsXDPPacket_XDP( CFX_XMLNode* pXMLConfigDOMRoot = nullptr; CXFA_Node* pXFAConfigDOMRoot = nullptr; - for (CFX_XMLNode* pChildItem = - pXMLDocumentNode->GetNodeItem(CFX_XMLNode::FirstChild); - pChildItem; - pChildItem = pChildItem->GetNodeItem(CFX_XMLNode::NextSibling)) { + for (CFX_XMLNode* pChildItem = pXMLDocumentNode->GetFirstChild(); pChildItem; + pChildItem = pChildItem->GetNextSibling()) { const PacketInfo* pPacketInfo = GetPacketByIndex(XFA_PacketType::Config); if (!MatchNodeName(pChildItem, pPacketInfo->name, pPacketInfo->uri, pPacketInfo->flags)) { @@ -547,10 +535,8 @@ CXFA_Node* CXFA_SimpleParser::ParseAsXDPPacket_XDP( CFX_XMLNode* pXMLDatasetsDOMRoot = nullptr; CFX_XMLNode* pXMLFormDOMRoot = nullptr; CFX_XMLNode* pXMLTemplateDOMRoot = nullptr; - for (CFX_XMLNode* pChildItem = - pXMLDocumentNode->GetNodeItem(CFX_XMLNode::FirstChild); - pChildItem; - pChildItem = pChildItem->GetNodeItem(CFX_XMLNode::NextSibling)) { + for (CFX_XMLNode* pChildItem = pXMLDocumentNode->GetFirstChild(); pChildItem; + pChildItem = pChildItem->GetNextSibling()) { if (!pChildItem || pChildItem->GetType() != FX_XMLNODE_Element) continue; if (pChildItem == pXMLConfigDOMRoot) @@ -754,8 +740,7 @@ CXFA_Node* CXFA_SimpleParser::ParseAsXDPPacket_Data( pDataXMLNode = pXMLDocumentNode; } else { CFX_XMLElement* pDataElement = new CFX_XMLElement(L"xfa:data"); - CFX_XMLNode* pParentXMLNode = - pXMLDocumentNode->GetNodeItem(CFX_XMLNode::Parent); + CFX_XMLNode* pParentXMLNode = pXMLDocumentNode->GetParent(); if (pParentXMLNode) pParentXMLNode->RemoveChildNode(pXMLDocumentNode); @@ -863,9 +848,8 @@ CXFA_Node* CXFA_SimpleParser::NormalLoader(CXFA_Node* pXFANode, XFA_PacketType ePacketID, bool bUseAttribute) { bool bOneOfPropertyFound = false; - for (CFX_XMLNode* pXMLChild = pXMLDoc->GetNodeItem(CFX_XMLNode::FirstChild); - pXMLChild; - pXMLChild = pXMLChild->GetNodeItem(CFX_XMLNode::NextSibling)) { + for (CFX_XMLNode* pXMLChild = pXMLDoc->GetFirstChild(); pXMLChild; + pXMLChild = pXMLChild->GetNextSibling()) { switch (pXMLChild->GetType()) { case FX_XMLNODE_Element: { CFX_XMLElement* pXMLElement = static_cast<CFX_XMLElement*>(pXMLChild); @@ -958,9 +942,8 @@ void CXFA_SimpleParser::ParseContentNode(CXFA_Node* pXFANode, pXFANode->SetXMLMappingNode(pXMLNode); WideString wsValue; - for (CFX_XMLNode* pXMLChild = pXMLNode->GetNodeItem(CFX_XMLNode::FirstChild); - pXMLChild; - pXMLChild = pXMLChild->GetNodeItem(CFX_XMLNode::NextSibling)) { + for (CFX_XMLNode* pXMLChild = pXMLNode->GetFirstChild(); pXMLChild; + pXMLChild = pXMLChild->GetNextSibling()) { FX_XMLNODETYPE eNodeType = pXMLChild->GetType(); if (eNodeType == FX_XMLNODE_Instruction) continue; @@ -1003,9 +986,8 @@ void CXFA_SimpleParser::ParseContentNode(CXFA_Node* pXFANode, void CXFA_SimpleParser::ParseDataGroup(CXFA_Node* pXFANode, CFX_XMLNode* pXMLNode, XFA_PacketType ePacketID) { - for (CFX_XMLNode* pXMLChild = pXMLNode->GetNodeItem(CFX_XMLNode::FirstChild); - pXMLChild; - pXMLChild = pXMLChild->GetNodeItem(CFX_XMLNode::NextSibling)) { + for (CFX_XMLNode* pXMLChild = pXMLNode->GetFirstChild(); pXMLChild; + pXMLChild = pXMLChild->GetNextSibling()) { switch (pXMLChild->GetType()) { case FX_XMLNODE_Element: { CFX_XMLElement* pXMLElement = static_cast<CFX_XMLElement*>(pXMLChild); @@ -1040,10 +1022,8 @@ void CXFA_SimpleParser::ParseDataGroup(CXFA_Node* pXFANode, } } if (eNodeType == XFA_Element::DataModel) { - for (CFX_XMLNode* pXMLDataChild = - pXMLElement->GetNodeItem(CFX_XMLNode::FirstChild); - pXMLDataChild; pXMLDataChild = pXMLDataChild->GetNodeItem( - CFX_XMLNode::NextSibling)) { + for (CFX_XMLNode* pXMLDataChild = pXMLElement->GetFirstChild(); + pXMLDataChild; pXMLDataChild = pXMLDataChild->GetNextSibling()) { if (pXMLDataChild->GetType() == FX_XMLNODE_Element) { if (!XFA_RecognizeRichText( static_cast<CFX_XMLElement*>(pXMLDataChild))) { @@ -1145,9 +1125,8 @@ void CXFA_SimpleParser::ParseDataValue(CXFA_Node* pXFANode, CFX_WideTextBuf wsCurValueTextBuf; bool bMarkAsCompound = false; CFX_XMLNode* pXMLCurValueNode = nullptr; - for (CFX_XMLNode* pXMLChild = pXMLNode->GetNodeItem(CFX_XMLNode::FirstChild); - pXMLChild; - pXMLChild = pXMLChild->GetNodeItem(CFX_XMLNode::NextSibling)) { + for (CFX_XMLNode* pXMLChild = pXMLNode->GetFirstChild(); pXMLChild; + pXMLChild = pXMLChild->GetNextSibling()) { FX_XMLNODETYPE eNodeType = pXMLChild->GetType(); if (eNodeType == FX_XMLNODE_Instruction) continue; diff --git a/xfa/fxfa/parser/xfa_utils.cpp b/xfa/fxfa/parser/xfa_utils.cpp index f0d2afdbcc..66b4e9d561 100644 --- a/xfa/fxfa/parser/xfa_utils.cpp +++ b/xfa/fxfa/parser/xfa_utils.cpp @@ -211,8 +211,7 @@ void RegenerateFormFile_Changed(CXFA_Node* pNode, if (!pExDataXML) break; - CFX_XMLNode* pRichTextXML = - pExDataXML->GetNodeItem(CFX_XMLNode::FirstChild); + CFX_XMLNode* pRichTextXML = pExDataXML->GetFirstChild(); if (!pRichTextXML) break; @@ -464,7 +463,7 @@ bool XFA_FDEExtension_ResolveNamespaceQualifier(CFX_XMLElement* pNode, if (!pNode) return false; - CFX_XMLNode* pFakeRoot = pNode->GetNodeItem(CFX_XMLNode::Root); + CFX_XMLNode* pFakeRoot = pNode->GetRoot(); WideString wsNSAttribute; bool bRet = false; if (wsQualifier.IsEmpty()) { @@ -474,7 +473,7 @@ bool XFA_FDEExtension_ResolveNamespaceQualifier(CFX_XMLElement* pNode, wsNSAttribute = L"xmlns:" + wsQualifier; } for (CFX_XMLNode* pParent = pNode; pParent != pFakeRoot; - pParent = pParent->GetNodeItem(CFX_XMLNode::Parent)) { + pParent = pParent->GetParent()) { if (pParent->GetType() != FX_XMLNODE_Element) continue; |