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

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

Issue 143983002: Rework end-of-value field handling in VTTRegion::parseSettingValue (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 11 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
« no previous file with comments | « Source/core/html/track/vtt/VTTParser.h ('k') | Source/core/html/track/vtt/VTTRegion.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 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 30 matching lines...) Expand all
41 41
42 namespace WebCore { 42 namespace WebCore {
43 43
44 using namespace HTMLNames; 44 using namespace HTMLNames;
45 45
46 const double secondsPerHour = 3600; 46 const double secondsPerHour = 3600;
47 const double secondsPerMinute = 60; 47 const double secondsPerMinute = 60;
48 const double secondsPerMillisecond = 0.001; 48 const double secondsPerMillisecond = 0.001;
49 const unsigned fileIdentifierLength = 6; 49 const unsigned fileIdentifierLength = 6;
50 50
51 unsigned VTTParser::collectDigitsToInt(const String& input, unsigned* position, int& number)
52 {
53 VTTLegacyScanner inputScanner(input, position);
54 return inputScanner.scanDigits(number);
55 }
56
57 bool VTTParser::parseFloatPercentageValue(VTTScanner& valueScanner, float& perce ntage) 51 bool VTTParser::parseFloatPercentageValue(VTTScanner& valueScanner, float& perce ntage)
58 { 52 {
59 float number; 53 float number;
60 if (!valueScanner.scanFloat(number)) 54 if (!valueScanner.scanFloat(number))
61 return false; 55 return false;
62 // '%' must be present and at the end of the setting value. 56 // '%' must be present and at the end of the setting value.
63 if (!valueScanner.scan('%')) 57 if (!valueScanner.scan('%'))
64 return false; 58 return false;
65 if (number < 0 || number > 100) 59 if (number < 0 || number > 100)
66 return false; 60 return false;
67 percentage = number; 61 percentage = number;
68 return true; 62 return true;
69 } 63 }
70 64
71 bool VTTParser::parseFloatPercentageValuePair(const String& value, char delimite r, FloatPoint& valuePair) 65 bool VTTParser::parseFloatPercentageValuePair(VTTScanner& valueScanner, char del imiter, FloatPoint& valuePair)
72 { 66 {
73 VTTScanner valueScanner(value);
74
75 float firstCoord; 67 float firstCoord;
76 if (!parseFloatPercentageValue(valueScanner, firstCoord)) 68 if (!parseFloatPercentageValue(valueScanner, firstCoord))
77 return false; 69 return false;
78 70
79 if (!valueScanner.scan(delimiter)) 71 if (!valueScanner.scan(delimiter))
80 return false; 72 return false;
81 73
82 float secondCoord; 74 float secondCoord;
83 if (!parseFloatPercentageValue(valueScanner, secondCoord)) 75 if (!parseFloatPercentageValue(valueScanner, secondCoord))
84 return false; 76 return false;
85 77
86 if (!valueScanner.isAtEnd())
87 return false;
88
89 valuePair = FloatPoint(firstCoord, secondCoord); 78 valuePair = FloatPoint(firstCoord, secondCoord);
90 return true; 79 return true;
91 } 80 }
92 81
93 VTTParser::VTTParser(VTTParserClient* client, Document& document) 82 VTTParser::VTTParser(VTTParserClient* client, Document& document)
94 : m_document(&document) 83 : m_document(&document)
95 , m_state(Initial) 84 , m_state(Initial)
96 , m_decoder(TextResourceDecoder::create("text/plain", UTF8Encoding())) 85 , m_decoder(TextResourceDecoder::create("text/plain", UTF8Encoding()))
97 , m_currentStartTime(0) 86 , m_currentStartTime(0)
98 , m_currentEndTime(0) 87 , m_currentEndTime(0)
(...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after
563 m_currentNode->parserAppendChild(ProcessingInstruction::create(docum ent, "timestamp", charactersString)); 552 m_currentNode->parserAppendChild(ProcessingInstruction::create(docum ent, "timestamp", charactersString));
564 break; 553 break;
565 } 554 }
566 default: 555 default:
567 break; 556 break;
568 } 557 }
569 } 558 }
570 559
571 } 560 }
572 561
OLDNEW
« no previous file with comments | « Source/core/html/track/vtt/VTTParser.h ('k') | Source/core/html/track/vtt/VTTRegion.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698