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

Side by Side Diff: Source/platform/Length.cpp

Issue 1111513003: Simplify parseHTMLAreaCoordinate (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 7 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 | « no previous file | no next file » | 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) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2001 Dirk Mueller ( mueller@kde.org ) 4 * (C) 2001 Dirk Mueller ( mueller@kde.org )
5 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserv ed. 5 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserv ed.
6 * Copyright (C) 2006 Andrew Wellington (proton@wiretapped.net) 6 * Copyright (C) 2006 Andrew Wellington (proton@wiretapped.net)
7 * 7 *
8 * This library is free software; you can redistribute it and/or 8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public 9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either 10 * License as published by the Free Software Foundation; either
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 return i; 59 return i;
60 } 60 }
61 61
62 template<typename CharType> 62 template<typename CharType>
63 static Length parseHTMLAreaCoordinate(const CharType* data, unsigned length) 63 static Length parseHTMLAreaCoordinate(const CharType* data, unsigned length)
64 { 64 {
65 unsigned intLength; 65 unsigned intLength;
66 unsigned doubleLength; 66 unsigned doubleLength;
67 splitLength(data, length, intLength, doubleLength); 67 splitLength(data, length, intLength, doubleLength);
68 68
69 bool ok; 69 return Length(charactersToIntStrict(data, intLength), Fixed);
70 int r = charactersToIntStrict(data, intLength, &ok);
71 if (ok)
72 return Length(r, Fixed);
73 return Length(0, Fixed);
74 } 70 }
75 71
76 // FIXME: Per HTML5, this should follow the "rules for parsing a list of integer s". 72 // FIXME: Per HTML5, this should follow the "rules for parsing a list of integer s".
77 Vector<Length> parseHTMLAreaElementCoords(const String& string) 73 Vector<Length> parseHTMLAreaElementCoords(const String& string)
78 { 74 {
79 unsigned length = string.length(); 75 unsigned length = string.length();
80 StringBuffer<LChar> spacified(length); 76 StringBuffer<LChar> spacified(length);
81 for (unsigned i = 0; i < length; i++) { 77 for (unsigned i = 0; i < length; i++) {
82 UChar cc = string[i]; 78 UChar cc = string[i];
83 if (cc > '9' || (cc < '0' && cc != '-' && cc != '.')) 79 if (cc > '9' || (cc < '0' && cc != '-' && cc != '.'))
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 return isCalculated() && (&calculationValue() == &o.calculationValue() || ca lculationValue() == o.calculationValue()); 242 return isCalculated() && (&calculationValue() == &o.calculationValue() || ca lculationValue() == o.calculationValue());
247 } 243 }
248 244
249 struct SameSizeAsLength { 245 struct SameSizeAsLength {
250 int32_t value; 246 int32_t value;
251 int32_t metaData; 247 int32_t metaData;
252 }; 248 };
253 static_assert(sizeof(Length) == sizeof(SameSizeAsLength), "length should stay sm all"); 249 static_assert(sizeof(Length) == sizeof(SameSizeAsLength), "length should stay sm all");
254 250
255 } // namespace blink 251 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698