Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(246)

Side by Side Diff: Source/core/html/parser/HTMLDocumentParser.cpp

Issue 1104103002: Add <meta viewport> support to the preloader (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: moved CachedDocumentParameters constructor to private Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Source/core/html/HTMLMetaElement-in.cpp ('k') | Source/core/html/parser/HTMLPreloadScanner.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 547 matching lines...) Expand 10 before | Expand all | Expand 10 after
592 593
593 Document* HTMLDocumentParser::contextForParsingSession() 594 Document* HTMLDocumentParser::contextForParsingSession()
594 { 595 {
595 // The parsing session should interact with the document only when parsing 596 // The parsing session should interact with the document only when parsing
596 // non-fragments. Otherwise, we might delay the load event mistakenly. 597 // non-fragments. Otherwise, we might delay the load event mistakenly.
597 if (isParsingFragment()) 598 if (isParsingFragment())
598 return nullptr; 599 return nullptr;
599 return document(); 600 return document();
600 } 601 }
601 602
602 static PassRefPtr<MediaValues> createMediaValues(Document* document)
603 {
604 ASSERT(document);
605 RefPtr<MediaValues> mediaValues = MediaValuesCached::create(*document);
606 ASSERT(mediaValues->isSafeToSendToAnotherThread());
607 return mediaValues;
608 }
609
610 void HTMLDocumentParser::pumpTokenizer() 603 void HTMLDocumentParser::pumpTokenizer()
611 { 604 {
612 ASSERT(!isStopped()); 605 ASSERT(!isStopped());
613 #if !ENABLE(OILPAN) 606 #if !ENABLE(OILPAN)
614 // ASSERT that this object is both attached to the Document and protected. 607 // ASSERT that this object is both attached to the Document and protected.
615 ASSERT(refCount() >= 2); 608 ASSERT(refCount() >= 2);
616 #endif 609 #endif
617 ASSERT(m_tokenizer); 610 ASSERT(m_tokenizer);
618 ASSERT(m_token); 611 ASSERT(m_token);
619 612
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
663 RELEASE_ASSERT(!isStopped()); 656 RELEASE_ASSERT(!isStopped());
664 657
665 if (isWaitingForScripts()) { 658 if (isWaitingForScripts()) {
666 ASSERT(m_tokenizer->state() == HTMLTokenizer::DataState); 659 ASSERT(m_tokenizer->state() == HTMLTokenizer::DataState);
667 660
668 ASSERT(m_preloader); 661 ASSERT(m_preloader);
669 // TODO(kouhei): m_preloader should be always available for synchronous parsing case, 662 // TODO(kouhei): m_preloader should be always available for synchronous parsing case,
670 // adding paranoia if for speculative crash fix for crbug.com/465478 663 // adding paranoia if for speculative crash fix for crbug.com/465478
671 if (m_preloader) { 664 if (m_preloader) {
672 if (!m_preloadScanner) { 665 if (!m_preloadScanner) {
673 m_preloadScanner = adoptPtr(new HTMLPreloadScanner(m_options, do cument()->url(), createMediaValues(document()))); 666 m_preloadScanner = adoptPtr(new HTMLPreloadScanner(m_options,
667 document()->url(),
668 CachedDocumentParameters::create(document())));
674 m_preloadScanner->appendToEnd(m_input.current()); 669 m_preloadScanner->appendToEnd(m_input.current());
675 } 670 }
676 m_preloadScanner->scan(m_preloader.get(), document()->baseElementURL ()); 671 m_preloadScanner->scan(m_preloader.get(), document()->baseElementURL ());
677 } 672 }
678 } 673 }
679 674
680 TRACE_EVENT_END1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "ParseHTML" , "endData", InspectorParseHtmlEvent::endData(m_input.current().currentLine().ze roBasedInt() - 1)); 675 TRACE_EVENT_END1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "ParseHTML" , "endData", InspectorParseHtmlEvent::endData(m_input.current().currentLine().ze roBasedInt() - 1));
681 } 676 }
682 677
683 void HTMLDocumentParser::constructTreeFromHTMLToken() 678 void HTMLDocumentParser::constructTreeFromHTMLToken()
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
744 } 739 }
745 740
746 SegmentedString excludedLineNumberSource(source); 741 SegmentedString excludedLineNumberSource(source);
747 excludedLineNumberSource.setExcludeLineNumbers(); 742 excludedLineNumberSource.setExcludeLineNumbers();
748 m_input.insertAtCurrentInsertionPoint(excludedLineNumberSource); 743 m_input.insertAtCurrentInsertionPoint(excludedLineNumberSource);
749 pumpTokenizerIfPossible(); 744 pumpTokenizerIfPossible();
750 745
751 if (isWaitingForScripts()) { 746 if (isWaitingForScripts()) {
752 // Check the document.write() output with a separate preload scanner as 747 // Check the document.write() output with a separate preload scanner as
753 // the main scanner can't deal with insertions. 748 // the main scanner can't deal with insertions.
754 if (!m_insertionPreloadScanner) 749 if (!m_insertionPreloadScanner) {
755 m_insertionPreloadScanner = adoptPtr(new HTMLPreloadScanner(m_option s, document()->url(), createMediaValues(document()))); 750 m_insertionPreloadScanner = adoptPtr(new HTMLPreloadScanner(m_option s,
751 document()->url(),
752 CachedDocumentParameters::create(document())));
753 }
756 754
757 m_insertionPreloadScanner->appendToEnd(source); 755 m_insertionPreloadScanner->appendToEnd(source);
758 m_insertionPreloadScanner->scan(m_preloader.get(), document()->baseEleme ntURL()); 756 m_insertionPreloadScanner->scan(m_preloader.get(), document()->baseEleme ntURL());
759 } 757 }
760 758
761 endIfDelayed(); 759 endIfDelayed();
762 } 760 }
763 761
764 void HTMLDocumentParser::startBackgroundParser() 762 void HTMLDocumentParser::startBackgroundParser()
765 { 763 {
766 ASSERT(!isStopped()); 764 ASSERT(!isStopped());
767 ASSERT(shouldUseThreading()); 765 ASSERT(shouldUseThreading());
768 ASSERT(!m_haveBackgroundParser); 766 ASSERT(!m_haveBackgroundParser);
767 ASSERT(document());
769 m_haveBackgroundParser = true; 768 m_haveBackgroundParser = true;
770 769
771 RefPtr<WeakReference<BackgroundHTMLParser>> reference = WeakReference<Backgr oundHTMLParser>::createUnbound(); 770 RefPtr<WeakReference<BackgroundHTMLParser>> reference = WeakReference<Backgr oundHTMLParser>::createUnbound();
772 m_backgroundParser = WeakPtr<BackgroundHTMLParser>(reference); 771 m_backgroundParser = WeakPtr<BackgroundHTMLParser>(reference);
773 772
774 // FIXME(oysteine): Disabled due to crbug.com/398076 until a full fix can be implemented. 773 // FIXME(oysteine): Disabled due to crbug.com/398076 until a full fix can be implemented.
775 if (RuntimeEnabledFeatures::threadedParserDataReceiverEnabled()) { 774 if (RuntimeEnabledFeatures::threadedParserDataReceiverEnabled()) {
776 if (DocumentLoader* loader = document()->loader()) 775 if (DocumentLoader* loader = document()->loader())
777 loader->attachThreadedDataReceiver(ParserDataReceiver::create(m_back groundParser, document()->contextDocument().get())); 776 loader->attachThreadedDataReceiver(ParserDataReceiver::create(m_back groundParser, document()->contextDocument().get()));
778 } 777 }
779 778
780 OwnPtr<BackgroundHTMLParser::Configuration> config = adoptPtr(new Background HTMLParser::Configuration); 779 OwnPtr<BackgroundHTMLParser::Configuration> config = adoptPtr(new Background HTMLParser::Configuration);
781 config->options = m_options; 780 config->options = m_options;
782 config->parser = m_weakFactory.createWeakPtr(); 781 config->parser = m_weakFactory.createWeakPtr();
783 config->xssAuditor = adoptPtr(new XSSAuditor); 782 config->xssAuditor = adoptPtr(new XSSAuditor);
784 config->xssAuditor->init(document(), &m_xssAuditorDelegate); 783 config->xssAuditor->init(document(), &m_xssAuditorDelegate);
785 config->preloadScanner = adoptPtr(new TokenPreloadScanner(document()->url(). copy(), createMediaValues(document()))); 784 config->preloadScanner = adoptPtr(new TokenPreloadScanner(document()->url(). copy(), CachedDocumentParameters::create(document())));
786 config->decoder = takeDecoder(); 785 config->decoder = takeDecoder();
787 786
788 ASSERT(config->xssAuditor->isSafeToSendToAnotherThread()); 787 ASSERT(config->xssAuditor->isSafeToSendToAnotherThread());
789 ASSERT(config->preloadScanner->isSafeToSendToAnotherThread()); 788 ASSERT(config->preloadScanner->isSafeToSendToAnotherThread());
790 HTMLParserThread::shared()->postTask(threadSafeBind(&BackgroundHTMLParser::s tart, reference.release(), config.release(), 789 HTMLParserThread::shared()->postTask(threadSafeBind(&BackgroundHTMLParser::s tart, reference.release(), config.release(),
791 AllowCrossThreadAccess(Platform::current()->currentThread()->scheduler() ))); 790 AllowCrossThreadAccess(Platform::current()->currentThread()->scheduler() )));
792 } 791 }
793 792
794 void HTMLDocumentParser::stopBackgroundParser() 793 void HTMLDocumentParser::stopBackgroundParser()
795 { 794 {
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after
1109 void HTMLDocumentParser::setDecoder(PassOwnPtr<TextResourceDecoder> decoder) 1108 void HTMLDocumentParser::setDecoder(PassOwnPtr<TextResourceDecoder> decoder)
1110 { 1109 {
1111 ASSERT(decoder); 1110 ASSERT(decoder);
1112 DecodedDataDocumentParser::setDecoder(decoder); 1111 DecodedDataDocumentParser::setDecoder(decoder);
1113 1112
1114 if (m_haveBackgroundParser) 1113 if (m_haveBackgroundParser)
1115 HTMLParserThread::shared()->postTask(threadSafeBind(&BackgroundHTMLParse r::setDecoder, AllowCrossThreadAccess(m_backgroundParser), takeDecoder())); 1114 HTMLParserThread::shared()->postTask(threadSafeBind(&BackgroundHTMLParse r::setDecoder, AllowCrossThreadAccess(m_backgroundParser), takeDecoder()));
1116 } 1115 }
1117 1116
1118 } 1117 }
OLDNEW
« no previous file with comments | « Source/core/html/HTMLMetaElement-in.cpp ('k') | Source/core/html/parser/HTMLPreloadScanner.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698