| 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 |
| 11 * documentation and/or other materials provided with the distribution. | 11 * documentation and/or other materials provided with the distribution. |
| 12 * | 12 * |
| 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY | 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY |
| 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
| 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR | 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR |
| 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
| 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
| 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
| 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 "HTMLNames.h" | 29 #include "HTMLNames.h" |
| 30 #include "core/css/MediaValues.h" |
| 30 #include "core/dom/DocumentFragment.h" | 31 #include "core/dom/DocumentFragment.h" |
| 31 #include "core/dom/Element.h" | 32 #include "core/dom/Element.h" |
| 32 #include "core/frame/LocalFrame.h" | 33 #include "core/frame/LocalFrame.h" |
| 33 #include "core/html/HTMLDocument.h" | 34 #include "core/html/HTMLDocument.h" |
| 34 #include "core/html/parser/AtomicHTMLToken.h" | 35 #include "core/html/parser/AtomicHTMLToken.h" |
| 35 #include "core/html/parser/BackgroundHTMLParser.h" | 36 #include "core/html/parser/BackgroundHTMLParser.h" |
| 36 #include "core/html/parser/HTMLParserScheduler.h" | 37 #include "core/html/parser/HTMLParserScheduler.h" |
| 37 #include "core/html/parser/HTMLParserThread.h" | 38 #include "core/html/parser/HTMLParserThread.h" |
| 38 #include "core/html/parser/HTMLScriptRunner.h" | 39 #include "core/html/parser/HTMLScriptRunner.h" |
| 39 #include "core/html/parser/HTMLTreeBuilder.h" | 40 #include "core/html/parser/HTMLTreeBuilder.h" |
| (...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 564 if (mode == ForceSynchronous) | 565 if (mode == ForceSynchronous) |
| 565 m_treeBuilder->flush(); | 566 m_treeBuilder->flush(); |
| 566 RELEASE_ASSERT(!isStopped()); | 567 RELEASE_ASSERT(!isStopped()); |
| 567 | 568 |
| 568 if (session.needsYield) | 569 if (session.needsYield) |
| 569 m_parserScheduler->scheduleForResume(); | 570 m_parserScheduler->scheduleForResume(); |
| 570 | 571 |
| 571 if (isWaitingForScripts()) { | 572 if (isWaitingForScripts()) { |
| 572 ASSERT(m_tokenizer->state() == HTMLTokenizer::DataState); | 573 ASSERT(m_tokenizer->state() == HTMLTokenizer::DataState); |
| 573 if (!m_preloadScanner) { | 574 if (!m_preloadScanner) { |
| 574 m_preloadScanner = adoptPtr(new HTMLPreloadScanner(m_options, docume
nt()->url(), document()->devicePixelRatio())); | 575 m_preloadScanner = adoptPtr(new HTMLPreloadScanner(m_options, docume
nt()->url(), MediaValues::create(document(), MediaValues::CachingMode))); |
| 575 m_preloadScanner->appendToEnd(m_input.current()); | 576 m_preloadScanner->appendToEnd(m_input.current()); |
| 576 } | 577 } |
| 577 m_preloadScanner->scan(m_preloader.get(), document()->baseElementURL()); | 578 m_preloadScanner->scan(m_preloader.get(), document()->baseElementURL()); |
| 578 } | 579 } |
| 579 | 580 |
| 580 InspectorInstrumentation::didWriteHTML(cookie, m_input.current().currentLine
().zeroBasedInt()); | 581 InspectorInstrumentation::didWriteHTML(cookie, m_input.current().currentLine
().zeroBasedInt()); |
| 581 } | 582 } |
| 582 | 583 |
| 583 void HTMLDocumentParser::constructTreeFromHTMLToken(HTMLToken& rawToken) | 584 void HTMLDocumentParser::constructTreeFromHTMLToken(HTMLToken& rawToken) |
| 584 { | 585 { |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 641 | 642 |
| 642 SegmentedString excludedLineNumberSource(source); | 643 SegmentedString excludedLineNumberSource(source); |
| 643 excludedLineNumberSource.setExcludeLineNumbers(); | 644 excludedLineNumberSource.setExcludeLineNumbers(); |
| 644 m_input.insertAtCurrentInsertionPoint(excludedLineNumberSource); | 645 m_input.insertAtCurrentInsertionPoint(excludedLineNumberSource); |
| 645 pumpTokenizerIfPossible(ForceSynchronous); | 646 pumpTokenizerIfPossible(ForceSynchronous); |
| 646 | 647 |
| 647 if (isWaitingForScripts()) { | 648 if (isWaitingForScripts()) { |
| 648 // Check the document.write() output with a separate preload scanner as | 649 // Check the document.write() output with a separate preload scanner as |
| 649 // the main scanner can't deal with insertions. | 650 // the main scanner can't deal with insertions. |
| 650 if (!m_insertionPreloadScanner) | 651 if (!m_insertionPreloadScanner) |
| 651 m_insertionPreloadScanner = adoptPtr(new HTMLPreloadScanner(m_option
s, document()->url(), document()->devicePixelRatio())); | 652 m_insertionPreloadScanner = adoptPtr(new HTMLPreloadScanner(m_option
s, document()->url(), MediaValues::create(document(), MediaValues::CachingMode))
); |
| 652 | 653 |
| 653 m_insertionPreloadScanner->appendToEnd(source); | 654 m_insertionPreloadScanner->appendToEnd(source); |
| 654 m_insertionPreloadScanner->scan(m_preloader.get(), document()->baseEleme
ntURL()); | 655 m_insertionPreloadScanner->scan(m_preloader.get(), document()->baseEleme
ntURL()); |
| 655 } | 656 } |
| 656 | 657 |
| 657 endIfDelayed(); | 658 endIfDelayed(); |
| 658 } | 659 } |
| 659 | 660 |
| 660 void HTMLDocumentParser::startBackgroundParser() | 661 void HTMLDocumentParser::startBackgroundParser() |
| 661 { | 662 { |
| 662 ASSERT(!isStopped()); | 663 ASSERT(!isStopped()); |
| 663 ASSERT(shouldUseThreading()); | 664 ASSERT(shouldUseThreading()); |
| 664 ASSERT(!m_haveBackgroundParser); | 665 ASSERT(!m_haveBackgroundParser); |
| 665 m_haveBackgroundParser = true; | 666 m_haveBackgroundParser = true; |
| 666 | 667 |
| 667 RefPtr<WeakReference<BackgroundHTMLParser> > reference = WeakReference<Backg
roundHTMLParser>::createUnbound(); | 668 RefPtr<WeakReference<BackgroundHTMLParser> > reference = WeakReference<Backg
roundHTMLParser>::createUnbound(); |
| 668 m_backgroundParser = WeakPtr<BackgroundHTMLParser>(reference); | 669 m_backgroundParser = WeakPtr<BackgroundHTMLParser>(reference); |
| 669 | 670 |
| 670 OwnPtr<BackgroundHTMLParser::Configuration> config = adoptPtr(new Background
HTMLParser::Configuration); | 671 OwnPtr<BackgroundHTMLParser::Configuration> config = adoptPtr(new Background
HTMLParser::Configuration); |
| 671 config->options = m_options; | 672 config->options = m_options; |
| 672 config->parser = m_weakFactory.createWeakPtr(); | 673 config->parser = m_weakFactory.createWeakPtr(); |
| 673 config->xssAuditor = adoptPtr(new XSSAuditor); | 674 config->xssAuditor = adoptPtr(new XSSAuditor); |
| 674 config->xssAuditor->init(document(), &m_xssAuditorDelegate); | 675 config->xssAuditor->init(document(), &m_xssAuditorDelegate); |
| 675 config->preloadScanner = adoptPtr(new TokenPreloadScanner(document()->url().
copy(), document()->devicePixelRatio())); | 676 config->preloadScanner = adoptPtr(new TokenPreloadScanner(document()->url().
copy(), MediaValues::create(document(), MediaValues::CachingMode))); |
| 676 config->decoder = takeDecoder(); | 677 config->decoder = takeDecoder(); |
| 677 | 678 |
| 678 ASSERT(config->xssAuditor->isSafeToSendToAnotherThread()); | 679 ASSERT(config->xssAuditor->isSafeToSendToAnotherThread()); |
| 679 ASSERT(config->preloadScanner->isSafeToSendToAnotherThread()); | 680 ASSERT(config->preloadScanner->isSafeToSendToAnotherThread()); |
| 680 HTMLParserThread::shared()->postTask(bind(&BackgroundHTMLParser::start, refe
rence.release(), config.release())); | 681 HTMLParserThread::shared()->postTask(bind(&BackgroundHTMLParser::start, refe
rence.release(), config.release())); |
| 681 } | 682 } |
| 682 | 683 |
| 683 void HTMLDocumentParser::stopBackgroundParser() | 684 void HTMLDocumentParser::stopBackgroundParser() |
| 684 { | 685 { |
| 685 ASSERT(shouldUseThreading()); | 686 ASSERT(shouldUseThreading()); |
| (...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 998 void HTMLDocumentParser::setDecoder(PassOwnPtr<TextResourceDecoder> decoder) | 999 void HTMLDocumentParser::setDecoder(PassOwnPtr<TextResourceDecoder> decoder) |
| 999 { | 1000 { |
| 1000 ASSERT(decoder); | 1001 ASSERT(decoder); |
| 1001 DecodedDataDocumentParser::setDecoder(decoder); | 1002 DecodedDataDocumentParser::setDecoder(decoder); |
| 1002 | 1003 |
| 1003 if (m_haveBackgroundParser) | 1004 if (m_haveBackgroundParser) |
| 1004 HTMLParserThread::shared()->postTask(bind(&BackgroundHTMLParser::setDeco
der, m_backgroundParser, takeDecoder())); | 1005 HTMLParserThread::shared()->postTask(bind(&BackgroundHTMLParser::setDeco
der, m_backgroundParser, takeDecoder())); |
| 1005 } | 1006 } |
| 1006 | 1007 |
| 1007 } | 1008 } |
| OLD | NEW |