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

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

Issue 23861003: Enable srcset support in HTMLImageElement (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Addressed issues raised in review. Merged Romain Perier's new parser implementation. Created 7 years, 3 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
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 540 matching lines...) Expand 10 before | Expand all | Expand 10 after
551 551
552 if (isStopped()) 552 if (isStopped())
553 return; 553 return;
554 554
555 if (session.needsYield) 555 if (session.needsYield)
556 m_parserScheduler->scheduleForResume(); 556 m_parserScheduler->scheduleForResume();
557 557
558 if (isWaitingForScripts()) { 558 if (isWaitingForScripts()) {
559 ASSERT(m_tokenizer->state() == HTMLTokenizer::DataState); 559 ASSERT(m_tokenizer->state() == HTMLTokenizer::DataState);
560 if (!m_preloadScanner) { 560 if (!m_preloadScanner) {
561 m_preloadScanner = adoptPtr(new HTMLPreloadScanner(m_options, docume nt()->url())); 561 m_preloadScanner = adoptPtr(new HTMLPreloadScanner(m_options, docume nt()->url(), document()->devicePixelRatio()));
562 m_preloadScanner->appendToEnd(m_input.current()); 562 m_preloadScanner->appendToEnd(m_input.current());
563 } 563 }
564 m_preloadScanner->scan(m_preloader.get(), document()->baseElementURL()); 564 m_preloadScanner->scan(m_preloader.get(), document()->baseElementURL());
565 } 565 }
566 566
567 InspectorInstrumentation::didWriteHTML(cookie, m_input.current().currentLine ().zeroBasedInt()); 567 InspectorInstrumentation::didWriteHTML(cookie, m_input.current().currentLine ().zeroBasedInt());
568 } 568 }
569 569
570 void HTMLDocumentParser::constructTreeFromHTMLToken(HTMLToken& rawToken) 570 void HTMLDocumentParser::constructTreeFromHTMLToken(HTMLToken& rawToken)
571 { 571 {
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
625 } 625 }
626 626
627 SegmentedString excludedLineNumberSource(source); 627 SegmentedString excludedLineNumberSource(source);
628 excludedLineNumberSource.setExcludeLineNumbers(); 628 excludedLineNumberSource.setExcludeLineNumbers();
629 m_input.insertAtCurrentInsertionPoint(excludedLineNumberSource); 629 m_input.insertAtCurrentInsertionPoint(excludedLineNumberSource);
630 pumpTokenizerIfPossible(ForceSynchronous); 630 pumpTokenizerIfPossible(ForceSynchronous);
631 631
632 if (isWaitingForScripts()) { 632 if (isWaitingForScripts()) {
633 // Check the document.write() output with a separate preload scanner as 633 // Check the document.write() output with a separate preload scanner as
634 // the main scanner can't deal with insertions. 634 // the main scanner can't deal with insertions.
635 if (!m_insertionPreloadScanner) 635 if (!m_insertionPreloadScanner) {
636 m_insertionPreloadScanner = adoptPtr(new HTMLPreloadScanner(m_option s, document()->url())); 636 m_insertionPreloadScanner = adoptPtr(new HTMLPreloadScanner(m_option s, document()->url(), document()->devicePixelRatio()));
637 }
637 m_insertionPreloadScanner->appendToEnd(source); 638 m_insertionPreloadScanner->appendToEnd(source);
638 m_insertionPreloadScanner->scan(m_preloader.get(), document()->baseEleme ntURL()); 639 m_insertionPreloadScanner->scan(m_preloader.get(), document()->baseEleme ntURL());
639 } 640 }
640 641
641 endIfDelayed(); 642 endIfDelayed();
642 } 643 }
643 644
644 void HTMLDocumentParser::startBackgroundParser() 645 void HTMLDocumentParser::startBackgroundParser()
645 { 646 {
646 ASSERT(shouldUseThreading()); 647 ASSERT(shouldUseThreading());
647 ASSERT(!m_haveBackgroundParser); 648 ASSERT(!m_haveBackgroundParser);
648 m_haveBackgroundParser = true; 649 m_haveBackgroundParser = true;
649 650
650 HTMLIdentifier::init(); 651 HTMLIdentifier::init();
651 652
652 RefPtr<WeakReference<BackgroundHTMLParser> > reference = WeakReference<Backg roundHTMLParser>::createUnbound(); 653 RefPtr<WeakReference<BackgroundHTMLParser> > reference = WeakReference<Backg roundHTMLParser>::createUnbound();
653 m_backgroundParser = WeakPtr<BackgroundHTMLParser>(reference); 654 m_backgroundParser = WeakPtr<BackgroundHTMLParser>(reference);
654 655
655 OwnPtr<BackgroundHTMLParser::Configuration> config = adoptPtr(new Background HTMLParser::Configuration); 656 OwnPtr<BackgroundHTMLParser::Configuration> config = adoptPtr(new Background HTMLParser::Configuration);
656 config->options = m_options; 657 config->options = m_options;
657 config->parser = m_weakFactory.createWeakPtr(); 658 config->parser = m_weakFactory.createWeakPtr();
658 config->xssAuditor = adoptPtr(new XSSAuditor); 659 config->xssAuditor = adoptPtr(new XSSAuditor);
659 config->xssAuditor->init(document(), &m_xssAuditorDelegate); 660 config->xssAuditor->init(document(), &m_xssAuditorDelegate);
660 config->preloadScanner = adoptPtr(new TokenPreloadScanner(document()->url(). copy())); 661 config->preloadScanner = adoptPtr(new TokenPreloadScanner(document()->url(). copy(), document()->devicePixelRatio()));
661 662
662 ASSERT(config->xssAuditor->isSafeToSendToAnotherThread()); 663 ASSERT(config->xssAuditor->isSafeToSendToAnotherThread());
663 ASSERT(config->preloadScanner->isSafeToSendToAnotherThread()); 664 ASSERT(config->preloadScanner->isSafeToSendToAnotherThread());
664 HTMLParserThread::shared()->postTask(bind(&BackgroundHTMLParser::create, ref erence.release(), config.release())); 665 HTMLParserThread::shared()->postTask(bind(&BackgroundHTMLParser::create, ref erence.release(), config.release()));
665 } 666 }
666 667
667 void HTMLDocumentParser::stopBackgroundParser() 668 void HTMLDocumentParser::stopBackgroundParser()
668 { 669 {
669 ASSERT(shouldUseThreading()); 670 ASSERT(shouldUseThreading());
670 ASSERT(m_haveBackgroundParser); 671 ASSERT(m_haveBackgroundParser);
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
951 m_parserScheduler->suspend(); 952 m_parserScheduler->suspend();
952 } 953 }
953 954
954 void HTMLDocumentParser::resumeScheduledTasks() 955 void HTMLDocumentParser::resumeScheduledTasks()
955 { 956 {
956 if (m_parserScheduler) 957 if (m_parserScheduler)
957 m_parserScheduler->resume(); 958 m_parserScheduler->resume();
958 } 959 }
959 960
960 } 961 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698