OSDN Git Service

am 5a1f66aa: am ec92ec7c: merge from open-source master
[android-x86/external-webkit.git] / 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 "Node.h"
26 #include "RenderStyleConstants.h"
27
28 namespace WebCore {
29
30 class CSSMutableStyleDeclaration;
31 class ShadowData;
32
33 enum EUpdateLayout { DoNotUpdateLayout = false, UpdateLayout = true };
34
35 class CSSComputedStyleDeclaration : public CSSStyleDeclaration {
36 public:
37     friend PassRefPtr<CSSComputedStyleDeclaration> computedStyle(PassRefPtr<Node>, bool allowVisitedStyle, const String& pseudoElementName);
38     virtual ~CSSComputedStyleDeclaration();
39
40     virtual String cssText() const;
41
42     virtual unsigned virtualLength() const;
43     virtual String item(unsigned index) const;
44
45     virtual PassRefPtr<CSSValue> getPropertyCSSValue(int propertyID) const;
46     virtual String getPropertyValue(int propertyID) const;
47     virtual bool getPropertyPriority(int propertyID) const;
48     virtual int getPropertyShorthand(int /*propertyID*/) const { return -1; }
49     virtual bool isPropertyImplicit(int /*propertyID*/) const { return false; }
50
51     virtual PassRefPtr<CSSMutableStyleDeclaration> copy() const;
52     virtual PassRefPtr<CSSMutableStyleDeclaration> makeMutable();
53
54     PassRefPtr<CSSValue> getPropertyCSSValue(int propertyID, EUpdateLayout) const;
55     PassRefPtr<CSSValue> getFontSizeCSSValuePreferringKeyword() const;
56 #if ENABLE(SVG)
57     PassRefPtr<CSSValue> getSVGPropertyCSSValue(int propertyID, EUpdateLayout) const;
58 #endif
59
60 protected:
61     virtual bool cssPropertyMatches(const CSSProperty*) const;
62
63 private:
64     CSSComputedStyleDeclaration(PassRefPtr<Node>, bool allowVisitedStyle, const String&);
65
66     virtual void setCssText(const String&, ExceptionCode&);
67
68     virtual String removeProperty(int propertyID, ExceptionCode&);
69     virtual void setProperty(int propertyId, const String& value, bool important, ExceptionCode&);
70
71     PassRefPtr<CSSValue> valueForShadow(const ShadowData*, int) const;
72
73     RefPtr<Node> m_node;
74     PseudoId m_pseudoElementSpecifier;
75     bool m_allowVisitedStyle;
76 };
77
78 inline PassRefPtr<CSSComputedStyleDeclaration> computedStyle(PassRefPtr<Node> node,  bool allowVisitedStyle = false, const String& pseudoElementName = String())
79 {
80     return adoptRef(new CSSComputedStyleDeclaration(node, allowVisitedStyle, pseudoElementName));
81 }
82
83 } // namespace WebCore
84
85 #endif // CSSComputedStyleDeclaration_h