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 669 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
680 RELEASE_ASSERT(!isStopped()); | 680 RELEASE_ASSERT(!isStopped()); |
681 | 681 |
682 if (isWaitingForScripts()) { | 682 if (isWaitingForScripts()) { |
683 ASSERT(m_tokenizer->state() == HTMLTokenizer::DataState); | 683 ASSERT(m_tokenizer->state() == HTMLTokenizer::DataState); |
684 | 684 |
685 ASSERT(m_preloader); | 685 ASSERT(m_preloader); |
686 // TODO(kouhei): m_preloader should be always available for synchronous
parsing case, | 686 // TODO(kouhei): m_preloader should be always available for synchronous
parsing case, |
687 // adding paranoia if for speculative crash fix for crbug.com/465478 | 687 // adding paranoia if for speculative crash fix for crbug.com/465478 |
688 if (m_preloader) { | 688 if (m_preloader) { |
689 if (!m_preloadScanner) { | 689 if (!m_preloadScanner) { |
690 m_preloadScanner = adoptPtr(new HTMLPreloadScanner(m_options, | 690 m_preloadScanner = HTMLPreloadScanner::create( |
| 691 m_options, |
691 document()->url(), | 692 document()->url(), |
692 CachedDocumentParameters::create(document()))); | 693 CachedDocumentParameters::create(document()), |
| 694 MediaValuesCached::MediaValuesCachedData(*document())); |
693 m_preloadScanner->appendToEnd(m_input.current()); | 695 m_preloadScanner->appendToEnd(m_input.current()); |
694 } | 696 } |
695 m_preloadScanner->scan(m_preloader.get(), document()->baseElementURL
()); | 697 m_preloadScanner->scan(m_preloader.get(), document()->baseElementURL
()); |
696 } | 698 } |
697 } | 699 } |
698 | 700 |
699 TRACE_EVENT_END1("devtools.timeline", "ParseHTML", "endData", InspectorParse
HtmlEvent::endData(m_input.current().currentLine().zeroBasedInt() - 1)); | 701 TRACE_EVENT_END1("devtools.timeline", "ParseHTML", "endData", InspectorParse
HtmlEvent::endData(m_input.current().currentLine().zeroBasedInt() - 1)); |
700 } | 702 } |
701 | 703 |
702 void HTMLDocumentParser::constructTreeFromHTMLToken() | 704 void HTMLDocumentParser::constructTreeFromHTMLToken() |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
764 | 766 |
765 SegmentedString excludedLineNumberSource(source); | 767 SegmentedString excludedLineNumberSource(source); |
766 excludedLineNumberSource.setExcludeLineNumbers(); | 768 excludedLineNumberSource.setExcludeLineNumbers(); |
767 m_input.insertAtCurrentInsertionPoint(excludedLineNumberSource); | 769 m_input.insertAtCurrentInsertionPoint(excludedLineNumberSource); |
768 pumpTokenizerIfPossible(); | 770 pumpTokenizerIfPossible(); |
769 | 771 |
770 if (isWaitingForScripts()) { | 772 if (isWaitingForScripts()) { |
771 // Check the document.write() output with a separate preload scanner as | 773 // Check the document.write() output with a separate preload scanner as |
772 // the main scanner can't deal with insertions. | 774 // the main scanner can't deal with insertions. |
773 if (!m_insertionPreloadScanner) { | 775 if (!m_insertionPreloadScanner) { |
774 m_insertionPreloadScanner = adoptPtr(new HTMLPreloadScanner(m_option
s, | 776 m_insertionPreloadScanner = HTMLPreloadScanner::create( |
| 777 m_options, |
775 document()->url(), | 778 document()->url(), |
776 CachedDocumentParameters::create(document()))); | 779 CachedDocumentParameters::create(document()), |
| 780 MediaValuesCached::MediaValuesCachedData(*document())); |
777 } | 781 } |
778 | 782 |
779 m_insertionPreloadScanner->appendToEnd(source); | 783 m_insertionPreloadScanner->appendToEnd(source); |
780 m_insertionPreloadScanner->scan(m_preloader.get(), document()->baseEleme
ntURL()); | 784 m_insertionPreloadScanner->scan(m_preloader.get(), document()->baseEleme
ntURL()); |
781 } | 785 } |
782 | 786 |
783 endIfDelayed(); | 787 endIfDelayed(); |
784 } | 788 } |
785 | 789 |
786 void HTMLDocumentParser::startBackgroundParser() | 790 void HTMLDocumentParser::startBackgroundParser() |
(...skipping 16 matching lines...) Expand all Loading... |
803 if (DocumentLoader* loader = document()->loader()) | 807 if (DocumentLoader* loader = document()->loader()) |
804 loader->attachThreadedDataReceiver(ParserDataReceiver::create(m_back
groundParser, document()->contextDocument().get())); | 808 loader->attachThreadedDataReceiver(ParserDataReceiver::create(m_back
groundParser, document()->contextDocument().get())); |
805 } | 809 } |
806 | 810 |
807 OwnPtr<BackgroundHTMLParser::Configuration> config = adoptPtr(new Background
HTMLParser::Configuration); | 811 OwnPtr<BackgroundHTMLParser::Configuration> config = adoptPtr(new Background
HTMLParser::Configuration); |
808 config->options = m_options; | 812 config->options = m_options; |
809 config->parser = m_weakFactory.createWeakPtr(); | 813 config->parser = m_weakFactory.createWeakPtr(); |
810 config->xssAuditor = adoptPtr(new XSSAuditor); | 814 config->xssAuditor = adoptPtr(new XSSAuditor); |
811 config->xssAuditor->init(document(), &m_xssAuditorDelegate); | 815 config->xssAuditor->init(document(), &m_xssAuditorDelegate); |
812 | 816 |
813 config->preloadScanner = adoptPtr(new TokenPreloadScanner(document()->url().
copy(), CachedDocumentParameters::create(document()))); | |
814 config->decoder = takeDecoder(); | 817 config->decoder = takeDecoder(); |
815 config->parsedChunkQueue = m_parsedChunkQueue.get(); | 818 config->parsedChunkQueue = m_parsedChunkQueue.get(); |
816 if (document()->settings()) { | 819 if (document()->settings()) { |
817 if (document()->settings()->backgroundHtmlParserOutstandingTokenLimit()) | 820 if (document()->settings()->backgroundHtmlParserOutstandingTokenLimit()) |
818 config->outstandingTokenLimit = document()->settings()->backgroundHt
mlParserOutstandingTokenLimit(); | 821 config->outstandingTokenLimit = document()->settings()->backgroundHt
mlParserOutstandingTokenLimit(); |
819 if (document()->settings()->backgroundHtmlParserPendingTokenLimit()) | 822 if (document()->settings()->backgroundHtmlParserPendingTokenLimit()) |
820 config->pendingTokenLimit = document()->settings()->backgroundHtmlPa
rserPendingTokenLimit(); | 823 config->pendingTokenLimit = document()->settings()->backgroundHtmlPa
rserPendingTokenLimit(); |
821 } | 824 } |
822 | 825 |
823 ASSERT(config->xssAuditor->isSafeToSendToAnotherThread()); | 826 ASSERT(config->xssAuditor->isSafeToSendToAnotherThread()); |
824 ASSERT(config->preloadScanner->isSafeToSendToAnotherThread()); | 827 HTMLParserThread::shared()->postTask(threadSafeBind( |
825 HTMLParserThread::shared()->postTask(threadSafeBind(&BackgroundHTMLParser::s
tart, reference.release(), config.release(), | 828 &BackgroundHTMLParser::start, |
| 829 reference.release(), |
| 830 config.release(), |
| 831 document()->url(), |
| 832 CachedDocumentParameters::create(document()), |
| 833 MediaValuesCached::MediaValuesCachedData(*document()), |
826 adoptPtr(m_loadingTaskRunner->clone()))); | 834 adoptPtr(m_loadingTaskRunner->clone()))); |
827 } | 835 } |
828 | 836 |
829 void HTMLDocumentParser::stopBackgroundParser() | 837 void HTMLDocumentParser::stopBackgroundParser() |
830 { | 838 { |
831 ASSERT(shouldUseThreading()); | 839 ASSERT(shouldUseThreading()); |
832 ASSERT(m_haveBackgroundParser); | 840 ASSERT(m_haveBackgroundParser); |
833 m_haveBackgroundParser = false; | 841 m_haveBackgroundParser = false; |
834 | 842 |
835 HTMLParserThread::shared()->postTask(threadSafeBind(&BackgroundHTMLParser::s
top, AllowCrossThreadAccess(m_backgroundParser))); | 843 HTMLParserThread::shared()->postTask(threadSafeBind(&BackgroundHTMLParser::s
top, AllowCrossThreadAccess(m_backgroundParser))); |
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1155 void HTMLDocumentParser::setDecoder(PassOwnPtr<TextResourceDecoder> decoder) | 1163 void HTMLDocumentParser::setDecoder(PassOwnPtr<TextResourceDecoder> decoder) |
1156 { | 1164 { |
1157 ASSERT(decoder); | 1165 ASSERT(decoder); |
1158 DecodedDataDocumentParser::setDecoder(decoder); | 1166 DecodedDataDocumentParser::setDecoder(decoder); |
1159 | 1167 |
1160 if (m_haveBackgroundParser) | 1168 if (m_haveBackgroundParser) |
1161 HTMLParserThread::shared()->postTask(threadSafeBind(&BackgroundHTMLParse
r::setDecoder, AllowCrossThreadAccess(m_backgroundParser), takeDecoder())); | 1169 HTMLParserThread::shared()->postTask(threadSafeBind(&BackgroundHTMLParse
r::setDecoder, AllowCrossThreadAccess(m_backgroundParser), takeDecoder())); |
1162 } | 1170 } |
1163 | 1171 |
1164 } // namespace blink | 1172 } // namespace blink |
OLD | NEW |