summaryrefslogtreecommitdiff
path: root/xfa/fxfa/parser/xfa_utils.h
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2017-11-14 21:29:35 +0000
committerChromium commit bot <commit-bot@chromium.org>2017-11-14 21:29:35 +0000
commit4011677aed8b258fcf87cf52b0d541ef04c832ff (patch)
treedc5f8124fc0e81c15213e4b0ebeecc83c96049d7 /xfa/fxfa/parser/xfa_utils.h
parentaee28693976cc246eea8230a999906802e52cab7 (diff)
downloadpdfium-4011677aed8b258fcf87cf52b0d541ef04c832ff.tar.xz
Move code out of xfa_utilschromium/3271chromium/3270chromium/3269
This CL splits the node template out of xfa_utils into its own file. The XFA_ByteStringToDouble method was moved to the only calling file. Change-Id: I85fb2dfa3afc4a675ec69574e32d643c0dca731f Reviewed-on: https://pdfium-review.googlesource.com/18490 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'xfa/fxfa/parser/xfa_utils.h')
-rw-r--r--xfa/fxfa/parser/xfa_utils.h120
1 files changed, 0 insertions, 120 deletions
diff --git a/xfa/fxfa/parser/xfa_utils.h b/xfa/fxfa/parser/xfa_utils.h
index cfa27bbccd..b00f7aace6 100644
--- a/xfa/fxfa/parser/xfa_utils.h
+++ b/xfa/fxfa/parser/xfa_utils.h
@@ -23,127 +23,7 @@ bool XFA_FDEExtension_ResolveNamespaceQualifier(CFX_XMLElement* pNode,
const WideString& wsQualifier,
WideString* wsNamespaceURI);
-template <class NodeType, class TraverseStrategy>
-class CXFA_NodeIteratorTemplate {
- public:
- explicit CXFA_NodeIteratorTemplate(NodeType* pRoot)
- : m_pRoot(pRoot), m_pCurrent(pRoot) {}
-
- NodeType* GetRoot() const { return m_pRoot; }
- NodeType* GetCurrent() const { return m_pCurrent; }
-
- void Reset() { m_pCurrent = m_pRoot; }
- bool SetCurrent(NodeType* pNode) {
- if (!RootReachableFromNode(pNode)) {
- m_pCurrent = nullptr;
- return false;
- }
- m_pCurrent = pNode;
- return true;
- }
-
- NodeType* MoveToPrev() {
- if (!m_pRoot)
- return nullptr;
- if (!m_pCurrent) {
- m_pCurrent = LastDescendant(m_pRoot);
- return m_pCurrent;
- }
- NodeType* pSibling = PreviousSiblingWithinSubtree(m_pCurrent);
- if (pSibling) {
- m_pCurrent = LastDescendant(pSibling);
- return m_pCurrent;
- }
- NodeType* pParent = ParentWithinSubtree(m_pCurrent);
- if (pParent) {
- m_pCurrent = pParent;
- return m_pCurrent;
- }
- return nullptr;
- }
-
- NodeType* MoveToNext() {
- if (!m_pRoot || !m_pCurrent)
- return nullptr;
- NodeType* pChild = TraverseStrategy::GetFirstChild(m_pCurrent);
- if (pChild) {
- m_pCurrent = pChild;
- return m_pCurrent;
- }
- return SkipChildrenAndMoveToNext();
- }
-
- NodeType* SkipChildrenAndMoveToNext() {
- if (!m_pRoot)
- return nullptr;
- NodeType* pNode = m_pCurrent;
- while (pNode) {
- NodeType* pSibling = NextSiblingWithinSubtree(pNode);
- if (pSibling) {
- m_pCurrent = pSibling;
- return m_pCurrent;
- }
- pNode = ParentWithinSubtree(pNode);
- }
- m_pCurrent = nullptr;
- return m_pCurrent;
- }
-
- private:
- bool RootReachableFromNode(NodeType* pNode) {
- if (!pNode)
- return false;
- if (pNode == m_pRoot)
- return true;
- return RootReachableFromNode(TraverseStrategy::GetParent(pNode));
- }
-
- NodeType* ParentWithinSubtree(NodeType* pNode) {
- if (!pNode || pNode == m_pRoot)
- return nullptr;
- return TraverseStrategy::GetParent(pNode);
- }
-
- NodeType* NextSiblingWithinSubtree(NodeType* pNode) {
- if (pNode == m_pRoot)
- return nullptr;
- return TraverseStrategy::GetNextSibling(pNode);
- }
-
- NodeType* PreviousSiblingWithinSubtree(NodeType* pNode) {
- NodeType* pParent = ParentWithinSubtree(pNode);
- if (!pParent)
- return nullptr;
- NodeType* pCurrent = TraverseStrategy::GetFirstChild(pParent);
- NodeType* pPrevious = nullptr;
- while (pCurrent != pNode) {
- pPrevious = pCurrent;
- pCurrent = TraverseStrategy::GetNextSibling(pCurrent);
- }
- return pPrevious;
- }
-
- NodeType* LastChild(NodeType* pNode) {
- NodeType* pPrevious = nullptr;
- NodeType* pChild = TraverseStrategy::GetFirstChild(pNode);
- while (pChild) {
- pPrevious = pChild;
- pChild = NextSiblingWithinSubtree(pChild);
- }
- return pPrevious;
- }
-
- NodeType* LastDescendant(NodeType* pNode) {
- NodeType* pChild = LastChild(pNode);
- return pChild ? LastDescendant(pChild) : pNode;
- }
-
- NodeType* m_pRoot;
- NodeType* m_pCurrent;
-};
-
CXFA_LocaleValue XFA_GetLocaleValue(CXFA_WidgetData* pWidgetData);
-double XFA_ByteStringToDouble(const ByteStringView& szStringVal);
int32_t XFA_MapRotation(int32_t nRotation);
bool XFA_RecognizeRichText(CFX_XMLElement* pRichTextXMLNode);