| 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 23 matching lines...) Expand all Loading... |
| 34 #include "core/html/HTMLDocument.h" | 34 #include "core/html/HTMLDocument.h" |
| 35 #include "core/html/HTMLScriptElement.h" | 35 #include "core/html/HTMLScriptElement.h" |
| 36 #include "core/html/parser/AtomicHTMLToken.h" | 36 #include "core/html/parser/AtomicHTMLToken.h" |
| 37 #include "core/html/parser/BackgroundHTMLParser.h" | 37 #include "core/html/parser/BackgroundHTMLParser.h" |
| 38 #include "core/html/parser/HTMLParserScheduler.h" | 38 #include "core/html/parser/HTMLParserScheduler.h" |
| 39 #include "core/html/parser/HTMLParserThread.h" | 39 #include "core/html/parser/HTMLParserThread.h" |
| 40 #include "core/html/parser/HTMLTreeBuilder.h" | 40 #include "core/html/parser/HTMLTreeBuilder.h" |
| 41 #include "core/inspector/InspectorTraceEvents.h" | 41 #include "core/inspector/InspectorTraceEvents.h" |
| 42 #include "platform/SharedBuffer.h" | 42 #include "platform/SharedBuffer.h" |
| 43 #include "platform/TraceEvent.h" | 43 #include "platform/TraceEvent.h" |
| 44 #include "wtf/Functional.h" | |
| 45 | 44 |
| 46 namespace blink { | 45 namespace blink { |
| 47 | 46 |
| 48 HTMLDocumentParser::HTMLDocumentParser(HTMLDocument& document, bool reportErrors
) | 47 HTMLDocumentParser::HTMLDocumentParser(HTMLDocument& document, bool reportErrors
) |
| 49 : DocumentParser(&document) | 48 : DocumentParser(&document) |
| 50 , m_treeBuilder(HTMLTreeBuilder::create(this, &document, reportErrors)) | 49 , m_treeBuilder(HTMLTreeBuilder::create(this, &document, reportErrors)) |
| 51 , m_parserScheduler(HTMLParserScheduler::create(this)) | 50 , m_parserScheduler(HTMLParserScheduler::create(this)) |
| 52 , m_weakFactory(this) | 51 , m_weakFactory(this) |
| 53 , m_isFragment(false) | 52 , m_isFragment(false) |
| 54 , m_endWasDelayed(false) | 53 , m_endWasDelayed(false) |
| (...skipping 20 matching lines...) Expand all Loading... |
| 75 } | 74 } |
| 76 | 75 |
| 77 void HTMLDocumentParser::parse(mojo::ScopedDataPipeConsumerHandle source) | 76 void HTMLDocumentParser::parse(mojo::ScopedDataPipeConsumerHandle source) |
| 78 { | 77 { |
| 79 ASSERT(!isStopped()); | 78 ASSERT(!isStopped()); |
| 80 ASSERT(!m_haveBackgroundParser); | 79 ASSERT(!m_haveBackgroundParser); |
| 81 m_haveBackgroundParser = true; | 80 m_haveBackgroundParser = true; |
| 82 | 81 |
| 83 OwnPtr<BackgroundHTMLParser::Configuration> config = adoptPtr(new Background
HTMLParser::Configuration); | 82 OwnPtr<BackgroundHTMLParser::Configuration> config = adoptPtr(new Background
HTMLParser::Configuration); |
| 84 config->source = source.Pass(); | 83 config->source = source.Pass(); |
| 85 config->parser = m_weakFactory.createWeakPtr(); | 84 config->parser = m_weakFactory.GetWeakPtr(); |
| 86 | 85 |
| 87 m_backgroundParser = BackgroundHTMLParser::create(config.release()); | 86 m_backgroundParser = BackgroundHTMLParser::create(config.release()); |
| 88 HTMLParserThread::taskRunner()->PostTask(FROM_HERE, | 87 HTMLParserThread::taskRunner()->PostTask(FROM_HERE, |
| 89 base::Bind(&BackgroundHTMLParser::start, m_backgroundParser)); | 88 base::Bind(&BackgroundHTMLParser::start, m_backgroundParser)); |
| 90 } | 89 } |
| 91 | 90 |
| 92 void HTMLDocumentParser::detach() | 91 void HTMLDocumentParser::detach() |
| 93 { | 92 { |
| 94 if (m_haveBackgroundParser) | 93 if (m_haveBackgroundParser) |
| 95 stopBackgroundParser(); | 94 stopBackgroundParser(); |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 343 { | 342 { |
| 344 } | 343 } |
| 345 | 344 |
| 346 void HTMLDocumentParser::stopBackgroundParser() | 345 void HTMLDocumentParser::stopBackgroundParser() |
| 347 { | 346 { |
| 348 ASSERT(m_haveBackgroundParser); | 347 ASSERT(m_haveBackgroundParser); |
| 349 m_haveBackgroundParser = false; | 348 m_haveBackgroundParser = false; |
| 350 | 349 |
| 351 HTMLParserThread::taskRunner()->PostTask(FROM_HERE, | 350 HTMLParserThread::taskRunner()->PostTask(FROM_HERE, |
| 352 base::Bind(&BackgroundHTMLParser::stop, m_backgroundParser)); | 351 base::Bind(&BackgroundHTMLParser::stop, m_backgroundParser)); |
| 353 m_weakFactory.revokeAll(); | 352 m_weakFactory.InvalidateWeakPtrs(); |
| 354 } | 353 } |
| 355 | 354 |
| 356 void HTMLDocumentParser::end() | 355 void HTMLDocumentParser::end() |
| 357 { | 356 { |
| 358 ASSERT(!isDetached()); | 357 ASSERT(!isDetached()); |
| 359 ASSERT(!isScheduledForResume()); | 358 ASSERT(!isScheduledForResume()); |
| 360 | 359 |
| 361 if (m_haveBackgroundParser) | 360 if (m_haveBackgroundParser) |
| 362 stopBackgroundParser(); | 361 stopBackgroundParser(); |
| 363 | 362 |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 427 { | 426 { |
| 428 if (!m_scriptRunner.hasPendingScripts()) | 427 if (!m_scriptRunner.hasPendingScripts()) |
| 429 return; | 428 return; |
| 430 RefPtr<HTMLDocumentParser> protect(this); | 429 RefPtr<HTMLDocumentParser> protect(this); |
| 431 m_scriptRunner.executePendingScripts(); | 430 m_scriptRunner.executePendingScripts(); |
| 432 if (!isWaitingForScripts()) | 431 if (!isWaitingForScripts()) |
| 433 resumeParsingAfterScriptExecution(); | 432 resumeParsingAfterScriptExecution(); |
| 434 } | 433 } |
| 435 | 434 |
| 436 } | 435 } |
| OLD | NEW |