06aecf6f358b8b30c10b146196f599db1124a277
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / core / css / CSSComputedStyleDeclaration.h
1 /*
2  * Copyright (C) 2004 Zack Rusin <zack@kde.org>
3  * Copyright (C) 2004, 2005, 2006, 2008, 2012 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 Lesser 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  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18  * 02110-1301  USA
19  */
20
21 #ifndef CSSComputedStyleDeclaration_h
22 #define CSSComputedStyleDeclaration_h
23
24 #include "core/css/CSSStyleDeclaration.h"
25 #include "core/rendering/style/RenderStyleConstants.h"
26 #include "wtf/HashMap.h"
27 #include "wtf/RefPtr.h"
28 #include "wtf/text/AtomicString.h"
29 #include "wtf/text/AtomicStringHash.h"
30 #include "wtf/text/WTFString.h"
31
32 namespace WebCore {
33
34 class CSSPrimitiveValue;
35 class CSSValueList;
36 class ExceptionState;
37 class MutableStylePropertySet;
38 class Node;
39 class RenderObject;
40 class RenderStyle;
41 class SVGPaint;
42 class ShadowData;
43 class ShadowList;
44 class StyleColor;
45 class StylePropertySet;
46 class StylePropertyShorthand;
47
48 enum EUpdateLayout { DoNotUpdateLayout = false, UpdateLayout = true };
49
50 class CSSComputedStyleDeclaration FINAL : public CSSStyleDeclaration {
51 public:
52     static PassRefPtrWillBeRawPtr<CSSComputedStyleDeclaration> create(PassRefPtr<Node> node, bool allowVisitedStyle = false, const String& pseudoElementName = String())
53     {
54         return adoptRefWillBeNoop(new CSSComputedStyleDeclaration(node, allowVisitedStyle, pseudoElementName));
55     }
56     virtual ~CSSComputedStyleDeclaration();
57
58 #if !ENABLE(OILPAN)
59     virtual void ref() OVERRIDE;
60     virtual void deref() OVERRIDE;
61 #endif
62
63     PassRefPtrWillBeRawPtr<CSSValue> getPropertyCSSValue(CSSPropertyID) const;
64     String getPropertyValue(CSSPropertyID) const;
65     bool getPropertyPriority(CSSPropertyID) const;
66
67     virtual PassRefPtrWillBeRawPtr<MutableStylePropertySet> copyProperties() const OVERRIDE;
68
69     PassRefPtrWillBeRawPtr<CSSValue> getPropertyCSSValue(CSSPropertyID, EUpdateLayout) const;
70     PassRefPtrWillBeRawPtr<CSSValue> getFontSizeCSSValuePreferringKeyword() const;
71     bool useFixedFontDefaultSize() const;
72     PassRefPtrWillBeRawPtr<CSSValue> getSVGPropertyCSSValue(CSSPropertyID, EUpdateLayout) const;
73
74     PassRefPtrWillBeRawPtr<MutableStylePropertySet> copyPropertiesInSet(const Vector<CSSPropertyID>&) const;
75
76     virtual void trace(Visitor* visitor) { CSSStyleDeclaration::trace(visitor); }
77
78 private:
79     CSSComputedStyleDeclaration(PassRefPtr<Node>, bool allowVisitedStyle, const String&);
80
81     // The styled node is either the node passed into getComputedStyle, or the
82     // PseudoElement for :before and :after if they exist.
83     // FIXME: This should be styledElement since in JS getComputedStyle only works
84     // on Elements, but right now editing creates these for text nodes. We should fix
85     // that.
86     Node* styledNode() const;
87
88     // CSSOM functions. Don't make these public.
89     virtual CSSRule* parentRule() const OVERRIDE;
90     virtual unsigned length() const OVERRIDE;
91     virtual String item(unsigned index) const OVERRIDE;
92     PassRefPtr<RenderStyle> computeRenderStyle(CSSPropertyID) const;
93     virtual PassRefPtrWillBeRawPtr<CSSValue> getPropertyCSSValue(const String& propertyName) OVERRIDE;
94     virtual String getPropertyValue(const String& propertyName) OVERRIDE;
95     virtual String getPropertyPriority(const String& propertyName) OVERRIDE;
96     virtual String getPropertyShorthand(const String& propertyName) OVERRIDE;
97     virtual bool isPropertyImplicit(const String& propertyName) OVERRIDE;
98     virtual void setProperty(const String& propertyName, const String& value, const String& priority, ExceptionState&) OVERRIDE;
99     virtual String removeProperty(const String& propertyName, ExceptionState&) OVERRIDE;
100     virtual String cssText() const OVERRIDE;
101     virtual void setCSSText(const String&, ExceptionState&) OVERRIDE;
102     virtual PassRefPtrWillBeRawPtr<CSSValue> getPropertyCSSValueInternal(CSSPropertyID) OVERRIDE;
103     virtual String getPropertyValueInternal(CSSPropertyID) OVERRIDE;
104     virtual void setPropertyInternal(CSSPropertyID, const String& value, bool important, ExceptionState&) OVERRIDE;
105
106     virtual bool cssPropertyMatches(CSSPropertyID, const CSSValue*) const OVERRIDE;
107
108     PassRefPtrWillBeRawPtr<CSSValue> valueForShadowData(const ShadowData&, const RenderStyle&, bool useSpread) const;
109     PassRefPtrWillBeRawPtr<CSSValue> valueForShadowList(const ShadowList*, const RenderStyle&, bool useSpread) const;
110     PassRefPtrWillBeRawPtr<CSSPrimitiveValue> currentColorOrValidColor(const RenderStyle&, const StyleColor&) const;
111     PassRefPtrWillBeRawPtr<SVGPaint> adjustSVGPaintForCurrentColor(PassRefPtrWillBeRawPtr<SVGPaint>, RenderStyle&) const;
112
113     PassRefPtrWillBeRawPtr<CSSValue> valueForFilter(const RenderObject*, const RenderStyle&) const;
114
115     PassRefPtrWillBeRawPtr<CSSValueList> valuesForShorthandProperty(const StylePropertyShorthand&) const;
116     PassRefPtrWillBeRawPtr<CSSValueList> valuesForSidesShorthand(const StylePropertyShorthand&) const;
117     PassRefPtrWillBeRawPtr<CSSValueList> valuesForBackgroundShorthand() const;
118     PassRefPtrWillBeRawPtr<CSSValueList> valuesForGridShorthand(const StylePropertyShorthand&) const;
119
120     RefPtr<Node> m_node;
121     PseudoId m_pseudoElementSpecifier;
122     bool m_allowVisitedStyle;
123 #if !ENABLE(OILPAN)
124     unsigned m_refCount;
125 #endif
126 };
127
128 } // namespace WebCore
129
130 #endif // CSSComputedStyleDeclaration_h