OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2006, 2007, 2008, 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2006, 2007, 2008, 2009 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 851 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
862 CRASH(); | 862 CRASH(); |
863 } | 863 } |
864 } | 864 } |
865 | 865 |
866 bool isValidEnum(const String& value, | 866 bool isValidEnum(const String& value, |
867 const char** validValues, | 867 const char** validValues, |
868 size_t length, | 868 size_t length, |
869 const String& enumName, | 869 const String& enumName, |
870 ExceptionState& exceptionState) { | 870 ExceptionState& exceptionState) { |
871 for (size_t i = 0; i < length; ++i) { | 871 for (size_t i = 0; i < length; ++i) { |
872 if (value == validValues[i]) | 872 // Avoid the strlen inside String::operator== (because of the StringView). |
| 873 if (WTF::equal(value.impl(), validValues[i])) |
873 return true; | 874 return true; |
874 } | 875 } |
875 exceptionState.throwTypeError("The provided value '" + value + | 876 exceptionState.throwTypeError("The provided value '" + value + |
876 "' is not a valid enum value of type " + | 877 "' is not a valid enum value of type " + |
877 enumName + "."); | 878 enumName + "."); |
878 return false; | 879 return false; |
879 } | 880 } |
880 | 881 |
881 bool isValidEnum(const Vector<String>& values, | 882 bool isValidEnum(const Vector<String>& values, |
882 const char** validValues, | 883 const char** validValues, |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1012 if (!v8Call(v8::JSON::Parse(isolate, v8String(isolate, stringifiedJSON)), | 1013 if (!v8Call(v8::JSON::Parse(isolate, v8String(isolate, stringifiedJSON)), |
1013 parsed, tryCatch)) { | 1014 parsed, tryCatch)) { |
1014 if (tryCatch.HasCaught()) | 1015 if (tryCatch.HasCaught()) |
1015 exceptionState.rethrowV8Exception(tryCatch.Exception()); | 1016 exceptionState.rethrowV8Exception(tryCatch.Exception()); |
1016 } | 1017 } |
1017 | 1018 |
1018 return parsed; | 1019 return parsed; |
1019 } | 1020 } |
1020 | 1021 |
1021 } // namespace blink | 1022 } // namespace blink |
OLD | NEW |