Upstream version 5.34.98.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / core / css / VariablesIterator.h
1 /*
2  * Copyright (C) 2013 Google Inc. All rights reserved.
3  *
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.
8  *
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.
13  *
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.
18  */
19
20 #ifndef VariablesIterator_h
21 #define VariablesIterator_h
22
23 #include "core/css/CSSVariablesIterator.h"
24 #include "wtf/Vector.h"
25 #include "wtf/text/AtomicString.h"
26
27 namespace WebCore {
28
29 class MutableStylePropertySet;
30 class StylePropertySet;
31
32 class AbstractVariablesIterator : public CSSVariablesIterator {
33 public:
34     virtual ~AbstractVariablesIterator() { }
35
36 protected:
37     void takeRemainingNames(Vector<AtomicString>& remainingNames) { m_remainingNames.swap(remainingNames); }
38
39     void initRemainingNames(const StylePropertySet*);
40
41 private:
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;
49
50     virtual MutableStylePropertySet* propertySet() const = 0;
51
52     Vector<AtomicString> m_remainingNames;
53     Vector<AtomicString> m_newNames;
54 };
55
56 class VariablesIterator FINAL : public AbstractVariablesIterator {
57 public:
58     static PassRefPtr<VariablesIterator> create(MutableStylePropertySet*);
59
60 private:
61     explicit VariablesIterator(MutableStylePropertySet*);
62     virtual MutableStylePropertySet* propertySet() const OVERRIDE { return m_propertySet.get(); }
63
64     RefPtr<MutableStylePropertySet> m_propertySet;
65 };
66
67 } // namespace WebCore
68
69 #endif // VariablesIterator_h