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

Side by Side Diff: third_party/WebKit/Source/core/xml/parser/XMLDocumentParser.cpp

Issue 2743023002: Migrate WTF::Deque::append() to ::push_back() (Closed)
Patch Set: rebase Created 3 years, 9 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 /* 1 /*
2 * Copyright (C) 2000 Peter Kelly (pmk@post.com) 2 * Copyright (C) 2000 Peter Kelly (pmk@post.com)
3 * Copyright (C) 2005, 2006, 2008, 2014 Apple Inc. All rights reserved. 3 * Copyright (C) 2005, 2006, 2008, 2014 Apple Inc. All rights reserved.
4 * Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org) 4 * Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org)
5 * Copyright (C) 2007 Samuel Weinig (sam@webkit.org) 5 * Copyright (C) 2007 Samuel Weinig (sam@webkit.org)
6 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) 6 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
7 * Copyright (C) 2008 Holger Hans Peter Freyther 7 * Copyright (C) 2008 Holger Hans Peter Freyther
8 * Copyright (C) 2008 Torch Mobile Inc. All rights reserved. 8 * Copyright (C) 2008 Torch Mobile Inc. All rights reserved.
9 * (http://www.torchmobile.com/) 9 * (http://www.torchmobile.com/)
10 * 10 *
(...skipping 963 matching lines...) Expand 10 before | Expand all | Expand 10 after
974 int nbNamespaces, 974 int nbNamespaces,
975 const xmlChar** libxmlNamespaces, 975 const xmlChar** libxmlNamespaces,
976 int nbAttributes, 976 int nbAttributes,
977 int nbDefaulted, 977 int nbDefaulted,
978 const xmlChar** libxmlAttributes) { 978 const xmlChar** libxmlAttributes) {
979 if (isStopped()) 979 if (isStopped())
980 return; 980 return;
981 981
982 if (m_parserPaused) { 982 if (m_parserPaused) {
983 m_scriptStartPosition = textPosition(); 983 m_scriptStartPosition = textPosition();
984 m_pendingCallbacks.append(WTF::wrapUnique(new PendingStartElementNSCallback( 984 m_pendingCallbacks.push_back(
985 localName, prefix, uri, nbNamespaces, libxmlNamespaces, nbAttributes, 985 WTF::wrapUnique(new PendingStartElementNSCallback(
986 nbDefaulted, libxmlAttributes))); 986 localName, prefix, uri, nbNamespaces, libxmlNamespaces,
987 nbAttributes, nbDefaulted, libxmlAttributes)));
987 return; 988 return;
988 } 989 }
989 990
990 if (!updateLeafTextNode()) 991 if (!updateLeafTextNode())
991 return; 992 return;
992 993
993 AtomicString adjustedURI = uri; 994 AtomicString adjustedURI = uri;
994 if (m_parsingFragment && adjustedURI.isNull()) { 995 if (m_parsingFragment && adjustedURI.isNull()) {
995 if (!prefix.isNull()) 996 if (!prefix.isNull())
996 adjustedURI = m_prefixToNamespaceMap.at(prefix); 997 adjustedURI = m_prefixToNamespaceMap.at(prefix);
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
1056 document()->frame()->loader().runScriptsAtDocumentElementAvailable(); 1057 document()->frame()->loader().runScriptsAtDocumentElementAvailable();
1057 // runScriptsAtDocumentElementAvailable might have invalidated the document. 1058 // runScriptsAtDocumentElementAvailable might have invalidated the document.
1058 } 1059 }
1059 } 1060 }
1060 1061
1061 void XMLDocumentParser::endElementNs() { 1062 void XMLDocumentParser::endElementNs() {
1062 if (isStopped()) 1063 if (isStopped())
1063 return; 1064 return;
1064 1065
1065 if (m_parserPaused) { 1066 if (m_parserPaused) {
1066 m_pendingCallbacks.append( 1067 m_pendingCallbacks.push_back(
1067 WTF::makeUnique<PendingEndElementNSCallback>(m_scriptStartPosition)); 1068 WTF::makeUnique<PendingEndElementNSCallback>(m_scriptStartPosition));
1068 return; 1069 return;
1069 } 1070 }
1070 1071
1071 if (!updateLeafTextNode()) 1072 if (!updateLeafTextNode())
1072 return; 1073 return;
1073 1074
1074 ContainerNode* n = m_currentNode; 1075 ContainerNode* n = m_currentNode;
1075 if (m_currentNode->isElementNode()) 1076 if (m_currentNode->isElementNode())
1076 toElement(n)->finishParsingChildren(); 1077 toElement(n)->finishParsingChildren();
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
1144 1145
1145 void XMLDocumentParser::setScriptStartPosition(TextPosition textPosition) { 1146 void XMLDocumentParser::setScriptStartPosition(TextPosition textPosition) {
1146 m_scriptStartPosition = textPosition; 1147 m_scriptStartPosition = textPosition;
1147 } 1148 }
1148 1149
1149 void XMLDocumentParser::characters(const xmlChar* chars, int length) { 1150 void XMLDocumentParser::characters(const xmlChar* chars, int length) {
1150 if (isStopped()) 1151 if (isStopped())
1151 return; 1152 return;
1152 1153
1153 if (m_parserPaused) { 1154 if (m_parserPaused) {
1154 m_pendingCallbacks.append( 1155 m_pendingCallbacks.push_back(
1155 WTF::makeUnique<PendingCharactersCallback>(chars, length)); 1156 WTF::makeUnique<PendingCharactersCallback>(chars, length));
1156 return; 1157 return;
1157 } 1158 }
1158 1159
1159 createLeafTextNodeIfNeeded(); 1160 createLeafTextNodeIfNeeded();
1160 m_bufferedText.append(chars, length); 1161 m_bufferedText.append(chars, length);
1161 } 1162 }
1162 1163
1163 void XMLDocumentParser::error(XMLErrors::ErrorType type, 1164 void XMLDocumentParser::error(XMLErrors::ErrorType type,
1164 const char* message, 1165 const char* message,
1165 va_list args) { 1166 va_list args) {
1166 if (isStopped()) 1167 if (isStopped())
1167 return; 1168 return;
1168 1169
1169 char formattedMessage[1024]; 1170 char formattedMessage[1024];
1170 vsnprintf(formattedMessage, sizeof(formattedMessage) - 1, message, args); 1171 vsnprintf(formattedMessage, sizeof(formattedMessage) - 1, message, args);
1171 1172
1172 if (m_parserPaused) { 1173 if (m_parserPaused) {
1173 m_pendingCallbacks.append(WTF::wrapUnique(new PendingErrorCallback( 1174 m_pendingCallbacks.push_back(WTF::wrapUnique(new PendingErrorCallback(
1174 type, reinterpret_cast<const xmlChar*>(formattedMessage), lineNumber(), 1175 type, reinterpret_cast<const xmlChar*>(formattedMessage), lineNumber(),
1175 columnNumber()))); 1176 columnNumber())));
1176 return; 1177 return;
1177 } 1178 }
1178 1179
1179 handleError(type, formattedMessage, textPosition()); 1180 handleError(type, formattedMessage, textPosition());
1180 } 1181 }
1181 1182
1182 void XMLDocumentParser::processingInstruction(const String& target, 1183 void XMLDocumentParser::processingInstruction(const String& target,
1183 const String& data) { 1184 const String& data) {
1184 if (isStopped()) 1185 if (isStopped())
1185 return; 1186 return;
1186 1187
1187 if (m_parserPaused) { 1188 if (m_parserPaused) {
1188 m_pendingCallbacks.append( 1189 m_pendingCallbacks.push_back(
1189 WTF::makeUnique<PendingProcessingInstructionCallback>(target, data)); 1190 WTF::makeUnique<PendingProcessingInstructionCallback>(target, data));
1190 return; 1191 return;
1191 } 1192 }
1192 1193
1193 if (!updateLeafTextNode()) 1194 if (!updateLeafTextNode())
1194 return; 1195 return;
1195 1196
1196 // ### handle exceptions 1197 // ### handle exceptions
1197 DummyExceptionStateForTesting exceptionState; 1198 DummyExceptionStateForTesting exceptionState;
1198 ProcessingInstruction* pi = 1199 ProcessingInstruction* pi =
(...skipping 21 matching lines...) Expand all
1220 // FIXME: This contradicts the contract of DocumentParser. 1221 // FIXME: This contradicts the contract of DocumentParser.
1221 stopParsing(); 1222 stopParsing();
1222 } 1223 }
1223 } 1224 }
1224 1225
1225 void XMLDocumentParser::cdataBlock(const String& text) { 1226 void XMLDocumentParser::cdataBlock(const String& text) {
1226 if (isStopped()) 1227 if (isStopped())
1227 return; 1228 return;
1228 1229
1229 if (m_parserPaused) { 1230 if (m_parserPaused) {
1230 m_pendingCallbacks.append(WTF::makeUnique<PendingCDATABlockCallback>(text)); 1231 m_pendingCallbacks.push_back(
1232 WTF::makeUnique<PendingCDATABlockCallback>(text));
1231 return; 1233 return;
1232 } 1234 }
1233 1235
1234 if (!updateLeafTextNode()) 1236 if (!updateLeafTextNode())
1235 return; 1237 return;
1236 1238
1237 m_currentNode->parserAppendChild( 1239 m_currentNode->parserAppendChild(
1238 CDATASection::create(m_currentNode->document(), text)); 1240 CDATASection::create(m_currentNode->document(), text));
1239 } 1241 }
1240 1242
1241 void XMLDocumentParser::comment(const String& text) { 1243 void XMLDocumentParser::comment(const String& text) {
1242 if (isStopped()) 1244 if (isStopped())
1243 return; 1245 return;
1244 1246
1245 if (m_parserPaused) { 1247 if (m_parserPaused) {
1246 m_pendingCallbacks.append(WTF::makeUnique<PendingCommentCallback>(text)); 1248 m_pendingCallbacks.push_back(WTF::makeUnique<PendingCommentCallback>(text));
1247 return; 1249 return;
1248 } 1250 }
1249 1251
1250 if (!updateLeafTextNode()) 1252 if (!updateLeafTextNode())
1251 return; 1253 return;
1252 1254
1253 m_currentNode->parserAppendChild( 1255 m_currentNode->parserAppendChild(
1254 Comment::create(m_currentNode->document(), text)); 1256 Comment::create(m_currentNode->document(), text));
1255 } 1257 }
1256 1258
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
1291 updateLeafTextNode(); 1293 updateLeafTextNode();
1292 } 1294 }
1293 1295
1294 void XMLDocumentParser::internalSubset(const String& name, 1296 void XMLDocumentParser::internalSubset(const String& name,
1295 const String& externalID, 1297 const String& externalID,
1296 const String& systemID) { 1298 const String& systemID) {
1297 if (isStopped()) 1299 if (isStopped())
1298 return; 1300 return;
1299 1301
1300 if (m_parserPaused) { 1302 if (m_parserPaused) {
1301 m_pendingCallbacks.append(WTF::wrapUnique( 1303 m_pendingCallbacks.push_back(WTF::wrapUnique(
1302 new PendingInternalSubsetCallback(name, externalID, systemID))); 1304 new PendingInternalSubsetCallback(name, externalID, systemID)));
1303 return; 1305 return;
1304 } 1306 }
1305 1307
1306 if (document()) 1308 if (document())
1307 document()->parserAppendChild( 1309 document()->parserAppendChild(
1308 DocumentType::create(document(), name, externalID, systemID)); 1310 DocumentType::create(document(), name, externalID, systemID));
1309 } 1311 }
1310 1312
1311 static inline XMLDocumentParser* getParser(void* closure) { 1313 static inline XMLDocumentParser* getParser(void* closure) {
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after
1709 RefPtr<XMLParserContext> parser = 1711 RefPtr<XMLParserContext> parser =
1710 XMLParserContext::createStringParser(&sax, &state); 1712 XMLParserContext::createStringParser(&sax, &state);
1711 String parseString = "<?xml version=\"1.0\"?><attrs " + string + " />"; 1713 String parseString = "<?xml version=\"1.0\"?><attrs " + string + " />";
1712 parseChunk(parser->context(), parseString); 1714 parseChunk(parser->context(), parseString);
1713 finishParsing(parser->context()); 1715 finishParsing(parser->context());
1714 attrsOK = state.gotAttributes; 1716 attrsOK = state.gotAttributes;
1715 return state.attributes; 1717 return state.attributes;
1716 } 1718 }
1717 1719
1718 } // namespace blink 1720 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698