| 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 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 if (containsInternal(AtomicString(tokens[i]))) { | 114 if (containsInternal(AtomicString(tokens[i]))) { |
| 115 found = true; | 115 found = true; |
| 116 break; | 116 break; |
| 117 } | 117 } |
| 118 } | 118 } |
| 119 | 119 |
| 120 if (found) | 120 if (found) |
| 121 setValue(removeTokens(value(), tokens)); | 121 setValue(removeTokens(value(), tokens)); |
| 122 } | 122 } |
| 123 | 123 |
| 124 bool DOMTokenList::toggle(const AtomicString& token, ExceptionState& exceptionSt
ate) | 124 bool DOMTokenList::toggle(const AtomicString& token, Optional<bool> force, Excep
tionState& exceptionState) |
| 125 { | 125 { |
| 126 if (!validateToken(token, exceptionState)) | 126 if (!validateToken(token, exceptionState)) |
| 127 return false; | 127 return false; |
| 128 | 128 |
| 129 if (containsInternal(token)) { | 129 if (containsInternal(token)) { |
| 130 removeInternal(token); | 130 if (force.isMissing() || !force.get()) { |
| 131 return false; | 131 removeInternal(token); |
| 132 return false; |
| 133 } |
| 134 return true; |
| 135 } else { |
| 136 if (!force.isMissing() && !force.get()) |
| 137 return false; |
| 138 addInternal(token); |
| 139 return true; |
| 132 } | 140 } |
| 133 addInternal(token); | |
| 134 return true; | |
| 135 } | |
| 136 | |
| 137 bool DOMTokenList::toggle(const AtomicString& token, bool force, ExceptionState&
exceptionState) | |
| 138 { | |
| 139 if (!validateToken(token, exceptionState)) | |
| 140 return false; | |
| 141 | |
| 142 if (force) | |
| 143 addInternal(token); | |
| 144 else | |
| 145 removeInternal(token); | |
| 146 | |
| 147 return force; | |
| 148 } | 141 } |
| 149 | 142 |
| 150 void DOMTokenList::addInternal(const AtomicString& token) | 143 void DOMTokenList::addInternal(const AtomicString& token) |
| 151 { | 144 { |
| 152 if (!containsInternal(token)) | 145 if (!containsInternal(token)) |
| 153 setValue(addToken(value(), token)); | 146 setValue(addToken(value(), token)); |
| 154 } | 147 } |
| 155 | 148 |
| 156 void DOMTokenList::removeInternal(const AtomicString& token) | 149 void DOMTokenList::removeInternal(const AtomicString& token) |
| 157 { | 150 { |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 240 output.append(' '); | 233 output.append(' '); |
| 241 } else { | 234 } else { |
| 242 output.append(token); // Step 9 | 235 output.append(token); // Step 9 |
| 243 } | 236 } |
| 244 } | 237 } |
| 245 | 238 |
| 246 return output.toAtomicString(); | 239 return output.toAtomicString(); |
| 247 } | 240 } |
| 248 | 241 |
| 249 } // namespace blink | 242 } // namespace blink |
| OLD | NEW |