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 10 matching lines...) Expand all Loading... |
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
24 */ | 24 */ |
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/css/resolver/StyleResolver.h" |
31 #include "core/dom/DocumentFragment.h" | 32 #include "core/dom/DocumentFragment.h" |
32 #include "core/dom/DocumentLifecycleObserver.h" | 33 #include "core/dom/DocumentLifecycleObserver.h" |
33 #include "core/dom/Element.h" | 34 #include "core/dom/Element.h" |
34 #include "core/frame/LocalFrame.h" | 35 #include "core/frame/LocalFrame.h" |
35 #include "core/frame/Settings.h" | 36 #include "core/frame/Settings.h" |
36 #include "core/html/HTMLDocument.h" | 37 #include "core/html/HTMLDocument.h" |
37 #include "core/html/parser/AtomicHTMLToken.h" | 38 #include "core/html/parser/AtomicHTMLToken.h" |
38 #include "core/html/parser/BackgroundHTMLParser.h" | 39 #include "core/html/parser/BackgroundHTMLParser.h" |
39 #include "core/html/parser/HTMLParserScheduler.h" | 40 #include "core/html/parser/HTMLParserScheduler.h" |
40 #include "core/html/parser/HTMLParserThread.h" | 41 #include "core/html/parser/HTMLParserThread.h" |
(...skipping 730 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
771 } | 772 } |
772 | 773 |
773 void HTMLDocumentParser::startBackgroundParser() | 774 void HTMLDocumentParser::startBackgroundParser() |
774 { | 775 { |
775 ASSERT(!isStopped()); | 776 ASSERT(!isStopped()); |
776 ASSERT(shouldUseThreading()); | 777 ASSERT(shouldUseThreading()); |
777 ASSERT(!m_haveBackgroundParser); | 778 ASSERT(!m_haveBackgroundParser); |
778 ASSERT(document()); | 779 ASSERT(document()); |
779 m_haveBackgroundParser = true; | 780 m_haveBackgroundParser = true; |
780 | 781 |
| 782 // Make sure that a resolver is set up, so that the correct viewport dimensi
ons will be fed to the background parser and preload scanner. |
| 783 if (document()->loader()) |
| 784 document()->ensureStyleResolver(); |
| 785 |
781 RefPtr<WeakReference<BackgroundHTMLParser>> reference = WeakReference<Backgr
oundHTMLParser>::createUnbound(); | 786 RefPtr<WeakReference<BackgroundHTMLParser>> reference = WeakReference<Backgr
oundHTMLParser>::createUnbound(); |
782 m_backgroundParser = WeakPtr<BackgroundHTMLParser>(reference); | 787 m_backgroundParser = WeakPtr<BackgroundHTMLParser>(reference); |
783 | 788 |
784 // FIXME(oysteine): Disabled due to crbug.com/398076 until a full fix can be
implemented. | 789 // FIXME(oysteine): Disabled due to crbug.com/398076 until a full fix can be
implemented. |
785 if (RuntimeEnabledFeatures::threadedParserDataReceiverEnabled()) { | 790 if (RuntimeEnabledFeatures::threadedParserDataReceiverEnabled()) { |
786 if (DocumentLoader* loader = document()->loader()) | 791 if (DocumentLoader* loader = document()->loader()) |
787 loader->attachThreadedDataReceiver(ParserDataReceiver::create(m_back
groundParser, document()->contextDocument().get())); | 792 loader->attachThreadedDataReceiver(ParserDataReceiver::create(m_back
groundParser, document()->contextDocument().get())); |
788 } | 793 } |
789 | 794 |
790 OwnPtr<BackgroundHTMLParser::Configuration> config = adoptPtr(new Background
HTMLParser::Configuration); | 795 OwnPtr<BackgroundHTMLParser::Configuration> config = adoptPtr(new Background
HTMLParser::Configuration); |
791 config->options = m_options; | 796 config->options = m_options; |
792 config->parser = m_weakFactory.createWeakPtr(); | 797 config->parser = m_weakFactory.createWeakPtr(); |
793 config->xssAuditor = adoptPtr(new XSSAuditor); | 798 config->xssAuditor = adoptPtr(new XSSAuditor); |
794 config->xssAuditor->init(document(), &m_xssAuditorDelegate); | 799 config->xssAuditor->init(document(), &m_xssAuditorDelegate); |
| 800 |
795 config->preloadScanner = adoptPtr(new TokenPreloadScanner(document()->url().
copy(), CachedDocumentParameters::create(document()))); | 801 config->preloadScanner = adoptPtr(new TokenPreloadScanner(document()->url().
copy(), CachedDocumentParameters::create(document()))); |
796 config->decoder = takeDecoder(); | 802 config->decoder = takeDecoder(); |
797 if (document()->settings()) { | 803 if (document()->settings()) { |
798 if (document()->settings()->backgroundHtmlParserOutstandingTokenLimit()) | 804 if (document()->settings()->backgroundHtmlParserOutstandingTokenLimit()) |
799 config->outstandingTokenLimit = document()->settings()->backgroundHt
mlParserOutstandingTokenLimit(); | 805 config->outstandingTokenLimit = document()->settings()->backgroundHt
mlParserOutstandingTokenLimit(); |
800 if (document()->settings()->backgroundHtmlParserPendingTokenLimit()) | 806 if (document()->settings()->backgroundHtmlParserPendingTokenLimit()) |
801 config->pendingTokenLimit = document()->settings()->backgroundHtmlPa
rserPendingTokenLimit(); | 807 config->pendingTokenLimit = document()->settings()->backgroundHtmlPa
rserPendingTokenLimit(); |
802 } | 808 } |
803 | 809 |
804 ASSERT(config->xssAuditor->isSafeToSendToAnotherThread()); | 810 ASSERT(config->xssAuditor->isSafeToSendToAnotherThread()); |
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1136 void HTMLDocumentParser::setDecoder(PassOwnPtr<TextResourceDecoder> decoder) | 1142 void HTMLDocumentParser::setDecoder(PassOwnPtr<TextResourceDecoder> decoder) |
1137 { | 1143 { |
1138 ASSERT(decoder); | 1144 ASSERT(decoder); |
1139 DecodedDataDocumentParser::setDecoder(decoder); | 1145 DecodedDataDocumentParser::setDecoder(decoder); |
1140 | 1146 |
1141 if (m_haveBackgroundParser) | 1147 if (m_haveBackgroundParser) |
1142 HTMLParserThread::shared()->postTask(threadSafeBind(&BackgroundHTMLParse
r::setDecoder, AllowCrossThreadAccess(m_backgroundParser), takeDecoder())); | 1148 HTMLParserThread::shared()->postTask(threadSafeBind(&BackgroundHTMLParse
r::setDecoder, AllowCrossThreadAccess(m_backgroundParser), takeDecoder())); |
1143 } | 1149 } |
1144 | 1150 |
1145 } | 1151 } |
OLD | NEW |