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

Side by Side Diff: Source/core/html/MediaFragmentURIParser.cpp

Issue 606703002: Comply (more) with check-webkit-style in and around HTMLMediaElement (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 2 months 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/html/HTMLVideoElement.cpp ('k') | Source/core/html/shadow/MediaControlElements.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011, 2012 Apple Inc. All rights reserved. 2 * Copyright (C) 2011, 2012 Apple 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 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 // SHOULD be ignored by the UA. 191 // SHOULD be ignored by the UA.
192 } 192 }
193 } 193 }
194 m_fragments.clear(); 194 m_fragments.clear();
195 } 195 }
196 196
197 bool MediaFragmentURIParser::parseNPTFragment(const LChar* timeString, unsigned length, double& startTime, double& endTime) 197 bool MediaFragmentURIParser::parseNPTFragment(const LChar* timeString, unsigned length, double& startTime, double& endTime)
198 { 198 {
199 unsigned offset = 0; 199 unsigned offset = 0;
200 if (length >= nptIdentiferLength && timeString[0] == 'n' && timeString[1] == 'p' && timeString[2] == 't' && timeString[3] == ':') 200 if (length >= nptIdentiferLength && timeString[0] == 'n' && timeString[1] == 'p' && timeString[2] == 't' && timeString[3] == ':')
201 offset += nptIdentiferLength; 201 offset += nptIdentiferLength;
202 202
203 if (offset == length) 203 if (offset == length)
204 return false; 204 return false;
205 205
206 // http://www.w3.org/2008/WebVideo/Fragments/WD-media-fragments-spec/#naming -time 206 // http://www.w3.org/2008/WebVideo/Fragments/WD-media-fragments-spec/#naming -time
207 // If a single number only is given, this corresponds to the begin time exce pt if it is preceded 207 // If a single number only is given, this corresponds to the begin time exce pt if it is preceded
208 // by a comma that would in this case indicate the end time. 208 // by a comma that would in this case indicate the end time.
209 if (timeString[offset] == ',') 209 if (timeString[offset] == ',') {
210 startTime = 0; 210 startTime = 0;
211 else { 211 } else {
212 if (!parseNPTTime(timeString, length, offset, startTime)) 212 if (!parseNPTTime(timeString, length, offset, startTime))
213 return false; 213 return false;
214 } 214 }
215 215
216 if (offset == length) 216 if (offset == length)
217 return true; 217 return true;
218 218
219 if (timeString[offset] != ',') 219 if (timeString[offset] != ',')
220 return false; 220 return false;
221 if (++offset == length) 221 if (++offset == length)
222 return false; 222 return false;
223 223
224 if (!parseNPTTime(timeString, length, offset, endTime)) 224 if (!parseNPTTime(timeString, length, offset, endTime))
225 return false; 225 return false;
226 226
227 if (offset != length) 227 if (offset != length)
228 return false; 228 return false;
229 229
230 if (startTime >= endTime) 230 if (startTime >= endTime)
231 return false; 231 return false;
232 232
233 return true; 233 return true;
234 } 234 }
235 235
236 bool MediaFragmentURIParser::parseNPTTime(const LChar* timeString, unsigned leng th, unsigned& offset, double& time) 236 bool MediaFragmentURIParser::parseNPTTime(const LChar* timeString, unsigned leng th, unsigned& offset, double& time)
237 { 237 {
238 enum Mode { minutes, hours }; 238 enum Mode { Minutes, Hours };
239 Mode mode = minutes; 239 Mode mode = Minutes;
240 240
241 if (offset >= length || !isASCIIDigit(timeString[offset])) 241 if (offset >= length || !isASCIIDigit(timeString[offset]))
242 return false; 242 return false;
243 243
244 // http://www.w3.org/2008/WebVideo/Fragments/WD-media-fragments-spec/#npttim edef 244 // http://www.w3.org/2008/WebVideo/Fragments/WD-media-fragments-spec/#npttim edef
245 // Normal Play Time can either be specified as seconds, with an optional 245 // Normal Play Time can either be specified as seconds, with an optional
246 // fractional part to indicate miliseconds, or as colon-separated hours, 246 // fractional part to indicate miliseconds, or as colon-separated hours,
247 // minutes and seconds (again with an optional fraction). Minutes and 247 // minutes and seconds (again with an optional fraction). Minutes and
248 // seconds must be specified as exactly two digits, hours and fractional 248 // seconds must be specified as exactly two digits, hours and fractional
249 // seconds can be any number of digits. The hours, minutes and seconds 249 // seconds can be any number of digits. The hours, minutes and seconds
(...skipping 23 matching lines...) Expand all
273 return true; 273 return true;
274 String digits = collectFraction(timeString, length, offset); 274 String digits = collectFraction(timeString, length, offset);
275 fraction = digits.toDouble(); 275 fraction = digits.toDouble();
276 time = value1 + fraction; 276 time = value1 + fraction;
277 return true; 277 return true;
278 } 278 }
279 279
280 if (digits1.length() < 2) 280 if (digits1.length() < 2)
281 return false; 281 return false;
282 if (digits1.length() > 2) 282 if (digits1.length() > 2)
283 mode = hours; 283 mode = Hours;
284 284
285 // Collect the next sequence of 0-9 after ':' 285 // Collect the next sequence of 0-9 after ':'
286 if (offset >= length || timeString[offset++] != ':') 286 if (offset >= length || timeString[offset++] != ':')
287 return false; 287 return false;
288 if (offset >= length || !isASCIIDigit(timeString[(offset)])) 288 if (offset >= length || !isASCIIDigit(timeString[(offset)]))
289 return false; 289 return false;
290 String digits2 = collectDigits(timeString, length, offset); 290 String digits2 = collectDigits(timeString, length, offset);
291 int value2 = digits2.toInt(); 291 int value2 = digits2.toInt();
292 if (digits2.length() != 2) 292 if (digits2.length() != 2)
293 return false; 293 return false;
294 294
295 // Detect whether this timestamp includes hours. 295 // Detect whether this timestamp includes hours.
296 int value3; 296 int value3;
297 if (mode == hours || (offset < length && timeString[offset] == ':')) { 297 if (mode == Hours || (offset < length && timeString[offset] == ':')) {
298 if (offset >= length || timeString[offset++] != ':') 298 if (offset >= length || timeString[offset++] != ':')
299 return false; 299 return false;
300 if (offset >= length || !isASCIIDigit(timeString[offset])) 300 if (offset >= length || !isASCIIDigit(timeString[offset]))
301 return false; 301 return false;
302 String digits3 = collectDigits(timeString, length, offset); 302 String digits3 = collectDigits(timeString, length, offset);
303 if (digits3.length() != 2) 303 if (digits3.length() != 2)
304 return false; 304 return false;
305 value3 = digits3.toInt(); 305 value3 = digits3.toInt();
306 } else { 306 } else {
307 value3 = value2; 307 value3 = value2;
308 value2 = value1; 308 value2 = value1;
309 value1 = 0; 309 value1 = 0;
310 } 310 }
311 311
312 if (offset < length && timeString[offset] == '.') 312 if (offset < length && timeString[offset] == '.')
313 fraction = collectFraction(timeString, length, offset).toDouble(); 313 fraction = collectFraction(timeString, length, offset).toDouble();
314 314
315 time = (value1 * secondsPerHour) + (value2 * secondsPerMinute) + value3 + fr action; 315 time = (value1 * secondsPerHour) + (value2 * secondsPerMinute) + value3 + fr action;
316 return true; 316 return true;
317 } 317 }
318 318
319 } 319 }
OLDNEW
« no previous file with comments | « Source/core/html/HTMLVideoElement.cpp ('k') | Source/core/html/shadow/MediaControlElements.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698