Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(435)

Side by Side Diff: core/src/fxcrt/xml_int.h

Issue 1577503002: Merge to XFA: Switch most min/max macros to std::min/max. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
Patch Set: rebase Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « core/src/fxcrt/fx_extension.cpp ('k') | core/src/fxge/agg/src/fx_agg_driver.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #ifndef CORE_SRC_FXCRT_XML_INT_H_ 7 #ifndef CORE_SRC_FXCRT_XML_INT_H_
8 #define CORE_SRC_FXCRT_XML_INT_H_ 8 #define CORE_SRC_FXCRT_XML_INT_H_
9 9
10 #include <algorithm>
11
10 #include "core/include/fxcrt/fx_stream.h" 12 #include "core/include/fxcrt/fx_stream.h"
11 13
12 class CFX_UTF8Decoder; 14 class CFX_UTF8Decoder;
13 class CXML_Element; 15 class CXML_Element;
14 16
15 class CXML_DataBufAcc : public IFX_BufferRead { 17 class CXML_DataBufAcc : public IFX_BufferRead {
16 public: 18 public:
17 CXML_DataBufAcc(const uint8_t* pBuffer, size_t size) 19 CXML_DataBufAcc(const uint8_t* pBuffer, size_t size)
18 : m_pBuffer(pBuffer), m_dwSize(size), m_dwCurPos(0) {} 20 : m_pBuffer(pBuffer), m_dwSize(size), m_dwCurPos(0) {}
19 ~CXML_DataBufAcc() override {} 21 ~CXML_DataBufAcc() override {}
(...skipping 16 matching lines...) Expand all
36 const uint8_t* GetBlockBuffer() override { return m_pBuffer; } 38 const uint8_t* GetBlockBuffer() override { return m_pBuffer; }
37 size_t GetBlockSize() override { return m_dwSize; } 39 size_t GetBlockSize() override { return m_dwSize; }
38 FX_FILESIZE GetBlockOffset() override { return 0; } 40 FX_FILESIZE GetBlockOffset() override { return 0; }
39 41
40 protected: 42 protected:
41 const uint8_t* m_pBuffer; 43 const uint8_t* m_pBuffer;
42 size_t m_dwSize; 44 size_t m_dwSize;
43 size_t m_dwCurPos; 45 size_t m_dwCurPos;
44 }; 46 };
45 47
46 #define FX_XMLDATASTREAM_BufferSize (32 * 1024)
47 class CXML_DataStmAcc : public IFX_BufferRead { 48 class CXML_DataStmAcc : public IFX_BufferRead {
48 public: 49 public:
49 CXML_DataStmAcc(IFX_FileRead* pFileRead) 50 explicit CXML_DataStmAcc(IFX_FileRead* pFileRead)
50 : m_pFileRead(pFileRead), m_pBuffer(NULL), m_nStart(0), m_dwSize(0) { 51 : m_pFileRead(pFileRead), m_pBuffer(NULL), m_nStart(0), m_dwSize(0) {
51 FXSYS_assert(m_pFileRead); 52 FXSYS_assert(m_pFileRead);
52 } 53 }
53 ~CXML_DataStmAcc() override { FX_Free(m_pBuffer); } 54 ~CXML_DataStmAcc() override { FX_Free(m_pBuffer); }
54 55
55 void Release() override { delete this; } 56 void Release() override { delete this; }
56 FX_BOOL IsEOF() override { 57 FX_BOOL IsEOF() override {
57 return m_nStart + (FX_FILESIZE)m_dwSize >= m_pFileRead->GetSize(); 58 return m_nStart + (FX_FILESIZE)m_dwSize >= m_pFileRead->GetSize();
58 } 59 }
59 FX_FILESIZE GetPosition() override { 60 FX_FILESIZE GetPosition() override {
60 return m_nStart + (FX_FILESIZE)m_dwSize; 61 return m_nStart + (FX_FILESIZE)m_dwSize;
61 } 62 }
62 size_t ReadBlock(void* buffer, size_t size) override { return 0; } 63 size_t ReadBlock(void* buffer, size_t size) override { return 0; }
63 FX_BOOL ReadNextBlock(FX_BOOL bRestart = FALSE) override { 64 FX_BOOL ReadNextBlock(FX_BOOL bRestart = FALSE) override {
64 if (bRestart) { 65 if (bRestart) {
65 m_nStart = 0; 66 m_nStart = 0;
66 } 67 }
67 FX_FILESIZE nLength = m_pFileRead->GetSize(); 68 FX_FILESIZE nLength = m_pFileRead->GetSize();
68 m_nStart += (FX_FILESIZE)m_dwSize; 69 m_nStart += (FX_FILESIZE)m_dwSize;
69 if (m_nStart >= nLength) { 70 if (m_nStart >= nLength) {
70 return FALSE; 71 return FALSE;
71 } 72 }
72 m_dwSize = (size_t)FX_MIN(FX_XMLDATASTREAM_BufferSize, nLength - m_nStart); 73 static const FX_FILESIZE FX_XMLDATASTREAM_BufferSize = 32 * 1024;
74 m_dwSize = static_cast<size_t>(
75 std::min(FX_XMLDATASTREAM_BufferSize, nLength - m_nStart));
73 if (!m_pBuffer) { 76 if (!m_pBuffer) {
74 m_pBuffer = FX_Alloc(uint8_t, m_dwSize); 77 m_pBuffer = FX_Alloc(uint8_t, m_dwSize);
75 } 78 }
76 return m_pFileRead->ReadBlock(m_pBuffer, m_nStart, m_dwSize); 79 return m_pFileRead->ReadBlock(m_pBuffer, m_nStart, m_dwSize);
77 } 80 }
78 const uint8_t* GetBlockBuffer() override { return (const uint8_t*)m_pBuffer; } 81 const uint8_t* GetBlockBuffer() override { return (const uint8_t*)m_pBuffer; }
79 size_t GetBlockSize() override { return m_dwSize; } 82 size_t GetBlockSize() override { return m_dwSize; }
80 FX_FILESIZE GetBlockOffset() override { return m_nStart; } 83 FX_FILESIZE GetBlockOffset() override { return m_nStart; }
81 84
82 protected: 85 protected:
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 const CFX_WideStringC& content, 121 const CFX_WideStringC& content,
119 CXML_Element* pElement); 122 CXML_Element* pElement);
120 void InsertCDATASegment(CFX_UTF8Decoder& decoder, CXML_Element* pElement); 123 void InsertCDATASegment(CFX_UTF8Decoder& decoder, CXML_Element* pElement);
121 }; 124 };
122 125
123 void FX_XML_SplitQualifiedName(const CFX_ByteStringC& bsFullName, 126 void FX_XML_SplitQualifiedName(const CFX_ByteStringC& bsFullName,
124 CFX_ByteStringC& bsSpace, 127 CFX_ByteStringC& bsSpace,
125 CFX_ByteStringC& bsName); 128 CFX_ByteStringC& bsName);
126 129
127 #endif // CORE_SRC_FXCRT_XML_INT_H_ 130 #endif // CORE_SRC_FXCRT_XML_INT_H_
OLDNEW
« no previous file with comments | « core/src/fxcrt/fx_extension.cpp ('k') | core/src/fxge/agg/src/fx_agg_driver.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698