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

Side by Side Diff: Source/core/dom/DOMTokenList.cpp

Issue 479243002: Simplify DOMTokenList::validateToken() code (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 4 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 | Annotate | Revision Log
« 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) 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
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
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
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