2 * Copyright (C) 2013 Google Inc. All rights reserved.
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library General Public License
15 * along with this library; see the file COPYING.LIB. If not, write to
16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
20 #ifndef VariablesIterator_h
21 #define VariablesIterator_h
23 #include "core/css/CSSVariablesIterator.h"
24 #include "wtf/Vector.h"
25 #include "wtf/text/AtomicString.h"
29 class MutableStylePropertySet;
30 class StylePropertySet;
32 class AbstractVariablesIterator : public CSSVariablesIterator {
34 virtual ~AbstractVariablesIterator() { }
37 void takeRemainingNames(Vector<AtomicString>& remainingNames) { m_remainingNames.swap(remainingNames); }
39 void initRemainingNames(const StylePropertySet*);
42 virtual void advance() OVERRIDE FINAL;
43 virtual bool atEnd() const OVERRIDE FINAL { return m_remainingNames.isEmpty(); }
44 virtual AtomicString name() const OVERRIDE FINAL { return m_remainingNames.last(); }
45 virtual String value() const OVERRIDE FINAL;
46 virtual void addedVariable(const AtomicString& name) OVERRIDE FINAL;
47 virtual void removedVariable(const AtomicString& name) OVERRIDE FINAL;
48 virtual void clearedVariables() OVERRIDE FINAL;
50 virtual MutableStylePropertySet* propertySet() const = 0;
52 Vector<AtomicString> m_remainingNames;
53 Vector<AtomicString> m_newNames;
56 class VariablesIterator FINAL : public AbstractVariablesIterator {
58 static PassRefPtr<VariablesIterator> create(MutableStylePropertySet*);
61 explicit VariablesIterator(MutableStylePropertySet*);
62 virtual MutableStylePropertySet* propertySet() const OVERRIDE { return m_propertySet.get(); }
64 RefPtr<MutableStylePropertySet> m_propertySet;
67 } // namespace WebCore
69 #endif // VariablesIterator_h