summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--BUILD.gn4
-rw-r--r--fpdfsdk/fpdfsave.cpp16
-rw-r--r--fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp41
-rw-r--r--xfa/fxfa/cxfa_ffdocview.cpp18
-rw-r--r--xfa/fxfa/cxfa_ffdocview.h4
-rw-r--r--xfa/fxfa/cxfa_readynodeiterator.cpp31
-rw-r--r--xfa/fxfa/cxfa_readynodeiterator.h (renamed from xfa/fxfa/cxfa_widgetacciterator.h)17
-rw-r--r--xfa/fxfa/cxfa_widgetacciterator.cpp31
8 files changed, 79 insertions, 83 deletions
diff --git a/BUILD.gn b/BUILD.gn
index abdd414562..3ddf167e60 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -2076,6 +2076,8 @@ if (pdf_enable_xfa) {
"xfa/fxfa/cxfa_loadercontext.h",
"xfa/fxfa/cxfa_pieceline.cpp",
"xfa/fxfa/cxfa_pieceline.h",
+ "xfa/fxfa/cxfa_readynodeiterator.cpp",
+ "xfa/fxfa/cxfa_readynodeiterator.h",
"xfa/fxfa/cxfa_rendercontext.cpp",
"xfa/fxfa/cxfa_rendercontext.h",
"xfa/fxfa/cxfa_textlayout.cpp",
@@ -2094,8 +2096,6 @@ if (pdf_enable_xfa) {
"xfa/fxfa/cxfa_textuserdata.h",
"xfa/fxfa/cxfa_widgetacc.cpp",
"xfa/fxfa/cxfa_widgetacc.h",
- "xfa/fxfa/cxfa_widgetacciterator.cpp",
- "xfa/fxfa/cxfa_widgetacciterator.h",
"xfa/fxfa/fxfa.h",
"xfa/fxfa/fxfa_basic.h",
]
diff --git a/fpdfsdk/fpdfsave.cpp b/fpdfsdk/fpdfsave.cpp
index b4d4a4107a..b95850f7b6 100644
--- a/fpdfsdk/fpdfsave.cpp
+++ b/fpdfsdk/fpdfsave.cpp
@@ -31,8 +31,8 @@
#include "xfa/fxfa/cxfa_ffapp.h"
#include "xfa/fxfa/cxfa_ffdocview.h"
#include "xfa/fxfa/cxfa_ffwidgethandler.h"
+#include "xfa/fxfa/cxfa_readynodeiterator.h"
#include "xfa/fxfa/cxfa_widgetacc.h"
-#include "xfa/fxfa/cxfa_widgetacciterator.h"
#include "xfa/fxfa/parser/cxfa_object.h"
#endif
@@ -205,12 +205,11 @@ bool SendPostSaveToXFADoc(CPDFXFA_Context* pContext) {
return false;
CXFA_FFWidgetHandler* pWidgetHandler = pXFADocView->GetWidgetHandler();
- std::unique_ptr<CXFA_WidgetAccIterator> pWidgetAccIterator =
- pXFADocView->CreateWidgetAccIterator();
- while (CXFA_WidgetAcc* pWidgetAcc = pWidgetAccIterator->MoveToNext()) {
+ auto it = pXFADocView->CreateReadyNodeIterator();
+ while (CXFA_Node* pNode = it->MoveToNext()) {
CXFA_EventParam preParam;
preParam.m_eType = XFA_EVENT_PostSave;
- pWidgetHandler->ProcessEvent(pWidgetAcc->GetNode(), &preParam);
+ pWidgetHandler->ProcessEvent(pNode, &preParam);
}
pXFADocView->UpdateDocView();
pContext->ClearChangeMark();
@@ -227,12 +226,11 @@ bool SendPreSaveToXFADoc(CPDFXFA_Context* pContext,
return true;
CXFA_FFWidgetHandler* pWidgetHandler = pXFADocView->GetWidgetHandler();
- std::unique_ptr<CXFA_WidgetAccIterator> pWidgetAccIterator =
- pXFADocView->CreateWidgetAccIterator();
- while (CXFA_WidgetAcc* pWidgetAcc = pWidgetAccIterator->MoveToNext()) {
+ auto it = pXFADocView->CreateReadyNodeIterator();
+ while (CXFA_Node* pNode = it->MoveToNext()) {
CXFA_EventParam preParam;
preParam.m_eType = XFA_EVENT_PreSave;
- pWidgetHandler->ProcessEvent(pWidgetAcc->GetNode(), &preParam);
+ pWidgetHandler->ProcessEvent(pNode, &preParam);
}
pXFADocView->UpdateDocView();
return SaveXFADocumentData(pContext, fileList);
diff --git a/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp b/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp
index 9735584369..f3acf5624c 100644
--- a/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp
+++ b/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp
@@ -21,8 +21,8 @@
#include "xfa/fxfa/cxfa_ffdocview.h"
#include "xfa/fxfa/cxfa_ffwidget.h"
#include "xfa/fxfa/cxfa_ffwidgethandler.h"
-#include "xfa/fxfa/cxfa_widgetacc.h"
-#include "xfa/fxfa/cxfa_widgetacciterator.h"
+#include "xfa/fxfa/cxfa_readynodeiterator.h"
+#include "xfa/fxfa/parser/cxfa_node.h"
#include "xfa/fxfa/parser/cxfa_submit.h"
#define IDS_XFA_Validate_Input \
@@ -620,23 +620,23 @@ bool CPDFXFA_DocEnvironment::OnBeforeNotifySubmit() {
if (!pWidgetHandler)
return true;
- std::unique_ptr<CXFA_WidgetAccIterator> pWidgetAccIterator =
- docView->CreateWidgetAccIterator();
- if (pWidgetAccIterator) {
+ auto it = docView->CreateReadyNodeIterator();
+ if (it) {
CXFA_EventParam Param;
Param.m_eType = XFA_EVENT_PreSubmit;
- while (CXFA_WidgetAcc* pWidgetAcc = pWidgetAccIterator->MoveToNext())
- pWidgetHandler->ProcessEvent(pWidgetAcc->GetNode(), &Param);
+ while (CXFA_Node* pNode = it->MoveToNext())
+ pWidgetHandler->ProcessEvent(pNode, &Param);
}
- pWidgetAccIterator = docView->CreateWidgetAccIterator();
- if (!pWidgetAccIterator)
+ it = docView->CreateReadyNodeIterator();
+ if (!it)
return true;
- CXFA_WidgetAcc* pWidgetAcc = pWidgetAccIterator->MoveToNext();
- pWidgetAcc = pWidgetAccIterator->MoveToNext();
- while (pWidgetAcc) {
- int fRet = pWidgetAcc->GetNode()->ProcessValidate(docView, -1);
+ (void)it->MoveToNext();
+ CXFA_Node* pNode = it->MoveToNext();
+
+ while (pNode) {
+ int fRet = pNode->ProcessValidate(docView, -1);
if (fRet == XFA_EVENTERROR_Error) {
CPDFSDK_FormFillEnvironment* pFormFillEnv = m_pContext->GetFormFillEnv();
if (!pFormFillEnv)
@@ -650,7 +650,7 @@ bool CPDFXFA_DocEnvironment::OnBeforeNotifySubmit() {
bs.ReleaseBuffer(len);
return false;
}
- pWidgetAcc = pWidgetAccIterator->MoveToNext();
+ pNode = it->MoveToNext();
}
docView->UpdateDocView();
@@ -669,17 +669,16 @@ void CPDFXFA_DocEnvironment::OnAfterNotifySubmit() {
if (!pWidgetHandler)
return;
- std::unique_ptr<CXFA_WidgetAccIterator> pWidgetAccIterator =
- m_pContext->GetXFADocView()->CreateWidgetAccIterator();
- if (!pWidgetAccIterator)
+ auto it = m_pContext->GetXFADocView()->CreateReadyNodeIterator();
+ if (!it)
return;
CXFA_EventParam Param;
Param.m_eType = XFA_EVENT_PostSubmit;
- CXFA_WidgetAcc* pWidgetAcc = pWidgetAccIterator->MoveToNext();
- while (pWidgetAcc) {
- pWidgetHandler->ProcessEvent(pWidgetAcc->GetNode(), &Param);
- pWidgetAcc = pWidgetAccIterator->MoveToNext();
+ CXFA_Node* pNode = it->MoveToNext();
+ while (pNode) {
+ pWidgetHandler->ProcessEvent(pNode, &Param);
+ pNode = it->MoveToNext();
}
m_pContext->GetXFADocView()->UpdateDocView();
}
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;
-}