initial import
[vuplus_webkit] / Source / WebCore / css / CSSComputedStyleDeclaration.h
1 /*
2  * Copyright (C) 2004 Zack Rusin <zack@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 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 "CSSStyleDeclaration.h"
25 #include "RenderStyleConstants.h"
26 #include <wtf/RefPtr.h>
27 #include <wtf/text/WTFString.h>
28
29 namespace WebCore {
30
31 class Color;
32 class CSSMutableStyleDeclaration;
33 class CSSPrimitiveValue;
34 class Node;
35 class RenderStyle;
36 class ShadowData;
37 class SVGPaint;
38
39 enum EUpdateLayout { DoNotUpdateLayout = false, UpdateLayout = true };
40
41 class CSSComputedStyleDeclaration : public CSSStyleDeclaration {
42 public:
43     friend PassRefPtr<CSSComputedStyleDeclaration> computedStyle(PassRefPtr<Node>, bool allowVisitedStyle, const String& pseudoElementName);
44     virtual ~CSSComputedStyleDeclaration();
45
46     virtual String cssText() const;
47
48     virtual unsigned virtualLength() const;
49     virtual String item(unsigned index) const;
50
51     virtual PassRefPtr<CSSValue> getPropertyCSSValue(int propertyID) const;
52     virtual String getPropertyValue(int propertyID) const;
53     virtual bool getPropertyPriority(int propertyID) const;
54     virtual int getPropertyShorthand(int /*propertyID*/) const { return -1; }
55     virtual bool isPropertyImplicit(int /*propertyID*/) const { return false; }
56
57     virtual PassRefPtr<CSSMutableStyleDeclaration> copy() const;
58     virtual PassRefPtr<CSSMutableStyleDeclaration> makeMutable();
59
60     PassRefPtr<CSSValue> getPropertyCSSValue(int propertyID, EUpdateLayout) const;
61     PassRefPtr<CSSValue> getFontSizeCSSValuePreferringKeyword() const;
62     bool useFixedFontDefaultSize() const;
63 #if ENABLE(SVG)
64     PassRefPtr<CSSValue> getSVGPropertyCSSValue(int propertyID, EUpdateLayout) const;
65 #endif
66
67 protected:
68     virtual bool cssPropertyMatches(const CSSProperty*) const;
69
70 private:
71     CSSComputedStyleDeclaration(PassRefPtr<Node>, bool allowVisitedStyle, const String&);
72
73     virtual void setCssText(const String&, ExceptionCode&);
74
75     virtual String removeProperty(int propertyID, ExceptionCode&);
76     virtual void setProperty(int propertyId, const String& value, bool important, ExceptionCode&);
77
78     PassRefPtr<CSSValue> valueForShadow(const ShadowData*, int, RenderStyle*) const;
79     PassRefPtr<CSSPrimitiveValue> currentColorOrValidColor(RenderStyle*, const Color&) const;
80 #if ENABLE(SVG)
81     PassRefPtr<SVGPaint> adjustSVGPaintForCurrentColor(PassRefPtr<SVGPaint>, RenderStyle*) const;
82 #endif
83
84     RefPtr<Node> m_node;
85     PseudoId m_pseudoElementSpecifier;
86     bool m_allowVisitedStyle;
87 };
88
89 inline PassRefPtr<CSSComputedStyleDeclaration> computedStyle(PassRefPtr<Node> node,  bool allowVisitedStyle = false, const String& pseudoElementName = String())
90 {
91     return adoptRef(new CSSComputedStyleDeclaration(node, allowVisitedStyle, pseudoElementName));
92 }
93
94 } // namespace WebCore
95
96 #endif // CSSComputedStyleDeclaration_h