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 20 matching lines...) Expand all Loading... | |
31 #include "core/dom/Element.h" | 31 #include "core/dom/Element.h" |
32 #include "core/frame/LocalFrame.h" | 32 #include "core/frame/LocalFrame.h" |
33 #include "core/html/HTMLDocument.h" | 33 #include "core/html/HTMLDocument.h" |
34 #include "core/html/parser/AtomicHTMLToken.h" | 34 #include "core/html/parser/AtomicHTMLToken.h" |
35 #include "core/html/parser/BackgroundHTMLParser.h" | 35 #include "core/html/parser/BackgroundHTMLParser.h" |
36 #include "core/html/parser/HTMLParserScheduler.h" | 36 #include "core/html/parser/HTMLParserScheduler.h" |
37 #include "core/html/parser/HTMLParserThread.h" | 37 #include "core/html/parser/HTMLParserThread.h" |
38 #include "core/html/parser/HTMLScriptRunner.h" | 38 #include "core/html/parser/HTMLScriptRunner.h" |
39 #include "core/html/parser/HTMLTreeBuilder.h" | 39 #include "core/html/parser/HTMLTreeBuilder.h" |
40 #include "core/inspector/InspectorInstrumentation.h" | 40 #include "core/inspector/InspectorInstrumentation.h" |
41 #include "core/loader/DocumentLoader.h" | |
41 #include "platform/SharedBuffer.h" | 42 #include "platform/SharedBuffer.h" |
42 #include "platform/TraceEvent.h" | 43 #include "platform/TraceEvent.h" |
44 #include "public/platform/WebThreadedDataReceiver.h" | |
43 #include "wtf/Functional.h" | 45 #include "wtf/Functional.h" |
44 | 46 |
45 namespace WebCore { | 47 namespace WebCore { |
46 | 48 |
47 using namespace HTMLNames; | 49 using namespace HTMLNames; |
48 | 50 |
49 // This is a direct transcription of step 4 from: | 51 // This is a direct transcription of step 4 from: |
50 // http://www.whatwg.org/specs/web-apps/current-work/multipage/the-end.html#frag ment-case | 52 // http://www.whatwg.org/specs/web-apps/current-work/multipage/the-end.html#frag ment-case |
51 static HTMLTokenizer::State tokenizerStateForContextElement(Element* contextElem ent, bool reportErrors, const HTMLParserOptions& options) | 53 static HTMLTokenizer::State tokenizerStateForContextElement(Element* contextElem ent, bool reportErrors, const HTMLParserOptions& options) |
52 { | 54 { |
(...skipping 11 matching lines...) Expand all Loading... | |
64 || (contextTag.matches(noscriptTag) && options.scriptEnabled) | 66 || (contextTag.matches(noscriptTag) && options.scriptEnabled) |
65 || contextTag.matches(noframesTag)) | 67 || contextTag.matches(noframesTag)) |
66 return reportErrors ? HTMLTokenizer::RAWTEXTState : HTMLTokenizer::PLAIN TEXTState; | 68 return reportErrors ? HTMLTokenizer::RAWTEXTState : HTMLTokenizer::PLAIN TEXTState; |
67 if (contextTag.matches(scriptTag)) | 69 if (contextTag.matches(scriptTag)) |
68 return reportErrors ? HTMLTokenizer::ScriptDataState : HTMLTokenizer::PL AINTEXTState; | 70 return reportErrors ? HTMLTokenizer::ScriptDataState : HTMLTokenizer::PL AINTEXTState; |
69 if (contextTag.matches(plaintextTag)) | 71 if (contextTag.matches(plaintextTag)) |
70 return HTMLTokenizer::PLAINTEXTState; | 72 return HTMLTokenizer::PLAINTEXTState; |
71 return HTMLTokenizer::DataState; | 73 return HTMLTokenizer::DataState; |
72 } | 74 } |
73 | 75 |
76 class ParserDataReceiver : public blink::WebThreadedDataReceiver { | |
77 public: | |
78 ParserDataReceiver(WeakPtr<BackgroundHTMLParser> backgroundParser) | |
abarth-chromium
2014/03/10 21:52:20
Please make one-argument constructors explicit.
oystein (OOO til 10th of July)
2014/03/17 21:19:11
Done.
| |
79 : m_backgroundParser(backgroundParser) | |
80 { | |
81 } | |
82 | |
83 // WebThreadedDataReceiver | |
84 virtual void acceptData(const char* data, int dataLength) OVERRIDE FINAL | |
85 { | |
86 ASSERT(backgroundThread()->isCurrentThread()); | |
87 if (m_backgroundParser.get()) | |
88 m_backgroundParser.get()->acceptData(data, dataLength); | |
89 } | |
90 | |
91 virtual blink::WebThread* backgroundThread() OVERRIDE FINAL | |
92 { | |
93 return &HTMLParserThread::shared()->ensureThread(); | |
94 } | |
95 | |
96 private: | |
97 WeakPtr<BackgroundHTMLParser> m_backgroundParser; | |
98 }; | |
99 | |
74 HTMLDocumentParser::HTMLDocumentParser(HTMLDocument* document, bool reportErrors ) | 100 HTMLDocumentParser::HTMLDocumentParser(HTMLDocument* document, bool reportErrors ) |
75 : ScriptableDocumentParser(document) | 101 : ScriptableDocumentParser(document) |
76 , m_options(document) | 102 , m_options(document) |
77 , m_token(m_options.useThreading ? nullptr : adoptPtr(new HTMLToken)) | 103 , m_token(m_options.useThreading ? nullptr : adoptPtr(new HTMLToken)) |
78 , m_tokenizer(m_options.useThreading ? nullptr : HTMLTokenizer::create(m_opt ions)) | 104 , m_tokenizer(m_options.useThreading ? nullptr : HTMLTokenizer::create(m_opt ions)) |
79 , m_scriptRunner(HTMLScriptRunner::create(document, this)) | 105 , m_scriptRunner(HTMLScriptRunner::create(document, this)) |
80 , m_treeBuilder(HTMLTreeBuilder::create(this, document, parserContentPolicy( ), reportErrors, m_options)) | 106 , m_treeBuilder(HTMLTreeBuilder::create(this, document, parserContentPolicy( ), reportErrors, m_options)) |
81 , m_parserScheduler(HTMLParserScheduler::create(this)) | 107 , m_parserScheduler(HTMLParserScheduler::create(this)) |
82 , m_xssAuditorDelegate(document) | 108 , m_xssAuditorDelegate(document) |
83 , m_weakFactory(this) | 109 , m_weakFactory(this) |
(...skipping 576 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
660 void HTMLDocumentParser::startBackgroundParser() | 686 void HTMLDocumentParser::startBackgroundParser() |
661 { | 687 { |
662 ASSERT(!isStopped()); | 688 ASSERT(!isStopped()); |
663 ASSERT(shouldUseThreading()); | 689 ASSERT(shouldUseThreading()); |
664 ASSERT(!m_haveBackgroundParser); | 690 ASSERT(!m_haveBackgroundParser); |
665 m_haveBackgroundParser = true; | 691 m_haveBackgroundParser = true; |
666 | 692 |
667 RefPtr<WeakReference<BackgroundHTMLParser> > reference = WeakReference<Backg roundHTMLParser>::createUnbound(); | 693 RefPtr<WeakReference<BackgroundHTMLParser> > reference = WeakReference<Backg roundHTMLParser>::createUnbound(); |
668 m_backgroundParser = WeakPtr<BackgroundHTMLParser>(reference); | 694 m_backgroundParser = WeakPtr<BackgroundHTMLParser>(reference); |
669 | 695 |
696 document()->loader()->attachThreadedDataReceiver(new ParserDataReceiver(m_ba ckgroundParser)); | |
abarth-chromium
2014/03/10 21:52:20
adoptPtr(new ParserDataReceiver(...
oystein (OOO til 10th of July)
2014/03/17 21:19:11
Done.
| |
697 | |
670 OwnPtr<BackgroundHTMLParser::Configuration> config = adoptPtr(new Background HTMLParser::Configuration); | 698 OwnPtr<BackgroundHTMLParser::Configuration> config = adoptPtr(new Background HTMLParser::Configuration); |
671 config->options = m_options; | 699 config->options = m_options; |
672 config->parser = m_weakFactory.createWeakPtr(); | 700 config->parser = m_weakFactory.createWeakPtr(); |
673 config->xssAuditor = adoptPtr(new XSSAuditor); | 701 config->xssAuditor = adoptPtr(new XSSAuditor); |
674 config->xssAuditor->init(document(), &m_xssAuditorDelegate); | 702 config->xssAuditor->init(document(), &m_xssAuditorDelegate); |
675 config->preloadScanner = adoptPtr(new TokenPreloadScanner(document()->url(). copy(), document()->devicePixelRatio())); | 703 config->preloadScanner = adoptPtr(new TokenPreloadScanner(document()->url(). copy(), document()->devicePixelRatio())); |
676 config->decoder = takeDecoder(); | 704 config->decoder = takeDecoder(); |
677 | 705 |
678 ASSERT(config->xssAuditor->isSafeToSendToAnotherThread()); | 706 ASSERT(config->xssAuditor->isSafeToSendToAnotherThread()); |
679 ASSERT(config->preloadScanner->isSafeToSendToAnotherThread()); | 707 ASSERT(config->preloadScanner->isSafeToSendToAnotherThread()); |
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
998 void HTMLDocumentParser::setDecoder(PassOwnPtr<TextResourceDecoder> decoder) | 1026 void HTMLDocumentParser::setDecoder(PassOwnPtr<TextResourceDecoder> decoder) |
999 { | 1027 { |
1000 ASSERT(decoder); | 1028 ASSERT(decoder); |
1001 DecodedDataDocumentParser::setDecoder(decoder); | 1029 DecodedDataDocumentParser::setDecoder(decoder); |
1002 | 1030 |
1003 if (m_haveBackgroundParser) | 1031 if (m_haveBackgroundParser) |
1004 HTMLParserThread::shared()->postTask(bind(&BackgroundHTMLParser::setDeco der, m_backgroundParser, takeDecoder())); | 1032 HTMLParserThread::shared()->postTask(bind(&BackgroundHTMLParser::setDeco der, m_backgroundParser, takeDecoder())); |
1005 } | 1033 } |
1006 | 1034 |
1007 } | 1035 } |
OLD | NEW |