diff options
Diffstat (limited to 'xfa/fxfa')
-rw-r--r-- | xfa/fxfa/cxfa_ffdocview.cpp | 18 | ||||
-rw-r--r-- | xfa/fxfa/cxfa_ffdocview.h | 4 | ||||
-rw-r--r-- | xfa/fxfa/cxfa_readynodeiterator.cpp | 31 | ||||
-rw-r--r-- | xfa/fxfa/cxfa_readynodeiterator.h (renamed from xfa/fxfa/cxfa_widgetacciterator.h) | 17 | ||||
-rw-r--r-- | xfa/fxfa/cxfa_widgetacciterator.cpp | 31 |
5 files changed, 50 insertions, 51 deletions
diff --git a/xfa/fxfa/cxfa_ffdocview.cpp b/xfa/fxfa/cxfa_ffdocview.cpp index f7dbb98ce0..95b8b9cfb6 100644 --- a/xfa/fxfa/cxfa_ffdocview.cpp +++ b/xfa/fxfa/cxfa_ffdocview.cpp @@ -28,8 +28,8 @@ #include "xfa/fxfa/cxfa_ffwidget.h" #include "xfa/fxfa/cxfa_ffwidgethandler.h" #include "xfa/fxfa/cxfa_fwladapterwidgetmgr.h" +#include "xfa/fxfa/cxfa_readynodeiterator.h" #include "xfa/fxfa/cxfa_textprovider.h" -#include "xfa/fxfa/cxfa_widgetacciterator.h" #include "xfa/fxfa/parser/cxfa_acrobat.h" #include "xfa/fxfa/parser/cxfa_binditems.h" #include "xfa/fxfa/parser/cxfa_calculate.h" @@ -245,11 +245,11 @@ void CXFA_FFDocView::ResetNode(CXFA_Node* pNode) { if (pFormNode->GetElementType() != XFA_Element::Field && pFormNode->GetElementType() != XFA_Element::ExclGroup) { - CXFA_WidgetAccIterator Iterator(pFormNode); - while (CXFA_WidgetAcc* pAcc = Iterator.MoveToNext()) { - bChanged |= ResetSingleNodeData(pAcc->GetNode()); - if (pAcc->GetNode()->GetElementType() == XFA_Element::ExclGroup) - Iterator.SkipTree(); + CXFA_ReadyNodeIterator it(pFormNode); + while (CXFA_Node* pNode = it.MoveToNext()) { + bChanged |= ResetSingleNodeData(pNode); + if (pNode->GetElementType() == XFA_Element::ExclGroup) + it.SkipTree(); } } if (bChanged) @@ -312,10 +312,10 @@ CXFA_FFWidgetHandler* CXFA_FFDocView::GetWidgetHandler() { return m_pWidgetHandler.get(); } -std::unique_ptr<CXFA_WidgetAccIterator> -CXFA_FFDocView::CreateWidgetAccIterator() { +std::unique_ptr<CXFA_ReadyNodeIterator> +CXFA_FFDocView::CreateReadyNodeIterator() { CXFA_Subform* pFormRoot = GetRootSubform(); - return pFormRoot ? pdfium::MakeUnique<CXFA_WidgetAccIterator>(pFormRoot) + return pFormRoot ? pdfium::MakeUnique<CXFA_ReadyNodeIterator>(pFormRoot) : nullptr; } diff --git a/xfa/fxfa/cxfa_ffdocview.h b/xfa/fxfa/cxfa_ffdocview.h index 8d472ee0bc..dd7ed28ad6 100644 --- a/xfa/fxfa/cxfa_ffdocview.h +++ b/xfa/fxfa/cxfa_ffdocview.h @@ -21,7 +21,7 @@ class CXFA_FFDoc; class CXFA_FFWidget; class CXFA_Subform; class CXFA_WidgetAcc; -class CXFA_WidgetAccIterator; +class CXFA_ReadyNodeIterator; extern const XFA_AttributeEnum gs_EventActivity[]; enum XFA_DOCVIEW_LAYOUTSTATUS { @@ -59,7 +59,7 @@ class CXFA_FFDocView { int32_t ProcessWidgetEvent(CXFA_EventParam* pParam, CXFA_WidgetAcc* pWidgetAcc); CXFA_FFWidgetHandler* GetWidgetHandler(); - std::unique_ptr<CXFA_WidgetAccIterator> CreateWidgetAccIterator(); + std::unique_ptr<CXFA_ReadyNodeIterator> CreateReadyNodeIterator(); CXFA_FFWidget* GetFocusWidget() const { return m_pFocusWidget.Get(); } void KillFocus(); bool SetFocus(CXFA_FFWidget* hWidget); diff --git a/xfa/fxfa/cxfa_readynodeiterator.cpp b/xfa/fxfa/cxfa_readynodeiterator.cpp new file mode 100644 index 0000000000..728d9d6377 --- /dev/null +++ b/xfa/fxfa/cxfa_readynodeiterator.cpp @@ -0,0 +1,31 @@ +// Copyright 2017 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/cxfa_readynodeiterator.h" + +#include "xfa/fxfa/parser/cxfa_node.h" + +CXFA_ReadyNodeIterator::CXFA_ReadyNodeIterator(CXFA_Node* pTravelRoot) + : m_ContentIterator(pTravelRoot) {} + +CXFA_ReadyNodeIterator::~CXFA_ReadyNodeIterator() {} + +CXFA_Node* CXFA_ReadyNodeIterator::MoveToNext() { + CXFA_Node* pItem = m_pCurNode ? m_ContentIterator.MoveToNext() + : m_ContentIterator.GetCurrent(); + while (pItem) { + m_pCurNode = pItem->IsWidgetReady() ? pItem : nullptr; + if (m_pCurNode) + return m_pCurNode.Get(); + pItem = m_ContentIterator.MoveToNext(); + } + return nullptr; +} + +void CXFA_ReadyNodeIterator::SkipTree() { + m_ContentIterator.SkipChildrenAndMoveToNext(); + m_pCurNode = nullptr; +} diff --git a/xfa/fxfa/cxfa_widgetacciterator.h b/xfa/fxfa/cxfa_readynodeiterator.h index 79860a4c4c..d3cd9016e8 100644 --- a/xfa/fxfa/cxfa_widgetacciterator.h +++ b/xfa/fxfa/cxfa_readynodeiterator.h @@ -4,26 +4,25 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com -#ifndef XFA_FXFA_CXFA_WIDGETACCITERATOR_H_ -#define XFA_FXFA_CXFA_WIDGETACCITERATOR_H_ +#ifndef XFA_FXFA_CXFA_READYNODEITERATOR_H_ +#define XFA_FXFA_CXFA_READYNODEITERATOR_H_ #include "core/fxcrt/unowned_ptr.h" #include "xfa/fxfa/parser/cxfa_traversestrategy_xfacontainernode.h" class CXFA_Node; -class CXFA_WidgetAcc; -class CXFA_WidgetAccIterator { +class CXFA_ReadyNodeIterator { public: - explicit CXFA_WidgetAccIterator(CXFA_Node* pTravelRoot); - ~CXFA_WidgetAccIterator(); + explicit CXFA_ReadyNodeIterator(CXFA_Node* pTravelRoot); + ~CXFA_ReadyNodeIterator(); - CXFA_WidgetAcc* MoveToNext(); + CXFA_Node* MoveToNext(); void SkipTree(); private: CXFA_ContainerIterator m_ContentIterator; - UnownedPtr<CXFA_WidgetAcc> m_pCurWidgetAcc; + UnownedPtr<CXFA_Node> m_pCurNode; }; -#endif // XFA_FXFA_CXFA_WIDGETACCITERATOR_H_ +#endif // XFA_FXFA_CXFA_READYNODEITERATOR_H_ diff --git a/xfa/fxfa/cxfa_widgetacciterator.cpp b/xfa/fxfa/cxfa_widgetacciterator.cpp deleted file mode 100644 index c92832f029..0000000000 --- a/xfa/fxfa/cxfa_widgetacciterator.cpp +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright 2017 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/cxfa_widgetacciterator.h" - -#include "xfa/fxfa/cxfa_widgetacc.h" - -CXFA_WidgetAccIterator::CXFA_WidgetAccIterator(CXFA_Node* pTravelRoot) - : m_ContentIterator(pTravelRoot), m_pCurWidgetAcc(nullptr) {} - -CXFA_WidgetAccIterator::~CXFA_WidgetAccIterator() {} - -CXFA_WidgetAcc* CXFA_WidgetAccIterator::MoveToNext() { - CXFA_Node* pItem = m_pCurWidgetAcc ? m_ContentIterator.MoveToNext() - : m_ContentIterator.GetCurrent(); - while (pItem) { - m_pCurWidgetAcc = pItem->IsWidgetReady() ? pItem->GetWidgetAcc() : nullptr; - if (m_pCurWidgetAcc) - return m_pCurWidgetAcc.Get(); - pItem = m_ContentIterator.MoveToNext(); - } - return nullptr; -} - -void CXFA_WidgetAccIterator::SkipTree() { - m_ContentIterator.SkipChildrenAndMoveToNext(); - m_pCurWidgetAcc = nullptr; -} |