2 * Copyright (C) 2010 Google Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
15 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
16 * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
17 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
18 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
19 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
20 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
22 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 #include "DOMSettableTokenList.h"
30 DOMSettableTokenList::DOMSettableTokenList()
36 DOMSettableTokenList::~DOMSettableTokenList()
40 const AtomicString DOMSettableTokenList::item(unsigned index) const
42 if (index >= length())
43 return AtomicString();
44 return m_tokens[index];
47 bool DOMSettableTokenList::contains(const AtomicString& token, ExceptionCode& ec) const
49 if (!validateToken(token, ec))
51 return m_tokens.contains(token);
54 void DOMSettableTokenList::add(const AtomicString& token, ExceptionCode& ec)
56 if (!validateToken(token, ec) || m_tokens.contains(token))
61 void DOMSettableTokenList::addInternal(const AtomicString& token)
63 m_value = addToken(m_value, token);
64 if (m_tokens.isNull())
65 m_tokens.set(token, false);
70 void DOMSettableTokenList::remove(const AtomicString& token, ExceptionCode& ec)
72 if (!validateToken(token, ec) || !m_tokens.contains(token))
74 removeInternal(token);
77 void DOMSettableTokenList::removeInternal(const AtomicString& token)
79 m_value = removeToken(m_value, token);
80 m_tokens.remove(token);
83 bool DOMSettableTokenList::toggle(const AtomicString& token, ExceptionCode& ec)
85 if (!validateToken(token, ec))
87 if (m_tokens.contains(token)) {
88 removeInternal(token);
95 void DOMSettableTokenList::setValue(const String& value)
98 m_tokens.set(value, false);
101 } // namespace WebCore