| Index: third_party/WebKit/Source/core/dom/DOMTokenList.cpp
|
| diff --git a/third_party/WebKit/Source/core/dom/DOMTokenList.cpp b/third_party/WebKit/Source/core/dom/DOMTokenList.cpp
|
| index 11dbfc79c3da346fa9a9da1d7a923e6631701e4c..60e9c7f6f6c185af61343ecb7129fad18d16bafe 100644
|
| --- a/third_party/WebKit/Source/core/dom/DOMTokenList.cpp
|
| +++ b/third_party/WebKit/Source/core/dom/DOMTokenList.cpp
|
| @@ -126,29 +126,44 @@ void DOMTokenList::remove(const Vector<String>& tokens,
|
| RemoveTokens(tokens);
|
| }
|
|
|
| +// https://dom.spec.whatwg.org/#dom-domtokenlist-toggle
|
| bool DOMTokenList::toggle(const AtomicString& token,
|
| ExceptionState& exception_state) {
|
| if (!ValidateToken(token, exception_state))
|
| return false;
|
|
|
| + // 4. If context object’s token set[token] exists, then:
|
| if (contains(token)) {
|
| - RemoveInternal(token);
|
| + // 1. If force is either not given or is false, then remove token from
|
| + // context object’s token set.
|
| + RemoveTokens(Vector<String>({token}));
|
| return false;
|
| }
|
| - AddInternal(token);
|
| + // 5. Otherwise, if force not given or is true, append token to context
|
| + // object’s token set and set result to true.
|
| + AddTokens(Vector<String>({token}));
|
| return true;
|
| }
|
|
|
| +// https://dom.spec.whatwg.org/#dom-domtokenlist-toggle
|
| bool DOMTokenList::toggle(const AtomicString& token,
|
| bool force,
|
| ExceptionState& exception_state) {
|
| if (!ValidateToken(token, exception_state))
|
| return false;
|
|
|
| - if (force)
|
| - AddInternal(token);
|
| - else
|
| - RemoveInternal(token);
|
| + // 4. If context object’s token set[token] exists, then:
|
| + if (contains(token)) {
|
| + // 1. If force is either not given or is false, then remove token from
|
| + // context object’s token set.
|
| + if (!force)
|
| + RemoveTokens(Vector<String>({token}));
|
| + } else {
|
| + // 5. Otherwise, if force not given or is true, append token to context
|
| + // object’s token set and set result to true.
|
| + if (force)
|
| + AddTokens(Vector<String>({token}));
|
| + }
|
|
|
| return force;
|
| }
|
| @@ -158,23 +173,6 @@ bool DOMTokenList::supports(const AtomicString& token,
|
| return ValidateTokenValue(token, exception_state);
|
| }
|
|
|
| -void DOMTokenList::AddInternal(const AtomicString& token) {
|
| - if (contains(token))
|
| - return;
|
| - Vector<String> tokens;
|
| - tokens.push_back(token.GetString());
|
| - AddTokens(tokens);
|
| -}
|
| -
|
| -void DOMTokenList::RemoveInternal(const AtomicString& token) {
|
| - // Check using contains first to skip unnecessary reserialization.
|
| - if (!contains(token))
|
| - return;
|
| - Vector<String> tokens;
|
| - tokens.push_back(token.GetString());
|
| - RemoveTokens(tokens);
|
| -}
|
| -
|
| // https://dom.spec.whatwg.org/#dom-domtokenlist-add
|
| void DOMTokenList::AddTokens(const Vector<String>& tokens) {
|
| // 2. For each token in tokens, append token to context object’s token set.
|
|
|