Chromium Code Reviews| 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 14 matching lines...) Expand all Loading... | |
| 25 | 25 |
| 26 #include "config.h" | 26 #include "config.h" |
| 27 #include "core/html/parser/HTMLDocumentParser.h" | 27 #include "core/html/parser/HTMLDocumentParser.h" |
| 28 | 28 |
| 29 #include "core/HTMLNames.h" | 29 #include "core/HTMLNames.h" |
| 30 #include "core/css/MediaValuesCached.h" | 30 #include "core/css/MediaValuesCached.h" |
| 31 #include "core/dom/DocumentFragment.h" | 31 #include "core/dom/DocumentFragment.h" |
| 32 #include "core/dom/DocumentLifecycleObserver.h" | 32 #include "core/dom/DocumentLifecycleObserver.h" |
| 33 #include "core/dom/Element.h" | 33 #include "core/dom/Element.h" |
| 34 #include "core/frame/LocalFrame.h" | 34 #include "core/frame/LocalFrame.h" |
| 35 #include "core/frame/Settings.h" | |
| 35 #include "core/html/HTMLDocument.h" | 36 #include "core/html/HTMLDocument.h" |
| 36 #include "core/html/parser/AtomicHTMLToken.h" | 37 #include "core/html/parser/AtomicHTMLToken.h" |
| 37 #include "core/html/parser/BackgroundHTMLParser.h" | 38 #include "core/html/parser/BackgroundHTMLParser.h" |
| 38 #include "core/html/parser/HTMLParserScheduler.h" | 39 #include "core/html/parser/HTMLParserScheduler.h" |
| 39 #include "core/html/parser/HTMLParserThread.h" | 40 #include "core/html/parser/HTMLParserThread.h" |
| 40 #include "core/html/parser/HTMLScriptRunner.h" | 41 #include "core/html/parser/HTMLScriptRunner.h" |
| 41 #include "core/html/parser/HTMLTreeBuilder.h" | 42 #include "core/html/parser/HTMLTreeBuilder.h" |
| 42 #include "core/inspector/InspectorInstrumentation.h" | 43 #include "core/inspector/InspectorInstrumentation.h" |
| 43 #include "core/inspector/InspectorTraceEvents.h" | 44 #include "core/inspector/InspectorTraceEvents.h" |
| 44 #include "core/loader/DocumentLoader.h" | 45 #include "core/loader/DocumentLoader.h" |
| (...skipping 618 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 663 RELEASE_ASSERT(!isStopped()); | 664 RELEASE_ASSERT(!isStopped()); |
| 664 | 665 |
| 665 if (isWaitingForScripts()) { | 666 if (isWaitingForScripts()) { |
| 666 ASSERT(m_tokenizer->state() == HTMLTokenizer::DataState); | 667 ASSERT(m_tokenizer->state() == HTMLTokenizer::DataState); |
| 667 | 668 |
| 668 ASSERT(m_preloader); | 669 ASSERT(m_preloader); |
| 669 // TODO(kouhei): m_preloader should be always available for synchronous parsing case, | 670 // TODO(kouhei): m_preloader should be always available for synchronous parsing case, |
| 670 // adding paranoia if for speculative crash fix for crbug.com/465478 | 671 // adding paranoia if for speculative crash fix for crbug.com/465478 |
| 671 if (m_preloader) { | 672 if (m_preloader) { |
| 672 if (!m_preloadScanner) { | 673 if (!m_preloadScanner) { |
| 673 m_preloadScanner = adoptPtr(new HTMLPreloadScanner(m_options, do cument()->url(), createMediaValues(document()))); | 674 m_preloadScanner = adoptPtr(new HTMLPreloadScanner(m_options, |
| 675 document()->url(), | |
| 676 createMediaValues(document()), | |
| 677 document()->viewportDefaultMinWidth(), | |
| 678 document()->settings() && document()->settings()->viewportMe taZeroValuesQuirk())); | |
|
kouhei (in TOK)
2015/04/30 12:45:39
Can these 3 parameters be made a struct? with a he
| |
| 674 m_preloadScanner->appendToEnd(m_input.current()); | 679 m_preloadScanner->appendToEnd(m_input.current()); |
| 675 } | 680 } |
| 676 m_preloadScanner->scan(m_preloader.get(), document()->baseElementURL ()); | 681 m_preloadScanner->scan(m_preloader.get(), document()->baseElementURL ()); |
| 677 } | 682 } |
| 678 } | 683 } |
| 679 | 684 |
| 680 TRACE_EVENT_END1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "ParseHTML" , "endData", InspectorParseHtmlEvent::endData(m_input.current().currentLine().ze roBasedInt() - 1)); | 685 TRACE_EVENT_END1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "ParseHTML" , "endData", InspectorParseHtmlEvent::endData(m_input.current().currentLine().ze roBasedInt() - 1)); |
| 681 } | 686 } |
| 682 | 687 |
| 683 void HTMLDocumentParser::constructTreeFromHTMLToken() | 688 void HTMLDocumentParser::constructTreeFromHTMLToken() |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 744 } | 749 } |
| 745 | 750 |
| 746 SegmentedString excludedLineNumberSource(source); | 751 SegmentedString excludedLineNumberSource(source); |
| 747 excludedLineNumberSource.setExcludeLineNumbers(); | 752 excludedLineNumberSource.setExcludeLineNumbers(); |
| 748 m_input.insertAtCurrentInsertionPoint(excludedLineNumberSource); | 753 m_input.insertAtCurrentInsertionPoint(excludedLineNumberSource); |
| 749 pumpTokenizerIfPossible(); | 754 pumpTokenizerIfPossible(); |
| 750 | 755 |
| 751 if (isWaitingForScripts()) { | 756 if (isWaitingForScripts()) { |
| 752 // Check the document.write() output with a separate preload scanner as | 757 // Check the document.write() output with a separate preload scanner as |
| 753 // the main scanner can't deal with insertions. | 758 // the main scanner can't deal with insertions. |
| 754 if (!m_insertionPreloadScanner) | 759 if (!m_insertionPreloadScanner) { |
| 755 m_insertionPreloadScanner = adoptPtr(new HTMLPreloadScanner(m_option s, document()->url(), createMediaValues(document()))); | 760 m_insertionPreloadScanner = adoptPtr(new HTMLPreloadScanner(m_option s, |
| 761 document()->url(), | |
| 762 createMediaValues(document()), | |
| 763 document()->viewportDefaultMinWidth(), | |
| 764 document()->settings() && document()->settings()->viewportMetaZe roValuesQuirk())); | |
| 765 } | |
| 756 | 766 |
| 757 m_insertionPreloadScanner->appendToEnd(source); | 767 m_insertionPreloadScanner->appendToEnd(source); |
| 758 m_insertionPreloadScanner->scan(m_preloader.get(), document()->baseEleme ntURL()); | 768 m_insertionPreloadScanner->scan(m_preloader.get(), document()->baseEleme ntURL()); |
| 759 } | 769 } |
| 760 | 770 |
| 761 endIfDelayed(); | 771 endIfDelayed(); |
| 762 } | 772 } |
| 763 | 773 |
| 764 void HTMLDocumentParser::startBackgroundParser() | 774 void HTMLDocumentParser::startBackgroundParser() |
| 765 { | 775 { |
| 766 ASSERT(!isStopped()); | 776 ASSERT(!isStopped()); |
| 767 ASSERT(shouldUseThreading()); | 777 ASSERT(shouldUseThreading()); |
| 768 ASSERT(!m_haveBackgroundParser); | 778 ASSERT(!m_haveBackgroundParser); |
| 779 ASSERT(document()); | |
| 769 m_haveBackgroundParser = true; | 780 m_haveBackgroundParser = true; |
| 770 | 781 |
| 771 RefPtr<WeakReference<BackgroundHTMLParser>> reference = WeakReference<Backgr oundHTMLParser>::createUnbound(); | 782 RefPtr<WeakReference<BackgroundHTMLParser>> reference = WeakReference<Backgr oundHTMLParser>::createUnbound(); |
| 772 m_backgroundParser = WeakPtr<BackgroundHTMLParser>(reference); | 783 m_backgroundParser = WeakPtr<BackgroundHTMLParser>(reference); |
| 773 | 784 |
| 774 // FIXME(oysteine): Disabled due to crbug.com/398076 until a full fix can be implemented. | 785 // FIXME(oysteine): Disabled due to crbug.com/398076 until a full fix can be implemented. |
| 775 if (RuntimeEnabledFeatures::threadedParserDataReceiverEnabled()) { | 786 if (RuntimeEnabledFeatures::threadedParserDataReceiverEnabled()) { |
| 776 if (DocumentLoader* loader = document()->loader()) | 787 if (DocumentLoader* loader = document()->loader()) |
| 777 loader->attachThreadedDataReceiver(ParserDataReceiver::create(m_back groundParser, document()->contextDocument().get())); | 788 loader->attachThreadedDataReceiver(ParserDataReceiver::create(m_back groundParser, document()->contextDocument().get())); |
| 778 } | 789 } |
| 779 | 790 |
| 780 OwnPtr<BackgroundHTMLParser::Configuration> config = adoptPtr(new Background HTMLParser::Configuration); | 791 OwnPtr<BackgroundHTMLParser::Configuration> config = adoptPtr(new Background HTMLParser::Configuration); |
| 781 config->options = m_options; | 792 config->options = m_options; |
| 782 config->parser = m_weakFactory.createWeakPtr(); | 793 config->parser = m_weakFactory.createWeakPtr(); |
| 783 config->xssAuditor = adoptPtr(new XSSAuditor); | 794 config->xssAuditor = adoptPtr(new XSSAuditor); |
| 784 config->xssAuditor->init(document(), &m_xssAuditorDelegate); | 795 config->xssAuditor->init(document(), &m_xssAuditorDelegate); |
| 785 config->preloadScanner = adoptPtr(new TokenPreloadScanner(document()->url(). copy(), createMediaValues(document()))); | 796 config->preloadScanner = adoptPtr(new TokenPreloadScanner(document()->url(). copy(), |
| 797 createMediaValues(document()), | |
| 798 document()->viewportDefaultMinWidth(), | |
| 799 document()->settings() && document()->settings()->viewportMetaZeroValues Quirk())); | |
| 786 config->decoder = takeDecoder(); | 800 config->decoder = takeDecoder(); |
| 787 | 801 |
| 788 ASSERT(config->xssAuditor->isSafeToSendToAnotherThread()); | 802 ASSERT(config->xssAuditor->isSafeToSendToAnotherThread()); |
| 789 ASSERT(config->preloadScanner->isSafeToSendToAnotherThread()); | 803 ASSERT(config->preloadScanner->isSafeToSendToAnotherThread()); |
| 790 HTMLParserThread::shared()->postTask(threadSafeBind(&BackgroundHTMLParser::s tart, reference.release(), config.release(), | 804 HTMLParserThread::shared()->postTask(threadSafeBind(&BackgroundHTMLParser::s tart, reference.release(), config.release(), |
| 791 AllowCrossThreadAccess(Platform::current()->currentThread()->scheduler() ))); | 805 AllowCrossThreadAccess(Platform::current()->currentThread()->scheduler() ))); |
| 792 } | 806 } |
| 793 | 807 |
| 794 void HTMLDocumentParser::stopBackgroundParser() | 808 void HTMLDocumentParser::stopBackgroundParser() |
| 795 { | 809 { |
| (...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1109 void HTMLDocumentParser::setDecoder(PassOwnPtr<TextResourceDecoder> decoder) | 1123 void HTMLDocumentParser::setDecoder(PassOwnPtr<TextResourceDecoder> decoder) |
| 1110 { | 1124 { |
| 1111 ASSERT(decoder); | 1125 ASSERT(decoder); |
| 1112 DecodedDataDocumentParser::setDecoder(decoder); | 1126 DecodedDataDocumentParser::setDecoder(decoder); |
| 1113 | 1127 |
| 1114 if (m_haveBackgroundParser) | 1128 if (m_haveBackgroundParser) |
| 1115 HTMLParserThread::shared()->postTask(threadSafeBind(&BackgroundHTMLParse r::setDecoder, AllowCrossThreadAccess(m_backgroundParser), takeDecoder())); | 1129 HTMLParserThread::shared()->postTask(threadSafeBind(&BackgroundHTMLParse r::setDecoder, AllowCrossThreadAccess(m_backgroundParser), takeDecoder())); |
| 1116 } | 1130 } |
| 1117 | 1131 |
| 1118 } | 1132 } |
| OLD | NEW |