OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 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 | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 21 matching lines...) Expand all Loading... |
32 | 32 |
33 namespace blink { | 33 namespace blink { |
34 | 34 |
35 bool DOMTokenList::validateToken(const String& token, ExceptionState& exceptionS
tate) | 35 bool DOMTokenList::validateToken(const String& token, ExceptionState& exceptionS
tate) |
36 { | 36 { |
37 if (token.isEmpty()) { | 37 if (token.isEmpty()) { |
38 exceptionState.throwDOMException(SyntaxError, "The token provided must n
ot be empty."); | 38 exceptionState.throwDOMException(SyntaxError, "The token provided must n
ot be empty."); |
39 return false; | 39 return false; |
40 } | 40 } |
41 | 41 |
42 unsigned length = token.length(); | 42 if (token.find(isHTMLSpace) != kNotFound) { |
43 for (unsigned i = 0; i < length; ++i) { | 43 exceptionState.throwDOMException(InvalidCharacterError, "The token provi
ded ('" + token + "') contains HTML space characters, which are not valid in tok
ens."); |
44 if (isHTMLSpace<UChar>(token[i])) { | 44 return false; |
45 exceptionState.throwDOMException(InvalidCharacterError, "The token p
rovided ('" + token + "') contains HTML space characters, which are not valid in
tokens."); | |
46 return false; | |
47 } | |
48 } | 45 } |
49 | 46 |
50 return true; | 47 return true; |
51 } | 48 } |
52 | 49 |
53 bool DOMTokenList::validateTokens(const Vector<String>& tokens, ExceptionState&
exceptionState) | 50 bool DOMTokenList::validateTokens(const Vector<String>& tokens, ExceptionState&
exceptionState) |
54 { | 51 { |
55 for (size_t i = 0; i < tokens.size(); ++i) { | 52 for (size_t i = 0; i < tokens.size(); ++i) { |
56 if (!validateToken(tokens[i], exceptionState)) | 53 if (!validateToken(tokens[i], exceptionState)) |
57 return false; | 54 return false; |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
243 output.append(' '); | 240 output.append(' '); |
244 } else { | 241 } else { |
245 output.append(token); // Step 9 | 242 output.append(token); // Step 9 |
246 } | 243 } |
247 } | 244 } |
248 | 245 |
249 return output.toAtomicString(); | 246 return output.toAtomicString(); |
250 } | 247 } |
251 | 248 |
252 } // namespace blink | 249 } // namespace blink |
OLD | NEW |