diff options
author | dsinclair <dsinclair@chromium.org> | 2016-05-18 06:09:33 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-05-18 06:09:33 -0700 |
commit | be9b8947d0090e20116822fe7caf5e7973d6b20a (patch) | |
tree | b88d67f0ed52956ad5d918110f449ecffa2f2a87 /core | |
parent | 56286b311543331d02fee90b832d66389a307961 (diff) | |
download | pdfium-be9b8947d0090e20116822fe7caf5e7973d6b20a.tar.xz |
Pass objects instead of strings for undo/redo records.
Currently the Undo/Redo records are serialized as byte strings and stored
into a CFX_ByteStringArray. They are deserialized when used.
This CL removes the serialization and stores the objects in a deque of unique
pointers.
Review-Url: https://codereview.chromium.org/1980293004
Diffstat (limited to 'core')
-rw-r--r-- | core/fxcrt/fx_basic_buffer.cpp | 127 | ||||
-rw-r--r-- | core/fxcrt/include/fx_basic.h | 65 |
2 files changed, 0 insertions, 192 deletions
diff --git a/core/fxcrt/fx_basic_buffer.cpp b/core/fxcrt/fx_basic_buffer.cpp index 2762497e5c..91ca6dad7c 100644 --- a/core/fxcrt/fx_basic_buffer.cpp +++ b/core/fxcrt/fx_basic_buffer.cpp @@ -182,133 +182,6 @@ CFX_WideTextBuf& CFX_WideTextBuf::operator<<(const CFX_WideTextBuf& buf) { return *this; } -#ifdef PDF_ENABLE_XFA -CFX_ArchiveSaver& CFX_ArchiveSaver::operator<<(uint8_t i) { - if (m_pStream) { - m_pStream->WriteBlock(&i, 1); - } else { - m_SavingBuf.AppendByte(i); - } - return *this; -} -CFX_ArchiveSaver& CFX_ArchiveSaver::operator<<(int i) { - if (m_pStream) { - m_pStream->WriteBlock(&i, sizeof(int)); - } else { - m_SavingBuf.AppendBlock(&i, sizeof(int)); - } - return *this; -} -CFX_ArchiveSaver& CFX_ArchiveSaver::operator<<(uint32_t i) { - if (m_pStream) { - m_pStream->WriteBlock(&i, sizeof(uint32_t)); - } else { - m_SavingBuf.AppendBlock(&i, sizeof(uint32_t)); - } - return *this; -} -CFX_ArchiveSaver& CFX_ArchiveSaver::operator<<(FX_FLOAT f) { - if (m_pStream) { - m_pStream->WriteBlock(&f, sizeof(FX_FLOAT)); - } else { - m_SavingBuf.AppendBlock(&f, sizeof(FX_FLOAT)); - } - return *this; -} -CFX_ArchiveSaver& CFX_ArchiveSaver::operator<<(const CFX_ByteStringC& bstr) { - int len = bstr.GetLength(); - if (m_pStream) { - m_pStream->WriteBlock(&len, sizeof(int)); - m_pStream->WriteBlock(bstr.raw_str(), len); - } else { - m_SavingBuf.AppendBlock(&len, sizeof(int)); - m_SavingBuf.AppendBlock(bstr.raw_str(), len); - } - return *this; -} -CFX_ArchiveSaver& CFX_ArchiveSaver::operator<<(const FX_WCHAR* wstr) { - FX_STRSIZE len = FXSYS_wcslen(wstr); - if (m_pStream) { - m_pStream->WriteBlock(&len, sizeof(int)); - m_pStream->WriteBlock(wstr, len); - } else { - m_SavingBuf.AppendBlock(&len, sizeof(int)); - m_SavingBuf.AppendBlock(wstr, len); - } - return *this; -} -CFX_ArchiveSaver& CFX_ArchiveSaver::operator<<(const CFX_WideString& wstr) { - CFX_ByteString encoded = wstr.UTF16LE_Encode(); - return operator<<(encoded.AsStringC()); -} -void CFX_ArchiveSaver::Write(const void* pData, FX_STRSIZE dwSize) { - if (m_pStream) { - m_pStream->WriteBlock(pData, dwSize); - } else { - m_SavingBuf.AppendBlock(pData, dwSize); - } -} -CFX_ArchiveLoader::CFX_ArchiveLoader(const uint8_t* pData, uint32_t dwSize) { - m_pLoadingBuf = pData; - m_LoadingPos = 0; - m_LoadingSize = dwSize; -} -FX_BOOL CFX_ArchiveLoader::IsEOF() { - return m_LoadingPos >= m_LoadingSize; -} -CFX_ArchiveLoader& CFX_ArchiveLoader::operator>>(uint8_t& i) { - if (m_LoadingPos >= m_LoadingSize) { - return *this; - } - i = m_pLoadingBuf[m_LoadingPos++]; - return *this; -} -CFX_ArchiveLoader& CFX_ArchiveLoader::operator>>(int& i) { - Read(&i, sizeof(int)); - return *this; -} -CFX_ArchiveLoader& CFX_ArchiveLoader::operator>>(uint32_t& i) { - Read(&i, sizeof(uint32_t)); - return *this; -} -CFX_ArchiveLoader& CFX_ArchiveLoader::operator>>(FX_FLOAT& i) { - Read(&i, sizeof(FX_FLOAT)); - return *this; -} -CFX_ArchiveLoader& CFX_ArchiveLoader::operator>>(CFX_ByteString& str) { - if (m_LoadingPos + 4 > m_LoadingSize) { - return *this; - } - int len; - operator>>(len); - str.clear(); - if (len <= 0 || m_LoadingPos + len > m_LoadingSize) { - return *this; - } - FX_CHAR* buffer = str.GetBuffer(len); - FXSYS_memcpy(buffer, m_pLoadingBuf + m_LoadingPos, len); - str.ReleaseBuffer(len); - m_LoadingPos += len; - return *this; -} -CFX_ArchiveLoader& CFX_ArchiveLoader::operator>>(CFX_WideString& str) { - CFX_ByteString encoded; - operator>>(encoded); - str = CFX_WideString::FromUTF16LE( - reinterpret_cast<const unsigned short*>(encoded.c_str()), - encoded.GetLength() / sizeof(unsigned short)); - return *this; -} -FX_BOOL CFX_ArchiveLoader::Read(void* pBuf, uint32_t dwSize) { - if (m_LoadingPos + dwSize > m_LoadingSize) { - return FALSE; - } - FXSYS_memcpy(pBuf, m_pLoadingBuf + m_LoadingPos, dwSize); - m_LoadingPos += dwSize; - return TRUE; -} -#endif // PDF_ENABLE_XFA - void CFX_BitStream::Init(const uint8_t* pData, uint32_t dwSize) { m_pData = pData; m_BitSize = dwSize * 8; diff --git a/core/fxcrt/include/fx_basic.h b/core/fxcrt/include/fx_basic.h index 59d72b8f5a..1835d9e0a6 100644 --- a/core/fxcrt/include/fx_basic.h +++ b/core/fxcrt/include/fx_basic.h @@ -108,71 +108,6 @@ class CFX_WideTextBuf : public CFX_BinaryBuf { CFX_WideTextBuf& operator<<(const CFX_WideTextBuf& buf); }; -#ifdef PDF_ENABLE_XFA -class CFX_ArchiveSaver { - public: - CFX_ArchiveSaver() : m_pStream(NULL) {} - - CFX_ArchiveSaver& operator<<(uint8_t i); - - CFX_ArchiveSaver& operator<<(int i); - - CFX_ArchiveSaver& operator<<(uint32_t i); - - CFX_ArchiveSaver& operator<<(FX_FLOAT i); - - CFX_ArchiveSaver& operator<<(double i); - - CFX_ArchiveSaver& operator<<(const CFX_ByteStringC& bstr); - - CFX_ArchiveSaver& operator<<(const FX_WCHAR* bstr); - - CFX_ArchiveSaver& operator<<(const CFX_WideString& wstr); - - void Write(const void* pData, FX_STRSIZE dwSize); - - intptr_t GetLength() { return m_SavingBuf.GetSize(); } - - const uint8_t* GetBuffer() { return m_SavingBuf.GetBuffer(); } - - void SetStream(IFX_FileStream* pStream) { m_pStream = pStream; } - - protected: - CFX_BinaryBuf m_SavingBuf; - - IFX_FileStream* m_pStream; -}; -class CFX_ArchiveLoader { - public: - CFX_ArchiveLoader(const uint8_t* pData, uint32_t dwSize); - - CFX_ArchiveLoader& operator>>(uint8_t& i); - - CFX_ArchiveLoader& operator>>(int& i); - - CFX_ArchiveLoader& operator>>(uint32_t& i); - - CFX_ArchiveLoader& operator>>(FX_FLOAT& i); - - CFX_ArchiveLoader& operator>>(double& i); - - CFX_ArchiveLoader& operator>>(CFX_ByteString& bstr); - - CFX_ArchiveLoader& operator>>(CFX_WideString& wstr); - - FX_BOOL IsEOF(); - - FX_BOOL Read(void* pBuf, uint32_t dwSize); - - protected: - uint32_t m_LoadingPos; - - const uint8_t* m_pLoadingBuf; - - uint32_t m_LoadingSize; -}; -#endif // PDF_ENABLE_XFA - class CFX_FileBufferArchive { public: CFX_FileBufferArchive(); |