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

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

Issue 555223002: Revert of HTMLConstructionSite: avoid n^2 running time for large scripts. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 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 480 matching lines...) Expand 10 before | Expand all | Expand 10 after
491 ASSERT(it + 1 == tokens->end()); // The EOF is assumed to be the las t token of this bunch. 491 ASSERT(it + 1 == tokens->end()); // The EOF is assumed to be the las t token of this bunch.
492 ASSERT(m_speculations.isEmpty()); // There should never be any chunk s after the EOF. 492 ASSERT(m_speculations.isEmpty()); // There should never be any chunk s after the EOF.
493 prepareToStopParsing(); 493 prepareToStopParsing();
494 break; 494 break;
495 } 495 }
496 496
497 ASSERT(!m_tokenizer); 497 ASSERT(!m_tokenizer);
498 ASSERT(!m_token); 498 ASSERT(!m_token);
499 } 499 }
500 500
501 // Make sure all required pending text nodes are emitted before returning. 501 // Make sure any pending text nodes are emitted before returning.
502 // This leaves "script", "style" and "svg" nodes text nodes intact.
503 if (!isStopped()) 502 if (!isStopped())
504 m_treeBuilder->flush(FlushIfAtTextLimit); 503 m_treeBuilder->flush();
505 } 504 }
506 505
507 void HTMLDocumentParser::pumpPendingSpeculations() 506 void HTMLDocumentParser::pumpPendingSpeculations()
508 { 507 {
509 // FIXME: Share this constant with the parser scheduler. 508 // FIXME: Share this constant with the parser scheduler.
510 const double parserTimeLimit = 0.500; 509 const double parserTimeLimit = 0.500;
511 510
512 #if !ENABLE(OILPAN) 511 #if !ENABLE(OILPAN)
513 // ASSERT that this object is both attached to the Document and protected. 512 // ASSERT that this object is both attached to the Document and protected.
514 ASSERT(refCount() >= 2); 513 ASSERT(refCount() >= 2);
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
629 // function should be holding a RefPtr to this to ensure we weren't deleted. 628 // function should be holding a RefPtr to this to ensure we weren't deleted.
630 ASSERT(refCount() >= 1); 629 ASSERT(refCount() >= 1);
631 #endif 630 #endif
632 631
633 if (isStopped()) 632 if (isStopped())
634 return; 633 return;
635 634
636 // There should only be PendingText left since the tree-builder always flush es 635 // There should only be PendingText left since the tree-builder always flush es
637 // the task queue before returning. In case that ever changes, crash. 636 // the task queue before returning. In case that ever changes, crash.
638 if (mode == ForceSynchronous) 637 if (mode == ForceSynchronous)
639 m_treeBuilder->flush(FlushAlways); 638 m_treeBuilder->flush();
640 RELEASE_ASSERT(!isStopped()); 639 RELEASE_ASSERT(!isStopped());
641 640
642 if (session.needsYield) 641 if (session.needsYield)
643 m_parserScheduler->scheduleForResume(); 642 m_parserScheduler->scheduleForResume();
644 643
645 if (isWaitingForScripts()) { 644 if (isWaitingForScripts()) {
646 ASSERT(m_tokenizer->state() == HTMLTokenizer::DataState); 645 ASSERT(m_tokenizer->state() == HTMLTokenizer::DataState);
647 if (!m_preloadScanner) { 646 if (!m_preloadScanner) {
648 m_preloadScanner = adoptPtr(new HTMLPreloadScanner(m_options, docume nt()->url(), createMediaValues(document()))); 647 m_preloadScanner = adoptPtr(new HTMLPreloadScanner(m_options, docume nt()->url(), createMediaValues(document())));
649 m_preloadScanner->appendToEnd(m_input.current()); 648 m_preloadScanner->appendToEnd(m_input.current());
(...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after
1072 void HTMLDocumentParser::setDecoder(PassOwnPtr<TextResourceDecoder> decoder) 1071 void HTMLDocumentParser::setDecoder(PassOwnPtr<TextResourceDecoder> decoder)
1073 { 1072 {
1074 ASSERT(decoder); 1073 ASSERT(decoder);
1075 DecodedDataDocumentParser::setDecoder(decoder); 1074 DecodedDataDocumentParser::setDecoder(decoder);
1076 1075
1077 if (m_haveBackgroundParser) 1076 if (m_haveBackgroundParser)
1078 HTMLParserThread::shared()->postTask(bind(&BackgroundHTMLParser::setDeco der, m_backgroundParser, takeDecoder())); 1077 HTMLParserThread::shared()->postTask(bind(&BackgroundHTMLParser::setDeco der, m_backgroundParser, takeDecoder()));
1079 } 1078 }
1080 1079
1081 } 1080 }
OLDNEW
« no previous file with comments | « Source/core/html/parser/HTMLConstructionSite.cpp ('k') | Source/core/html/parser/HTMLTreeBuilder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698