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
27 namespace WebCore {
28
29 class CSSMutableStyleDeclaration;
30
31 enum EUpdateLayout { DoNotUpdateLayout = false, UpdateLayout = true };
32
33 class CSSComputedStyleDeclaration : public CSSStyleDeclaration {
34 public:
35 friend PassRefPtr<CSSComputedStyleDeclaration> computedStyle(PassRefPtr<Node>);
36 virtual ~CSSComputedStyleDeclaration();
37
38 virtual String cssText() const;
39
40 virtual unsigned length() const;
41 virtual String item(unsigned index) const;
42
43 virtual PassRefPtr<CSSValue> getPropertyCSSValue(int propertyID) const;
44 virtual String getPropertyValue(int propertyID) const;
45 virtual bool getPropertyPriority(int propertyID) const;
getPropertyShorthand(int)46 virtual int getPropertyShorthand(int /*propertyID*/) const { return -1; }
isPropertyImplicit(int)47 virtual bool isPropertyImplicit(int /*propertyID*/) const { return false; }
48
49 virtual PassRefPtr<CSSMutableStyleDeclaration> copy() const;
50 virtual PassRefPtr<CSSMutableStyleDeclaration> makeMutable();
51
52 PassRefPtr<CSSValue> getPropertyCSSValue(int propertyID, EUpdateLayout) const;
53 PassRefPtr<CSSValue> getFontSizeCSSValuePreferringKeyword() const;
54 #if ENABLE(SVG)
55 PassRefPtr<CSSValue> getSVGPropertyCSSValue(int propertyID, EUpdateLayout) const;
56 #endif
57
58 protected:
59 virtual bool cssPropertyMatches(const CSSProperty*) const;
60
61 private:
62 CSSComputedStyleDeclaration(PassRefPtr<Node>);
63
64 virtual void setCssText(const String&, ExceptionCode&);
65
66 virtual String removeProperty(int propertyID, ExceptionCode&);
67 virtual void setProperty(int propertyId, const String& value, bool important, ExceptionCode&);
68
69 RefPtr<Node> m_node;
70 };
71
computedStyle(PassRefPtr<Node> node)72 inline PassRefPtr<CSSComputedStyleDeclaration> computedStyle(PassRefPtr<Node> node)
73 {
74 return adoptRef(new CSSComputedStyleDeclaration(node));
75 }
76
77 } // namespace WebCore
78
79 #endif // CSSComputedStyleDeclaration_h
80