summaryrefslogtreecommitdiff
path: root/xfa/fgas/xml
diff options
context:
space:
mode:
authordsinclair <dsinclair@chromium.org>2016-04-27 12:47:01 -0700
committerCommit bot <commit-bot@chromium.org>2016-04-27 12:47:01 -0700
commit303e525325904cd9b6a847f48951510e7dd8a45e (patch)
treedab3ff0e3bda317dc51ef0caf8d15daf88e7e6b8 /xfa/fgas/xml
parent43854a5073602a4613131aa6dbac5f7b9a095bcd (diff)
downloadpdfium-303e525325904cd9b6a847f48951510e7dd8a45e.tar.xz
More IFX_ interface cleanup.
Remove IFX_FontProvider, IFX_FontSourceEnum, IFX_SAXReader and IFX_SAXReaderHandler. Review-Url: https://codereview.chromium.org/1930533002
Diffstat (limited to 'xfa/fgas/xml')
-rw-r--r--xfa/fgas/xml/fgas_sax.cpp (renamed from xfa/fgas/xml/fgas_sax_imp.cpp)42
-rw-r--r--xfa/fgas/xml/fgas_sax.h159
-rw-r--r--xfa/fgas/xml/fgas_sax_imp.h141
3 files changed, 148 insertions, 194 deletions
diff --git a/xfa/fgas/xml/fgas_sax_imp.cpp b/xfa/fgas/xml/fgas_sax.cpp
index d47bc44000..b97aeb0a7c 100644
--- a/xfa/fgas/xml/fgas_sax_imp.cpp
+++ b/xfa/fgas/xml/fgas_sax.cpp
@@ -4,19 +4,18 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#include "xfa/fgas/xml/fgas_sax_imp.h"
+#include "xfa/fgas/xml/fgas_sax.h"
#include <algorithm>
+#include "xfa/fxfa/include/xfa_checksum.h"
+
namespace {
const uint32_t kSaxFileBufSize = 32768;
} // namespace
-IFX_SAXReader* FX_SAXReader_Create() {
- return new CFX_SAXReader;
-}
CFX_SAXFile::CFX_SAXFile()
: m_pFile(NULL),
m_dwStart(0),
@@ -618,16 +617,16 @@ void CFX_SAXReader::SkipNode() {
ParseChar(m_CurByte);
}
}
+
void CFX_SAXReader::NotifyData() {
- ASSERT(m_pHandler != NULL);
if (m_pCurItem->m_eNode == FX_SAXNODE_Tag)
m_pHandler->OnTagData(m_pCurItem->m_pNode,
m_bCharData ? FX_SAXNODE_CharData : FX_SAXNODE_Text,
CFX_ByteStringC(m_pszData, m_iDataLength),
m_File.m_dwCur + m_dwDataOffset);
}
+
void CFX_SAXReader::NotifyEnter() {
- ASSERT(m_pHandler != NULL);
if (m_pCurItem->m_eNode == FX_SAXNODE_Tag ||
m_pCurItem->m_eNode == FX_SAXNODE_Instruction) {
m_pCurItem->m_pNode =
@@ -635,8 +634,8 @@ void CFX_SAXReader::NotifyEnter() {
m_pCurItem->m_eNode, m_dwNodePos);
}
}
+
void CFX_SAXReader::NotifyAttribute() {
- ASSERT(m_pHandler != NULL);
if (m_pCurItem->m_eNode == FX_SAXNODE_Tag ||
m_pCurItem->m_eNode == FX_SAXNODE_Instruction) {
m_pHandler->OnTagAttribute(m_pCurItem->m_pNode,
@@ -644,29 +643,28 @@ void CFX_SAXReader::NotifyAttribute() {
CFX_ByteStringC(m_pszData, m_iDataLength));
}
}
+
void CFX_SAXReader::NotifyBreak() {
- ASSERT(m_pHandler != NULL);
- if (m_pCurItem->m_eNode == FX_SAXNODE_Tag) {
+ if (m_pCurItem->m_eNode == FX_SAXNODE_Tag)
m_pHandler->OnTagBreak(m_pCurItem->m_pNode);
- }
}
+
void CFX_SAXReader::NotifyClose() {
- ASSERT(m_pHandler != NULL);
if (m_pCurItem->m_eNode == FX_SAXNODE_Tag ||
m_pCurItem->m_eNode == FX_SAXNODE_Instruction) {
m_pHandler->OnTagClose(m_pCurItem->m_pNode, m_dwNodePos);
}
}
+
void CFX_SAXReader::NotifyEnd() {
- ASSERT(m_pHandler != NULL);
- if (m_pCurItem->m_eNode == FX_SAXNODE_Tag) {
- m_pHandler->OnTagEnd(m_pCurItem->m_pNode,
- CFX_ByteStringC(m_pszData, m_iDataLength),
- m_dwNodePos);
- }
+ if (m_pCurItem->m_eNode != FX_SAXNODE_Tag)
+ return;
+
+ m_pHandler->OnTagEnd(m_pCurItem->m_pNode,
+ CFX_ByteStringC(m_pszData, m_iDataLength), m_dwNodePos);
}
+
void CFX_SAXReader::NotifyTargetData() {
- ASSERT(m_pHandler != NULL);
if (m_pCurItem->m_eNode == FX_SAXNODE_Instruction) {
m_pHandler->OnTargetData(m_pCurItem->m_pNode, m_pCurItem->m_eNode,
CFX_ByteStringC(m_pszName, m_iNameLength),
@@ -677,12 +675,14 @@ void CFX_SAXReader::NotifyTargetData() {
m_dwNodePos);
}
}
+
void CFX_SAXReader::SkipCurrentNode() {
- if (!m_pCurItem) {
+ if (!m_pCurItem)
return;
- }
+
m_pCurItem->m_bSkip = TRUE;
}
-void CFX_SAXReader::SetHandler(IFX_SAXReaderHandler* pHandler) {
+
+void CFX_SAXReader::SetHandler(CXFA_SAXReaderHandler* pHandler) {
m_pHandler = pHandler;
}
diff --git a/xfa/fgas/xml/fgas_sax.h b/xfa/fgas/xml/fgas_sax.h
index 501c358e0f..57ff6b2470 100644
--- a/xfa/fgas/xml/fgas_sax.h
+++ b/xfa/fgas/xml/fgas_sax.h
@@ -27,42 +27,137 @@ enum FX_SAXNODE {
FX_SAXNODE_CharData,
};
-class IFX_SAXReaderHandler {
+enum FX_SAXMODE {
+ FX_SAXMODE_Text = 0,
+ FX_SAXMODE_NodeStart,
+ FX_SAXMODE_DeclOrComment,
+ FX_SAXMODE_DeclNode,
+ FX_SAXMODE_Comment,
+ FX_SAXMODE_CommentContent,
+ FX_SAXMODE_TagName,
+ FX_SAXMODE_TagAttributeName,
+ FX_SAXMODE_TagAttributeEqual,
+ FX_SAXMODE_TagAttributeValue,
+ FX_SAXMODE_TagMaybeClose,
+ FX_SAXMODE_TagClose,
+ FX_SAXMODE_TagEnd,
+ FX_SAXMODE_TargetData,
+ FX_SAXMODE_MAX,
+};
+
+class CXFA_SAXReaderHandler;
+
+class CFX_SAXFile {
+ public:
+ CFX_SAXFile();
+ FX_BOOL StartFile(IFX_FileRead* pFile, uint32_t dwStart, uint32_t dwLen);
+ FX_BOOL ReadNextBlock();
+ void Reset();
+ IFX_FileRead* m_pFile;
+ uint32_t m_dwStart;
+ uint32_t m_dwEnd;
+ uint32_t m_dwCur;
+ uint8_t* m_pBuf;
+ uint32_t m_dwBufSize;
+ uint32_t m_dwBufIndex;
+};
+
+class CFX_SAXItem {
public:
- virtual ~IFX_SAXReaderHandler() {}
- virtual void* OnTagEnter(const CFX_ByteStringC& bsTagName,
- FX_SAXNODE eType,
- uint32_t dwStartPos) = 0;
- virtual void OnTagAttribute(void* pTag,
- const CFX_ByteStringC& bsAttri,
- const CFX_ByteStringC& bsValue) = 0;
- virtual void OnTagBreak(void* pTag) = 0;
- virtual void OnTagData(void* pTag,
- FX_SAXNODE eType,
- const CFX_ByteStringC& bsData,
- uint32_t dwStartPos) = 0;
- virtual void OnTagClose(void* pTag, uint32_t dwEndPos) = 0;
- virtual void OnTagEnd(void* pTag,
- const CFX_ByteStringC& bsTagName,
- uint32_t dwEndPos) = 0;
- virtual void OnTargetData(void* pTag,
- FX_SAXNODE eType,
- const CFX_ByteStringC& bsData,
- uint32_t dwStartPos) = 0;
+ CFX_SAXItem()
+ : m_pNode(NULL),
+ m_eNode(FX_SAXNODE_Unknown),
+ m_dwID(0),
+ m_bSkip(FALSE),
+ m_pPrev(NULL),
+ m_pNext(NULL) {}
+ void* m_pNode;
+ FX_SAXNODE m_eNode;
+ uint32_t m_dwID;
+ FX_BOOL m_bSkip;
+ CFX_SAXItem* m_pPrev;
+ CFX_SAXItem* m_pNext;
};
-class IFX_SAXReader {
+class CFX_SAXCommentContext {
public:
- virtual ~IFX_SAXReader() {}
- virtual void Release() = 0;
- virtual int32_t StartParse(IFX_FileRead* pFile,
- uint32_t dwStart = 0,
- uint32_t dwLen = -1,
- uint32_t dwParseMode = 0) = 0;
- virtual int32_t ContinueParse(IFX_Pause* pPause = NULL) = 0;
- virtual void SkipCurrentNode() = 0;
- virtual void SetHandler(IFX_SAXReaderHandler* pHandler) = 0;
+ CFX_SAXCommentContext() : m_iHeaderCount(0), m_iTailCount(0) {}
+ int32_t m_iHeaderCount;
+ int32_t m_iTailCount;
+};
+
+class CFX_SAXReader {
+ public:
+ CFX_SAXReader();
+ ~CFX_SAXReader();
+
+ void Release() { delete this; }
+ int32_t StartParse(IFX_FileRead* pFile,
+ uint32_t dwStart = 0,
+ uint32_t dwLen = -1,
+ uint32_t dwParseMode = 0);
+ int32_t ContinueParse(IFX_Pause* pPause = NULL);
+ void SkipCurrentNode();
+ void SetHandler(CXFA_SAXReaderHandler* pHandler);
+ void AppendData(uint8_t ch);
+ void AppendName(uint8_t ch);
+ void ParseText();
+ void ParseNodeStart();
+ void ParseInstruction();
+ void ParseDeclOrComment();
+ void ParseDeclNode();
+ void ParseComment();
+ void ParseCommentContent();
+ void ParseTagName();
+ void ParseTagAttributeName();
+ void ParseTagAttributeEqual();
+ void ParseTagAttributeValue();
+ void ParseMaybeClose();
+ void ParseTagClose();
+ void ParseTagEnd();
+ void ParseTargetData();
+
+ protected:
+ void Reset();
+ void Push();
+ void Pop();
+ FX_BOOL SkipSpace(uint8_t ch);
+ void SkipNode();
+ void NotifyData();
+ void NotifyEnter();
+ void NotifyAttribute();
+ void NotifyBreak();
+ void NotifyClose();
+ void NotifyEnd();
+ void NotifyTargetData();
+ void ReallocDataBuffer();
+ void ReallocNameBuffer();
+ void ParseChar(uint8_t ch);
+
+ CFX_SAXFile m_File;
+ CXFA_SAXReaderHandler* m_pHandler;
+ int32_t m_iState;
+ CFX_SAXItem* m_pRoot;
+ CFX_SAXItem* m_pCurItem;
+ uint32_t m_dwItemID;
+ FX_SAXMODE m_eMode;
+ FX_SAXMODE m_ePrevMode;
+ FX_BOOL m_bCharData;
+ uint8_t m_CurByte;
+ uint32_t m_dwDataOffset;
+ CFX_ByteArray m_SkipStack;
+ uint8_t m_SkipChar;
+ uint32_t m_dwNodePos;
+ uint8_t* m_pszData;
+ int32_t m_iDataSize;
+ int32_t m_iDataLength;
+ int32_t m_iEntityStart;
+ int32_t m_iDataPos;
+ uint8_t* m_pszName;
+ int32_t m_iNameSize;
+ int32_t m_iNameLength;
+ uint32_t m_dwParseMode;
+ CFX_SAXCommentContext* m_pCommentContext;
};
-IFX_SAXReader* FX_SAXReader_Create();
#endif // XFA_FGAS_XML_FGAS_SAX_H_
diff --git a/xfa/fgas/xml/fgas_sax_imp.h b/xfa/fgas/xml/fgas_sax_imp.h
deleted file mode 100644
index a52d8356ee..0000000000
--- a/xfa/fgas/xml/fgas_sax_imp.h
+++ /dev/null
@@ -1,141 +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_FGAS_XML_FGAS_SAX_IMP_H_
-#define XFA_FGAS_XML_FGAS_SAX_IMP_H_
-
-#include "xfa/fgas/xml/fgas_sax.h"
-
-class CFX_SAXFile {
- public:
- CFX_SAXFile();
- FX_BOOL StartFile(IFX_FileRead* pFile, uint32_t dwStart, uint32_t dwLen);
- FX_BOOL ReadNextBlock();
- void Reset();
- IFX_FileRead* m_pFile;
- uint32_t m_dwStart;
- uint32_t m_dwEnd;
- uint32_t m_dwCur;
- uint8_t* m_pBuf;
- uint32_t m_dwBufSize;
- uint32_t m_dwBufIndex;
-};
-
-enum FX_SAXMODE {
- FX_SAXMODE_Text = 0,
- FX_SAXMODE_NodeStart,
- FX_SAXMODE_DeclOrComment,
- FX_SAXMODE_DeclNode,
- FX_SAXMODE_Comment,
- FX_SAXMODE_CommentContent,
- FX_SAXMODE_TagName,
- FX_SAXMODE_TagAttributeName,
- FX_SAXMODE_TagAttributeEqual,
- FX_SAXMODE_TagAttributeValue,
- FX_SAXMODE_TagMaybeClose,
- FX_SAXMODE_TagClose,
- FX_SAXMODE_TagEnd,
- FX_SAXMODE_TargetData,
- FX_SAXMODE_MAX,
-};
-
-class CFX_SAXItem {
- public:
- CFX_SAXItem()
- : m_pNode(NULL),
- m_eNode(FX_SAXNODE_Unknown),
- m_dwID(0),
- m_bSkip(FALSE),
- m_pPrev(NULL),
- m_pNext(NULL) {}
- void* m_pNode;
- FX_SAXNODE m_eNode;
- uint32_t m_dwID;
- FX_BOOL m_bSkip;
- CFX_SAXItem* m_pPrev;
- CFX_SAXItem* m_pNext;
-};
-
-class CFX_SAXCommentContext {
- public:
- CFX_SAXCommentContext() : m_iHeaderCount(0), m_iTailCount(0) {}
- int32_t m_iHeaderCount;
- int32_t m_iTailCount;
-};
-
-class CFX_SAXReader : public IFX_SAXReader {
- public:
- CFX_SAXReader();
- ~CFX_SAXReader();
- virtual void Release() { delete this; }
- virtual int32_t StartParse(IFX_FileRead* pFile,
- uint32_t dwStart = 0,
- uint32_t dwLen = -1,
- uint32_t dwParseMode = 0);
- virtual int32_t ContinueParse(IFX_Pause* pPause = NULL);
- virtual void SkipCurrentNode();
- virtual void SetHandler(IFX_SAXReaderHandler* pHandler);
- void AppendData(uint8_t ch);
- void AppendName(uint8_t ch);
- void ParseText();
- void ParseNodeStart();
- void ParseInstruction();
- void ParseDeclOrComment();
- void ParseDeclNode();
- void ParseComment();
- void ParseCommentContent();
- void ParseTagName();
- void ParseTagAttributeName();
- void ParseTagAttributeEqual();
- void ParseTagAttributeValue();
- void ParseMaybeClose();
- void ParseTagClose();
- void ParseTagEnd();
- void ParseTargetData();
-
- protected:
- CFX_SAXFile m_File;
- IFX_SAXReaderHandler* m_pHandler;
- int32_t m_iState;
- CFX_SAXItem* m_pRoot;
- CFX_SAXItem* m_pCurItem;
- uint32_t m_dwItemID;
- FX_SAXMODE m_eMode;
- FX_SAXMODE m_ePrevMode;
- FX_BOOL m_bCharData;
- uint8_t m_CurByte;
- uint32_t m_dwDataOffset;
- CFX_ByteArray m_SkipStack;
- uint8_t m_SkipChar;
- uint32_t m_dwNodePos;
- uint8_t* m_pszData;
- int32_t m_iDataSize;
- int32_t m_iDataLength;
- int32_t m_iEntityStart;
- int32_t m_iDataPos;
- uint8_t* m_pszName;
- int32_t m_iNameSize;
- int32_t m_iNameLength;
- uint32_t m_dwParseMode;
- CFX_SAXCommentContext* m_pCommentContext;
- void Reset();
- void Push();
- void Pop();
- FX_BOOL SkipSpace(uint8_t ch);
- void SkipNode();
- void NotifyData();
- void NotifyEnter();
- void NotifyAttribute();
- void NotifyBreak();
- void NotifyClose();
- void NotifyEnd();
- void NotifyTargetData();
- void ReallocDataBuffer();
- void ReallocNameBuffer();
- void ParseChar(uint8_t ch);
-};
-
-#endif // XFA_FGAS_XML_FGAS_SAX_IMP_H_