OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2010 Google, Inc. All Rights Reserved. | 2 * Copyright (C) 2010 Google, Inc. All Rights Reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 600 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
611 ASSERT(m_tokenizer->getState() == HTMLTokenizer::DataState); | 611 ASSERT(m_tokenizer->getState() == HTMLTokenizer::DataState); |
612 | 612 |
613 ASSERT(m_preloader); | 613 ASSERT(m_preloader); |
614 // TODO(kouhei): m_preloader should be always available for synchronous
parsing case, | 614 // TODO(kouhei): m_preloader should be always available for synchronous
parsing case, |
615 // adding paranoia if for speculative crash fix for crbug.com/465478 | 615 // adding paranoia if for speculative crash fix for crbug.com/465478 |
616 if (m_preloader) { | 616 if (m_preloader) { |
617 if (!m_preloadScanner) { | 617 if (!m_preloadScanner) { |
618 m_preloadScanner = createPreloadScanner(); | 618 m_preloadScanner = createPreloadScanner(); |
619 m_preloadScanner->appendToEnd(m_input.current()); | 619 m_preloadScanner->appendToEnd(m_input.current()); |
620 } | 620 } |
621 m_preloadScanner->scanAndPreload(m_preloader.get(), document()->base
ElementURL(), nullptr); | 621 m_preloadScanner->scanAndPreload(m_preloader.get(), document()->vali
dBaseElementURL(), nullptr); |
622 } | 622 } |
623 } | 623 } |
624 | 624 |
625 TRACE_EVENT_END1("devtools.timeline", "ParseHTML", "endData", InspectorParse
HtmlEvent::endData(m_input.current().currentLine().zeroBasedInt() - 1)); | 625 TRACE_EVENT_END1("devtools.timeline", "ParseHTML", "endData", InspectorParse
HtmlEvent::endData(m_input.current().currentLine().zeroBasedInt() - 1)); |
626 } | 626 } |
627 | 627 |
628 void HTMLDocumentParser::constructTreeFromHTMLToken() | 628 void HTMLDocumentParser::constructTreeFromHTMLToken() |
629 { | 629 { |
630 AtomicHTMLToken atomicToken(token()); | 630 AtomicHTMLToken atomicToken(token()); |
631 | 631 |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
688 excludedLineNumberSource.setExcludeLineNumbers(); | 688 excludedLineNumberSource.setExcludeLineNumbers(); |
689 m_input.insertAtCurrentInsertionPoint(excludedLineNumberSource); | 689 m_input.insertAtCurrentInsertionPoint(excludedLineNumberSource); |
690 pumpTokenizerIfPossible(); | 690 pumpTokenizerIfPossible(); |
691 | 691 |
692 if (isWaitingForScripts()) { | 692 if (isWaitingForScripts()) { |
693 // Check the document.write() output with a separate preload scanner as | 693 // Check the document.write() output with a separate preload scanner as |
694 // the main scanner can't deal with insertions. | 694 // the main scanner can't deal with insertions. |
695 if (!m_insertionPreloadScanner) | 695 if (!m_insertionPreloadScanner) |
696 m_insertionPreloadScanner = createPreloadScanner(); | 696 m_insertionPreloadScanner = createPreloadScanner(); |
697 m_insertionPreloadScanner->appendToEnd(source); | 697 m_insertionPreloadScanner->appendToEnd(source); |
698 m_insertionPreloadScanner->scanAndPreload(m_preloader.get(), document()-
>baseElementURL(), nullptr); | 698 m_insertionPreloadScanner->scanAndPreload(m_preloader.get(), document()-
>validBaseElementURL(), nullptr); |
699 } | 699 } |
700 | 700 |
701 endIfDelayed(); | 701 endIfDelayed(); |
702 } | 702 } |
703 | 703 |
704 void HTMLDocumentParser::startBackgroundParser() | 704 void HTMLDocumentParser::startBackgroundParser() |
705 { | 705 { |
706 ASSERT(!isStopped()); | 706 ASSERT(!isStopped()); |
707 ASSERT(shouldUseThreading()); | 707 ASSERT(shouldUseThreading()); |
708 ASSERT(!m_haveBackgroundParser); | 708 ASSERT(!m_haveBackgroundParser); |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
768 const SegmentedString source(inputSource); | 768 const SegmentedString source(inputSource); |
769 | 769 |
770 if (m_preloadScanner) { | 770 if (m_preloadScanner) { |
771 if (m_input.current().isEmpty() && !isWaitingForScripts()) { | 771 if (m_input.current().isEmpty() && !isWaitingForScripts()) { |
772 // We have parsed until the end of the current input and so are now
moving ahead of the preload scanner. | 772 // We have parsed until the end of the current input and so are now
moving ahead of the preload scanner. |
773 // Clear the scanner so we know to scan starting from the current in
put point if we block again. | 773 // Clear the scanner so we know to scan starting from the current in
put point if we block again. |
774 m_preloadScanner.reset(); | 774 m_preloadScanner.reset(); |
775 } else { | 775 } else { |
776 m_preloadScanner->appendToEnd(source); | 776 m_preloadScanner->appendToEnd(source); |
777 if (isWaitingForScripts()) | 777 if (isWaitingForScripts()) |
778 m_preloadScanner->scanAndPreload(m_preloader.get(), document()->
baseElementURL(), nullptr); | 778 m_preloadScanner->scanAndPreload(m_preloader.get(), document()->
validBaseElementURL(), nullptr); |
779 } | 779 } |
780 } | 780 } |
781 | 781 |
782 m_input.appendToEnd(source); | 782 m_input.appendToEnd(source); |
783 | 783 |
784 if (inPumpSession()) { | 784 if (inPumpSession()) { |
785 // We've gotten data off the network in a nested write. | 785 // We've gotten data off the network in a nested write. |
786 // We don't want to consume any more of the input stream now. Do | 786 // We don't want to consume any more of the input stream now. Do |
787 // not worry. We'll consume this data in a less-nested write(). | 787 // not worry. We'll consume this data in a less-nested write(). |
788 return; | 788 return; |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
943 | 943 |
944 m_insertionPreloadScanner.reset(); | 944 m_insertionPreloadScanner.reset(); |
945 pumpTokenizerIfPossible(); | 945 pumpTokenizerIfPossible(); |
946 endIfDelayed(); | 946 endIfDelayed(); |
947 } | 947 } |
948 | 948 |
949 void HTMLDocumentParser::appendCurrentInputStreamToPreloadScannerAndScan() | 949 void HTMLDocumentParser::appendCurrentInputStreamToPreloadScannerAndScan() |
950 { | 950 { |
951 ASSERT(m_preloadScanner); | 951 ASSERT(m_preloadScanner); |
952 m_preloadScanner->appendToEnd(m_input.current()); | 952 m_preloadScanner->appendToEnd(m_input.current()); |
953 m_preloadScanner->scanAndPreload(m_preloader.get(), document()->baseElementU
RL(), nullptr); | 953 m_preloadScanner->scanAndPreload(m_preloader.get(), document()->validBaseEle
mentURL(), nullptr); |
954 } | 954 } |
955 | 955 |
956 void HTMLDocumentParser::notifyScriptLoaded(Resource* cachedResource) | 956 void HTMLDocumentParser::notifyScriptLoaded(Resource* cachedResource) |
957 { | 957 { |
958 ASSERT(m_scriptRunner); | 958 ASSERT(m_scriptRunner); |
959 ASSERT(!isExecutingScript()); | 959 ASSERT(!isExecutingScript()); |
960 | 960 |
961 if (isStopped()) { | 961 if (isStopped()) { |
962 return; | 962 return; |
963 } | 963 } |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1099 bool neededInitialization = m_evaluator->ensureEvaluationContext(); | 1099 bool neededInitialization = m_evaluator->ensureEvaluationContext(); |
1100 double initializationDuration = monotonicallyIncreasingTimeMS() - initialize
StartTime; | 1100 double initializationDuration = monotonicallyIncreasingTimeMS() - initialize
StartTime; |
1101 | 1101 |
1102 double startTime = monotonicallyIncreasingTimeMS(); | 1102 double startTime = monotonicallyIncreasingTimeMS(); |
1103 String writtenSource = m_evaluator->evaluateAndEmitWrittenSource(source); | 1103 String writtenSource = m_evaluator->evaluateAndEmitWrittenSource(source); |
1104 double duration = monotonicallyIncreasingTimeMS() - startTime; | 1104 double duration = monotonicallyIncreasingTimeMS() - startTime; |
1105 | 1105 |
1106 int currentPreloadCount = document()->loader()->fetcher()->countPreloads(); | 1106 int currentPreloadCount = document()->loader()->fetcher()->countPreloads(); |
1107 std::unique_ptr<HTMLPreloadScanner> scanner = createPreloadScanner(); | 1107 std::unique_ptr<HTMLPreloadScanner> scanner = createPreloadScanner(); |
1108 scanner->appendToEnd(SegmentedString(writtenSource)); | 1108 scanner->appendToEnd(SegmentedString(writtenSource)); |
1109 scanner->scanAndPreload(m_preloader.get(), document()->baseElementURL(), nul
lptr); | 1109 scanner->scanAndPreload(m_preloader.get(), document()->validBaseElementURL()
, nullptr); |
1110 int numPreloads = document()->loader()->fetcher()->countPreloads() - current
PreloadCount; | 1110 int numPreloads = document()->loader()->fetcher()->countPreloads() - current
PreloadCount; |
1111 | 1111 |
1112 TRACE_EVENT_INSTANT2("blink", "HTMLDocumentParser::evaluateAndPreloadScriptF
orDocumentWrite.data", TRACE_EVENT_SCOPE_THREAD, "numPreloads", numPreloads, "sc
riptLength", source.length()); | 1112 TRACE_EVENT_INSTANT2("blink", "HTMLDocumentParser::evaluateAndPreloadScriptF
orDocumentWrite.data", TRACE_EVENT_SCOPE_THREAD, "numPreloads", numPreloads, "sc
riptLength", source.length()); |
1113 | 1113 |
1114 if (neededInitialization) { | 1114 if (neededInitialization) { |
1115 DEFINE_STATIC_LOCAL(CustomCountHistogram, initializeHistograms, ("Preloa
dScanner.DocumentWrite.InitializationTime", 1, 10000, 50)); | 1115 DEFINE_STATIC_LOCAL(CustomCountHistogram, initializeHistograms, ("Preloa
dScanner.DocumentWrite.InitializationTime", 1, 10000, 50)); |
1116 initializeHistograms.count(initializationDuration); | 1116 initializeHistograms.count(initializationDuration); |
1117 } | 1117 } |
1118 | 1118 |
1119 if (numPreloads) { | 1119 if (numPreloads) { |
(...skipping 19 matching lines...) Expand all Loading... |
1139 (*closure)(); | 1139 (*closure)(); |
1140 return; | 1140 return; |
1141 case Asynchronous: | 1141 case Asynchronous: |
1142 m_loadingTaskRunner->postTask(BLINK_FROM_HERE, std::move(closure)); | 1142 m_loadingTaskRunner->postTask(BLINK_FROM_HERE, std::move(closure)); |
1143 return; | 1143 return; |
1144 } | 1144 } |
1145 NOTREACHED(); | 1145 NOTREACHED(); |
1146 } | 1146 } |
1147 | 1147 |
1148 } // namespace blink | 1148 } // namespace blink |
OLD | NEW |