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

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

Issue 664573004: Live the dream (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: DEPS Created 6 years, 1 month 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 * Copyright (C) 2011, 2014 Apple Inc. All rights reserved. 3 * Copyright (C) 2011, 2014 Apple Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 return; 205 return;
206 } 206 }
207 207
208 ASSERT(mode == TextMode); 208 ASSERT(mode == TextMode);
209 if (token->name() == HTMLNames::scriptTag) { 209 if (token->name() == HTMLNames::scriptTag) {
210 // Pause ourselves so that parsing stops until the script can be process ed by the caller. 210 // Pause ourselves so that parsing stops until the script can be process ed by the caller.
211 ASSERT(m_tree.currentElement()->hasLocalName(HTMLNames::scriptTag.localN ame())); 211 ASSERT(m_tree.currentElement()->hasLocalName(HTMLNames::scriptTag.localN ame()));
212 m_scriptToProcess = m_tree.currentElement(); 212 m_scriptToProcess = m_tree.currentElement();
213 m_tree.openElements()->pop(); 213 m_tree.openElements()->pop();
214 setInsertionMode(m_originalInsertionMode); 214 setInsertionMode(m_originalInsertionMode);
215
216 if (m_parser->tokenizer()) {
217 // We must set the tokenizer's state to
218 // DataState explicitly if the tokenizer didn't have a chance to.
219 ASSERT(m_parser->tokenizer()->state() == HTMLTokenizer::DataState || m_options.useThreading);
220 m_parser->tokenizer()->setState(HTMLTokenizer::DataState);
221 }
222 return; 215 return;
223 } 216 }
224 m_tree.openElements()->pop(); 217 m_tree.openElements()->pop();
225 setInsertionMode(m_originalInsertionMode); 218 setInsertionMode(m_originalInsertionMode);
226 } 219 }
227 220
228 void HTMLTreeBuilder::processCharacter(AtomicHTMLToken* token) 221 void HTMLTreeBuilder::processCharacter(AtomicHTMLToken* token)
229 { 222 {
230 ASSERT(token->type() == HTMLToken::Character); 223 ASSERT(token->type() == HTMLToken::Character);
231 m_tree.insertTextNode(token->characters()); 224 m_tree.insertTextNode(token->characters());
232 } 225 }
233 226
234 void HTMLTreeBuilder::processEndOfFile(AtomicHTMLToken* token) 227 void HTMLTreeBuilder::processEndOfFile(AtomicHTMLToken* token)
235 { 228 {
236 ASSERT(token->type() == HTMLToken::EndOfFile); 229 ASSERT(token->type() == HTMLToken::EndOfFile);
237 m_tree.processEndOfFile(); 230 m_tree.processEndOfFile();
238 } 231 }
239 232
240 void HTMLTreeBuilder::processGenericRawTextStartTag(AtomicHTMLToken* token) 233 void HTMLTreeBuilder::processGenericRawTextStartTag(AtomicHTMLToken* token)
241 { 234 {
242 ASSERT(token->type() == HTMLToken::StartTag); 235 ASSERT(token->type() == HTMLToken::StartTag);
243 m_tree.insertHTMLElement(token); 236 m_tree.insertHTMLElement(token);
244 if (m_parser->tokenizer())
245 m_parser->tokenizer()->setState(HTMLTokenizer::RAWTEXTState);
246 m_originalInsertionMode = m_insertionMode; 237 m_originalInsertionMode = m_insertionMode;
247 setInsertionMode(TextMode); 238 setInsertionMode(TextMode);
248 } 239 }
249 240
250 void HTMLTreeBuilder::processScriptStartTag(AtomicHTMLToken* token) 241 void HTMLTreeBuilder::processScriptStartTag(AtomicHTMLToken* token)
251 { 242 {
252 ASSERT(token->type() == HTMLToken::StartTag); 243 ASSERT(token->type() == HTMLToken::StartTag);
253 m_tree.insertScriptElement(token); 244 m_tree.insertScriptElement(token);
254 if (m_parser->tokenizer())
255 m_parser->tokenizer()->setState(HTMLTokenizer::ScriptDataState);
256 m_originalInsertionMode = m_insertionMode; 245 m_originalInsertionMode = m_insertionMode;
257 TextPosition position = m_parser->textPosition(); 246 TextPosition position = m_parser->textPosition();
258 m_scriptToProcessStartPosition = position; 247 m_scriptToProcessStartPosition = position;
259 setInsertionMode(TextMode); 248 setInsertionMode(TextMode);
260 } 249 }
261 250
262 void HTMLTreeBuilder::finished() 251 void HTMLTreeBuilder::finished()
263 { 252 {
264 if (isParsingFragment()) 253 if (isParsingFragment())
265 return; 254 return;
266 ASSERT(m_isAttached); 255 ASSERT(m_isAttached);
267 // Warning, this may detach the parser. Do not do anything else after this. 256 // Warning, this may detach the parser. Do not do anything else after this.
268 m_tree.finishedParsing(); 257 m_tree.finishedParsing();
269 } 258 }
270 259
271 } // namespace blink 260 } // namespace blink
OLDNEW
« no previous file with comments | « sky/engine/core/html/parser/HTMLParserOptions.cpp ('k') | sky/engine/core/loader/DocumentWriter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698