1e78cbe89e6f337f2f1fe40315be88f742b547151Steve Block/* 2e78cbe89e6f337f2f1fe40315be88f742b547151Steve Block * Copyright (C) 2010 Google Inc. All Rights Reserved. 3e78cbe89e6f337f2f1fe40315be88f742b547151Steve Block * 4e78cbe89e6f337f2f1fe40315be88f742b547151Steve Block * Redistribution and use in source and binary forms, with or without 5e78cbe89e6f337f2f1fe40315be88f742b547151Steve Block * modification, are permitted provided that the following conditions 6e78cbe89e6f337f2f1fe40315be88f742b547151Steve Block * are met: 7e78cbe89e6f337f2f1fe40315be88f742b547151Steve Block * 1. Redistributions of source code must retain the above copyright 8e78cbe89e6f337f2f1fe40315be88f742b547151Steve Block * notice, this list of conditions and the following disclaimer. 9e78cbe89e6f337f2f1fe40315be88f742b547151Steve Block * 2. Redistributions in binary form must reproduce the above copyright 10e78cbe89e6f337f2f1fe40315be88f742b547151Steve Block * notice, this list of conditions and the following disclaimer in the 11e78cbe89e6f337f2f1fe40315be88f742b547151Steve Block * documentation and/or other materials provided with the distribution. 12e78cbe89e6f337f2f1fe40315be88f742b547151Steve Block * 13e78cbe89e6f337f2f1fe40315be88f742b547151Steve Block * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY 14e78cbe89e6f337f2f1fe40315be88f742b547151Steve Block * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 15e78cbe89e6f337f2f1fe40315be88f742b547151Steve Block * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 16e78cbe89e6f337f2f1fe40315be88f742b547151Steve Block * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR 17e78cbe89e6f337f2f1fe40315be88f742b547151Steve Block * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 18e78cbe89e6f337f2f1fe40315be88f742b547151Steve Block * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 19e78cbe89e6f337f2f1fe40315be88f742b547151Steve Block * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 20e78cbe89e6f337f2f1fe40315be88f742b547151Steve Block * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 21e78cbe89e6f337f2f1fe40315be88f742b547151Steve Block * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22e78cbe89e6f337f2f1fe40315be88f742b547151Steve Block * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 23e78cbe89e6f337f2f1fe40315be88f742b547151Steve Block * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24e78cbe89e6f337f2f1fe40315be88f742b547151Steve Block */ 25e78cbe89e6f337f2f1fe40315be88f742b547151Steve Block 26e78cbe89e6f337f2f1fe40315be88f742b547151Steve Block#ifndef DOMStringList_h 27e78cbe89e6f337f2f1fe40315be88f742b547151Steve Block#define DOMStringList_h 28e78cbe89e6f337f2f1fe40315be88f742b547151Steve Block 29e78cbe89e6f337f2f1fe40315be88f742b547151Steve Block#include "PlatformString.h" 30e78cbe89e6f337f2f1fe40315be88f742b547151Steve Block#include <wtf/PassRefPtr.h> 31e78cbe89e6f337f2f1fe40315be88f742b547151Steve Block#include <wtf/RefCounted.h> 32e78cbe89e6f337f2f1fe40315be88f742b547151Steve Block#include <wtf/Vector.h> 33e78cbe89e6f337f2f1fe40315be88f742b547151Steve Block 34e78cbe89e6f337f2f1fe40315be88f742b547151Steve Blocknamespace WebCore { 35e78cbe89e6f337f2f1fe40315be88f742b547151Steve Block 36e78cbe89e6f337f2f1fe40315be88f742b547151Steve Block// FIXME: Some consumers of this class may benefit from lazily fetching items rather 37e78cbe89e6f337f2f1fe40315be88f742b547151Steve Block// than creating the list statically as is currently the only option. 38e78cbe89e6f337f2f1fe40315be88f742b547151Steve Blockclass DOMStringList : public RefCounted<DOMStringList> { 39e78cbe89e6f337f2f1fe40315be88f742b547151Steve Blockpublic: 40e78cbe89e6f337f2f1fe40315be88f742b547151Steve Block static PassRefPtr<DOMStringList> create() 41e78cbe89e6f337f2f1fe40315be88f742b547151Steve Block { 42e78cbe89e6f337f2f1fe40315be88f742b547151Steve Block return adoptRef(new DOMStringList()); 43e78cbe89e6f337f2f1fe40315be88f742b547151Steve Block } 44e78cbe89e6f337f2f1fe40315be88f742b547151Steve Block 45e78cbe89e6f337f2f1fe40315be88f742b547151Steve Block bool isEmpty() const { return m_strings.isEmpty(); } 46e78cbe89e6f337f2f1fe40315be88f742b547151Steve Block void clear() { m_strings.clear(); } 47e78cbe89e6f337f2f1fe40315be88f742b547151Steve Block void append(const String& string) { m_strings.append(string); } 48e78cbe89e6f337f2f1fe40315be88f742b547151Steve Block 49e78cbe89e6f337f2f1fe40315be88f742b547151Steve Block // Implements the IDL. 50e78cbe89e6f337f2f1fe40315be88f742b547151Steve Block size_t length() const { return m_strings.size(); } 51a94275402997c11dd2e778633dacf4b7e630a35dBen Murdoch String item(unsigned index) const; 52e78cbe89e6f337f2f1fe40315be88f742b547151Steve Block bool contains(const String& str) const; 53e78cbe89e6f337f2f1fe40315be88f742b547151Steve Block 54e78cbe89e6f337f2f1fe40315be88f742b547151Steve Blockprivate: 55e78cbe89e6f337f2f1fe40315be88f742b547151Steve Block DOMStringList() { } 56e78cbe89e6f337f2f1fe40315be88f742b547151Steve Block 57e78cbe89e6f337f2f1fe40315be88f742b547151Steve Block Vector<String> m_strings; 58e78cbe89e6f337f2f1fe40315be88f742b547151Steve Block}; 59e78cbe89e6f337f2f1fe40315be88f742b547151Steve Block 60e78cbe89e6f337f2f1fe40315be88f742b547151Steve Block} // namespace WebCore 61e78cbe89e6f337f2f1fe40315be88f742b547151Steve Block 62e78cbe89e6f337f2f1fe40315be88f742b547151Steve Block#endif // DOMStringList_h 63e78cbe89e6f337f2f1fe40315be88f742b547151Steve Block 64