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

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

Issue 680583003: Delete ScriptableDocumentParser (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Sort headers 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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 const QualifiedName& contextTag = contextElement->tagQName(); 56 const QualifiedName& contextTag = contextElement->tagQName();
57 57
58 if (contextTag == HTMLNames::styleTag) 58 if (contextTag == HTMLNames::styleTag)
59 return HTMLTokenizer::RAWTEXTState; 59 return HTMLTokenizer::RAWTEXTState;
60 if (contextTag == HTMLNames::scriptTag) 60 if (contextTag == HTMLNames::scriptTag)
61 return HTMLTokenizer::ScriptDataState; 61 return HTMLTokenizer::ScriptDataState;
62 return HTMLTokenizer::DataState; 62 return HTMLTokenizer::DataState;
63 } 63 }
64 64
65 HTMLDocumentParser::HTMLDocumentParser(HTMLDocument& document, bool reportErrors ) 65 HTMLDocumentParser::HTMLDocumentParser(HTMLDocument& document, bool reportErrors )
66 : ScriptableDocumentParser(document) 66 : DecodedDataDocumentParser(document)
67 , m_options(&document) 67 , m_options(&document)
68 , m_token(m_options.useThreading ? nullptr : adoptPtr(new HTMLToken)) 68 , m_token(m_options.useThreading ? nullptr : adoptPtr(new HTMLToken))
69 , m_tokenizer(m_options.useThreading ? nullptr : HTMLTokenizer::create(m_opt ions)) 69 , m_tokenizer(m_options.useThreading ? nullptr : HTMLTokenizer::create(m_opt ions))
70 , m_treeBuilder(HTMLTreeBuilder::create(this, &document, parserContentPolicy (), reportErrors, m_options)) 70 , m_treeBuilder(HTMLTreeBuilder::create(this, &document, reportErrors, m_opt ions))
71 , m_parserScheduler(HTMLParserScheduler::create(this)) 71 , m_parserScheduler(HTMLParserScheduler::create(this))
72 , m_weakFactory(this) 72 , m_weakFactory(this)
73 , m_isFragment(false) 73 , m_isFragment(false)
74 , m_endWasDelayed(false) 74 , m_endWasDelayed(false)
75 , m_haveBackgroundParser(false) 75 , m_haveBackgroundParser(false)
76 , m_pumpSessionNestingLevel(0) 76 , m_pumpSessionNestingLevel(0)
77 { 77 {
78 ASSERT(shouldUseThreading() || (m_token && m_tokenizer)); 78 ASSERT(shouldUseThreading() || (m_token && m_tokenizer));
79 } 79 }
80 80
81 // FIXME: Member variables should be grouped into self-initializing structs to 81 // FIXME: Member variables should be grouped into self-initializing structs to
82 // minimize code duplication between these constructors. 82 // minimize code duplication between these constructors.
83 HTMLDocumentParser::HTMLDocumentParser(DocumentFragment* fragment, Element* cont extElement, ParserContentPolicy parserContentPolicy) 83 HTMLDocumentParser::HTMLDocumentParser(DocumentFragment* fragment, Element* cont extElement)
84 : ScriptableDocumentParser(fragment->document(), parserContentPolicy) 84 : DecodedDataDocumentParser(fragment->document())
85 , m_options(&fragment->document()) 85 , m_options(&fragment->document())
86 , m_token(adoptPtr(new HTMLToken)) 86 , m_token(adoptPtr(new HTMLToken))
87 , m_tokenizer(HTMLTokenizer::create(m_options)) 87 , m_tokenizer(HTMLTokenizer::create(m_options))
88 , m_treeBuilder(HTMLTreeBuilder::create(this, fragment, contextElement, this ->parserContentPolicy(), m_options)) 88 , m_treeBuilder(HTMLTreeBuilder::create(this, fragment, contextElement, m_op tions))
89 , m_weakFactory(this) 89 , m_weakFactory(this)
90 , m_isFragment(true) 90 , m_isFragment(true)
91 , m_endWasDelayed(false) 91 , m_endWasDelayed(false)
92 , m_haveBackgroundParser(false) 92 , m_haveBackgroundParser(false)
93 , m_pumpSessionNestingLevel(0) 93 , m_pumpSessionNestingLevel(0)
94 { 94 {
95 ASSERT(!shouldUseThreading()); 95 ASSERT(!shouldUseThreading());
96 bool reportErrors = false; // For now document fragment parsing never report s errors. 96 bool reportErrors = false; // For now document fragment parsing never report s errors.
97 m_tokenizer->setState(tokenizerStateForContextElement(contextElement, report Errors, m_options)); 97 m_tokenizer->setState(tokenizerStateForContextElement(contextElement, report Errors, m_options));
98 } 98 }
(...skipping 11 matching lines...) Expand all
110 ASSERT(!m_haveBackgroundParser); 110 ASSERT(!m_haveBackgroundParser);
111 // FIXME: We should be able to ASSERT(m_speculations.isEmpty()), 111 // FIXME: We should be able to ASSERT(m_speculations.isEmpty()),
112 // but there are cases where that's not true currently. For example, 112 // but there are cases where that's not true currently. For example,
113 // we we're told to stop parsing before we've consumed all the input. 113 // we we're told to stop parsing before we've consumed all the input.
114 #endif 114 #endif
115 } 115 }
116 116
117 void HTMLDocumentParser::trace(Visitor* visitor) 117 void HTMLDocumentParser::trace(Visitor* visitor)
118 { 118 {
119 visitor->trace(m_treeBuilder); 119 visitor->trace(m_treeBuilder);
120 ScriptableDocumentParser::trace(visitor); 120 DecodedDataDocumentParser::trace(visitor);
121 } 121 }
122 122
123 void HTMLDocumentParser::detach() 123 void HTMLDocumentParser::detach()
124 { 124 {
125 if (m_haveBackgroundParser) 125 if (m_haveBackgroundParser)
126 stopBackgroundParser(); 126 stopBackgroundParser();
127 DocumentParser::detach(); 127 DocumentParser::detach();
128 m_treeBuilder->detach(); 128 m_treeBuilder->detach();
129 // FIXME: It seems wrong that we would have a preload scanner here. 129 // FIXME: It seems wrong that we would have a preload scanner here.
130 // Yet during fast/dom/HTMLScriptElement/script-load-events.html we do. 130 // Yet during fast/dom/HTMLScriptElement/script-load-events.html we do.
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 } 221 }
222 222
223 // We should never be here unless we can pump immediately. Call pumpTokeniz er() 223 // We should never be here unless we can pump immediately. Call pumpTokeniz er()
224 // directly so that ASSERTS will fire if we're wrong. 224 // directly so that ASSERTS will fire if we're wrong.
225 pumpTokenizer(AllowYield); 225 pumpTokenizer(AllowYield);
226 endIfDelayed(); 226 endIfDelayed();
227 } 227 }
228 228
229 void HTMLDocumentParser::runScriptsForPausedTreeBuilder() 229 void HTMLDocumentParser::runScriptsForPausedTreeBuilder()
230 { 230 {
231 ASSERT(scriptingContentIsAllowed(parserContentPolicy()));
232 if (m_isFragment) 231 if (m_isFragment)
233 return; 232 return;
234 TextPosition scriptStartPosition = TextPosition::belowRangePosition(); 233 TextPosition scriptStartPosition = TextPosition::belowRangePosition();
235 RefPtrWillBeRawPtr<Element> scriptToProcess = m_treeBuilder->takeScriptToPro cess(scriptStartPosition); 234 RefPtrWillBeRawPtr<Element> scriptToProcess = m_treeBuilder->takeScriptToPro cess(scriptStartPosition);
236 m_scriptRunner.runScript(toHTMLScriptElement(scriptToProcess.get()), scriptS tartPosition); 235 m_scriptRunner.runScript(toHTMLScriptElement(scriptToProcess.get()), scriptS tartPosition);
237 } 236 }
238 237
239 bool HTMLDocumentParser::canTakeNextToken(SynchronousMode mode, PumpSession& ses sion) 238 bool HTMLDocumentParser::canTakeNextToken(SynchronousMode mode, PumpSession& ses sion)
240 { 239 {
241 if (isStopped()) 240 if (isStopped())
(...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after
696 void HTMLDocumentParser::executeScriptsWaitingForResources() 695 void HTMLDocumentParser::executeScriptsWaitingForResources()
697 { 696 {
698 if (!m_scriptRunner.hasPendingScripts()) 697 if (!m_scriptRunner.hasPendingScripts())
699 return; 698 return;
700 RefPtrWillBeRawPtr<HTMLDocumentParser> protect(this); 699 RefPtrWillBeRawPtr<HTMLDocumentParser> protect(this);
701 m_scriptRunner.executePendingScripts(); 700 m_scriptRunner.executePendingScripts();
702 if (!isWaitingForScripts()) 701 if (!isWaitingForScripts())
703 resumeParsingAfterScriptExecution(); 702 resumeParsingAfterScriptExecution();
704 } 703 }
705 704
706 void HTMLDocumentParser::parseDocumentFragment(const String& source, DocumentFra gment* fragment, Element* contextElement, ParserContentPolicy parserContentPolic y) 705 void HTMLDocumentParser::parseDocumentFragment(const String& source, DocumentFra gment* fragment, Element* contextElement)
707 { 706 {
708 RefPtrWillBeRawPtr<HTMLDocumentParser> parser = HTMLDocumentParser::create(f ragment, contextElement, parserContentPolicy); 707 RefPtrWillBeRawPtr<HTMLDocumentParser> parser = HTMLDocumentParser::create(f ragment, contextElement);
709 parser->insert(source); // Use insert() so that the parser will not yield. 708 parser->insert(source); // Use insert() so that the parser will not yield.
710 parser->finish(); 709 parser->finish();
711 ASSERT(!parser->processingData()); // Make sure we're done. <rdar://problem/ 3963151> 710 ASSERT(!parser->processingData()); // Make sure we're done. <rdar://problem/ 3963151>
712 parser->detach(); // Allows ~DocumentParser to assert it was detached before destruction. 711 parser->detach(); // Allows ~DocumentParser to assert it was detached before destruction.
713 } 712 }
714 713
715 void HTMLDocumentParser::appendBytes(const char* data, size_t length) 714 void HTMLDocumentParser::appendBytes(const char* data, size_t length)
716 { 715 {
717 if (!length || isStopped()) 716 if (!length || isStopped())
718 return; 717 return;
(...skipping 22 matching lines...) Expand all
741 740
742 if (m_haveBackgroundParser) { 741 if (m_haveBackgroundParser) {
743 HTMLParserThread::taskRunner()->PostTask(FROM_HERE, 742 HTMLParserThread::taskRunner()->PostTask(FROM_HERE,
744 base::Bind(&BackgroundHTMLParser::flush, m_backgroundParser)); 743 base::Bind(&BackgroundHTMLParser::flush, m_backgroundParser));
745 } else { 744 } else {
746 DecodedDataDocumentParser::flush(); 745 DecodedDataDocumentParser::flush();
747 } 746 }
748 } 747 }
749 748
750 } 749 }
OLDNEW
« no previous file with comments | « sky/engine/core/html/parser/HTMLDocumentParser.h ('k') | sky/engine/core/html/parser/HTMLTreeBuilder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698