2 * (C) 1999-2003 Lars Knoll (knoll@kde.org)
3 * Copyright (C) 2004, 2005, 2006, 2007, 2010 Apple Inc. All rights reserved.
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details.
15 * You should have received a copy of the GNU Library General Public License
16 * along with this library; see the file COPYING.LIB. If not, write to
17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
22 #include "CSSValueList.h"
24 #include "CSSParserValues.h"
25 #include "PlatformString.h"
26 #include <wtf/PassOwnPtr.h>
30 CSSValueList::CSSValueList(bool isSpaceSeparated)
31 : m_isSpaceSeparated(isSpaceSeparated)
35 CSSValueList::CSSValueList(CSSParserValueList* list)
36 : m_isSpaceSeparated(true)
39 size_t size = list->size();
40 for (unsigned i = 0; i < size; ++i)
41 append(list->valueAt(i)->createCSSValue());
45 CSSValueList::~CSSValueList()
49 unsigned short CSSValueList::cssValueType() const
51 return CSS_VALUE_LIST;
54 void CSSValueList::append(PassRefPtr<CSSValue> val)
59 void CSSValueList::prepend(PassRefPtr<CSSValue> val)
61 m_values.prepend(val);
64 bool CSSValueList::removeAll(CSSValue* val)
67 // FIXME: we should be implementing operator== to CSSValue and its derived classes
68 // to make comparison more flexible and fast.
69 for (size_t index = 0; index < m_values.size(); index++) {
70 if (m_values.at(index)->cssText() == val->cssText()) {
71 m_values.remove(index);
79 bool CSSValueList::hasValue(CSSValue* val)
81 // FIXME: we should be implementing operator== to CSSValue and its derived classes
82 // to make comparison more flexible and fast.
83 for (size_t index = 0; index < m_values.size(); index++) {
84 if (m_values.at(index)->cssText() == val->cssText())
90 PassRefPtr<CSSValueList> CSSValueList::copy()
92 PassRefPtr<CSSValueList> newList = m_isSpaceSeparated ? createSpaceSeparated() : createCommaSeparated();
93 for (size_t index = 0; index < m_values.size(); index++)
94 newList->append(m_values[index]);
98 String CSSValueList::cssText() const
102 unsigned size = m_values.size();
103 for (unsigned i = 0; i < size; i++) {
104 if (!result.isEmpty()) {
105 if (m_isSpaceSeparated)
110 result += m_values[i]->cssText();
116 void CSSValueList::addSubresourceStyleURLs(ListHashSet<KURL>& urls, const CSSStyleSheet* styleSheet)
118 size_t size = m_values.size();
119 for (size_t i = 0; i < size; ++i)
120 m_values[i]->addSubresourceStyleURLs(urls, styleSheet);
123 } // namespace WebCore