OLD | NEW |
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 964 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
975 int nbNamespaces, | 975 int nbNamespaces, |
976 const xmlChar** libxmlNamespaces, | 976 const xmlChar** libxmlNamespaces, |
977 int nbAttributes, | 977 int nbAttributes, |
978 int nbDefaulted, | 978 int nbDefaulted, |
979 const xmlChar** libxmlAttributes) { | 979 const xmlChar** libxmlAttributes) { |
980 if (isStopped()) | 980 if (isStopped()) |
981 return; | 981 return; |
982 | 982 |
983 if (m_parserPaused) { | 983 if (m_parserPaused) { |
984 m_scriptStartPosition = textPosition(); | 984 m_scriptStartPosition = textPosition(); |
985 m_pendingCallbacks.append(wrapUnique(new PendingStartElementNSCallback( | 985 m_pendingCallbacks.append(WTF::wrapUnique(new PendingStartElementNSCallback( |
986 localName, prefix, uri, nbNamespaces, libxmlNamespaces, nbAttributes, | 986 localName, prefix, uri, nbNamespaces, libxmlNamespaces, nbAttributes, |
987 nbDefaulted, libxmlAttributes))); | 987 nbDefaulted, libxmlAttributes))); |
988 return; | 988 return; |
989 } | 989 } |
990 | 990 |
991 if (!updateLeafTextNode()) | 991 if (!updateLeafTextNode()) |
992 return; | 992 return; |
993 | 993 |
994 AtomicString adjustedURI = uri; | 994 AtomicString adjustedURI = uri; |
995 if (m_parsingFragment && adjustedURI.isNull()) { | 995 if (m_parsingFragment && adjustedURI.isNull()) { |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1058 // runScriptsAtDocumentElementAvailable might have invalidated the document. | 1058 // runScriptsAtDocumentElementAvailable might have invalidated the document. |
1059 } | 1059 } |
1060 } | 1060 } |
1061 | 1061 |
1062 void XMLDocumentParser::endElementNs() { | 1062 void XMLDocumentParser::endElementNs() { |
1063 if (isStopped()) | 1063 if (isStopped()) |
1064 return; | 1064 return; |
1065 | 1065 |
1066 if (m_parserPaused) { | 1066 if (m_parserPaused) { |
1067 m_pendingCallbacks.append( | 1067 m_pendingCallbacks.append( |
1068 makeUnique<PendingEndElementNSCallback>(m_scriptStartPosition)); | 1068 WTF::makeUnique<PendingEndElementNSCallback>(m_scriptStartPosition)); |
1069 return; | 1069 return; |
1070 } | 1070 } |
1071 | 1071 |
1072 if (!updateLeafTextNode()) | 1072 if (!updateLeafTextNode()) |
1073 return; | 1073 return; |
1074 | 1074 |
1075 ContainerNode* n = m_currentNode; | 1075 ContainerNode* n = m_currentNode; |
1076 if (m_currentNode->isElementNode()) | 1076 if (m_currentNode->isElementNode()) |
1077 toElement(n)->finishParsingChildren(); | 1077 toElement(n)->finishParsingChildren(); |
1078 | 1078 |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1146 void XMLDocumentParser::setScriptStartPosition(TextPosition textPosition) { | 1146 void XMLDocumentParser::setScriptStartPosition(TextPosition textPosition) { |
1147 m_scriptStartPosition = textPosition; | 1147 m_scriptStartPosition = textPosition; |
1148 } | 1148 } |
1149 | 1149 |
1150 void XMLDocumentParser::characters(const xmlChar* chars, int length) { | 1150 void XMLDocumentParser::characters(const xmlChar* chars, int length) { |
1151 if (isStopped()) | 1151 if (isStopped()) |
1152 return; | 1152 return; |
1153 | 1153 |
1154 if (m_parserPaused) { | 1154 if (m_parserPaused) { |
1155 m_pendingCallbacks.append( | 1155 m_pendingCallbacks.append( |
1156 makeUnique<PendingCharactersCallback>(chars, length)); | 1156 WTF::makeUnique<PendingCharactersCallback>(chars, length)); |
1157 return; | 1157 return; |
1158 } | 1158 } |
1159 | 1159 |
1160 createLeafTextNodeIfNeeded(); | 1160 createLeafTextNodeIfNeeded(); |
1161 m_bufferedText.append(chars, length); | 1161 m_bufferedText.append(chars, length); |
1162 } | 1162 } |
1163 | 1163 |
1164 void XMLDocumentParser::error(XMLErrors::ErrorType type, | 1164 void XMLDocumentParser::error(XMLErrors::ErrorType type, |
1165 const char* message, | 1165 const char* message, |
1166 va_list args) { | 1166 va_list args) { |
1167 if (isStopped()) | 1167 if (isStopped()) |
1168 return; | 1168 return; |
1169 | 1169 |
1170 char formattedMessage[1024]; | 1170 char formattedMessage[1024]; |
1171 vsnprintf(formattedMessage, sizeof(formattedMessage) - 1, message, args); | 1171 vsnprintf(formattedMessage, sizeof(formattedMessage) - 1, message, args); |
1172 | 1172 |
1173 if (m_parserPaused) { | 1173 if (m_parserPaused) { |
1174 m_pendingCallbacks.append(wrapUnique(new PendingErrorCallback( | 1174 m_pendingCallbacks.append(WTF::wrapUnique(new PendingErrorCallback( |
1175 type, reinterpret_cast<const xmlChar*>(formattedMessage), lineNumber(), | 1175 type, reinterpret_cast<const xmlChar*>(formattedMessage), lineNumber(), |
1176 columnNumber()))); | 1176 columnNumber()))); |
1177 return; | 1177 return; |
1178 } | 1178 } |
1179 | 1179 |
1180 handleError(type, formattedMessage, textPosition()); | 1180 handleError(type, formattedMessage, textPosition()); |
1181 } | 1181 } |
1182 | 1182 |
1183 void XMLDocumentParser::processingInstruction(const String& target, | 1183 void XMLDocumentParser::processingInstruction(const String& target, |
1184 const String& data) { | 1184 const String& data) { |
1185 if (isStopped()) | 1185 if (isStopped()) |
1186 return; | 1186 return; |
1187 | 1187 |
1188 if (m_parserPaused) { | 1188 if (m_parserPaused) { |
1189 m_pendingCallbacks.append( | 1189 m_pendingCallbacks.append( |
1190 makeUnique<PendingProcessingInstructionCallback>(target, data)); | 1190 WTF::makeUnique<PendingProcessingInstructionCallback>(target, data)); |
1191 return; | 1191 return; |
1192 } | 1192 } |
1193 | 1193 |
1194 if (!updateLeafTextNode()) | 1194 if (!updateLeafTextNode()) |
1195 return; | 1195 return; |
1196 | 1196 |
1197 // ### handle exceptions | 1197 // ### handle exceptions |
1198 DummyExceptionStateForTesting exceptionState; | 1198 DummyExceptionStateForTesting exceptionState; |
1199 ProcessingInstruction* pi = | 1199 ProcessingInstruction* pi = |
1200 m_currentNode->document().createProcessingInstruction(target, data, | 1200 m_currentNode->document().createProcessingInstruction(target, data, |
(...skipping 20 matching lines...) Expand all Loading... |
1221 // FIXME: This contradicts the contract of DocumentParser. | 1221 // FIXME: This contradicts the contract of DocumentParser. |
1222 stopParsing(); | 1222 stopParsing(); |
1223 } | 1223 } |
1224 } | 1224 } |
1225 | 1225 |
1226 void XMLDocumentParser::cdataBlock(const String& text) { | 1226 void XMLDocumentParser::cdataBlock(const String& text) { |
1227 if (isStopped()) | 1227 if (isStopped()) |
1228 return; | 1228 return; |
1229 | 1229 |
1230 if (m_parserPaused) { | 1230 if (m_parserPaused) { |
1231 m_pendingCallbacks.append(makeUnique<PendingCDATABlockCallback>(text)); | 1231 m_pendingCallbacks.append(WTF::makeUnique<PendingCDATABlockCallback>(text)); |
1232 return; | 1232 return; |
1233 } | 1233 } |
1234 | 1234 |
1235 if (!updateLeafTextNode()) | 1235 if (!updateLeafTextNode()) |
1236 return; | 1236 return; |
1237 | 1237 |
1238 m_currentNode->parserAppendChild( | 1238 m_currentNode->parserAppendChild( |
1239 CDATASection::create(m_currentNode->document(), text)); | 1239 CDATASection::create(m_currentNode->document(), text)); |
1240 } | 1240 } |
1241 | 1241 |
1242 void XMLDocumentParser::comment(const String& text) { | 1242 void XMLDocumentParser::comment(const String& text) { |
1243 if (isStopped()) | 1243 if (isStopped()) |
1244 return; | 1244 return; |
1245 | 1245 |
1246 if (m_parserPaused) { | 1246 if (m_parserPaused) { |
1247 m_pendingCallbacks.append(makeUnique<PendingCommentCallback>(text)); | 1247 m_pendingCallbacks.append(WTF::makeUnique<PendingCommentCallback>(text)); |
1248 return; | 1248 return; |
1249 } | 1249 } |
1250 | 1250 |
1251 if (!updateLeafTextNode()) | 1251 if (!updateLeafTextNode()) |
1252 return; | 1252 return; |
1253 | 1253 |
1254 m_currentNode->parserAppendChild( | 1254 m_currentNode->parserAppendChild( |
1255 Comment::create(m_currentNode->document(), text)); | 1255 Comment::create(m_currentNode->document(), text)); |
1256 } | 1256 } |
1257 | 1257 |
(...skipping 27 matching lines...) Expand all Loading... |
1285 updateLeafTextNode(); | 1285 updateLeafTextNode(); |
1286 } | 1286 } |
1287 | 1287 |
1288 void XMLDocumentParser::internalSubset(const String& name, | 1288 void XMLDocumentParser::internalSubset(const String& name, |
1289 const String& externalID, | 1289 const String& externalID, |
1290 const String& systemID) { | 1290 const String& systemID) { |
1291 if (isStopped()) | 1291 if (isStopped()) |
1292 return; | 1292 return; |
1293 | 1293 |
1294 if (m_parserPaused) { | 1294 if (m_parserPaused) { |
1295 m_pendingCallbacks.append(wrapUnique( | 1295 m_pendingCallbacks.append(WTF::wrapUnique( |
1296 new PendingInternalSubsetCallback(name, externalID, systemID))); | 1296 new PendingInternalSubsetCallback(name, externalID, systemID))); |
1297 return; | 1297 return; |
1298 } | 1298 } |
1299 | 1299 |
1300 if (document()) | 1300 if (document()) |
1301 document()->parserAppendChild( | 1301 document()->parserAppendChild( |
1302 DocumentType::create(document(), name, externalID, systemID)); | 1302 DocumentType::create(document(), name, externalID, systemID)); |
1303 } | 1303 } |
1304 | 1304 |
1305 static inline XMLDocumentParser* getParser(void* closure) { | 1305 static inline XMLDocumentParser* getParser(void* closure) { |
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1543 const char noStyleMessage[] = | 1543 const char noStyleMessage[] = |
1544 "This XML file does not appear to have any style information " | 1544 "This XML file does not appear to have any style information " |
1545 "associated with it. The document tree is shown below."; | 1545 "associated with it. The document tree is shown below."; |
1546 document()->setIsViewSource(true); | 1546 document()->setIsViewSource(true); |
1547 V8Document::PrivateScript::transformDocumentToTreeViewMethod( | 1547 V8Document::PrivateScript::transformDocumentToTreeViewMethod( |
1548 document()->frame(), document(), noStyleMessage); | 1548 document()->frame(), document(), noStyleMessage); |
1549 } else if (m_sawXSLTransform) { | 1549 } else if (m_sawXSLTransform) { |
1550 xmlDocPtr doc = | 1550 xmlDocPtr doc = |
1551 xmlDocPtrForString(document(), m_originalSourceForTransform.toString(), | 1551 xmlDocPtrForString(document(), m_originalSourceForTransform.toString(), |
1552 document()->url().getString()); | 1552 document()->url().getString()); |
1553 document()->setTransformSource(makeUnique<TransformSource>(doc)); | 1553 document()->setTransformSource(WTF::makeUnique<TransformSource>(doc)); |
1554 DocumentParser::stopParsing(); | 1554 DocumentParser::stopParsing(); |
1555 } | 1555 } |
1556 } | 1556 } |
1557 | 1557 |
1558 xmlDocPtr xmlDocPtrForString(Document* document, | 1558 xmlDocPtr xmlDocPtrForString(Document* document, |
1559 const String& source, | 1559 const String& source, |
1560 const String& url) { | 1560 const String& url) { |
1561 if (source.isEmpty()) | 1561 if (source.isEmpty()) |
1562 return 0; | 1562 return 0; |
1563 // Parse in a single chunk into an xmlDocPtr | 1563 // Parse in a single chunk into an xmlDocPtr |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1707 RefPtr<XMLParserContext> parser = | 1707 RefPtr<XMLParserContext> parser = |
1708 XMLParserContext::createStringParser(&sax, &state); | 1708 XMLParserContext::createStringParser(&sax, &state); |
1709 String parseString = "<?xml version=\"1.0\"?><attrs " + string + " />"; | 1709 String parseString = "<?xml version=\"1.0\"?><attrs " + string + " />"; |
1710 parseChunk(parser->context(), parseString); | 1710 parseChunk(parser->context(), parseString); |
1711 finishParsing(parser->context()); | 1711 finishParsing(parser->context()); |
1712 attrsOK = state.gotAttributes; | 1712 attrsOK = state.gotAttributes; |
1713 return state.attributes; | 1713 return state.attributes; |
1714 } | 1714 } |
1715 | 1715 |
1716 } // namespace blink | 1716 } // namespace blink |
OLD | NEW |