From 08915150a3fb64aa1ebf9bdf20d1158a20b4266f Mon Sep 17 00:00:00 2001 From: Dan Sinclair Date: Tue, 23 Jan 2018 15:22:54 +0000 Subject: Convert CXFA_WidgetAccIterator to CXFA_ReadyNodeIterator This CL converts the WidgetAcc iterator to return nodes in which the OnReady event has been fired. Change-Id: I5ec6809c1610ac3467019d8492121901d3845a37 Reviewed-on: https://pdfium-review.googlesource.com/23490 Reviewed-by: Ryan Harrison Commit-Queue: dsinclair --- xfa/fxfa/cxfa_readynodeiterator.cpp | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 xfa/fxfa/cxfa_readynodeiterator.cpp (limited to 'xfa/fxfa/cxfa_readynodeiterator.cpp') 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; +} -- cgit v1.2.3