| 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 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 240 // 4.1 Extension of WebVTT header parsing (11 - 15) | 240 // 4.1 Extension of WebVTT header parsing (11 - 15) |
| 241 DEFINE_STATIC_LOCAL(const AtomicString, regionHeaderName, ("Region", AtomicS
tring::ConstructFromLiteral)); | 241 DEFINE_STATIC_LOCAL(const AtomicString, regionHeaderName, ("Region", AtomicS
tring::ConstructFromLiteral)); |
| 242 | 242 |
| 243 // 15.4 If line contains the character ":" (A U+003A COLON), then set metada
ta's | 243 // 15.4 If line contains the character ":" (A U+003A COLON), then set metada
ta's |
| 244 // name to the substring of line before the first ":" character and | 244 // name to the substring of line before the first ":" character and |
| 245 // metadata's value to the substring after this character. | 245 // metadata's value to the substring after this character. |
| 246 if (!RuntimeEnabledFeatures::webVTTRegionsEnabled() || !line.contains(":")) | 246 if (!RuntimeEnabledFeatures::webVTTRegionsEnabled() || !line.contains(":")) |
| 247 return; | 247 return; |
| 248 | 248 |
| 249 unsigned colonPosition = line.find(":"); | 249 unsigned colonPosition = line.find(":"); |
| 250 m_currentHeaderName = line.substring(0, colonPosition); | 250 String headerName = line.substring(0, colonPosition); |
| 251 | 251 |
| 252 // 15.5 If metadata's name equals "Region": | 252 // 15.5 If metadata's name equals "Region": |
| 253 if (m_currentHeaderName == regionHeaderName) { | 253 if (headerName == regionHeaderName) { |
| 254 m_currentHeaderValue = line.substring(colonPosition + 1, line.length() -
1); | 254 String headerValue = line.substring(colonPosition + 1); |
| 255 // 15.5.1 - 15.5.8 Region creation: Let region be a new text track regio
n [...] | 255 // 15.5.1 - 15.5.8 Region creation: Let region be a new text track regio
n [...] |
| 256 createNewRegion(); | 256 createNewRegion(headerValue); |
| 257 } | 257 } |
| 258 } | 258 } |
| 259 | 259 |
| 260 WebVTTParser::ParseState WebVTTParser::collectCueId(const String& line) | 260 WebVTTParser::ParseState WebVTTParser::collectCueId(const String& line) |
| 261 { | 261 { |
| 262 if (line.contains("-->")) | 262 if (line.contains("-->")) |
| 263 return collectTimingsAndSettings(line); | 263 return collectTimingsAndSettings(line); |
| 264 m_currentId = line; | 264 m_currentId = line; |
| 265 return TimingsAndSettings; | 265 return TimingsAndSettings; |
| 266 } | 266 } |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 386 | 386 |
| 387 void WebVTTParser::resetCueValues() | 387 void WebVTTParser::resetCueValues() |
| 388 { | 388 { |
| 389 m_currentId = emptyString(); | 389 m_currentId = emptyString(); |
| 390 m_currentSettings = emptyString(); | 390 m_currentSettings = emptyString(); |
| 391 m_currentStartTime = 0; | 391 m_currentStartTime = 0; |
| 392 m_currentEndTime = 0; | 392 m_currentEndTime = 0; |
| 393 m_currentContent.clear(); | 393 m_currentContent.clear(); |
| 394 } | 394 } |
| 395 | 395 |
| 396 void WebVTTParser::createNewRegion() | 396 void WebVTTParser::createNewRegion(const String& headerValue) |
| 397 { | 397 { |
| 398 if (!m_currentHeaderValue.length()) | 398 if (headerValue.isEmpty()) |
| 399 return; | 399 return; |
| 400 | 400 |
| 401 RefPtr<VTTRegion> region = VTTRegion::create(); | 401 RefPtr<VTTRegion> region = VTTRegion::create(); |
| 402 region->setRegionSettings(m_currentHeaderValue); | 402 region->setRegionSettings(headerValue); |
| 403 | 403 |
| 404 // 15.5.10 If the text track list of regions regions contains a region | 404 // 15.5.10 If the text track list of regions regions contains a region |
| 405 // with the same region identifier value as region, remove that region. | 405 // with the same region identifier value as region, remove that region. |
| 406 for (size_t i = 0; i < m_regionList.size(); ++i) | 406 for (size_t i = 0; i < m_regionList.size(); ++i) |
| 407 if (m_regionList[i]->id() == region->id()) { | 407 if (m_regionList[i]->id() == region->id()) { |
| 408 m_regionList.remove(i); | 408 m_regionList.remove(i); |
| 409 break; | 409 break; |
| 410 } | 410 } |
| 411 | 411 |
| 412 m_regionList.append(region); | 412 m_regionList.append(region); |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 561 } | 561 } |
| 562 | 562 |
| 563 void WebVTTParser::skipWhiteSpace(const String& line, unsigned* position) | 563 void WebVTTParser::skipWhiteSpace(const String& line, unsigned* position) |
| 564 { | 564 { |
| 565 while (*position < line.length() && isASpace(line[*position])) | 565 while (*position < line.length() && isASpace(line[*position])) |
| 566 (*position)++; | 566 (*position)++; |
| 567 } | 567 } |
| 568 | 568 |
| 569 } | 569 } |
| 570 | 570 |
| OLD | NEW |