diff options
author | dsinclair <dsinclair@chromium.org> | 2016-08-03 10:20:32 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-08-03 10:20:32 -0700 |
commit | 6ea5ba035a396bf0956b4b4ab3a5b3ee33b6c546 (patch) | |
tree | 04083808d748c93226f6c3752fb05f47fc0851cb /xfa/fxfa/parser | |
parent | e85f971fe9ba628e46bcb0709d5da4368c15d0b0 (diff) | |
download | pdfium-6ea5ba035a396bf0956b4b4ab3a5b3ee33b6c546.tar.xz |
Split xfa_layout_appadapter
This moves the needed traverse strategies into their own files, removes the
unused one and cleans up the includes.
Review-Url: https://codereview.chromium.org/2207033002
Diffstat (limited to 'xfa/fxfa/parser')
-rw-r--r-- | xfa/fxfa/parser/cscript_layoutpseudomodel.cpp | 2 | ||||
-rw-r--r-- | xfa/fxfa/parser/cxfa_layoutitem.cpp | 23 | ||||
-rw-r--r-- | xfa/fxfa/parser/cxfa_layoutitem.h | 2 | ||||
-rw-r--r-- | xfa/fxfa/parser/cxfa_layoutprocessor.cpp | 2 | ||||
-rw-r--r-- | xfa/fxfa/parser/cxfa_traversestrategy_contentareacontainerlayoutitem.h | 44 | ||||
-rw-r--r-- | xfa/fxfa/parser/cxfa_traversestrategy_contentlayoutitem.h | 30 | ||||
-rw-r--r-- | xfa/fxfa/parser/xfa_layout_appadapter.cpp | 36 | ||||
-rw-r--r-- | xfa/fxfa/parser/xfa_layout_appadapter.h | 81 | ||||
-rw-r--r-- | xfa/fxfa/parser/xfa_layout_itemlayout.cpp | 3 | ||||
-rw-r--r-- | xfa/fxfa/parser/xfa_layout_pagemgr_new.cpp | 4 |
10 files changed, 106 insertions, 121 deletions
diff --git a/xfa/fxfa/parser/cscript_layoutpseudomodel.cpp b/xfa/fxfa/parser/cscript_layoutpseudomodel.cpp index 492e8d9db9..b8330ed909 100644 --- a/xfa/fxfa/parser/cscript_layoutpseudomodel.cpp +++ b/xfa/fxfa/parser/cscript_layoutpseudomodel.cpp @@ -18,7 +18,7 @@ #include "xfa/fxfa/parser/cxfa_layoutprocessor.h" #include "xfa/fxfa/parser/cxfa_measurement.h" #include "xfa/fxfa/parser/cxfa_scriptcontext.h" -#include "xfa/fxfa/parser/xfa_layout_appadapter.h" +#include "xfa/fxfa/parser/cxfa_traversestrategy_contentlayoutitem.h" #include "xfa/fxfa/parser/xfa_localemgr.h" #include "xfa/fxfa/parser/xfa_object.h" #include "xfa/fxfa/parser/xfa_utils.h" diff --git a/xfa/fxfa/parser/cxfa_layoutitem.cpp b/xfa/fxfa/parser/cxfa_layoutitem.cpp index a9ba3490d8..ebe33b650f 100644 --- a/xfa/fxfa/parser/cxfa_layoutitem.cpp +++ b/xfa/fxfa/parser/cxfa_layoutitem.cpp @@ -6,9 +6,32 @@ #include "xfa/fxfa/parser/cxfa_layoutitem.h" +#include "xfa/fxfa/app/xfa_ffnotify.h" #include "xfa/fxfa/parser/cxfa_containerlayoutitem.h" #include "xfa/fxfa/parser/cxfa_contentlayoutitem.h" +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(); + while (pNode) { + CXFA_LayoutItem* pNext = pNode->m_pNextSibling; + pNode->m_pParent = nullptr; + pNotify->OnLayoutItemRemoving(pDocLayout, + static_cast<CXFA_LayoutItem*>(pNode)); + XFA_ReleaseLayoutItem(pNode); + pNode = pNext; + } + + pNotify->OnLayoutItemRemoving(pDocLayout, pLayoutItem); + if (pLayoutItem->m_pFormNode->GetElementType() == XFA_Element::PageArea) { + pNotify->OnPageEvent(static_cast<CXFA_ContainerLayoutItem*>(pLayoutItem), + XFA_PAGEVIEWEVENT_PostRemoved); + } + delete pLayoutItem; +} + CXFA_LayoutItem::CXFA_LayoutItem(CXFA_Node* pNode, FX_BOOL bIsContentLayoutItem) : m_pFormNode(pNode), m_pParent(nullptr), diff --git a/xfa/fxfa/parser/cxfa_layoutitem.h b/xfa/fxfa/parser/cxfa_layoutitem.h index c8b29811e8..bacb2b8682 100644 --- a/xfa/fxfa/parser/cxfa_layoutitem.h +++ b/xfa/fxfa/parser/cxfa_layoutitem.h @@ -13,6 +13,8 @@ class CXFA_ContainerLayoutItem; class CXFA_ContentLayoutItem; class CXFA_LayoutProcessor; +void XFA_ReleaseLayoutItem(CXFA_LayoutItem* pLayoutItem); + class CXFA_LayoutItem { public: virtual ~CXFA_LayoutItem(); diff --git a/xfa/fxfa/parser/cxfa_layoutprocessor.cpp b/xfa/fxfa/parser/cxfa_layoutprocessor.cpp index 89ea0ce5bb..875bcc6542 100644 --- a/xfa/fxfa/parser/cxfa_layoutprocessor.cpp +++ b/xfa/fxfa/parser/cxfa_layoutprocessor.cpp @@ -6,10 +6,10 @@ #include "xfa/fxfa/parser/cxfa_layoutprocessor.h" +#include "xfa/fxfa/parser/cxfa_contentlayoutitem.h" #include "xfa/fxfa/parser/cxfa_document.h" #include "xfa/fxfa/parser/cxfa_measurement.h" #include "xfa/fxfa/parser/xfa_document_datamerger_imp.h" -#include "xfa/fxfa/parser/xfa_layout_appadapter.h" #include "xfa/fxfa/parser/xfa_layout_itemlayout.h" #include "xfa/fxfa/parser/xfa_layout_pagemgr_new.h" #include "xfa/fxfa/parser/xfa_localemgr.h" diff --git a/xfa/fxfa/parser/cxfa_traversestrategy_contentareacontainerlayoutitem.h b/xfa/fxfa/parser/cxfa_traversestrategy_contentareacontainerlayoutitem.h new file mode 100644 index 0000000000..e0a584edf0 --- /dev/null +++ b/xfa/fxfa/parser/cxfa_traversestrategy_contentareacontainerlayoutitem.h @@ -0,0 +1,44 @@ +// Copyright 2016 PDFium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com + +#ifndef XFA_FXFA_PARSER_CXFA_TRAVERSESTRATEGY_CONTENTAREACONTAINERLAYOUTITEM_H_ +#define XFA_FXFA_PARSER_CXFA_TRAVERSESTRATEGY_CONTENTAREACONTAINERLAYOUTITEM_H_ + +#include "xfa/fxfa/parser/cxfa_containerlayoutitem.h" + +class CXFA_TraverseStrategy_ContentAreaContainerLayoutItem { + public: + static CXFA_ContainerLayoutItem* GetFirstChild( + CXFA_ContainerLayoutItem* pLayoutItem) { + for (CXFA_LayoutItem* pChildItem = pLayoutItem->m_pFirstChild; pChildItem; + pChildItem = pChildItem->m_pNextSibling) { + if (CXFA_ContainerLayoutItem* pContainer = + pChildItem->AsContainerLayoutItem()) { + return pContainer; + } + } + return nullptr; + } + + static CXFA_ContainerLayoutItem* GetNextSibling( + CXFA_ContainerLayoutItem* pLayoutItem) { + for (CXFA_LayoutItem* pChildItem = pLayoutItem->m_pNextSibling; pChildItem; + pChildItem = pChildItem->m_pNextSibling) { + if (CXFA_ContainerLayoutItem* pContainer = + pChildItem->AsContainerLayoutItem()) { + return pContainer; + } + } + return nullptr; + } + + static CXFA_ContainerLayoutItem* GetParent( + CXFA_ContainerLayoutItem* pLayoutItem) { + return static_cast<CXFA_ContainerLayoutItem*>(pLayoutItem->m_pParent); + } +}; + +#endif // XFA_FXFA_PARSER_CXFA_TRAVERSESTRATEGY_CONTENTAREACONTAINERLAYOUTITEM_H_ diff --git a/xfa/fxfa/parser/cxfa_traversestrategy_contentlayoutitem.h b/xfa/fxfa/parser/cxfa_traversestrategy_contentlayoutitem.h new file mode 100644 index 0000000000..de0d52ab10 --- /dev/null +++ b/xfa/fxfa/parser/cxfa_traversestrategy_contentlayoutitem.h @@ -0,0 +1,30 @@ +// Copyright 2016 PDFium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com + +#ifndef XFA_FXFA_PARSER_CXFA_TRAVERSESTRATEGY_CONTENTLAYOUTITEM_H_ +#define XFA_FXFA_PARSER_CXFA_TRAVERSESTRATEGY_CONTENTLAYOUTITEM_H_ + +#include "xfa/fxfa/parser/cxfa_contentlayoutitem.h" + +class CXFA_TraverseStrategy_ContentLayoutItem { + public: + static CXFA_ContentLayoutItem* GetFirstChild( + CXFA_ContentLayoutItem* pLayoutItem) { + return static_cast<CXFA_ContentLayoutItem*>(pLayoutItem->m_pFirstChild); + } + + static CXFA_ContentLayoutItem* GetNextSibling( + CXFA_ContentLayoutItem* pLayoutItem) { + return static_cast<CXFA_ContentLayoutItem*>(pLayoutItem->m_pNextSibling); + } + + static CXFA_ContentLayoutItem* GetParent( + CXFA_ContentLayoutItem* pLayoutItem) { + return static_cast<CXFA_ContentLayoutItem*>(pLayoutItem->m_pParent); + } +}; + +#endif // XFA_FXFA_PARSER_CXFA_TRAVERSESTRATEGY_CONTENTLAYOUTITEM_H_ diff --git a/xfa/fxfa/parser/xfa_layout_appadapter.cpp b/xfa/fxfa/parser/xfa_layout_appadapter.cpp deleted file mode 100644 index fdf9a27d0b..0000000000 --- a/xfa/fxfa/parser/xfa_layout_appadapter.cpp +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright 2014 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com - -#include "xfa/fxfa/parser/xfa_layout_appadapter.h" - -#include "xfa/fxfa/app/xfa_ffnotify.h" -#include "xfa/fxfa/parser/cxfa_document.h" -#include "xfa/fxfa/parser/xfa_layout_itemlayout.h" -#include "xfa/fxfa/parser/xfa_layout_pagemgr_new.h" -#include "xfa/fxfa/parser/xfa_localemgr.h" -#include "xfa/fxfa/parser/xfa_object.h" -#include "xfa/fxfa/parser/xfa_utils.h" - -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(); - while (pNode) { - CXFA_LayoutItem* pNext = pNode->m_pNextSibling; - pNode->m_pParent = nullptr; - pNotify->OnLayoutItemRemoving(pDocLayout, - static_cast<CXFA_LayoutItem*>(pNode)); - XFA_ReleaseLayoutItem(pNode); - pNode = pNext; - } - pNotify->OnLayoutItemRemoving(pDocLayout, pLayoutItem); - if (pLayoutItem->m_pFormNode->GetElementType() == XFA_Element::PageArea) { - pNotify->OnPageEvent(static_cast<CXFA_ContainerLayoutItem*>(pLayoutItem), - XFA_PAGEVIEWEVENT_PostRemoved); - } - delete pLayoutItem; -} diff --git a/xfa/fxfa/parser/xfa_layout_appadapter.h b/xfa/fxfa/parser/xfa_layout_appadapter.h deleted file mode 100644 index 7de62e6282..0000000000 --- a/xfa/fxfa/parser/xfa_layout_appadapter.h +++ /dev/null @@ -1,81 +0,0 @@ -// Copyright 2014 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com - -#ifndef XFA_FXFA_PARSER_XFA_LAYOUT_APPADAPTER_H_ -#define XFA_FXFA_PARSER_XFA_LAYOUT_APPADAPTER_H_ - -#include "xfa/fxfa/parser/cxfa_containerlayoutitem.h" -#include "xfa/fxfa/parser/cxfa_contentlayoutitem.h" -#include "xfa/fxfa/parser/cxfa_layoutitem.h" - -class CXFA_TraverseStrategy_PageAreaContainerLayoutItem { - public: - static inline CXFA_ContainerLayoutItem* GetFirstChild( - CXFA_ContainerLayoutItem* pLayoutItem) { - if (pLayoutItem->m_pFormNode->GetElementType() == XFA_Element::PageSet) { - return static_cast<CXFA_ContainerLayoutItem*>(pLayoutItem->m_pFirstChild); - } - return nullptr; - } - static inline CXFA_ContainerLayoutItem* GetNextSibling( - CXFA_ContainerLayoutItem* pLayoutItem) { - return (CXFA_ContainerLayoutItem*)pLayoutItem->m_pNextSibling; - } - static inline CXFA_ContainerLayoutItem* GetParent( - CXFA_ContainerLayoutItem* pLayoutItem) { - return static_cast<CXFA_ContainerLayoutItem*>(pLayoutItem->m_pParent); - } -}; - -class CXFA_TraverseStrategy_ContentAreaContainerLayoutItem { - public: - static inline CXFA_ContainerLayoutItem* GetFirstChild( - CXFA_ContainerLayoutItem* pLayoutItem) { - for (CXFA_LayoutItem* pChildItem = pLayoutItem->m_pFirstChild; pChildItem; - pChildItem = pChildItem->m_pNextSibling) { - if (CXFA_ContainerLayoutItem* pContainer = - pChildItem->AsContainerLayoutItem()) { - return pContainer; - } - } - return nullptr; - } - static inline CXFA_ContainerLayoutItem* GetNextSibling( - CXFA_ContainerLayoutItem* pLayoutItem) { - for (CXFA_LayoutItem* pChildItem = pLayoutItem->m_pNextSibling; pChildItem; - pChildItem = pChildItem->m_pNextSibling) { - if (CXFA_ContainerLayoutItem* pContainer = - pChildItem->AsContainerLayoutItem()) { - return pContainer; - } - } - return nullptr; - } - static inline CXFA_ContainerLayoutItem* GetParent( - CXFA_ContainerLayoutItem* pLayoutItem) { - return static_cast<CXFA_ContainerLayoutItem*>(pLayoutItem->m_pParent); - } -}; - -class CXFA_TraverseStrategy_ContentLayoutItem { - public: - static inline CXFA_ContentLayoutItem* GetFirstChild( - CXFA_ContentLayoutItem* pLayoutItem) { - return static_cast<CXFA_ContentLayoutItem*>(pLayoutItem->m_pFirstChild); - } - static inline CXFA_ContentLayoutItem* GetNextSibling( - CXFA_ContentLayoutItem* pLayoutItem) { - return static_cast<CXFA_ContentLayoutItem*>(pLayoutItem->m_pNextSibling); - } - static inline CXFA_ContentLayoutItem* GetParent( - CXFA_ContentLayoutItem* pLayoutItem) { - return static_cast<CXFA_ContentLayoutItem*>(pLayoutItem->m_pParent); - } -}; - -void XFA_ReleaseLayoutItem(CXFA_LayoutItem* pLayoutItem); - -#endif // XFA_FXFA_PARSER_XFA_LAYOUT_APPADAPTER_H_ diff --git a/xfa/fxfa/parser/xfa_layout_itemlayout.cpp b/xfa/fxfa/parser/xfa_layout_itemlayout.cpp index 2a467a54f1..72a3ff4f18 100644 --- a/xfa/fxfa/parser/xfa_layout_itemlayout.cpp +++ b/xfa/fxfa/parser/xfa_layout_itemlayout.cpp @@ -10,10 +10,11 @@ #include <memory> #include "xfa/fxfa/app/xfa_ffnotify.h" +#include "xfa/fxfa/parser/cxfa_containerlayoutitem.h" +#include "xfa/fxfa/parser/cxfa_contentlayoutitem.h" #include "xfa/fxfa/parser/cxfa_document.h" #include "xfa/fxfa/parser/cxfa_measurement.h" #include "xfa/fxfa/parser/cxfa_occur.h" -#include "xfa/fxfa/parser/xfa_layout_appadapter.h" #include "xfa/fxfa/parser/xfa_layout_pagemgr_new.h" #include "xfa/fxfa/parser/xfa_localemgr.h" #include "xfa/fxfa/parser/xfa_object.h" diff --git a/xfa/fxfa/parser/xfa_layout_pagemgr_new.cpp b/xfa/fxfa/parser/xfa_layout_pagemgr_new.cpp index 914ce6fb36..a88ccce330 100644 --- a/xfa/fxfa/parser/xfa_layout_pagemgr_new.cpp +++ b/xfa/fxfa/parser/xfa_layout_pagemgr_new.cpp @@ -7,13 +7,15 @@ #include "xfa/fxfa/parser/xfa_layout_pagemgr_new.h" #include "xfa/fxfa/app/xfa_ffnotify.h" +#include "xfa/fxfa/parser/cxfa_containerlayoutitem.h" +#include "xfa/fxfa/parser/cxfa_contentlayoutitem.h" #include "xfa/fxfa/parser/cxfa_document.h" #include "xfa/fxfa/parser/cxfa_layoutprocessor.h" #include "xfa/fxfa/parser/cxfa_measurement.h" #include "xfa/fxfa/parser/cxfa_scriptcontext.h" +#include "xfa/fxfa/parser/cxfa_traversestrategy_contentareacontainerlayoutitem.h" #include "xfa/fxfa/parser/cxfa_traversestrategy_layoutitem.h" #include "xfa/fxfa/parser/xfa_document_datamerger_imp.h" -#include "xfa/fxfa/parser/xfa_layout_appadapter.h" #include "xfa/fxfa/parser/xfa_layout_itemlayout.h" #include "xfa/fxfa/parser/xfa_localemgr.h" #include "xfa/fxfa/parser/xfa_object.h" |