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

Side by Side Diff: Source/core/html/track/vtt/VTTParser.cpp

Issue 77553004: Defer setting type in the WebVTT tokenizer until emitting the token (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 7 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) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2011 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 are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * 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 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after
378 378
379 RefPtr<DocumentFragment> fragment = DocumentFragment::create(m_document); 379 RefPtr<DocumentFragment> fragment = DocumentFragment::create(m_document);
380 380
381 if (cueText.isEmpty()) { 381 if (cueText.isEmpty()) {
382 fragment->parserAppendChild(Text::create(m_document, "")); 382 fragment->parserAppendChild(Text::create(m_document, ""));
383 return fragment; 383 return fragment;
384 } 384 }
385 385
386 m_currentNode = fragment; 386 m_currentNode = fragment;
387 387
388 OwnPtr<VTTTokenizer> tokenizer(VTTTokenizer::create()); 388 VTTTokenizer tokenizer(cueText);
389 m_token.clear(); 389 m_token.clear();
390 m_languageStack.clear(); 390 m_languageStack.clear();
391 391
392 SegmentedString content(cueText); 392 while (tokenizer.nextToken(m_token))
393 while (tokenizer->nextToken(content, m_token))
394 constructTreeFromToken(m_document); 393 constructTreeFromToken(m_document);
395 394
396 return fragment.release(); 395 return fragment.release();
397 } 396 }
398 397
399 PassRefPtr<DocumentFragment> VTTParser::createDocumentFragmentFromCueText(Docume nt& document, const String& cueText) 398 PassRefPtr<DocumentFragment> VTTParser::createDocumentFragmentFromCueText(Docume nt& document, const String& cueText)
400 { 399 {
401 VTTTreeBuilder treeBuilder(document); 400 VTTTreeBuilder treeBuilder(document);
402 return treeBuilder.buildFromString(cueText); 401 return treeBuilder.buildFromString(cueText);
403 } 402 }
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
591 } 590 }
592 591
593 void VTTParser::skipWhiteSpace(const String& line, unsigned* position) 592 void VTTParser::skipWhiteSpace(const String& line, unsigned* position)
594 { 593 {
595 while (*position < line.length() && isASpace(line[*position])) 594 while (*position < line.length() && isASpace(line[*position]))
596 (*position)++; 595 (*position)++;
597 } 596 }
598 597
599 } 598 }
600 599
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698