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

Side by Side Diff: WebCore/dom/XMLDocumentParserLibxml2.cpp

Issue 3776004: Revert 66670 - 2010-09-01 Tony Gentilcore <tonyg@chromium.org>... (Closed) Base URL: http://svn.webkit.org/repository/webkit/branches/chromium/517/
Patch Set: Created 10 years, 2 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 | « WebCore/dom/XMLDocumentParser.cpp ('k') | WebCore/dom/XMLDocumentParserQt.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 Apple Inc. All rights reserved. 3 * Copyright (C) 2005, 2006, 2008 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, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/) 8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.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 642 matching lines...) Expand 10 before | Expand all | Expand 10 after
653 // JavaScript may cause the parser to detach during xmlParseChunk 653 // JavaScript may cause the parser to detach during xmlParseChunk
654 // keep this alive until this function is done. 654 // keep this alive until this function is done.
655 RefPtr<XMLDocumentParser> protect(this); 655 RefPtr<XMLDocumentParser> protect(this);
656 656
657 switchToUTF16(context->context()); 657 switchToUTF16(context->context());
658 XMLDocumentParserScope scope(document()->docLoader()); 658 XMLDocumentParserScope scope(document()->docLoader());
659 xmlParseChunk(context->context(), reinterpret_cast<const char*>(parseStr ing.characters()), sizeof(UChar) * parseString.length(), 0); 659 xmlParseChunk(context->context(), reinterpret_cast<const char*>(parseStr ing.characters()), sizeof(UChar) * parseString.length(), 0);
660 660
661 // JavaScript (which may be run under the xmlParseChunk callstack) may 661 // JavaScript (which may be run under the xmlParseChunk callstack) may
662 // cause the parser to be stopped or detached. 662 // cause the parser to be stopped or detached.
663 if (isStopped()) 663 if (isDetached() || m_parserStopped)
664 return; 664 return;
665 } 665 }
666 666
667 // FIXME: Why is this here? And why is it after we process the passed sourc e? 667 // FIXME: Why is this here? And why is it after we process the passed sourc e?
668 if (document()->decoder() && document()->decoder()->sawError()) { 668 if (document()->decoder() && document()->decoder()->sawError()) {
669 // If the decoder saw an error, report it as fatal (stops parsing) 669 // If the decoder saw an error, report it as fatal (stops parsing)
670 handleError(fatal, "Encoding error", context->context()->input->line, co ntext->context()->input->col); 670 handleError(fatal, "Encoding error", context->context()->input->line, co ntext->context()->input->col);
671 } 671 }
672 } 672 }
673 673
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
726 726
727 newElement->setAttributeNS(attrURI, attrQName, attrValue, ec, scriptingP ermission); 727 newElement->setAttributeNS(attrURI, attrQName, attrValue, ec, scriptingP ermission);
728 if (ec) // exception setting attributes 728 if (ec) // exception setting attributes
729 return; 729 return;
730 } 730 }
731 } 731 }
732 732
733 void XMLDocumentParser::startElementNs(const xmlChar* xmlLocalName, const xmlCha r* xmlPrefix, const xmlChar* xmlURI, int nb_namespaces, 733 void XMLDocumentParser::startElementNs(const xmlChar* xmlLocalName, const xmlCha r* xmlPrefix, const xmlChar* xmlURI, int nb_namespaces,
734 const xmlChar** libxmlNamespaces, int nb_attri butes, int nb_defaulted, const xmlChar** libxmlAttributes) 734 const xmlChar** libxmlNamespaces, int nb_attri butes, int nb_defaulted, const xmlChar** libxmlAttributes)
735 { 735 {
736 if (isStopped()) 736 if (m_parserStopped)
737 return; 737 return;
738 738
739 if (m_parserPaused) { 739 if (m_parserPaused) {
740 m_pendingCallbacks->appendStartElementNSCallback(xmlLocalName, xmlPrefix , xmlURI, nb_namespaces, libxmlNamespaces, 740 m_pendingCallbacks->appendStartElementNSCallback(xmlLocalName, xmlPrefix , xmlURI, nb_namespaces, libxmlNamespaces,
741 nb_attributes, nb_defau lted, libxmlAttributes); 741 nb_attributes, nb_defau lted, libxmlAttributes);
742 return; 742 return;
743 } 743 }
744 744
745 #if ENABLE(XHTMLMP) 745 #if ENABLE(XHTMLMP)
746 // check if the DOCTYPE Declaration of XHTMLMP document exists 746 // check if the DOCTYPE Declaration of XHTMLMP document exists
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
815 pushCurrentNode(newElement.get()); 815 pushCurrentNode(newElement.get());
816 if (m_view && !newElement->attached()) 816 if (m_view && !newElement->attached())
817 newElement->attach(); 817 newElement->attach();
818 818
819 if (!m_parsingFragment && isFirstElement && document()->frame()) 819 if (!m_parsingFragment && isFirstElement && document()->frame())
820 document()->frame()->loader()->dispatchDocumentElementAvailable(); 820 document()->frame()->loader()->dispatchDocumentElementAvailable();
821 } 821 }
822 822
823 void XMLDocumentParser::endElementNs() 823 void XMLDocumentParser::endElementNs()
824 { 824 {
825 if (isStopped()) 825 if (m_parserStopped)
826 return; 826 return;
827 827
828 if (m_parserPaused) { 828 if (m_parserPaused) {
829 m_pendingCallbacks->appendEndElementNSCallback(); 829 m_pendingCallbacks->appendEndElementNSCallback();
830 return; 830 return;
831 } 831 }
832 832
833 exitText(); 833 exitText();
834 834
835 Node* n = m_currentNode; 835 Node* n = m_currentNode;
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
899 // JavaScript may have detached the parser 899 // JavaScript may have detached the parser
900 if (isDetached()) 900 if (isDetached())
901 return; 901 return;
902 } 902 }
903 m_requestingScript = false; 903 m_requestingScript = false;
904 popCurrentNode(); 904 popCurrentNode();
905 } 905 }
906 906
907 void XMLDocumentParser::characters(const xmlChar* s, int len) 907 void XMLDocumentParser::characters(const xmlChar* s, int len)
908 { 908 {
909 if (isStopped()) 909 if (m_parserStopped)
910 return; 910 return;
911 911
912 if (m_parserPaused) { 912 if (m_parserPaused) {
913 m_pendingCallbacks->appendCharactersCallback(s, len); 913 m_pendingCallbacks->appendCharactersCallback(s, len);
914 return; 914 return;
915 } 915 }
916 916
917 if (!m_currentNode->isTextNode()) 917 if (!m_currentNode->isTextNode())
918 enterText(); 918 enterText();
919 m_bufferedText.append(s, len); 919 m_bufferedText.append(s, len);
920 } 920 }
921 921
922 void XMLDocumentParser::error(ErrorType type, const char* message, va_list args) 922 void XMLDocumentParser::error(ErrorType type, const char* message, va_list args)
923 { 923 {
924 if (isStopped()) 924 if (m_parserStopped)
925 return; 925 return;
926 926
927 #if COMPILER(MSVC) || COMPILER(RVCT) 927 #if COMPILER(MSVC) || COMPILER(RVCT)
928 char m[1024]; 928 char m[1024];
929 vsnprintf(m, sizeof(m) - 1, message, args); 929 vsnprintf(m, sizeof(m) - 1, message, args);
930 #else 930 #else
931 char* m; 931 char* m;
932 if (vasprintf(&m, message, args) == -1) 932 if (vasprintf(&m, message, args) == -1)
933 return; 933 return;
934 #endif 934 #endif
935 935
936 if (m_parserPaused) 936 if (m_parserPaused)
937 m_pendingCallbacks->appendErrorCallback(type, reinterpret_cast<const xml Char*>(m), lineNumber(), columnNumber()); 937 m_pendingCallbacks->appendErrorCallback(type, reinterpret_cast<const xml Char*>(m), lineNumber(), columnNumber());
938 else 938 else
939 handleError(type, m, lineNumber(), columnNumber()); 939 handleError(type, m, lineNumber(), columnNumber());
940 940
941 #if !COMPILER(MSVC) && !COMPILER(RVCT) 941 #if !COMPILER(MSVC) && !COMPILER(RVCT)
942 free(m); 942 free(m);
943 #endif 943 #endif
944 } 944 }
945 945
946 void XMLDocumentParser::processingInstruction(const xmlChar* target, const xmlCh ar* data) 946 void XMLDocumentParser::processingInstruction(const xmlChar* target, const xmlCh ar* data)
947 { 947 {
948 if (isStopped()) 948 if (m_parserStopped)
949 return; 949 return;
950 950
951 if (m_parserPaused) { 951 if (m_parserPaused) {
952 m_pendingCallbacks->appendProcessingInstructionCallback(target, data); 952 m_pendingCallbacks->appendProcessingInstructionCallback(target, data);
953 return; 953 return;
954 } 954 }
955 955
956 exitText(); 956 exitText();
957 957
958 // ### handle exceptions 958 // ### handle exceptions
(...skipping 13 matching lines...) Expand all
972 972
973 #if ENABLE(XSLT) 973 #if ENABLE(XSLT)
974 m_sawXSLTransform = !m_sawFirstElement && pi->isXSL(); 974 m_sawXSLTransform = !m_sawFirstElement && pi->isXSL();
975 if (m_sawXSLTransform && !document()->transformSourceDocument()) 975 if (m_sawXSLTransform && !document()->transformSourceDocument())
976 stopParsing(); 976 stopParsing();
977 #endif 977 #endif
978 } 978 }
979 979
980 void XMLDocumentParser::cdataBlock(const xmlChar* s, int len) 980 void XMLDocumentParser::cdataBlock(const xmlChar* s, int len)
981 { 981 {
982 if (isStopped()) 982 if (m_parserStopped)
983 return; 983 return;
984 984
985 if (m_parserPaused) { 985 if (m_parserPaused) {
986 m_pendingCallbacks->appendCDATABlockCallback(s, len); 986 m_pendingCallbacks->appendCDATABlockCallback(s, len);
987 return; 987 return;
988 } 988 }
989 989
990 exitText(); 990 exitText();
991 991
992 RefPtr<Node> newNode = CDATASection::create(document(), toString(s, len)); 992 RefPtr<Node> newNode = CDATASection::create(document(), toString(s, len));
993 m_currentNode->deprecatedParserAddChild(newNode.get()); 993 m_currentNode->deprecatedParserAddChild(newNode.get());
994 if (m_view && !newNode->attached()) 994 if (m_view && !newNode->attached())
995 newNode->attach(); 995 newNode->attach();
996 } 996 }
997 997
998 void XMLDocumentParser::comment(const xmlChar* s) 998 void XMLDocumentParser::comment(const xmlChar* s)
999 { 999 {
1000 if (isStopped()) 1000 if (m_parserStopped)
1001 return; 1001 return;
1002 1002
1003 if (m_parserPaused) { 1003 if (m_parserPaused) {
1004 m_pendingCallbacks->appendCommentCallback(s); 1004 m_pendingCallbacks->appendCommentCallback(s);
1005 return; 1005 return;
1006 } 1006 }
1007 1007
1008 exitText(); 1008 exitText();
1009 1009
1010 RefPtr<Node> newNode = Comment::create(document(), toString(s)); 1010 RefPtr<Node> newNode = Comment::create(document(), toString(s));
(...skipping 16 matching lines...) Expand all
1027 void XMLDocumentParser::endDocument() 1027 void XMLDocumentParser::endDocument()
1028 { 1028 {
1029 exitText(); 1029 exitText();
1030 #if ENABLE(XHTMLMP) 1030 #if ENABLE(XHTMLMP)
1031 m_hasDocTypeDeclaration = false; 1031 m_hasDocTypeDeclaration = false;
1032 #endif 1032 #endif
1033 } 1033 }
1034 1034
1035 void XMLDocumentParser::internalSubset(const xmlChar* name, const xmlChar* exter nalID, const xmlChar* systemID) 1035 void XMLDocumentParser::internalSubset(const xmlChar* name, const xmlChar* exter nalID, const xmlChar* systemID)
1036 { 1036 {
1037 if (isStopped()) 1037 if (m_parserStopped)
1038 return; 1038 return;
1039 1039
1040 if (m_parserPaused) { 1040 if (m_parserPaused) {
1041 m_pendingCallbacks->appendInternalSubsetCallback(name, externalID, syste mID); 1041 m_pendingCallbacks->appendInternalSubsetCallback(name, externalID, syste mID);
1042 return; 1042 return;
1043 } 1043 }
1044 1044
1045 if (document()) { 1045 if (document()) {
1046 #if ENABLE(WML) || ENABLE(XHTMLMP) 1046 #if ENABLE(WML) || ENABLE(XHTMLMP)
1047 String extId = toString(externalID); 1047 String extId = toString(externalID);
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
1287 sax.startElementNs = startElementNsHandler; 1287 sax.startElementNs = startElementNsHandler;
1288 sax.endElementNs = endElementNsHandler; 1288 sax.endElementNs = endElementNsHandler;
1289 sax.getEntity = getEntityHandler; 1289 sax.getEntity = getEntityHandler;
1290 sax.startDocument = startDocumentHandler; 1290 sax.startDocument = startDocumentHandler;
1291 sax.endDocument = endDocumentHandler; 1291 sax.endDocument = endDocumentHandler;
1292 sax.internalSubset = internalSubsetHandler; 1292 sax.internalSubset = internalSubsetHandler;
1293 sax.externalSubset = externalSubsetHandler; 1293 sax.externalSubset = externalSubsetHandler;
1294 sax.ignorableWhitespace = ignorableWhitespaceHandler; 1294 sax.ignorableWhitespace = ignorableWhitespaceHandler;
1295 sax.entityDecl = xmlSAX2EntityDecl; 1295 sax.entityDecl = xmlSAX2EntityDecl;
1296 sax.initialized = XML_SAX2_MAGIC; 1296 sax.initialized = XML_SAX2_MAGIC;
1297 DocumentParser::startParsing(); 1297 m_parserStopped = false;
1298 m_sawError = false; 1298 m_sawError = false;
1299 m_sawXSLTransform = false; 1299 m_sawXSLTransform = false;
1300 m_sawFirstElement = false; 1300 m_sawFirstElement = false;
1301 1301
1302 XMLDocumentParserScope scope(document()->docLoader()); 1302 XMLDocumentParserScope scope(document()->docLoader());
1303 if (m_parsingFragment) 1303 if (m_parsingFragment)
1304 m_context = XMLParserContext::createMemoryParser(&sax, this, chunk); 1304 m_context = XMLParserContext::createMemoryParser(&sax, this, chunk);
1305 else { 1305 else {
1306 ASSERT(!chunk); 1306 ASSERT(!chunk);
1307 m_context = XMLParserContext::createStringParser(&sax, this); 1307 m_context = XMLParserContext::createStringParser(&sax, this);
1308 } 1308 }
1309 } 1309 }
1310 1310
1311 void XMLDocumentParser::doEnd() 1311 void XMLDocumentParser::doEnd()
1312 { 1312 {
1313 #if ENABLE(XSLT) 1313 #if ENABLE(XSLT)
1314 if (m_sawXSLTransform) { 1314 if (m_sawXSLTransform) {
1315 void* doc = xmlDocPtrForString(document()->docLoader(), m_originalSource ForTransform, document()->url().string()); 1315 void* doc = xmlDocPtrForString(document()->docLoader(), m_originalSource ForTransform, document()->url().string());
1316 document()->setTransformSource(new TransformSource(doc)); 1316 document()->setTransformSource(new TransformSource(doc));
1317 1317
1318 document()->setParsing(false); // Make the doc think it's done, so it wi ll apply xsl sheets. 1318 document()->setParsing(false); // Make the doc think it's done, so it wi ll apply xsl sheets.
1319 document()->styleSelectorChanged(RecalcStyleImmediately); 1319 document()->styleSelectorChanged(RecalcStyleImmediately);
1320 document()->setParsing(true); 1320 document()->setParsing(true);
1321 DocumentParser::stopParsing(); 1321 m_parserStopped = true;
1322 } 1322 }
1323 #endif 1323 #endif
1324 1324
1325 if (isStopped()) 1325 if (m_parserStopped)
1326 return; 1326 return;
1327 1327
1328 if (m_context) { 1328 if (m_context) {
1329 // Tell libxml we're done. 1329 // Tell libxml we're done.
1330 { 1330 {
1331 XMLDocumentParserScope scope(document()->docLoader()); 1331 XMLDocumentParserScope scope(document()->docLoader());
1332 xmlParseChunk(context(), 0, 0, 1); 1332 xmlParseChunk(context(), 0, 0, 1);
1333 } 1333 }
1334 1334
1335 m_context = 0; 1335 m_context = 0;
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
1468 sax.startElementNs = attributesStartElementNsHandler; 1468 sax.startElementNs = attributesStartElementNsHandler;
1469 sax.initialized = XML_SAX2_MAGIC; 1469 sax.initialized = XML_SAX2_MAGIC;
1470 RefPtr<XMLParserContext> parser = XMLParserContext::createStringParser(&sax, &state); 1470 RefPtr<XMLParserContext> parser = XMLParserContext::createStringParser(&sax, &state);
1471 String parseString = "<?xml version=\"1.0\"?><attrs " + string + " />"; 1471 String parseString = "<?xml version=\"1.0\"?><attrs " + string + " />";
1472 xmlParseChunk(parser->context(), reinterpret_cast<const char*>(parseString.c haracters()), parseString.length() * sizeof(UChar), 1); 1472 xmlParseChunk(parser->context(), reinterpret_cast<const char*>(parseString.c haracters()), parseString.length() * sizeof(UChar), 1);
1473 attrsOK = state.gotAttributes; 1473 attrsOK = state.gotAttributes;
1474 return state.attributes; 1474 return state.attributes;
1475 } 1475 }
1476 1476
1477 } 1477 }
OLDNEW
« no previous file with comments | « WebCore/dom/XMLDocumentParser.cpp ('k') | WebCore/dom/XMLDocumentParserQt.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698