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 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 return false; | 237 return false; |
238 | 238 |
239 return true; | 239 return true; |
240 } | 240 } |
241 | 241 |
242 void WebVTTParser::collectMetadataHeader(const String& line) | 242 void WebVTTParser::collectMetadataHeader(const String& line) |
243 { | 243 { |
244 // WebVTT header parsing (WebVTT parser algorithm step 12) | 244 // WebVTT header parsing (WebVTT parser algorithm step 12) |
245 DEFINE_STATIC_LOCAL(const AtomicString, regionHeaderName, ("Region", AtomicS
tring::ConstructFromLiteral)); | 245 DEFINE_STATIC_LOCAL(const AtomicString, regionHeaderName, ("Region", AtomicS
tring::ConstructFromLiteral)); |
246 | 246 |
| 247 // The only currently supported header is the "Region" header. |
| 248 if (!RuntimeEnabledFeatures::webVTTRegionsEnabled()) |
| 249 return; |
| 250 |
247 // Step 12.4 If line contains the character ":" (A U+003A COLON), then set m
etadata's | 251 // Step 12.4 If line contains the character ":" (A U+003A COLON), then set m
etadata's |
248 // name to the substring of line before the first ":" character and | 252 // name to the substring of line before the first ":" character and |
249 // metadata's value to the substring after this character. | 253 // metadata's value to the substring after this character. |
250 if (!RuntimeEnabledFeatures::webVTTRegionsEnabled() || !line.contains(":")) | 254 unsigned colonPosition = line.find(':'); |
| 255 if (colonPosition == kNotFound) |
251 return; | 256 return; |
252 | 257 |
253 unsigned colonPosition = line.find(":"); | |
254 String headerName = line.substring(0, colonPosition); | 258 String headerName = line.substring(0, colonPosition); |
255 | 259 |
256 // Steps 12.5 If metadata's name equals "Region": | 260 // Steps 12.5 If metadata's name equals "Region": |
257 if (headerName == regionHeaderName) { | 261 if (headerName == regionHeaderName) { |
258 String headerValue = line.substring(colonPosition + 1); | 262 String headerValue = line.substring(colonPosition + 1); |
259 // Steps 12.5.1 - 12.5.11 Region creation: Let region be a new text trac
k region [...] | 263 // Steps 12.5.1 - 12.5.11 Region creation: Let region be a new text trac
k region [...] |
260 createNewRegion(headerValue); | 264 createNewRegion(headerValue); |
261 } | 265 } |
262 } | 266 } |
263 | 267 |
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
565 } | 569 } |
566 | 570 |
567 void WebVTTParser::skipWhiteSpace(const String& line, unsigned* position) | 571 void WebVTTParser::skipWhiteSpace(const String& line, unsigned* position) |
568 { | 572 { |
569 while (*position < line.length() && isASpace(line[*position])) | 573 while (*position < line.length() && isASpace(line[*position])) |
570 (*position)++; | 574 (*position)++; |
571 } | 575 } |
572 | 576 |
573 } | 577 } |
574 | 578 |
OLD | NEW |