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

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

Issue 1686483002: Oilpan: Remove most WillBe types from the code base (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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
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 356 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 if (isStopped() || m_sawXSLTransform) 367 if (isStopped() || m_sawXSLTransform)
368 return; 368 return;
369 369
370 if (m_parserPaused) { 370 if (m_parserPaused) {
371 m_pendingSrc.append(source); 371 m_pendingSrc.append(source);
372 return; 372 return;
373 } 373 }
374 374
375 // JavaScript can detach the parser. Make sure this is not released 375 // JavaScript can detach the parser. Make sure this is not released
376 // before the end of this method. 376 // before the end of this method.
377 RefPtrWillBeRawPtr<XMLDocumentParser> protect(this); 377 RawPtr<XMLDocumentParser> protect(this);
378 378
379 doWrite(source.toString()); 379 doWrite(source.toString());
380 } 380 }
381 381
382 void XMLDocumentParser::handleError(XMLErrors::ErrorType type, const char* forma ttedMessage, TextPosition position) 382 void XMLDocumentParser::handleError(XMLErrors::ErrorType type, const char* forma ttedMessage, TextPosition position)
383 { 383 {
384 m_xmlErrors.handleError(type, formattedMessage, position); 384 m_xmlErrors.handleError(type, formattedMessage, position);
385 if (type != XMLErrors::ErrorTypeWarning) 385 if (type != XMLErrors::ErrorTypeWarning)
386 m_sawError = true; 386 m_sawError = true;
387 if (type == XMLErrors::ErrorTypeFatal) 387 if (type == XMLErrors::ErrorTypeFatal)
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
458 document()->finishedParsing(); 458 document()->finishedParsing();
459 } 459 }
460 460
461 void XMLDocumentParser::finish() 461 void XMLDocumentParser::finish()
462 { 462 {
463 // FIXME: We should ASSERT(!m_parserStopped) here, since it does not 463 // FIXME: We should ASSERT(!m_parserStopped) here, since it does not
464 // makes sense to call any methods on DocumentParser once it's been stopped. 464 // makes sense to call any methods on DocumentParser once it's been stopped.
465 // However, FrameLoader::stop calls DocumentParser::finish unconditionally. 465 // However, FrameLoader::stop calls DocumentParser::finish unconditionally.
466 466
467 // flush may ending up executing arbitrary script, and possibly detach the p arser. 467 // flush may ending up executing arbitrary script, and possibly detach the p arser.
468 RefPtrWillBeRawPtr<XMLDocumentParser> protect(this); 468 RawPtr<XMLDocumentParser> protect(this);
469 flush(); 469 flush();
470 if (isDetached()) 470 if (isDetached())
471 return; 471 return;
472 472
473 if (m_parserPaused) 473 if (m_parserPaused)
474 m_finishCalled = true; 474 m_finishCalled = true;
475 else 475 else
476 end(); 476 end();
477 } 477 }
478 478
479 void XMLDocumentParser::insertErrorMessageBlock() 479 void XMLDocumentParser::insertErrorMessageBlock()
480 { 480 {
481 m_xmlErrors.insertErrorMessageBlock(); 481 m_xmlErrors.insertErrorMessageBlock();
482 } 482 }
483 483
484 void XMLDocumentParser::notifyFinished(Resource* unusedResource) 484 void XMLDocumentParser::notifyFinished(Resource* unusedResource)
485 { 485 {
486 ASSERT_UNUSED(unusedResource, unusedResource == m_pendingScript); 486 ASSERT_UNUSED(unusedResource, unusedResource == m_pendingScript);
487 487
488 ScriptSourceCode sourceCode(m_pendingScript.get()); 488 ScriptSourceCode sourceCode(m_pendingScript.get());
489 bool errorOccurred = m_pendingScript->errorOccurred(); 489 bool errorOccurred = m_pendingScript->errorOccurred();
490 bool wasCanceled = m_pendingScript->wasCanceled(); 490 bool wasCanceled = m_pendingScript->wasCanceled();
491 491
492 m_pendingScript->removeClient(this); 492 m_pendingScript->removeClient(this);
493 m_pendingScript = nullptr; 493 m_pendingScript = nullptr;
494 494
495 RefPtrWillBeRawPtr<Element> e = m_scriptElement; 495 RawPtr<Element> e = m_scriptElement;
496 m_scriptElement = nullptr; 496 m_scriptElement = nullptr;
497 497
498 ScriptLoader* scriptLoader = toScriptLoaderIfPossible(e.get()); 498 ScriptLoader* scriptLoader = toScriptLoaderIfPossible(e.get());
499 ASSERT(scriptLoader); 499 ASSERT(scriptLoader);
500 500
501 // JavaScript can detach this parser, make sure it's kept alive even if 501 // JavaScript can detach this parser, make sure it's kept alive even if
502 // detached. 502 // detached.
503 RefPtrWillBeRawPtr<XMLDocumentParser> protect(this); 503 RawPtr<XMLDocumentParser> protect(this);
504 504
505 if (errorOccurred) { 505 if (errorOccurred) {
506 scriptLoader->dispatchErrorEvent(); 506 scriptLoader->dispatchErrorEvent();
507 } else if (!wasCanceled) { 507 } else if (!wasCanceled) {
508 if (!scriptLoader->executeScript(sourceCode)) 508 if (!scriptLoader->executeScript(sourceCode))
509 scriptLoader->dispatchErrorEvent(); 509 scriptLoader->dispatchErrorEvent();
510 else 510 else
511 scriptLoader->dispatchLoadEvent(); 511 scriptLoader->dispatchLoadEvent();
512 } 512 }
513 513
(...skipping 20 matching lines...) Expand all
534 return true; 534 return true;
535 535
536 // FIXME: We need to implement the HTML5 XML Fragment parsing algorithm: 536 // FIXME: We need to implement the HTML5 XML Fragment parsing algorithm:
537 // http://www.whatwg.org/specs/web-apps/current-work/multipage/the-xhtml-syn tax.html#xml-fragment-parsing-algorithm 537 // http://www.whatwg.org/specs/web-apps/current-work/multipage/the-xhtml-syn tax.html#xml-fragment-parsing-algorithm
538 // For now we have a hack for script/style innerHTML support: 538 // For now we have a hack for script/style innerHTML support:
539 if (contextElement && (contextElement->hasLocalName(scriptTag.localName()) | | contextElement->hasLocalName(styleTag.localName()))) { 539 if (contextElement && (contextElement->hasLocalName(scriptTag.localName()) | | contextElement->hasLocalName(styleTag.localName()))) {
540 fragment->parserAppendChild(fragment->document().createTextNode(chunk)); 540 fragment->parserAppendChild(fragment->document().createTextNode(chunk));
541 return true; 541 return true;
542 } 542 }
543 543
544 RefPtrWillBeRawPtr<XMLDocumentParser> parser = XMLDocumentParser::create(fra gment, contextElement, parserContentPolicy); 544 RawPtr<XMLDocumentParser> parser = XMLDocumentParser::create(fragment, conte xtElement, parserContentPolicy);
545 bool wellFormed = parser->appendFragmentSource(chunk); 545 bool wellFormed = parser->appendFragmentSource(chunk);
546 546
547 // Do not call finish(). Current finish() and doEnd() implementations touch 547 // Do not call finish(). Current finish() and doEnd() implementations touch
548 // the main Document/loader and can cause crashes in the fragment case. 548 // the main Document/loader and can cause crashes in the fragment case.
549 549
550 // Allows ~DocumentParser to assert it was detached before destruction. 550 // Allows ~DocumentParser to assert it was detached before destruction.
551 parser->detach(); 551 parser->detach();
552 // appendFragmentSource()'s wellFormed is more permissive than wellFormed(). 552 // appendFragmentSource()'s wellFormed is more permissive than wellFormed().
553 return wellFormed; 553 return wellFormed;
554 } 554 }
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
670 return &globalDescriptor; 670 return &globalDescriptor;
671 671
672 KURL finalURL; 672 KURL finalURL;
673 RefPtr<SharedBuffer> data; 673 RefPtr<SharedBuffer> data;
674 674
675 { 675 {
676 Document* document = XMLDocumentParserScope::currentDocument; 676 Document* document = XMLDocumentParserScope::currentDocument;
677 XMLDocumentParserScope scope(0); 677 XMLDocumentParserScope scope(0);
678 // FIXME: We should restore the original global error handler as well. 678 // FIXME: We should restore the original global error handler as well.
679 FetchRequest request(ResourceRequest(url), FetchInitiatorTypeNames::xml, ResourceFetcher::defaultResourceOptions()); 679 FetchRequest request(ResourceRequest(url), FetchInitiatorTypeNames::xml, ResourceFetcher::defaultResourceOptions());
680 RefPtrWillBeRawPtr<Resource> resource = RawResource::fetchSynchronously( request, document->fetcher()); 680 RawPtr<Resource> resource = RawResource::fetchSynchronously(request, doc ument->fetcher());
681 if (resource && !resource->errorOccurred()) { 681 if (resource && !resource->errorOccurred()) {
682 data = resource->resourceBuffer(); 682 data = resource->resourceBuffer();
683 finalURL = resource->response().url(); 683 finalURL = resource->response().url();
684 } 684 }
685 } 685 }
686 686
687 // We have to check the URL again after the load to catch redirects. 687 // We have to check the URL again after the load to catch redirects.
688 // See <https://bugs.webkit.org/show_bug.cgi?id=21963>. 688 // See <https://bugs.webkit.org/show_bug.cgi?id=21963>.
689 if (!shouldAllowExternalLoad(finalURL)) 689 if (!shouldAllowExternalLoad(finalURL))
690 return &globalDescriptor; 690 return &globalDescriptor;
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
830 , m_finishCalled(false) 830 , m_finishCalled(false)
831 , m_xmlErrors(&fragment->document()) 831 , m_xmlErrors(&fragment->document())
832 , m_scriptStartPosition(TextPosition::belowRangePosition()) 832 , m_scriptStartPosition(TextPosition::belowRangePosition())
833 , m_parsingFragment(true) 833 , m_parsingFragment(true)
834 { 834 {
835 #if !ENABLE(OILPAN) 835 #if !ENABLE(OILPAN)
836 fragment->ref(); 836 fragment->ref();
837 #endif 837 #endif
838 838
839 // Add namespaces based on the parent node 839 // Add namespaces based on the parent node
840 WillBeHeapVector<RawPtrWillBeMember<Element>> elemStack; 840 HeapVector<Member<Element>> elemStack;
841 while (parentElement) { 841 while (parentElement) {
842 elemStack.append(parentElement); 842 elemStack.append(parentElement);
843 843
844 Element* grandParentElement = parentElement->parentElement(); 844 Element* grandParentElement = parentElement->parentElement();
845 if (!grandParentElement) 845 if (!grandParentElement)
846 break; 846 break;
847 parentElement = grandParentElement; 847 parentElement = grandParentElement;
848 } 848 }
849 849
850 if (elemStack.isEmpty()) 850 if (elemStack.isEmpty())
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
904 initializeParserContext(); 904 initializeParserContext();
905 905
906 // Protect the libxml context from deletion during a callback 906 // Protect the libxml context from deletion during a callback
907 RefPtr<XMLParserContext> context = m_context; 907 RefPtr<XMLParserContext> context = m_context;
908 908
909 // libXML throws an error if you try to switch the encoding for an empty 909 // libXML throws an error if you try to switch the encoding for an empty
910 // string. 910 // string.
911 if (parseString.length()) { 911 if (parseString.length()) {
912 // JavaScript may cause the parser to detach during parseChunk 912 // JavaScript may cause the parser to detach during parseChunk
913 // keep this alive until this function is done. 913 // keep this alive until this function is done.
914 RefPtrWillBeRawPtr<XMLDocumentParser> protect(this); 914 RawPtr<XMLDocumentParser> protect(this);
915 915
916 XMLDocumentParserScope scope(document()); 916 XMLDocumentParserScope scope(document());
917 TemporaryChange<bool> encodingScope(m_isCurrentlyParsing8BitChunk, parse String.is8Bit()); 917 TemporaryChange<bool> encodingScope(m_isCurrentlyParsing8BitChunk, parse String.is8Bit());
918 parseChunk(context->context(), parseString); 918 parseChunk(context->context(), parseString);
919 919
920 // JavaScript (which may be run under the parseChunk callstack) may 920 // JavaScript (which may be run under the parseChunk callstack) may
921 // cause the parser to be stopped or detached. 921 // cause the parser to be stopped or detached.
922 if (isStopped()) 922 if (isStopped())
923 return; 923 return;
924 } 924 }
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
1018 if (!prefix.isNull()) 1018 if (!prefix.isNull())
1019 adjustedURI = m_prefixToNamespaceMap.get(prefix); 1019 adjustedURI = m_prefixToNamespaceMap.get(prefix);
1020 else 1020 else
1021 adjustedURI = m_defaultNamespaceURI; 1021 adjustedURI = m_defaultNamespaceURI;
1022 } 1022 }
1023 1023
1024 bool isFirstElement = !m_sawFirstElement; 1024 bool isFirstElement = !m_sawFirstElement;
1025 m_sawFirstElement = true; 1025 m_sawFirstElement = true;
1026 1026
1027 QualifiedName qName(prefix, localName, adjustedURI); 1027 QualifiedName qName(prefix, localName, adjustedURI);
1028 RefPtrWillBeRawPtr<Element> newElement = m_currentNode->document().createEle ment(qName, true); 1028 RawPtr<Element> newElement = m_currentNode->document().createElement(qName, true);
1029 if (!newElement) { 1029 if (!newElement) {
1030 stopParsing(); 1030 stopParsing();
1031 return; 1031 return;
1032 } 1032 }
1033 1033
1034 Vector<Attribute> prefixedAttributes; 1034 Vector<Attribute> prefixedAttributes;
1035 TrackExceptionState exceptionState; 1035 TrackExceptionState exceptionState;
1036 handleNamespaceAttributes(prefixedAttributes, libxmlNamespaces, nbNamespaces , exceptionState); 1036 handleNamespaceAttributes(prefixedAttributes, libxmlNamespaces, nbNamespaces , exceptionState);
1037 if (exceptionState.hadException()) { 1037 if (exceptionState.hadException()) {
1038 setAttributes(newElement.get(), prefixedAttributes, parserContentPolicy( )); 1038 setAttributes(newElement.get(), prefixedAttributes, parserContentPolicy( ));
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
1079 if (isStopped()) 1079 if (isStopped())
1080 return; 1080 return;
1081 1081
1082 if (m_parserPaused) { 1082 if (m_parserPaused) {
1083 m_pendingCallbacks.append(adoptPtr(new PendingEndElementNSCallback(m_scr iptStartPosition))); 1083 m_pendingCallbacks.append(adoptPtr(new PendingEndElementNSCallback(m_scr iptStartPosition)));
1084 return; 1084 return;
1085 } 1085 }
1086 1086
1087 // JavaScript can detach the parser. Make sure this is not released before 1087 // JavaScript can detach the parser. Make sure this is not released before
1088 // the end of this method. 1088 // the end of this method.
1089 RefPtrWillBeRawPtr<XMLDocumentParser> protect(this); 1089 RawPtr<XMLDocumentParser> protect(this);
1090 1090
1091 if (!updateLeafTextNode()) 1091 if (!updateLeafTextNode())
1092 return; 1092 return;
1093 1093
1094 RefPtrWillBeRawPtr<ContainerNode> n = m_currentNode; 1094 RawPtr<ContainerNode> n = m_currentNode;
1095 if (m_currentNode->isElementNode()) 1095 if (m_currentNode->isElementNode())
1096 toElement(n.get())->finishParsingChildren(); 1096 toElement(n.get())->finishParsingChildren();
1097 1097
1098 if (!scriptingContentIsAllowed(parserContentPolicy()) && n->isElementNode() && toScriptLoaderIfPossible(toElement(n))) { 1098 if (!scriptingContentIsAllowed(parserContentPolicy()) && n->isElementNode() && toScriptLoaderIfPossible(toElement(n))) {
1099 popCurrentNode(); 1099 popCurrentNode();
1100 n->remove(IGNORE_EXCEPTION); 1100 n->remove(IGNORE_EXCEPTION);
1101 return; 1101 return;
1102 } 1102 }
1103 1103
1104 if (!n->isElementNode() || !m_hasView) { 1104 if (!n->isElementNode() || !m_hasView) {
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
1198 if (m_parserPaused) { 1198 if (m_parserPaused) {
1199 m_pendingCallbacks.append(adoptPtr(new PendingProcessingInstructionCallb ack(target, data))); 1199 m_pendingCallbacks.append(adoptPtr(new PendingProcessingInstructionCallb ack(target, data)));
1200 return; 1200 return;
1201 } 1201 }
1202 1202
1203 if (!updateLeafTextNode()) 1203 if (!updateLeafTextNode())
1204 return; 1204 return;
1205 1205
1206 // ### handle exceptions 1206 // ### handle exceptions
1207 TrackExceptionState exceptionState; 1207 TrackExceptionState exceptionState;
1208 RefPtrWillBeRawPtr<ProcessingInstruction> pi = m_currentNode->document().cre ateProcessingInstruction(target, data, exceptionState); 1208 RawPtr<ProcessingInstruction> pi = m_currentNode->document().createProcessin gInstruction(target, data, exceptionState);
1209 if (exceptionState.hadException()) 1209 if (exceptionState.hadException())
1210 return; 1210 return;
1211 1211
1212 pi->setCreatedByParser(true); 1212 pi->setCreatedByParser(true);
1213 1213
1214 m_currentNode->parserAppendChild(pi.get()); 1214 m_currentNode->parserAppendChild(pi.get());
1215 1215
1216 pi->setCreatedByParser(false); 1216 pi->setCreatedByParser(false);
1217 1217
1218 if (pi->isCSS()) 1218 if (pi->isCSS())
(...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after
1698 sax.initialized = XML_SAX2_MAGIC; 1698 sax.initialized = XML_SAX2_MAGIC;
1699 RefPtr<XMLParserContext> parser = XMLParserContext::createStringParser(&sax, &state); 1699 RefPtr<XMLParserContext> parser = XMLParserContext::createStringParser(&sax, &state);
1700 String parseString = "<?xml version=\"1.0\"?><attrs " + string + " />"; 1700 String parseString = "<?xml version=\"1.0\"?><attrs " + string + " />";
1701 parseChunk(parser->context(), parseString); 1701 parseChunk(parser->context(), parseString);
1702 finishParsing(parser->context()); 1702 finishParsing(parser->context());
1703 attrsOK = state.gotAttributes; 1703 attrsOK = state.gotAttributes;
1704 return state.attributes; 1704 return state.attributes;
1705 } 1705 }
1706 1706
1707 } // namespace blink 1707 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698