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

Side by Side Diff: sky/engine/core/html/parser/HTMLDocumentParser.cpp

Issue 676133002: Remove HTMLParserOptions (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Fixup Created 6 years, 2 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 28 matching lines...) Expand all
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" 44 #include "wtf/Functional.h"
45 45
46 namespace blink { 46 namespace blink {
47 47
48 HTMLDocumentParser::HTMLDocumentParser(HTMLDocument& document, bool reportErrors ) 48 HTMLDocumentParser::HTMLDocumentParser(HTMLDocument& document, bool reportErrors )
49 : DecodedDataDocumentParser(document) 49 : DocumentParser(&document)
50 , m_options(&document) 50 , m_options(&document)
51 , m_treeBuilder(HTMLTreeBuilder::create(this, &document, reportErrors, m_opt ions)) 51 , m_treeBuilder(HTMLTreeBuilder::create(this, &document, reportErrors))
52 , m_parserScheduler(HTMLParserScheduler::create(this)) 52 , m_parserScheduler(HTMLParserScheduler::create(this))
53 , m_weakFactory(this) 53 , m_weakFactory(this)
54 , m_isFragment(false) 54 , m_isFragment(false)
55 , m_endWasDelayed(false) 55 , m_endWasDelayed(false)
56 , m_haveBackgroundParser(false) 56 , m_haveBackgroundParser(false)
57 , m_pumpSessionNestingLevel(0) 57 , m_pumpSessionNestingLevel(0)
58 { 58 {
59 ASSERT(shouldUseThreading());
60 } 59 }
61 60
62 HTMLDocumentParser::~HTMLDocumentParser() 61 HTMLDocumentParser::~HTMLDocumentParser()
63 { 62 {
64 #if ENABLE(OILPAN) 63 #if ENABLE(OILPAN)
65 if (m_haveBackgroundParser) 64 if (m_haveBackgroundParser)
66 stopBackgroundParser(); 65 stopBackgroundParser();
67 // In Oilpan, HTMLDocumentParser can die together with Document, and 66 // In Oilpan, HTMLDocumentParser can die together with Document, and
68 // detach() is not called in this case. 67 // detach() is not called in this case.
69 #else 68 #else
70 ASSERT(!m_parserScheduler); 69 ASSERT(!m_parserScheduler);
71 ASSERT(!m_pumpSessionNestingLevel); 70 ASSERT(!m_pumpSessionNestingLevel);
72 ASSERT(!m_haveBackgroundParser); 71 ASSERT(!m_haveBackgroundParser);
73 // FIXME: We should be able to ASSERT(m_speculations.isEmpty()), 72 // FIXME: We should be able to ASSERT(m_speculations.isEmpty()),
74 // but there are cases where that's not true currently. For example, 73 // but there are cases where that's not true currently. For example,
75 // we we're told to stop parsing before we've consumed all the input. 74 // we we're told to stop parsing before we've consumed all the input.
76 #endif 75 #endif
77 } 76 }
78 77
79 void HTMLDocumentParser::trace(Visitor* visitor)
80 {
81 visitor->trace(m_treeBuilder);
82 DecodedDataDocumentParser::trace(visitor);
83 }
84
85 void HTMLDocumentParser::parse(mojo::ScopedDataPipeConsumerHandle source) 78 void HTMLDocumentParser::parse(mojo::ScopedDataPipeConsumerHandle source)
86 { 79 {
87 ASSERT(!isStopped()); 80 ASSERT(!isStopped());
88 ASSERT(shouldUseThreading());
89 ASSERT(!m_haveBackgroundParser); 81 ASSERT(!m_haveBackgroundParser);
90 m_haveBackgroundParser = true; 82 m_haveBackgroundParser = true;
91 83
92 OwnPtr<BackgroundHTMLParser::Configuration> config = adoptPtr(new Background HTMLParser::Configuration); 84 OwnPtr<BackgroundHTMLParser::Configuration> config = adoptPtr(new Background HTMLParser::Configuration);
93 config->options = m_options;
94 config->source = source.Pass(); 85 config->source = source.Pass();
95 config->parser = m_weakFactory.createWeakPtr(); 86 config->parser = m_weakFactory.createWeakPtr();
96 87
97 m_backgroundParser = BackgroundHTMLParser::create(config.release()); 88 m_backgroundParser = BackgroundHTMLParser::create(config.release());
98 HTMLParserThread::taskRunner()->PostTask(FROM_HERE, 89 HTMLParserThread::taskRunner()->PostTask(FROM_HERE,
99 base::Bind(&BackgroundHTMLParser::start, m_backgroundParser)); 90 base::Bind(&BackgroundHTMLParser::start, m_backgroundParser));
100 } 91 }
101 92
102 void HTMLDocumentParser::detach() 93 void HTMLDocumentParser::detach()
103 { 94 {
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 TRACE_EVENT0("blink", "HTMLDocumentParser::processParsedChunkFromBackgroundP arser"); 215 TRACE_EVENT0("blink", "HTMLDocumentParser::processParsedChunkFromBackgroundP arser");
225 216
226 ASSERT_WITH_SECURITY_IMPLICATION(!document()->activeParserCount()); 217 ASSERT_WITH_SECURITY_IMPLICATION(!document()->activeParserCount());
227 ASSERT(!isParsingFragment()); 218 ASSERT(!isParsingFragment());
228 ASSERT(!isWaitingForScripts()); 219 ASSERT(!isWaitingForScripts());
229 ASSERT(!isStopped()); 220 ASSERT(!isStopped());
230 #if !ENABLE(OILPAN) 221 #if !ENABLE(OILPAN)
231 // ASSERT that this object is both attached to the Document and protected. 222 // ASSERT that this object is both attached to the Document and protected.
232 ASSERT(refCount() >= 2); 223 ASSERT(refCount() >= 2);
233 #endif 224 #endif
234 ASSERT(shouldUseThreading());
235 ASSERT(!m_lastChunkBeforeScript); 225 ASSERT(!m_lastChunkBeforeScript);
236 226
237 ActiveParserSession session(contextForParsingSession()); 227 ActiveParserSession session(contextForParsingSession());
238 228
239 OwnPtr<ParsedChunk> chunk(popChunk); 229 OwnPtr<ParsedChunk> chunk(popChunk);
240 OwnPtr<CompactHTMLTokenStream> tokens = chunk->tokens.release(); 230 OwnPtr<CompactHTMLTokenStream> tokens = chunk->tokens.release();
241 231
242 for (Vector<CompactHTMLToken>::const_iterator it = tokens->begin(); it != to kens->end(); ++it) { 232 for (Vector<CompactHTMLToken>::const_iterator it = tokens->begin(); it != to kens->end(); ++it) {
243 ASSERT(!isWaitingForScripts()); 233 ASSERT(!isWaitingForScripts());
244 234
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 { 339 {
350 return false; 340 return false;
351 } 341 }
352 342
353 void HTMLDocumentParser::startBackgroundParser() 343 void HTMLDocumentParser::startBackgroundParser()
354 { 344 {
355 } 345 }
356 346
357 void HTMLDocumentParser::stopBackgroundParser() 347 void HTMLDocumentParser::stopBackgroundParser()
358 { 348 {
359 ASSERT(shouldUseThreading());
360 ASSERT(m_haveBackgroundParser); 349 ASSERT(m_haveBackgroundParser);
361 m_haveBackgroundParser = false; 350 m_haveBackgroundParser = false;
362 351
363 HTMLParserThread::taskRunner()->PostTask(FROM_HERE, 352 HTMLParserThread::taskRunner()->PostTask(FROM_HERE,
364 base::Bind(&BackgroundHTMLParser::stop, m_backgroundParser)); 353 base::Bind(&BackgroundHTMLParser::stop, m_backgroundParser));
365 m_weakFactory.revokeAll(); 354 m_weakFactory.revokeAll();
366 } 355 }
367 356
368 void HTMLDocumentParser::end() 357 void HTMLDocumentParser::end()
369 { 358 {
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
439 { 428 {
440 if (!m_scriptRunner.hasPendingScripts()) 429 if (!m_scriptRunner.hasPendingScripts())
441 return; 430 return;
442 RefPtrWillBeRawPtr<HTMLDocumentParser> protect(this); 431 RefPtrWillBeRawPtr<HTMLDocumentParser> protect(this);
443 m_scriptRunner.executePendingScripts(); 432 m_scriptRunner.executePendingScripts();
444 if (!isWaitingForScripts()) 433 if (!isWaitingForScripts())
445 resumeParsingAfterScriptExecution(); 434 resumeParsingAfterScriptExecution();
446 } 435 }
447 436
448 } 437 }
OLDNEW
« no previous file with comments | « sky/engine/core/html/parser/HTMLDocumentParser.h ('k') | sky/engine/core/html/parser/HTMLParserOptions.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698