2 * Copyright (C) 2004 Zack Rusin <zack@kde.org>
3 * Copyright (C) 2004, 2005, 2006, 2008, 2012 Apple Inc. All rights reserved.
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.
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.
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
21 #ifndef CSSComputedStyleDeclaration_h
22 #define CSSComputedStyleDeclaration_h
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"
34 class CSSPrimitiveValue;
37 class MutableStylePropertySet;
45 class StylePropertySet;
46 class StylePropertyShorthand;
48 enum EUpdateLayout { DoNotUpdateLayout = false, UpdateLayout = true };
50 class CSSComputedStyleDeclaration FINAL : public CSSStyleDeclaration {
52 static PassRefPtrWillBeRawPtr<CSSComputedStyleDeclaration> create(PassRefPtr<Node> node, bool allowVisitedStyle = false, const String& pseudoElementName = String())
54 return adoptRefWillBeNoop(new CSSComputedStyleDeclaration(node, allowVisitedStyle, pseudoElementName));
56 virtual ~CSSComputedStyleDeclaration();
59 virtual void ref() OVERRIDE;
60 virtual void deref() OVERRIDE;
63 PassRefPtrWillBeRawPtr<CSSValue> getPropertyCSSValue(CSSPropertyID) const;
64 String getPropertyValue(CSSPropertyID) const;
65 bool getPropertyPriority(CSSPropertyID) const;
67 virtual PassRefPtrWillBeRawPtr<MutableStylePropertySet> copyProperties() const OVERRIDE;
69 PassRefPtrWillBeRawPtr<CSSValue> getPropertyCSSValue(CSSPropertyID, EUpdateLayout) const;
70 PassRefPtrWillBeRawPtr<CSSValue> getFontSizeCSSValuePreferringKeyword() const;
71 bool useFixedFontDefaultSize() const;
72 PassRefPtrWillBeRawPtr<CSSValue> getSVGPropertyCSSValue(CSSPropertyID, EUpdateLayout) const;
74 PassRefPtrWillBeRawPtr<MutableStylePropertySet> copyPropertiesInSet(const Vector<CSSPropertyID>&) const;
76 virtual void trace(Visitor* visitor) { CSSStyleDeclaration::trace(visitor); }
79 CSSComputedStyleDeclaration(PassRefPtr<Node>, bool allowVisitedStyle, const String&);
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
86 Node* styledNode() const;
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;
106 virtual bool cssPropertyMatches(CSSPropertyID, const CSSValue*) const OVERRIDE;
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;
113 PassRefPtrWillBeRawPtr<CSSValue> valueForFilter(const RenderObject*, const RenderStyle&) const;
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;
121 PseudoId m_pseudoElementSpecifier;
122 bool m_allowVisitedStyle;
128 } // namespace WebCore
130 #endif // CSSComputedStyleDeclaration_h