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

Side by Side Diff: third_party/WebKit/Source/core/svg/SVGParserUtilities.cpp

Issue 1667353003: Error reporting for number-or-percentage (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2002, 2003 The Karbon Developers 2 * Copyright (C) 2002, 2003 The Karbon Developers
3 * Copyright (C) 2006 Alexander Kellett <lypanov@kde.org> 3 * Copyright (C) 2006 Alexander Kellett <lypanov@kde.org>
4 * Copyright (C) 2006, 2007 Rob Buis <buis@kde.org> 4 * Copyright (C) 2006, 2007 Rob Buis <buis@kde.org>
5 * Copyright (C) 2007, 2009, 2013 Apple Inc. All rights reserved. 5 * Copyright (C) 2007, 2009, 2013 Apple Inc. All rights reserved.
6 * 6 *
7 * This library is free software; you can redistribute it and/or 7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public 8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either 9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version. 10 * version 2 of the License, or (at your option) any later version.
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 if (string.is8Bit()) { 207 if (string.is8Bit()) {
208 const LChar* ptr = string.characters8(); 208 const LChar* ptr = string.characters8();
209 const LChar* end = ptr + string.length(); 209 const LChar* end = ptr + string.length();
210 return genericParseNumberOptionalNumber(ptr, end, x, y); 210 return genericParseNumberOptionalNumber(ptr, end, x, y);
211 } 211 }
212 const UChar* ptr = string.characters16(); 212 const UChar* ptr = string.characters16();
213 const UChar* end = ptr + string.length(); 213 const UChar* end = ptr + string.length();
214 return genericParseNumberOptionalNumber(ptr, end, x, y); 214 return genericParseNumberOptionalNumber(ptr, end, x, y);
215 } 215 }
216 216
217 template<typename CharType>
218 bool genericParseNumberOrPercentage(const CharType*& ptr, const CharType* end, f loat& number)
219 {
220 if (genericParseNumber(ptr, end, number, AllowLeadingWhitespace)) {
221 if (ptr == end)
222 return true;
223
224 bool isPercentage = (*ptr == '%');
225 if (isPercentage)
226 ptr++;
227
228 skipOptionalSVGSpaces(ptr, end);
229
230 if (isPercentage)
231 number /= 100.f;
232
233 return ptr == end;
234 }
235
236 return false;
237 }
238
239 bool parseNumberOrPercentage(const String& string, float& number)
240 {
241 if (string.isEmpty())
242 return false;
243
244 if (string.is8Bit()) {
245 const LChar* ptr = string.characters8();
246 const LChar* end = ptr + string.length();
247 return genericParseNumberOrPercentage(ptr, end, number);
248 }
249 const UChar* ptr = string.characters16();
250 const UChar* end = ptr + string.length();
251 return genericParseNumberOrPercentage(ptr, end, number);
252 }
253
254 } // namespace blink 217 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/svg/SVGParserUtilities.h ('k') | third_party/WebKit/Source/core/svg/SVGParsingError.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698