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

Side by Side Diff: xfa/fxfa/app/xfa_checksum.cpp

Issue 2051233002: Remove more casts, part 7. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 4 years, 6 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
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 #include "xfa/fxfa/include/xfa_checksum.h" 7 #include "xfa/fxfa/include/xfa_checksum.h"
8 8
9 #include "core/fdrm/crypto/include/fx_crypt.h" 9 #include "core/fdrm/crypto/include/fx_crypt.h"
10 10
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 return pDstEnd - pDst; 89 return pDstEnd - pDst;
90 } 90 }
91 91
92 } // namespace 92 } // namespace
93 93
94 CXFA_SAXReaderHandler::CXFA_SAXReaderHandler(CXFA_ChecksumContext* pContext) 94 CXFA_SAXReaderHandler::CXFA_SAXReaderHandler(CXFA_ChecksumContext* pContext)
95 : m_pContext(pContext) { 95 : m_pContext(pContext) {
96 ASSERT(m_pContext); 96 ASSERT(m_pContext);
97 } 97 }
98 CXFA_SAXReaderHandler::~CXFA_SAXReaderHandler() {} 98 CXFA_SAXReaderHandler::~CXFA_SAXReaderHandler() {}
99 void* CXFA_SAXReaderHandler::OnTagEnter(const CFX_ByteStringC& bsTagName, 99 CXFA_SAXContext* CXFA_SAXReaderHandler::OnTagEnter(
100 CFX_SAXItem::Type eType, 100 const CFX_ByteStringC& bsTagName,
101 uint32_t dwStartPos) { 101 CFX_SAXItem::Type eType,
102 uint32_t dwStartPos) {
102 UpdateChecksum(TRUE); 103 UpdateChecksum(TRUE);
103 if (eType != CFX_SAXItem::Type::Tag && 104 if (eType != CFX_SAXItem::Type::Tag &&
104 eType != CFX_SAXItem::Type::Instruction) { 105 eType != CFX_SAXItem::Type::Instruction) {
105 return NULL; 106 return NULL;
106 } 107 }
107 m_SAXContext.m_eNode = eType; 108 m_SAXContext.m_eNode = eType;
108 CFX_ByteTextBuf& textBuf = m_SAXContext.m_TextBuf; 109 CFX_ByteTextBuf& textBuf = m_SAXContext.m_TextBuf;
109 textBuf << "<"; 110 textBuf << "<";
110 if (eType == CFX_SAXItem::Type::Instruction) { 111 if (eType == CFX_SAXItem::Type::Instruction) {
111 textBuf << "?"; 112 textBuf << "?";
112 } 113 }
113 textBuf << bsTagName; 114 textBuf << bsTagName;
114 m_SAXContext.m_bsTagName = bsTagName; 115 m_SAXContext.m_bsTagName = bsTagName;
115 return &m_SAXContext; 116 return &m_SAXContext;
116 } 117 }
117 void CXFA_SAXReaderHandler::OnTagAttribute(void* pTag, 118
119 void CXFA_SAXReaderHandler::OnTagAttribute(CXFA_SAXContext* pTag,
118 const CFX_ByteStringC& bsAttri, 120 const CFX_ByteStringC& bsAttri,
119 const CFX_ByteStringC& bsValue) { 121 const CFX_ByteStringC& bsValue) {
120 if (pTag == NULL) { 122 if (!pTag)
121 return; 123 return;
122 } 124
123 CFX_ByteTextBuf& textBuf = ((CXFA_SAXContext*)pTag)->m_TextBuf; 125 pTag->m_TextBuf << " " << bsAttri << "=\"" << bsValue << "\"";
124 textBuf << " " << bsAttri << "=\"" << bsValue << "\"";
125 } 126 }
126 void CXFA_SAXReaderHandler::OnTagBreak(void* pTag) { 127
127 if (pTag == NULL) { 128 void CXFA_SAXReaderHandler::OnTagBreak(CXFA_SAXContext* pTag) {
129 if (!pTag)
128 return; 130 return;
129 } 131
130 CFX_ByteTextBuf& textBuf = ((CXFA_SAXContext*)pTag)->m_TextBuf; 132 pTag->m_TextBuf << ">";
131 textBuf << ">";
132 UpdateChecksum(FALSE); 133 UpdateChecksum(FALSE);
133 } 134 }
134 void CXFA_SAXReaderHandler::OnTagData(void* pTag, 135
136 void CXFA_SAXReaderHandler::OnTagData(CXFA_SAXContext* pTag,
135 CFX_SAXItem::Type eType, 137 CFX_SAXItem::Type eType,
136 const CFX_ByteStringC& bsData, 138 const CFX_ByteStringC& bsData,
137 uint32_t dwStartPos) { 139 uint32_t dwStartPos) {
138 if (pTag == NULL) { 140 if (!pTag)
139 return; 141 return;
140 } 142
141 CFX_ByteTextBuf& textBuf = ((CXFA_SAXContext*)pTag)->m_TextBuf; 143 CFX_ByteTextBuf& textBuf = pTag->m_TextBuf;
142 if (eType == CFX_SAXItem::Type::CharData) { 144 if (eType == CFX_SAXItem::Type::CharData)
143 textBuf << "<![CDATA["; 145 textBuf << "<![CDATA[";
144 } 146
145 textBuf << bsData; 147 textBuf << bsData;
146 if (eType == CFX_SAXItem::Type::CharData) { 148 if (eType == CFX_SAXItem::Type::CharData)
147 textBuf << "]]>"; 149 textBuf << "]]>";
148 }
149 } 150 }
150 void CXFA_SAXReaderHandler::OnTagClose(void* pTag, uint32_t dwEndPos) { 151
151 if (pTag == NULL) { 152 void CXFA_SAXReaderHandler::OnTagClose(CXFA_SAXContext* pTag,
153 uint32_t dwEndPos) {
154 if (!pTag)
152 return; 155 return;
153 } 156
154 CXFA_SAXContext* pSAXContext = (CXFA_SAXContext*)pTag; 157 CFX_ByteTextBuf& textBuf = pTag->m_TextBuf;
155 CFX_ByteTextBuf& textBuf = pSAXContext->m_TextBuf; 158 if (pTag->m_eNode == CFX_SAXItem::Type::Instruction)
156 if (pSAXContext->m_eNode == CFX_SAXItem::Type::Instruction) {
157 textBuf << "?>"; 159 textBuf << "?>";
158 } else if (pSAXContext->m_eNode == CFX_SAXItem::Type::Tag) { 160 else if (pTag->m_eNode == CFX_SAXItem::Type::Tag)
159 textBuf << "></" << pSAXContext->m_bsTagName.AsStringC() << ">"; 161 textBuf << "></" << pTag->m_bsTagName.AsStringC() << ">";
160 } 162
161 UpdateChecksum(FALSE); 163 UpdateChecksum(FALSE);
162 } 164 }
163 void CXFA_SAXReaderHandler::OnTagEnd(void* pTag, 165
166 void CXFA_SAXReaderHandler::OnTagEnd(CXFA_SAXContext* pTag,
164 const CFX_ByteStringC& bsTagName, 167 const CFX_ByteStringC& bsTagName,
165 uint32_t dwEndPos) { 168 uint32_t dwEndPos) {
166 if (pTag == NULL) { 169 if (!pTag)
167 return; 170 return;
168 } 171
169 CFX_ByteTextBuf& textBuf = ((CXFA_SAXContext*)pTag)->m_TextBuf; 172 pTag->m_TextBuf << "</" << bsTagName << ">";
170 textBuf << "</" << bsTagName << ">";
171 UpdateChecksum(FALSE); 173 UpdateChecksum(FALSE);
172 } 174 }
173 void CXFA_SAXReaderHandler::OnTargetData(void* pTag, 175
176 void CXFA_SAXReaderHandler::OnTargetData(CXFA_SAXContext* pTag,
174 CFX_SAXItem::Type eType, 177 CFX_SAXItem::Type eType,
175 const CFX_ByteStringC& bsData, 178 const CFX_ByteStringC& bsData,
176 uint32_t dwStartPos) { 179 uint32_t dwStartPos) {
177 if (pTag == NULL && eType != CFX_SAXItem::Type::Comment) { 180 if (!pTag && eType != CFX_SAXItem::Type::Comment)
178 return; 181 return;
179 } 182
180 if (eType == CFX_SAXItem::Type::Comment) { 183 if (eType == CFX_SAXItem::Type::Comment) {
181 CFX_ByteTextBuf& textBuf = m_SAXContext.m_TextBuf; 184 m_SAXContext.m_TextBuf << "<!--" << bsData << "-->";
182 textBuf << "<!--" << bsData << "-->";
183 UpdateChecksum(FALSE); 185 UpdateChecksum(FALSE);
184 } else { 186 } else {
185 CFX_ByteTextBuf& textBuf = ((CXFA_SAXContext*)pTag)->m_TextBuf; 187 pTag->m_TextBuf << " " << bsData;
186 textBuf << " " << bsData;
187 } 188 }
188 } 189 }
190
189 void CXFA_SAXReaderHandler::UpdateChecksum(FX_BOOL bCheckSpace) { 191 void CXFA_SAXReaderHandler::UpdateChecksum(FX_BOOL bCheckSpace) {
190 int32_t iLength = m_SAXContext.m_TextBuf.GetLength(); 192 int32_t iLength = m_SAXContext.m_TextBuf.GetLength();
191 if (iLength < 1) { 193 if (iLength < 1) {
192 return; 194 return;
193 } 195 }
194 uint8_t* pBuffer = m_SAXContext.m_TextBuf.GetBuffer(); 196 uint8_t* pBuffer = m_SAXContext.m_TextBuf.GetBuffer();
195 FX_BOOL bUpdata = TRUE; 197 FX_BOOL bUpdata = TRUE;
196 if (bCheckSpace) { 198 if (bCheckSpace) {
197 bUpdata = FALSE; 199 bUpdata = FALSE;
198 for (int32_t i = 0; i < iLength; i++) { 200 for (int32_t i = 0; i < iLength; i++) {
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 263
262 CFX_ByteString CXFA_ChecksumContext::GetChecksum() const { 264 CFX_ByteString CXFA_ChecksumContext::GetChecksum() const {
263 return m_bsChecksum; 265 return m_bsChecksum;
264 } 266 }
265 267
266 void CXFA_ChecksumContext::Update(const CFX_ByteStringC& bsText) { 268 void CXFA_ChecksumContext::Update(const CFX_ByteStringC& bsText) {
267 if (m_pByteContext) { 269 if (m_pByteContext) {
268 CRYPT_SHA1Update(m_pByteContext, bsText.raw_str(), bsText.GetLength()); 270 CRYPT_SHA1Update(m_pByteContext, bsText.raw_str(), bsText.GetLength());
269 } 271 }
270 } 272 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698