blob: 718eb2dfab3cd9fbfa5330cd7acc5a02269aa5c2 [file] [log] [blame]
The Android Open Source Project8e35f3c2009-03-03 19:30:52 -08001/*
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"
Steve Block54cdeee2011-06-10 16:52:27 +010025#include "PlatformString.h"
Steve Blockdcc8cf22010-04-27 16:31:00 +010026#include "RenderStyleConstants.h"
Leon Clarkee458d702010-07-15 12:03:35 +010027#include <wtf/RefPtr.h>
The Android Open Source Project8e35f3c2009-03-03 19:30:52 -080028
29namespace WebCore {
30
Steve Blocke78cbe82010-05-26 10:11:43 +010031class Color;
The Android Open Source Project8e35f3c2009-03-03 19:30:52 -080032class CSSMutableStyleDeclaration;
Steve Blocke78cbe82010-05-26 10:11:43 +010033class CSSPrimitiveValue;
Leon Clarkee458d702010-07-15 12:03:35 +010034class Node;
35class RenderStyle;
Steve Blockcac0f672009-11-05 09:23:40 +000036class ShadowData;
The Android Open Source Project8e35f3c2009-03-03 19:30:52 -080037
38enum EUpdateLayout { DoNotUpdateLayout = false, UpdateLayout = true };
39
40class CSSComputedStyleDeclaration : public CSSStyleDeclaration {
41public:
Steve Blockdcc8cf22010-04-27 16:31:00 +010042 friend PassRefPtr<CSSComputedStyleDeclaration> computedStyle(PassRefPtr<Node>, bool allowVisitedStyle, const String& pseudoElementName);
The Android Open Source Project8e35f3c2009-03-03 19:30:52 -080043 virtual ~CSSComputedStyleDeclaration();
44
45 virtual String cssText() const;
46
Ben Murdoch21939df2010-05-11 18:35:50 +010047 virtual unsigned virtualLength() const;
The Android Open Source Project8e35f3c2009-03-03 19:30:52 -080048 virtual String item(unsigned index) const;
49
50 virtual PassRefPtr<CSSValue> getPropertyCSSValue(int propertyID) const;
51 virtual String getPropertyValue(int propertyID) const;
52 virtual bool getPropertyPriority(int propertyID) const;
The Android Open Source Project63586082009-03-05 14:34:32 -080053 virtual int getPropertyShorthand(int /*propertyID*/) const { return -1; }
54 virtual bool isPropertyImplicit(int /*propertyID*/) const { return false; }
The Android Open Source Project8e35f3c2009-03-03 19:30:52 -080055
56 virtual PassRefPtr<CSSMutableStyleDeclaration> copy() const;
57 virtual PassRefPtr<CSSMutableStyleDeclaration> makeMutable();
58
59 PassRefPtr<CSSValue> getPropertyCSSValue(int propertyID, EUpdateLayout) const;
Feng Qian5f1ab042009-06-17 12:12:20 -070060 PassRefPtr<CSSValue> getFontSizeCSSValuePreferringKeyword() const;
Iain Merrick5abb8602010-09-13 16:35:48 +010061 bool useFixedFontDefaultSize() const;
The Android Open Source Project8e35f3c2009-03-03 19:30:52 -080062#if ENABLE(SVG)
63 PassRefPtr<CSSValue> getSVGPropertyCSSValue(int propertyID, EUpdateLayout) const;
64#endif
65
Ben Murdoch0bf48ef2009-08-11 17:01:47 +010066protected:
67 virtual bool cssPropertyMatches(const CSSProperty*) const;
The Android Open Source Project8e35f3c2009-03-03 19:30:52 -080068
69private:
Steve Blockdcc8cf22010-04-27 16:31:00 +010070 CSSComputedStyleDeclaration(PassRefPtr<Node>, bool allowVisitedStyle, const String&);
The Android Open Source Project8e35f3c2009-03-03 19:30:52 -080071
72 virtual void setCssText(const String&, ExceptionCode&);
73
74 virtual String removeProperty(int propertyID, ExceptionCode&);
75 virtual void setProperty(int propertyId, const String& value, bool important, ExceptionCode&);
76
Steve Block68513a72010-09-29 17:32:26 +010077 PassRefPtr<CSSValue> valueForShadow(const ShadowData*, int, RenderStyle*) const;
Steve Blocke78cbe82010-05-26 10:11:43 +010078 PassRefPtr<CSSPrimitiveValue> currentColorOrValidColor(RenderStyle*, const Color&) const;
Steve Block54cdeee2011-06-10 16:52:27 +010079
The Android Open Source Project8e35f3c2009-03-03 19:30:52 -080080 RefPtr<Node> m_node;
Steve Blockdcc8cf22010-04-27 16:31:00 +010081 PseudoId m_pseudoElementSpecifier;
82 bool m_allowVisitedStyle;
The Android Open Source Project8e35f3c2009-03-03 19:30:52 -080083};
84
Steve Blockdcc8cf22010-04-27 16:31:00 +010085inline PassRefPtr<CSSComputedStyleDeclaration> computedStyle(PassRefPtr<Node> node, bool allowVisitedStyle = false, const String& pseudoElementName = String())
The Android Open Source Project8e35f3c2009-03-03 19:30:52 -080086{
Steve Blockdcc8cf22010-04-27 16:31:00 +010087 return adoptRef(new CSSComputedStyleDeclaration(node, allowVisitedStyle, pseudoElementName));
The Android Open Source Project8e35f3c2009-03-03 19:30:52 -080088}
89
90} // namespace WebCore
91
92#endif // CSSComputedStyleDeclaration_h