| OLD | NEW |
| 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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 VTTParser::VTTParser(VTTParserClient* client, Document& document) | 82 VTTParser::VTTParser(VTTParserClient* client, Document& document) |
| 83 : m_document(&document) | 83 : m_document(&document) |
| 84 , m_state(Initial) | 84 , m_state(Initial) |
| 85 , m_decoder(TextResourceDecoder::create("text/plain", UTF8Encoding())) | 85 , m_decoder(TextResourceDecoder::create("text/plain", UTF8Encoding())) |
| 86 , m_currentStartTime(0) | 86 , m_currentStartTime(0) |
| 87 , m_currentEndTime(0) | 87 , m_currentEndTime(0) |
| 88 , m_client(client) | 88 , m_client(client) |
| 89 { | 89 { |
| 90 } | 90 } |
| 91 | 91 |
| 92 void VTTParser::getNewCues(Vector<RefPtr<VTTCue> >& outputCues) | 92 void VTTParser::getNewCues(WillBeHeapVector<RefPtrWillBeMember<VTTCue> >& output
Cues) |
| 93 { | 93 { |
| 94 outputCues = m_cuelist; | 94 outputCues = m_cueList; |
| 95 m_cuelist.clear(); | 95 m_cueList.clear(); |
| 96 } | 96 } |
| 97 | 97 |
| 98 void VTTParser::getNewRegions(Vector<RefPtr<VTTRegion> >& outputRegions) | 98 void VTTParser::getNewRegions(WillBeHeapVector<RefPtrWillBeMember<VTTRegion> >&
outputRegions) |
| 99 { | 99 { |
| 100 outputRegions = m_regionList; | 100 outputRegions = m_regionList; |
| 101 m_regionList.clear(); | 101 m_regionList.clear(); |
| 102 } | 102 } |
| 103 | 103 |
| 104 void VTTParser::parseBytes(const char* data, unsigned length) | 104 void VTTParser::parseBytes(const char* data, unsigned length) |
| 105 { | 105 { |
| 106 String textData = m_decoder->decode(data, length); | 106 String textData = m_decoder->decode(data, length); |
| 107 m_lineReader.append(textData); | 107 m_lineReader.append(textData); |
| 108 parse(); | 108 parse(); |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 356 } | 356 } |
| 357 | 357 |
| 358 PassRefPtr<DocumentFragment> VTTParser::createDocumentFragmentFromCueText(Docume
nt& document, const String& cueText) | 358 PassRefPtr<DocumentFragment> VTTParser::createDocumentFragmentFromCueText(Docume
nt& document, const String& cueText) |
| 359 { | 359 { |
| 360 VTTTreeBuilder treeBuilder(document); | 360 VTTTreeBuilder treeBuilder(document); |
| 361 return treeBuilder.buildFromString(cueText); | 361 return treeBuilder.buildFromString(cueText); |
| 362 } | 362 } |
| 363 | 363 |
| 364 void VTTParser::createNewCue() | 364 void VTTParser::createNewCue() |
| 365 { | 365 { |
| 366 RefPtr<VTTCue> cue = VTTCue::create(*m_document, m_currentStartTime, m_curre
ntEndTime, m_currentContent.toString()); | 366 RefPtrWillBeRawPtr<VTTCue> cue = VTTCue::create(*m_document, m_currentStartT
ime, m_currentEndTime, m_currentContent.toString()); |
| 367 cue->setId(m_currentId); | 367 cue->setId(m_currentId); |
| 368 cue->parseSettings(m_currentSettings); | 368 cue->parseSettings(m_currentSettings); |
| 369 | 369 |
| 370 m_cuelist.append(cue); | 370 m_cueList.append(cue); |
| 371 if (m_client) | 371 if (m_client) |
| 372 m_client->newCuesParsed(); | 372 m_client->newCuesParsed(); |
| 373 } | 373 } |
| 374 | 374 |
| 375 void VTTParser::resetCueValues() | 375 void VTTParser::resetCueValues() |
| 376 { | 376 { |
| 377 m_currentId = emptyAtom; | 377 m_currentId = emptyAtom; |
| 378 m_currentSettings = emptyString(); | 378 m_currentSettings = emptyString(); |
| 379 m_currentStartTime = 0; | 379 m_currentStartTime = 0; |
| 380 m_currentEndTime = 0; | 380 m_currentEndTime = 0; |
| 381 m_currentContent.clear(); | 381 m_currentContent.clear(); |
| 382 } | 382 } |
| 383 | 383 |
| 384 void VTTParser::createNewRegion(const String& headerValue) | 384 void VTTParser::createNewRegion(const String& headerValue) |
| 385 { | 385 { |
| 386 if (headerValue.isEmpty()) | 386 if (headerValue.isEmpty()) |
| 387 return; | 387 return; |
| 388 | 388 |
| 389 // Steps 12.5.1 - 12.5.9 - Construct and initialize a WebVTT Region object. | 389 // Steps 12.5.1 - 12.5.9 - Construct and initialize a WebVTT Region object. |
| 390 RefPtr<VTTRegion> region = VTTRegion::create(); | 390 RefPtrWillBeRawPtr<VTTRegion> region = VTTRegion::create(); |
| 391 region->setRegionSettings(headerValue); | 391 region->setRegionSettings(headerValue); |
| 392 | 392 |
| 393 // Step 12.5.10 If the text track list of regions regions contains a region | 393 // Step 12.5.10 If the text track list of regions regions contains a region |
| 394 // with the same region identifier value as region, remove that region. | 394 // with the same region identifier value as region, remove that region. |
| 395 for (size_t i = 0; i < m_regionList.size(); ++i) { | 395 for (size_t i = 0; i < m_regionList.size(); ++i) { |
| 396 if (m_regionList[i]->id() == region->id()) { | 396 if (m_regionList[i]->id() == region->id()) { |
| 397 m_regionList.remove(i); | 397 m_regionList.remove(i); |
| 398 break; | 398 break; |
| 399 } | 399 } |
| 400 } | 400 } |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 550 double parsedTimeStamp; | 550 double parsedTimeStamp; |
| 551 if (VTTParser::collectTimeStamp(charactersString, parsedTimeStamp)) | 551 if (VTTParser::collectTimeStamp(charactersString, parsedTimeStamp)) |
| 552 m_currentNode->parserAppendChild(ProcessingInstruction::create(docum
ent, "timestamp", charactersString)); | 552 m_currentNode->parserAppendChild(ProcessingInstruction::create(docum
ent, "timestamp", charactersString)); |
| 553 break; | 553 break; |
| 554 } | 554 } |
| 555 default: | 555 default: |
| 556 break; | 556 break; |
| 557 } | 557 } |
| 558 } | 558 } |
| 559 | 559 |
| 560 void VTTParser::trace(Visitor* visitor) |
| 561 { |
| 562 visitor->trace(m_cueList); |
| 563 visitor->trace(m_regionList); |
| 560 } | 564 } |
| 561 | 565 |
| 566 } |
| OLD | NEW |