From d8d6f55140bd4f0a67de833346113cfa6e03c4bd Mon Sep 17 00:00:00 2001 From: Dan Sinclair Date: Wed, 14 Feb 2018 15:44:21 +0000 Subject: Cleanup CXFA_Document const-ness This CL marks methods const where possible and removes redundant methods from CXFA_Document. Change-Id: I34804425469dfd52469daba68f64a4b511e5d4d0 Reviewed-on: https://pdfium-review.googlesource.com/26730 Commit-Queue: Ryan Harrison Reviewed-by: Ryan Harrison --- fxjs/xfa/cjx_hostpseudomodel.cpp | 2 +- fxjs/xfa/cjx_layoutpseudomodel.cpp | 10 +++++----- xfa/fxfa/cxfa_ffdocview.cpp | 2 +- xfa/fxfa/cxfa_ffdocview.h | 1 + xfa/fxfa/cxfa_ffnotify.cpp | 4 ++-- xfa/fxfa/cxfa_ffnotify.h | 1 + xfa/fxfa/parser/cxfa_document.cpp | 8 ++------ xfa/fxfa/parser/cxfa_document.h | 14 ++++++-------- xfa/fxfa/parser/cxfa_itemlayoutprocessor.cpp | 4 ++-- xfa/fxfa/parser/cxfa_layoutitem.cpp | 2 +- xfa/fxfa/parser/cxfa_layoutitem.h | 4 ++-- xfa/fxfa/parser/cxfa_layoutpagemgr.cpp | 4 ++-- xfa/fxfa/parser/xfa_document_datamerger_imp.cpp | 2 +- 13 files changed, 27 insertions(+), 31 deletions(-) diff --git a/fxjs/xfa/cjx_hostpseudomodel.cpp b/fxjs/xfa/cjx_hostpseudomodel.cpp index 5c63fc8986..37c639f6e4 100644 --- a/fxjs/xfa/cjx_hostpseudomodel.cpp +++ b/fxjs/xfa/cjx_hostpseudomodel.cpp @@ -302,7 +302,7 @@ CJS_Return CJX_HostPseudoModel::openList( pNode = resolveNodeRS.objects.front()->AsNode(); } - CXFA_LayoutProcessor* pDocLayout = GetDocument()->GetDocLayout(); + CXFA_LayoutProcessor* pDocLayout = GetDocument()->GetLayoutProcessor(); if (!pDocLayout) return CJS_Return(true); diff --git a/fxjs/xfa/cjx_layoutpseudomodel.cpp b/fxjs/xfa/cjx_layoutpseudomodel.cpp index fd8c8804f8..6a01d2914e 100644 --- a/fxjs/xfa/cjx_layoutpseudomodel.cpp +++ b/fxjs/xfa/cjx_layoutpseudomodel.cpp @@ -88,7 +88,7 @@ CJS_Return CJX_LayoutPseudoModel::HWXY( } int32_t iIndex = params.size() >= 3 ? runtime->ToInt32(params[2]) : 0; - CXFA_LayoutProcessor* pDocLayout = GetDocument()->GetDocLayout(); + CXFA_LayoutProcessor* pDocLayout = GetDocument()->GetLayoutProcessor(); if (!pDocLayout) return CJS_Return(true); @@ -152,7 +152,7 @@ CJS_Return CJX_LayoutPseudoModel::y( CJS_Return CJX_LayoutPseudoModel::NumberedPageCount(CFX_V8* runtime, bool bNumbered) { - CXFA_LayoutProcessor* pDocLayout = GetDocument()->GetDocLayout(); + CXFA_LayoutProcessor* pDocLayout = GetDocument()->GetLayoutProcessor(); if (!pDocLayout) return CJS_Return(true); @@ -191,7 +191,7 @@ CJS_Return CJX_LayoutPseudoModel::pageSpan( if (!pNode) return CJS_Return(true); - CXFA_LayoutProcessor* pDocLayout = GetDocument()->GetDocLayout(); + CXFA_LayoutProcessor* pDocLayout = GetDocument()->GetLayoutProcessor(); if (!pDocLayout) return CJS_Return(true); @@ -367,7 +367,7 @@ CJS_Return CJX_LayoutPseudoModel::pageContent( if (!pNotify) return CJS_Return(true); - CXFA_LayoutProcessor* pDocLayout = GetDocument()->GetDocLayout(); + CXFA_LayoutProcessor* pDocLayout = GetDocument()->GetLayoutProcessor(); if (!pDocLayout) return CJS_Return(true); @@ -472,7 +472,7 @@ CJS_Return CJX_LayoutPseudoModel::PageInternals( if (!pNode) return CJS_Return(runtime->NewNumber(0)); - CXFA_LayoutProcessor* pDocLayout = GetDocument()->GetDocLayout(); + CXFA_LayoutProcessor* pDocLayout = GetDocument()->GetLayoutProcessor(); if (!pDocLayout) return CJS_Return(true); diff --git a/xfa/fxfa/cxfa_ffdocview.cpp b/xfa/fxfa/cxfa_ffdocview.cpp index 8db075b3a5..42827c7d11 100644 --- a/xfa/fxfa/cxfa_ffdocview.cpp +++ b/xfa/fxfa/cxfa_ffdocview.cpp @@ -200,7 +200,7 @@ CXFA_FFPageView* CXFA_FFDocView::GetPageView(int32_t nIndex) const { } CXFA_LayoutProcessor* CXFA_FFDocView::GetXFALayout() const { - return m_pDoc->GetXFADoc()->GetDocLayout(); + return m_pDoc->GetXFADoc()->GetLayoutProcessor(); } bool CXFA_FFDocView::ResetSingleNodeData(CXFA_Node* pNode) { diff --git a/xfa/fxfa/cxfa_ffdocview.h b/xfa/fxfa/cxfa_ffdocview.h index b3cc5b83b7..bccbe33cb9 100644 --- a/xfa/fxfa/cxfa_ffdocview.h +++ b/xfa/fxfa/cxfa_ffdocview.h @@ -16,6 +16,7 @@ #include "xfa/fxfa/cxfa_ffdoc.h" class CXFA_BindItems; +class CXFA_ContainerLayoutItem; class CXFA_FFWidgetHandler; class CXFA_FFDoc; class CXFA_FFWidget; diff --git a/xfa/fxfa/cxfa_ffnotify.cpp b/xfa/fxfa/cxfa_ffnotify.cpp index 6802fd32b3..a0aa047134 100644 --- a/xfa/fxfa/cxfa_ffnotify.cpp +++ b/xfa/fxfa/cxfa_ffnotify.cpp @@ -97,7 +97,7 @@ CXFA_ContainerLayoutItem* CXFA_FFNotify::OnCreateContainerLayoutItem( ASSERT(type == XFA_Element::ContentArea || type == XFA_Element::PageArea); if (type == XFA_Element::PageArea) { - CXFA_LayoutProcessor* pLayout = m_pDoc->GetXFADoc()->GetDocLayout(); + CXFA_LayoutProcessor* pLayout = m_pDoc->GetXFADoc()->GetLayoutProcessor(); return new CXFA_FFPageView(m_pDoc->GetDocView(pLayout), pNode); } return new CXFA_ContainerLayoutItem(pNode); @@ -187,7 +187,7 @@ CXFA_ContentLayoutItem* CXFA_FFNotify::OnCreateContentLayoutItem( } ASSERT(pWidget); - CXFA_LayoutProcessor* pLayout = m_pDoc->GetXFADoc()->GetDocLayout(); + CXFA_LayoutProcessor* pLayout = m_pDoc->GetXFADoc()->GetLayoutProcessor(); pWidget->SetDocView(m_pDoc->GetDocView(pLayout)); return pWidget; diff --git a/xfa/fxfa/cxfa_ffnotify.h b/xfa/fxfa/cxfa_ffnotify.h index 2395748328..0fa474c5ef 100644 --- a/xfa/fxfa/cxfa_ffnotify.h +++ b/xfa/fxfa/cxfa_ffnotify.h @@ -13,6 +13,7 @@ class CXFA_FFWidgetHandler; class CXFA_ContainerLayoutItem; class CXFA_ContentLayoutItem; +class CXFA_LayoutItem; class CXFA_Script; class CXFA_FFNotify { diff --git a/xfa/fxfa/parser/cxfa_document.cpp b/xfa/fxfa/parser/cxfa_document.cpp index 2a9d80e0cd..01ba3205ed 100644 --- a/xfa/fxfa/parser/cxfa_document.cpp +++ b/xfa/fxfa/parser/cxfa_document.cpp @@ -107,10 +107,6 @@ CXFA_LayoutProcessor* CXFA_Document::GetLayoutProcessor() { return m_pLayoutProcessor.get(); } -CXFA_LayoutProcessor* CXFA_Document::GetDocLayout() { - return GetLayoutProcessor(); -} - void CXFA_Document::ClearLayoutData() { m_pLayoutProcessor.reset(); m_pScriptContext.reset(); @@ -258,7 +254,7 @@ CFXJSE_Engine* CXFA_Document::InitScriptContext(CFXJS_Engine* fxjs_engine) { // We have to call |InitScriptContext| before any calls to |GetScriptContext| // or the context won't have an isolate set into it. -CFXJSE_Engine* CXFA_Document::GetScriptContext() { +CFXJSE_Engine* CXFA_Document::GetScriptContext() const { ASSERT(m_pScriptContext); return m_pScriptContext.get(); } @@ -291,7 +287,7 @@ XFA_VERSION CXFA_Document::RecognizeXFAVersionNumber( } CXFA_Node* CXFA_Document::GetNodeByID(CXFA_Node* pRoot, - const WideStringView& wsID) { + const WideStringView& wsID) const { if (!pRoot || wsID.IsEmpty()) return nullptr; diff --git a/xfa/fxfa/parser/cxfa_document.h b/xfa/fxfa/parser/cxfa_document.h index 9dc8e52ab6..c04c31cfce 100644 --- a/xfa/fxfa/parser/cxfa_document.h +++ b/xfa/fxfa/parser/cxfa_document.h @@ -42,16 +42,13 @@ enum XFA_DocFlag { class CFXJSE_Engine; class CFXJS_Engine; -class CFX_XMLDoc; class CScript_DataWindow; class CScript_EventPseudoModel; class CScript_HostPseudoModel; class CScript_LayoutPseudoModel; class CScript_LogPseudoModel; class CScript_SignaturePseudoModel; -class CXFA_ContainerLayoutItem; class CXFA_FFNotify; -class CXFA_LayoutItem; class CXFA_LayoutProcessor; class CXFA_Node; class CXFA_Object; @@ -67,15 +64,16 @@ class CXFA_Document : public CXFA_NodeOwner { CXFA_FFNotify* GetNotify() const { return notify_.Get(); } CXFA_LocaleMgr* GetLocalMgr(); CXFA_Object* GetXFAObject(XFA_HashCode wsNodeNameHash); - CXFA_Node* GetNodeByID(CXFA_Node* pRoot, const WideStringView& wsID); - CXFA_Node* GetNotBindNode(const std::vector& arrayNodes); + CXFA_Node* GetNodeByID(CXFA_Node* pRoot, const WideStringView& wsID) const; + CXFA_Node* GetNotBindNode(const std::vector& arrayNodes) const; CXFA_LayoutProcessor* GetLayoutProcessor(); - CXFA_LayoutProcessor* GetDocLayout(); - CFXJSE_Engine* GetScriptContext(); + CFXJSE_Engine* GetScriptContext() const; void SetRoot(CXFA_Node* pNewRoot) { m_pRootNode = pNewRoot; } - bool HasFlag(uint32_t dwFlag) { return (m_dwDocFlags & dwFlag) == dwFlag; } + bool HasFlag(uint32_t dwFlag) const { + return (m_dwDocFlags & dwFlag) == dwFlag; + } void SetFlag(uint32_t dwFlag, bool bOn); bool IsInteractive(); diff --git a/xfa/fxfa/parser/cxfa_itemlayoutprocessor.cpp b/xfa/fxfa/parser/cxfa_itemlayoutprocessor.cpp index e01f6ee037..88dcd1b4ae 100644 --- a/xfa/fxfa/parser/cxfa_itemlayoutprocessor.cpp +++ b/xfa/fxfa/parser/cxfa_itemlayoutprocessor.cpp @@ -432,7 +432,7 @@ bool FindBreakNode(CXFA_Node* pContainerNode, void DeleteLayoutGeneratedNode(CXFA_Node* pGenerateNode) { CXFA_FFNotify* pNotify = pGenerateNode->GetDocument()->GetNotify(); CXFA_LayoutProcessor* pDocLayout = - pGenerateNode->GetDocument()->GetDocLayout(); + pGenerateNode->GetDocument()->GetLayoutProcessor(); CXFA_NodeIteratorTemplate sIterator( pGenerateNode); for (CXFA_Node* pNode = sIterator.GetCurrent(); pNode; @@ -819,7 +819,7 @@ CXFA_ContentLayoutItem* CXFA_ItemLayoutProcessor::ExtractLayoutItem() { CXFA_FFNotify* pNotify = m_pOldLayoutItem->m_pFormNode->GetDocument()->GetNotify(); CXFA_LayoutProcessor* pDocLayout = - m_pOldLayoutItem->m_pFormNode->GetDocument()->GetDocLayout(); + m_pOldLayoutItem->m_pFormNode->GetDocument()->GetLayoutProcessor(); CXFA_ContentLayoutItem* pOldLayoutItem = m_pOldLayoutItem; while (pOldLayoutItem) { CXFA_ContentLayoutItem* pNextOldLayoutItem = pOldLayoutItem->m_pNext; diff --git a/xfa/fxfa/parser/cxfa_layoutitem.cpp b/xfa/fxfa/parser/cxfa_layoutitem.cpp index 7fb921ab84..bd8ca2a58a 100644 --- a/xfa/fxfa/parser/cxfa_layoutitem.cpp +++ b/xfa/fxfa/parser/cxfa_layoutitem.cpp @@ -18,7 +18,7 @@ void XFA_ReleaseLayoutItem(CXFA_LayoutItem* pLayoutItem) { CXFA_LayoutItem* pNode = pLayoutItem->m_pFirstChild; CXFA_FFNotify* pNotify = pLayoutItem->m_pFormNode->GetDocument()->GetNotify(); CXFA_LayoutProcessor* pDocLayout = - pLayoutItem->m_pFormNode->GetDocument()->GetDocLayout(); + pLayoutItem->m_pFormNode->GetDocument()->GetLayoutProcessor(); while (pNode) { CXFA_LayoutItem* pNext = pNode->m_pNextSibling; pNode->m_pParent = nullptr; diff --git a/xfa/fxfa/parser/cxfa_layoutitem.h b/xfa/fxfa/parser/cxfa_layoutitem.h index 9c088601ef..e03f455de5 100644 --- a/xfa/fxfa/parser/cxfa_layoutitem.h +++ b/xfa/fxfa/parser/cxfa_layoutitem.h @@ -13,8 +13,6 @@ class CXFA_ContainerLayoutItem; class CXFA_ContentLayoutItem; class CXFA_LayoutProcessor; -void XFA_ReleaseLayoutItem(CXFA_LayoutItem* pLayoutItem); - class CXFA_LayoutItem { public: virtual ~CXFA_LayoutItem(); @@ -53,4 +51,6 @@ class CXFA_LayoutItem { bool m_bIsContentLayoutItem; }; +void XFA_ReleaseLayoutItem(CXFA_LayoutItem* pLayoutItem); + #endif // XFA_FXFA_PARSER_CXFA_LAYOUTITEM_H_ diff --git a/xfa/fxfa/parser/cxfa_layoutpagemgr.cpp b/xfa/fxfa/parser/cxfa_layoutpagemgr.cpp index f921d8014f..d6178bfc5e 100644 --- a/xfa/fxfa/parser/cxfa_layoutpagemgr.cpp +++ b/xfa/fxfa/parser/cxfa_layoutpagemgr.cpp @@ -1626,7 +1626,7 @@ void CXFA_LayoutPageMgr::SaveLayoutItem(CXFA_LayoutItem* pParentLayoutItem) { CXFA_FFNotify* pNotify = m_pTemplatePageSetRoot->GetDocument()->GetNotify(); CXFA_LayoutProcessor* pDocLayout = - m_pTemplatePageSetRoot->GetDocument()->GetDocLayout(); + m_pTemplatePageSetRoot->GetDocument()->GetLayoutProcessor(); if (pCurLayoutItem->m_pFirstChild) SyncRemoveLayoutItem(pCurLayoutItem, pNotify, pDocLayout); @@ -1687,7 +1687,7 @@ CXFA_Node* CXFA_LayoutPageMgr::QueryOverflow(CXFA_Node* pFormNode) { void CXFA_LayoutPageMgr::MergePageSetContents() { CXFA_Document* pDocument = m_pTemplatePageSetRoot->GetDocument(); CXFA_FFNotify* pNotify = pDocument->GetNotify(); - CXFA_LayoutProcessor* pDocLayout = pDocument->GetDocLayout(); + CXFA_LayoutProcessor* pDocLayout = pDocument->GetLayoutProcessor(); CXFA_ContainerLayoutItem* pRootLayout = GetRootLayoutItem(); for (CXFA_Node* pPageNode : pDocument->m_pPendingPageSet) { CXFA_NodeIteratorTemplate diff --git a/xfa/fxfa/parser/xfa_document_datamerger_imp.cpp b/xfa/fxfa/parser/xfa_document_datamerger_imp.cpp index fed59158aa..b06c9ce549 100644 --- a/xfa/fxfa/parser/xfa_document_datamerger_imp.cpp +++ b/xfa/fxfa/parser/xfa_document_datamerger_imp.cpp @@ -1356,7 +1356,7 @@ void CXFA_Document::DataMerge_UpdateBindingRelations( } CXFA_Node* CXFA_Document::GetNotBindNode( - const std::vector& arrayObjects) { + const std::vector& arrayObjects) const { for (CXFA_Object* pObject : arrayObjects) { CXFA_Node* pNode = pObject->AsNode(); if (pNode && !pNode->HasBindItem()) -- cgit v1.2.3