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

Unified Diff: Source/core/html/track/vtt/VTTCue.cpp

Issue 101513002: Add new helper VTTParser::collectDigitsToInt (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebased Created 7 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | Source/core/html/track/vtt/VTTParser.h » ('j') | Source/core/html/track/vtt/VTTRegion.cpp » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/html/track/vtt/VTTCue.cpp
diff --git a/Source/core/html/track/vtt/VTTCue.cpp b/Source/core/html/track/vtt/VTTCue.cpp
index dd9f6e84b738c66249ff4bcd4aac7c5cf79515bc..880a89f8e2f90ed61d3082d5fc66fe0d7146bfce 100644
--- a/Source/core/html/track/vtt/VTTCue.cpp
+++ b/Source/core/html/track/vtt/VTTCue.cpp
@@ -967,8 +967,8 @@ void VTTCue::parseSettings(const String& input)
// U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9), then jump to the step labeled next setting.
// 2. If value does not contain at least one character in the range U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9),
// then jump to the step labeled next setting.
- String textPosition = VTTParser::collectDigits(input, &position);
- if (textPosition.isEmpty())
+ int number;
+ if (!VTTParser::collectDigitsToInt(input, &position, number))
break;
if (position >= input.length())
break;
@@ -985,10 +985,6 @@ void VTTCue::parseSettings(const String& input)
// 5. Ignoring the trailing percent sign, interpret value as an integer, and let number be that number.
// 6. If number is not in the range 0 ≤ number ≤ 100, then jump to the step labeled next setting.
// NOTE: toInt ignores trailing non-digit characters, such as '%'.
- bool validNumber;
- int number = textPosition.toInt(&validNumber);
- if (!validNumber)
- break;
if (number < 0 || number > 100)
break;
@@ -1002,8 +998,8 @@ void VTTCue::parseSettings(const String& input)
// range U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9), then jump to the step labeled next setting.
// 2. If value does not contain at least one character in the range U+0030 DIGIT ZERO (0) to U+0039 DIGIT
// NINE (9), then jump to the step labeled next setting.
- String cueSize = VTTParser::collectDigits(input, &position);
- if (cueSize.isEmpty())
+ int number;
+ if (!VTTParser::collectDigitsToInt(input, &position, number))
break;
if (position >= input.length())
break;
@@ -1019,10 +1015,6 @@ void VTTCue::parseSettings(const String& input)
// 5. Ignoring the trailing percent sign, interpret value as an integer, and let number be that number.
// 6. If number is not in the range 0 ≤ number ≤ 100, then jump to the step labeled next setting.
- bool validNumber;
- int number = cueSize.toInt(&validNumber);
- if (!validNumber)
- break;
if (number < 0 || number > 100)
break;
« no previous file with comments | « no previous file | Source/core/html/track/vtt/VTTParser.h » ('j') | Source/core/html/track/vtt/VTTRegion.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698