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

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

Issue 739433003: Remove CDATASection (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: rebase Created 5 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/xml/parser/XMLDocumentParser.h ('k') | Source/web/AssertMatchingEnums.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 /* 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. (http://www.torchmo bile.com/) 8 * Copyright (C) 2008 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/)
9 * 9 *
10 * This library is free software; you can redistribute it and/or 10 * This library is free software; you can redistribute it and/or
(...skipping 16 matching lines...) Expand all
27 #include "core/xml/parser/XMLDocumentParser.h" 27 #include "core/xml/parser/XMLDocumentParser.h"
28 28
29 #include "bindings/core/v8/ExceptionState.h" 29 #include "bindings/core/v8/ExceptionState.h"
30 #include "bindings/core/v8/ExceptionStatePlaceholder.h" 30 #include "bindings/core/v8/ExceptionStatePlaceholder.h"
31 #include "bindings/core/v8/ScriptController.h" 31 #include "bindings/core/v8/ScriptController.h"
32 #include "bindings/core/v8/ScriptSourceCode.h" 32 #include "bindings/core/v8/ScriptSourceCode.h"
33 #include "bindings/core/v8/V8Document.h" 33 #include "bindings/core/v8/V8Document.h"
34 #include "core/FetchInitiatorTypeNames.h" 34 #include "core/FetchInitiatorTypeNames.h"
35 #include "core/HTMLNames.h" 35 #include "core/HTMLNames.h"
36 #include "core/XMLNSNames.h" 36 #include "core/XMLNSNames.h"
37 #include "core/dom/CDATASection.h"
38 #include "core/dom/Comment.h" 37 #include "core/dom/Comment.h"
39 #include "core/dom/Document.h" 38 #include "core/dom/Document.h"
40 #include "core/dom/DocumentFragment.h" 39 #include "core/dom/DocumentFragment.h"
41 #include "core/dom/DocumentType.h" 40 #include "core/dom/DocumentType.h"
42 #include "core/dom/ProcessingInstruction.h" 41 #include "core/dom/ProcessingInstruction.h"
43 #include "core/dom/ScriptLoader.h" 42 #include "core/dom/ScriptLoader.h"
43 #include "core/dom/Text.h"
44 #include "core/dom/TransformSource.h" 44 #include "core/dom/TransformSource.h"
45 #include "core/fetch/ResourceFetcher.h" 45 #include "core/fetch/ResourceFetcher.h"
46 #include "core/fetch/ScriptResource.h" 46 #include "core/fetch/ScriptResource.h"
47 #include "core/frame/LocalFrame.h" 47 #include "core/frame/LocalFrame.h"
48 #include "core/frame/UseCounter.h" 48 #include "core/frame/UseCounter.h"
49 #include "core/html/HTMLHtmlElement.h" 49 #include "core/html/HTMLHtmlElement.h"
50 #include "core/html/HTMLTemplateElement.h" 50 #include "core/html/HTMLTemplateElement.h"
51 #include "core/html/parser/HTMLEntityParser.h" 51 #include "core/html/parser/HTMLEntityParser.h"
52 #include "core/html/parser/TextResourceDecoder.h" 52 #include "core/html/parser/TextResourceDecoder.h"
53 #include "core/loader/FrameLoader.h" 53 #include "core/loader/FrameLoader.h"
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 virtual void call(XMLDocumentParser* parser) override 215 virtual void call(XMLDocumentParser* parser) override
216 { 216 {
217 parser->processingInstruction(m_target, m_data); 217 parser->processingInstruction(m_target, m_data);
218 } 218 }
219 219
220 private: 220 private:
221 String m_target; 221 String m_target;
222 String m_data; 222 String m_data;
223 }; 223 };
224 224
225 class PendingCDATABlockCallback final : public XMLDocumentParser::PendingCallbac k {
226 public:
227 explicit PendingCDATABlockCallback(const String& text) : m_text(text) { }
228
229 virtual void call(XMLDocumentParser* parser) override
230 {
231 parser->cdataBlock(m_text);
232 }
233
234 private:
235 String m_text;
236 };
237
238 class PendingCommentCallback final : public XMLDocumentParser::PendingCallback { 225 class PendingCommentCallback final : public XMLDocumentParser::PendingCallback {
239 public: 226 public:
240 explicit PendingCommentCallback(const String& text) : m_text(text) { } 227 explicit PendingCommentCallback(const String& text) : m_text(text) { }
241 228
242 virtual void call(XMLDocumentParser* parser) override 229 virtual void call(XMLDocumentParser* parser) override
243 { 230 {
244 parser->comment(m_text); 231 parser->comment(m_text);
245 } 232 }
246 233
247 private: 234 private:
(...skipping 921 matching lines...) Expand 10 before | Expand all | Expand 10 after
1169 // This behavior is very tricky. We call stopParsing() here because we 1156 // This behavior is very tricky. We call stopParsing() here because we
1170 // want to stop processing the document until we're ready to apply the 1157 // want to stop processing the document until we're ready to apply the
1171 // transform, but we actually still want to be fed decoded string pieces 1158 // transform, but we actually still want to be fed decoded string pieces
1172 // to accumulate in m_originalSourceForTransform. So, we call 1159 // to accumulate in m_originalSourceForTransform. So, we call
1173 // stopParsing() here and check isStopped() in element callbacks. 1160 // stopParsing() here and check isStopped() in element callbacks.
1174 // FIXME: This contradicts the contract of DocumentParser. 1161 // FIXME: This contradicts the contract of DocumentParser.
1175 stopParsing(); 1162 stopParsing();
1176 } 1163 }
1177 } 1164 }
1178 1165
1179 void XMLDocumentParser::cdataBlock(const String& text)
1180 {
1181 if (isStopped())
1182 return;
1183
1184 if (m_parserPaused) {
1185 m_pendingCallbacks.append(adoptPtr(new PendingCDATABlockCallback(text))) ;
1186 return;
1187 }
1188
1189 exitText();
1190
1191 m_currentNode->parserAppendChild(CDATASection::create(m_currentNode->documen t(), text));
1192 }
1193
1194 void XMLDocumentParser::comment(const String& text) 1166 void XMLDocumentParser::comment(const String& text)
1195 { 1167 {
1196 if (isStopped()) 1168 if (isStopped())
1197 return; 1169 return;
1198 1170
1199 if (m_parserPaused) { 1171 if (m_parserPaused) {
1200 m_pendingCallbacks.append(adoptPtr(new PendingCommentCallback(text))); 1172 m_pendingCallbacks.append(adoptPtr(new PendingCommentCallback(text)));
1201 return; 1173 return;
1202 } 1174 }
1203 1175
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
1268 static void charactersHandler(void* closure, const xmlChar* chars, int length) 1240 static void charactersHandler(void* closure, const xmlChar* chars, int length)
1269 { 1241 {
1270 getParser(closure)->characters(chars, length); 1242 getParser(closure)->characters(chars, length);
1271 } 1243 }
1272 1244
1273 static void processingInstructionHandler(void* closure, const xmlChar* target, c onst xmlChar* data) 1245 static void processingInstructionHandler(void* closure, const xmlChar* target, c onst xmlChar* data)
1274 { 1246 {
1275 getParser(closure)->processingInstruction(toString(target), toString(data)); 1247 getParser(closure)->processingInstruction(toString(target), toString(data));
1276 } 1248 }
1277 1249
1278 static void cdataBlockHandler(void* closure, const xmlChar* text, int length)
1279 {
1280 getParser(closure)->cdataBlock(toString(text, length));
1281 }
1282
1283 static void commentHandler(void* closure, const xmlChar* text) 1250 static void commentHandler(void* closure, const xmlChar* text)
1284 { 1251 {
1285 getParser(closure)->comment(toString(text)); 1252 getParser(closure)->comment(toString(text));
1286 } 1253 }
1287 1254
1288 WTF_ATTRIBUTE_PRINTF(2, 3) 1255 WTF_ATTRIBUTE_PRINTF(2, 3)
1289 static void warningHandler(void* closure, const char* message, ...) 1256 static void warningHandler(void* closure, const char* message, ...)
1290 { 1257 {
1291 va_list args; 1258 va_list args;
1292 va_start(args, message); 1259 va_start(args, message);
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
1424 memset(&sax, 0, sizeof(sax)); 1391 memset(&sax, 0, sizeof(sax));
1425 1392
1426 // According to http://xmlsoft.org/html/libxml-tree.html#xmlSAXHandler and 1393 // According to http://xmlsoft.org/html/libxml-tree.html#xmlSAXHandler and
1427 // http://xmlsoft.org/html/libxml-parser.html#fatalErrorSAXFunc the SAX 1394 // http://xmlsoft.org/html/libxml-parser.html#fatalErrorSAXFunc the SAX
1428 // fatalError callback is unused; error gets all the errors. Use normalError Handler 1395 // fatalError callback is unused; error gets all the errors. Use normalError Handler
1429 // for both the error and fatalError callbacks. 1396 // for both the error and fatalError callbacks.
1430 sax.error = normalErrorHandler; 1397 sax.error = normalErrorHandler;
1431 sax.fatalError = normalErrorHandler; 1398 sax.fatalError = normalErrorHandler;
1432 sax.characters = charactersHandler; 1399 sax.characters = charactersHandler;
1433 sax.processingInstruction = processingInstructionHandler; 1400 sax.processingInstruction = processingInstructionHandler;
1434 sax.cdataBlock = cdataBlockHandler; 1401 sax.cdataBlock = charactersHandler;
1435 sax.comment = commentHandler; 1402 sax.comment = commentHandler;
1436 sax.warning = warningHandler; 1403 sax.warning = warningHandler;
1437 sax.startElementNs = startElementNsHandler; 1404 sax.startElementNs = startElementNsHandler;
1438 sax.endElementNs = endElementNsHandler; 1405 sax.endElementNs = endElementNsHandler;
1439 sax.getEntity = getEntityHandler; 1406 sax.getEntity = getEntityHandler;
1440 sax.startDocument = startDocumentHandler; 1407 sax.startDocument = startDocumentHandler;
1441 sax.endDocument = endDocumentHandler; 1408 sax.endDocument = endDocumentHandler;
1442 sax.internalSubset = internalSubsetHandler; 1409 sax.internalSubset = internalSubsetHandler;
1443 sax.externalSubset = externalSubsetHandler; 1410 sax.externalSubset = externalSubsetHandler;
1444 sax.ignorableWhitespace = ignorableWhitespaceHandler; 1411 sax.ignorableWhitespace = ignorableWhitespaceHandler;
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
1639 sax.initialized = XML_SAX2_MAGIC; 1606 sax.initialized = XML_SAX2_MAGIC;
1640 RefPtr<XMLParserContext> parser = XMLParserContext::createStringParser(&sax, &state); 1607 RefPtr<XMLParserContext> parser = XMLParserContext::createStringParser(&sax, &state);
1641 String parseString = "<?xml version=\"1.0\"?><attrs " + string + " />"; 1608 String parseString = "<?xml version=\"1.0\"?><attrs " + string + " />";
1642 parseChunk(parser->context(), parseString); 1609 parseChunk(parser->context(), parseString);
1643 finishParsing(parser->context()); 1610 finishParsing(parser->context());
1644 attrsOK = state.gotAttributes; 1611 attrsOK = state.gotAttributes;
1645 return state.attributes; 1612 return state.attributes;
1646 } 1613 }
1647 1614
1648 } // namespace blink 1615 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/xml/parser/XMLDocumentParser.h ('k') | Source/web/AssertMatchingEnums.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698