Chromium Code Reviews| 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. (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 18 matching lines...) Expand all Loading... | |
| 29 #include "bindings/core/v8/ExceptionStatePlaceholder.h" | 29 #include "bindings/core/v8/ExceptionStatePlaceholder.h" |
| 30 #include "bindings/core/v8/ScriptController.h" | 30 #include "bindings/core/v8/ScriptController.h" |
| 31 #include "bindings/core/v8/ScriptSourceCode.h" | 31 #include "bindings/core/v8/ScriptSourceCode.h" |
| 32 #include "bindings/core/v8/V8Document.h" | 32 #include "bindings/core/v8/V8Document.h" |
| 33 #include "core/HTMLNames.h" | 33 #include "core/HTMLNames.h" |
| 34 #include "core/XMLNSNames.h" | 34 #include "core/XMLNSNames.h" |
| 35 #include "core/dom/CDATASection.h" | 35 #include "core/dom/CDATASection.h" |
| 36 #include "core/dom/Comment.h" | 36 #include "core/dom/Comment.h" |
| 37 #include "core/dom/Document.h" | 37 #include "core/dom/Document.h" |
| 38 #include "core/dom/DocumentFragment.h" | 38 #include "core/dom/DocumentFragment.h" |
| 39 #include "core/dom/DocumentParserTiming.h" | |
| 39 #include "core/dom/DocumentType.h" | 40 #include "core/dom/DocumentType.h" |
| 40 #include "core/dom/ProcessingInstruction.h" | 41 #include "core/dom/ProcessingInstruction.h" |
| 41 #include "core/dom/ScriptLoader.h" | 42 #include "core/dom/ScriptLoader.h" |
| 42 #include "core/dom/StyleEngine.h" | 43 #include "core/dom/StyleEngine.h" |
| 43 #include "core/dom/TransformSource.h" | 44 #include "core/dom/TransformSource.h" |
| 44 #include "core/fetch/FetchInitiatorTypeNames.h" | 45 #include "core/fetch/FetchInitiatorTypeNames.h" |
| 45 #include "core/fetch/RawResource.h" | 46 #include "core/fetch/RawResource.h" |
| 46 #include "core/fetch/ResourceFetcher.h" | 47 #include "core/fetch/ResourceFetcher.h" |
| 47 #include "core/fetch/ScriptResource.h" | 48 #include "core/fetch/ScriptResource.h" |
| 48 #include "core/frame/LocalFrame.h" | 49 #include "core/frame/LocalFrame.h" |
| (...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 392 | 393 |
| 393 // Mutation event handlers executed by appendData() might detach this parser . | 394 // Mutation event handlers executed by appendData() might detach this parser . |
| 394 return !isStopped(); | 395 return !isStopped(); |
| 395 } | 396 } |
| 396 | 397 |
| 397 void XMLDocumentParser::detach() | 398 void XMLDocumentParser::detach() |
| 398 { | 399 { |
| 399 if (m_pendingScript) { | 400 if (m_pendingScript) { |
| 400 m_pendingScript->removeClient(this); | 401 m_pendingScript->removeClient(this); |
| 401 m_pendingScript = nullptr; | 402 m_pendingScript = nullptr; |
| 403 m_parserBlockingPendingScriptLoadStartTime = 0.0; | |
| 402 } | 404 } |
| 403 clearCurrentNodeStack(); | 405 clearCurrentNodeStack(); |
| 404 ScriptableDocumentParser::detach(); | 406 ScriptableDocumentParser::detach(); |
| 405 } | 407 } |
| 406 | 408 |
| 407 void XMLDocumentParser::end() | 409 void XMLDocumentParser::end() |
| 408 { | 410 { |
| 409 TRACE_EVENT0("blink", "XMLDocumentParser::end"); | 411 TRACE_EVENT0("blink", "XMLDocumentParser::end"); |
| 410 // XMLDocumentParserLibxml2 will do bad things to the document if doEnd() is called. | 412 // XMLDocumentParserLibxml2 will do bad things to the document if doEnd() is called. |
| 411 // I don't believe XMLDocumentParserQt needs doEnd called in the fragment ca se. | 413 // I don't believe XMLDocumentParserQt needs doEnd called in the fragment ca se. |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 455 m_xmlErrors.insertErrorMessageBlock(); | 457 m_xmlErrors.insertErrorMessageBlock(); |
| 456 } | 458 } |
| 457 | 459 |
| 458 void XMLDocumentParser::notifyFinished(Resource* unusedResource) | 460 void XMLDocumentParser::notifyFinished(Resource* unusedResource) |
| 459 { | 461 { |
| 460 ASSERT_UNUSED(unusedResource, unusedResource == m_pendingScript); | 462 ASSERT_UNUSED(unusedResource, unusedResource == m_pendingScript); |
| 461 | 463 |
| 462 ScriptSourceCode sourceCode(m_pendingScript.get()); | 464 ScriptSourceCode sourceCode(m_pendingScript.get()); |
| 463 bool errorOccurred = m_pendingScript->errorOccurred(); | 465 bool errorOccurred = m_pendingScript->errorOccurred(); |
| 464 bool wasCanceled = m_pendingScript->wasCanceled(); | 466 bool wasCanceled = m_pendingScript->wasCanceled(); |
| 467 double scriptParserBlockingTime = m_parserBlockingPendingScriptLoadStartTime ; | |
| 468 m_parserBlockingPendingScriptLoadStartTime = 0.0; | |
| 465 | 469 |
| 466 m_pendingScript->removeClient(this); | 470 m_pendingScript->removeClient(this); |
| 467 m_pendingScript = nullptr; | 471 m_pendingScript = nullptr; |
| 468 | 472 |
| 469 Element* e = m_scriptElement; | 473 Element* e = m_scriptElement; |
| 470 m_scriptElement = nullptr; | 474 m_scriptElement = nullptr; |
| 471 | 475 |
| 472 ScriptLoader* scriptLoader = toScriptLoaderIfPossible(e); | 476 ScriptLoader* scriptLoader = toScriptLoaderIfPossible(e); |
| 473 ASSERT(scriptLoader); | 477 ASSERT(scriptLoader); |
| 474 | 478 |
| 475 if (errorOccurred) { | 479 if (errorOccurred) { |
| 476 scriptLoader->dispatchErrorEvent(); | 480 scriptLoader->dispatchErrorEvent(); |
| 477 } else if (!wasCanceled) { | 481 } else if (!wasCanceled) { |
| 482 if (scriptParserBlockingTime > 0.0) { | |
| 483 DocumentParserTiming::from(*document()).recordParserBlockedOnScriptL oadDuration(monotonicallyIncreasingTime() - scriptParserBlockingTime, scriptLoad er->wasCreatedDuringDocumentWrite()); | |
|
kouhei (in TOK)
2016/08/12 01:13:29
Can we record this to separate UMA?
XMLDocumentPar
| |
| 484 } | |
| 485 | |
| 478 if (!scriptLoader->executeScript(sourceCode)) | 486 if (!scriptLoader->executeScript(sourceCode)) |
| 479 scriptLoader->dispatchErrorEvent(); | 487 scriptLoader->dispatchErrorEvent(); |
| 480 else | 488 else |
| 481 scriptLoader->dispatchLoadEvent(); | 489 scriptLoader->dispatchLoadEvent(); |
| 482 } | 490 } |
| 483 | 491 |
| 484 m_scriptElement = nullptr; | 492 m_scriptElement = nullptr; |
| 485 | 493 |
| 486 if (!isDetached() && !m_requestingScript) | 494 if (!isDetached() && !m_requestingScript) |
| 487 resumeParsing(); | 495 resumeParsing(); |
| (...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 770 , m_sawError(false) | 778 , m_sawError(false) |
| 771 , m_sawCSS(false) | 779 , m_sawCSS(false) |
| 772 , m_sawXSLTransform(false) | 780 , m_sawXSLTransform(false) |
| 773 , m_sawFirstElement(false) | 781 , m_sawFirstElement(false) |
| 774 , m_isXHTMLDocument(false) | 782 , m_isXHTMLDocument(false) |
| 775 , m_parserPaused(false) | 783 , m_parserPaused(false) |
| 776 , m_requestingScript(false) | 784 , m_requestingScript(false) |
| 777 , m_finishCalled(false) | 785 , m_finishCalled(false) |
| 778 , m_xmlErrors(&document) | 786 , m_xmlErrors(&document) |
| 779 , m_scriptStartPosition(TextPosition::belowRangePosition()) | 787 , m_scriptStartPosition(TextPosition::belowRangePosition()) |
| 788 , m_parserBlockingPendingScriptLoadStartTime(0.0) | |
| 780 , m_parsingFragment(false) | 789 , m_parsingFragment(false) |
| 781 { | 790 { |
| 782 // This is XML being used as a document resource. | 791 // This is XML being used as a document resource. |
| 783 if (frameView && document.isXMLDocument()) | 792 if (frameView && document.isXMLDocument()) |
| 784 UseCounter::count(document, UseCounter::XMLDocument); | 793 UseCounter::count(document, UseCounter::XMLDocument); |
| 785 } | 794 } |
| 786 | 795 |
| 787 XMLDocumentParser::XMLDocumentParser(DocumentFragment* fragment, Element* parent Element, ParserContentPolicy parserContentPolicy) | 796 XMLDocumentParser::XMLDocumentParser(DocumentFragment* fragment, Element* parent Element, ParserContentPolicy parserContentPolicy) |
| 788 : ScriptableDocumentParser(fragment->document(), parserContentPolicy) | 797 : ScriptableDocumentParser(fragment->document(), parserContentPolicy) |
| 789 , m_hasView(false) | 798 , m_hasView(false) |
| (...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1086 // the libxml2 and Qt XMLDocumentParser implementations. | 1095 // the libxml2 and Qt XMLDocumentParser implementations. |
| 1087 | 1096 |
| 1088 | 1097 |
| 1089 if (scriptLoader->readyToBeParserExecuted()) { | 1098 if (scriptLoader->readyToBeParserExecuted()) { |
| 1090 if (!scriptLoader->executeScript(ScriptSourceCode(scriptLoader->scri ptContent(), document()->url(), m_scriptStartPosition))) { | 1099 if (!scriptLoader->executeScript(ScriptSourceCode(scriptLoader->scri ptContent(), document()->url(), m_scriptStartPosition))) { |
| 1091 scriptLoader->dispatchErrorEvent(); | 1100 scriptLoader->dispatchErrorEvent(); |
| 1092 return; | 1101 return; |
| 1093 } | 1102 } |
| 1094 } else if (scriptLoader->willBeParserExecuted()) { | 1103 } else if (scriptLoader->willBeParserExecuted()) { |
| 1095 m_pendingScript = scriptLoader->resource(); | 1104 m_pendingScript = scriptLoader->resource(); |
| 1105 DCHECK_EQ(m_parserBlockingPendingScriptLoadStartTime, 0.0); | |
| 1106 m_parserBlockingPendingScriptLoadStartTime = monotonicallyIncreasing Time(); | |
| 1096 m_scriptElement = element; | 1107 m_scriptElement = element; |
| 1097 m_pendingScript->addClient(this); | 1108 m_pendingScript->addClient(this); |
| 1098 // m_pendingScript will be 0 if script was already loaded and | 1109 // m_pendingScript will be 0 if script was already loaded and |
| 1099 // addClient() executed it. | 1110 // addClient() executed it. |
| 1100 if (m_pendingScript) | 1111 if (m_pendingScript) |
| 1101 pauseParsing(); | 1112 pauseParsing(); |
| 1102 } else { | 1113 } else { |
| 1103 m_scriptElement = nullptr; | 1114 m_scriptElement = nullptr; |
| 1104 } | 1115 } |
| 1105 | 1116 |
| (...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1640 sax.initialized = XML_SAX2_MAGIC; | 1651 sax.initialized = XML_SAX2_MAGIC; |
| 1641 RefPtr<XMLParserContext> parser = XMLParserContext::createStringParser(&sax, &state); | 1652 RefPtr<XMLParserContext> parser = XMLParserContext::createStringParser(&sax, &state); |
| 1642 String parseString = "<?xml version=\"1.0\"?><attrs " + string + " />"; | 1653 String parseString = "<?xml version=\"1.0\"?><attrs " + string + " />"; |
| 1643 parseChunk(parser->context(), parseString); | 1654 parseChunk(parser->context(), parseString); |
| 1644 finishParsing(parser->context()); | 1655 finishParsing(parser->context()); |
| 1645 attrsOK = state.gotAttributes; | 1656 attrsOK = state.gotAttributes; |
| 1646 return state.attributes; | 1657 return state.attributes; |
| 1647 } | 1658 } |
| 1648 | 1659 |
| 1649 } // namespace blink | 1660 } // namespace blink |
| OLD | NEW |