tizen beta release
[profile/ivi/webkit-efl.git] / Source / WebCore / css / CSSStyleDeclaration.h
1 /*
2  * (C) 1999-2003 Lars Knoll (knoll@kde.org)
3  * Copyright (C) 2004, 2005, 2006, 2008 Apple Inc. All rights reserved.
4  *
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.
9  *
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.
14  *
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.
19  */
20
21 #ifndef CSSStyleDeclaration_h
22 #define CSSStyleDeclaration_h
23
24 #include "CSSRule.h"
25 #include <wtf/Forward.h>
26
27 namespace WebCore {
28
29 class CSSMutableStyleDeclaration;
30 class CSSProperty;
31 class CSSStyleSheet;
32 class CSSValue;
33
34 typedef int ExceptionCode;
35
36 class CSSStyleDeclaration : public RefCounted<CSSStyleDeclaration> {
37 public:
38     virtual ~CSSStyleDeclaration() { }
39
40     static bool isPropertyName(const String&);
41
42     CSSRule* parentRule() const { return m_parentRule; }
43     void setParentRule(CSSRule* rule) { m_parentRule = rule; }
44
45     CSSStyleSheet* parentStyleSheet() const;
46
47     virtual String cssText() const = 0;
48     virtual void setCssText(const String&, ExceptionCode&) = 0;
49
50     unsigned length() const { return virtualLength(); }
51     virtual unsigned virtualLength() const = 0;
52     bool isEmpty() const { return !length(); }
53     virtual String item(unsigned index) const = 0;
54
55     PassRefPtr<CSSValue> getPropertyCSSValue(const String& propertyName);
56     String getPropertyValue(const String& propertyName);
57     String getPropertyPriority(const String& propertyName);
58     String getPropertyShorthand(const String& propertyName);
59     bool isPropertyImplicit(const String& propertyName);
60
61     virtual PassRefPtr<CSSValue> getPropertyCSSValue(int propertyID) const = 0;
62     virtual String getPropertyValue(int propertyID) const = 0;
63     virtual bool getPropertyPriority(int propertyID) const = 0;
64     virtual int getPropertyShorthand(int propertyID) const = 0;
65     virtual bool isPropertyImplicit(int propertyID) const = 0;
66
67     void setProperty(const String& propertyName, const String& value, ExceptionCode&);
68     void setProperty(const String& propertyName, const String& value, const String& priority, ExceptionCode&);
69     String removeProperty(const String& propertyName, ExceptionCode&);
70     virtual void setProperty(int propertyId, const String& value, bool important, ExceptionCode&) = 0;
71     virtual String removeProperty(int propertyID, ExceptionCode&) = 0;
72
73     virtual PassRefPtr<CSSMutableStyleDeclaration> copy() const = 0;
74     virtual PassRefPtr<CSSMutableStyleDeclaration> makeMutable() = 0;
75
76     void diff(CSSMutableStyleDeclaration*) const;
77
78     PassRefPtr<CSSMutableStyleDeclaration> copyPropertiesInSet(const int* set, unsigned length) const;
79
80 #ifndef NDEBUG
81     void showStyle();
82 #endif
83
84     bool isElementStyleDeclaration() const { return m_isElementStyleDeclaration; }
85     bool isInlineStyleDeclaration() const { return m_isInlineStyleDeclaration; }
86
87 protected:
88     CSSStyleDeclaration(CSSRule* parentRule = 0);
89
90     virtual bool cssPropertyMatches(const CSSProperty*) const;
91
92     // The bits in this section are only used by specific subclasses but kept here
93     // to maximize struct packing.
94
95     // CSSMutableStyleDeclaration bits:
96     bool m_strictParsing : 1;
97 #ifndef NDEBUG
98     unsigned m_iteratorCount : 4;
99 #endif
100
101     // CSSElementStyleDeclaration bits:
102     bool m_isElementStyleDeclaration : 1;
103     bool m_isInlineStyleDeclaration : 1;
104
105 private:
106     CSSRule* m_parentRule;
107 };
108
109 } // namespace WebCore
110
111 #endif // CSSStyleDeclaration_h