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

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

Issue 2898063003: DOMTokenList.contains() should not throw. (Closed)
Patch Set: Move the comment Created 3 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
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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 return true; 60 return true;
61 } 61 }
62 62
63 // https://dom.spec.whatwg.org/#concept-domtokenlist-validation 63 // https://dom.spec.whatwg.org/#concept-domtokenlist-validation
64 bool DOMTokenList::ValidateTokenValue(const AtomicString&, 64 bool DOMTokenList::ValidateTokenValue(const AtomicString&,
65 ExceptionState& exception_state) const { 65 ExceptionState& exception_state) const {
66 exception_state.ThrowTypeError("DOMTokenList has no supported tokens."); 66 exception_state.ThrowTypeError("DOMTokenList has no supported tokens.");
67 return false; 67 return false;
68 } 68 }
69 69
70 bool DOMTokenList::contains(const AtomicString& token, 70 // https://dom.spec.whatwg.org/#dom-domtokenlist-contains
71 ExceptionState& exception_state) const { 71 bool DOMTokenList::contains(const AtomicString& token) const {
72 if (!ValidateToken(token, exception_state))
73 return false;
74 return ContainsInternal(token); 72 return ContainsInternal(token);
75 } 73 }
76 74
77 void DOMTokenList::add(const AtomicString& token, 75 void DOMTokenList::add(const AtomicString& token,
78 ExceptionState& exception_state) { 76 ExceptionState& exception_state) {
79 Vector<String> tokens; 77 Vector<String> tokens;
80 tokens.push_back(token.GetString()); 78 tokens.push_back(token.GetString());
81 add(tokens, exception_state); 79 add(tokens, exception_state);
82 } 80 }
83 81
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 return tokens_.Contains(token); 272 return tokens_.Contains(token);
275 } 273 }
276 274
277 const AtomicString DOMTokenList::item(unsigned index) const { 275 const AtomicString DOMTokenList::item(unsigned index) const {
278 if (index >= length()) 276 if (index >= length())
279 return AtomicString(); 277 return AtomicString();
280 return tokens_[index]; 278 return tokens_[index];
281 } 279 }
282 280
283 } // namespace blink 281 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/DOMTokenList.h ('k') | third_party/WebKit/Source/core/dom/DOMTokenList.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698