1 /* 2 * Copyright (C) 2004 Zack Rusin <zack@kde.org> 3 * Copyright (C) 2004, 2005, 2006, 2008, 2012 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 "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" 31 32 namespace WebCore { 33 34 class CSSPrimitiveValue; 35 class CSSValueList; 36 class ExceptionState; 37 class MutableStylePropertySet; 38 class Node; 39 class RenderObject; 40 class RenderStyle; 41 class SVGPaint; 42 class ShadowData; 43 class ShadowList; 44 class StyleColor; 45 class StylePropertySet; 46 class StylePropertyShorthand; 47 48 enum EUpdateLayout { DoNotUpdateLayout = false, UpdateLayout = true }; 49 50 class CSSComputedStyleDeclaration FINAL : public CSSStyleDeclaration { 51 public: 52 static PassRefPtrWillBeRawPtr<CSSComputedStyleDeclaration> create(PassRefPtrWillBeRawPtr<Node> node, bool allowVisitedStyle = false, const String& pseudoElementName = String()) 53 { 54 return adoptRefWillBeNoop(new CSSComputedStyleDeclaration(node, allowVisitedStyle, pseudoElementName)); 55 } 56 virtual ~CSSComputedStyleDeclaration(); 57 58 #if !ENABLE(OILPAN) 59 virtual void ref() OVERRIDE; 60 virtual void deref() OVERRIDE; 61 #endif 62 63 String getPropertyValue(CSSPropertyID) const; 64 bool getPropertyPriority(CSSPropertyID) const; 65 66 virtual PassRefPtrWillBeRawPtr<MutableStylePropertySet> copyProperties() const OVERRIDE; 67 68 PassRefPtrWillBeRawPtr<CSSValue> getPropertyCSSValue(CSSPropertyID, EUpdateLayout = UpdateLayout) const; 69 PassRefPtrWillBeRawPtr<CSSValue> getFontSizeCSSValuePreferringKeyword() const; 70 bool useFixedFontDefaultSize() const; 71 PassRefPtrWillBeRawPtr<CSSValue> getSVGPropertyCSSValue(CSSPropertyID, EUpdateLayout) const; 72 73 PassRefPtrWillBeRawPtr<MutableStylePropertySet> copyPropertiesInSet(const Vector<CSSPropertyID>&) const; 74 75 virtual void trace(Visitor*) OVERRIDE; 76 77 private: 78 CSSComputedStyleDeclaration(PassRefPtrWillBeRawPtr<Node>, bool allowVisitedStyle, const String&); 79 80 // The styled node is either the node passed into getComputedStyle, or the 81 // PseudoElement for :before and :after if they exist. 82 // FIXME: This should be styledElement since in JS getComputedStyle only works 83 // on Elements, but right now editing creates these for text nodes. We should fix 84 // that. 85 Node* styledNode() const; 86 87 // CSSOM functions. Don't make these public. 88 virtual CSSRule* parentRule() const OVERRIDE; 89 virtual unsigned length() const OVERRIDE; 90 virtual String item(unsigned index) const OVERRIDE; 91 PassRefPtr<RenderStyle> computeRenderStyle(CSSPropertyID) const; 92 virtual PassRefPtrWillBeRawPtr<CSSValue> getPropertyCSSValue(const String& propertyName) OVERRIDE; 93 virtual String getPropertyValue(const String& propertyName) OVERRIDE; 94 virtual String getPropertyPriority(const String& propertyName) OVERRIDE; 95 virtual String getPropertyShorthand(const String& propertyName) OVERRIDE; 96 virtual bool isPropertyImplicit(const String& propertyName) OVERRIDE; 97 virtual void setProperty(const String& propertyName, const String& value, const String& priority, ExceptionState&) OVERRIDE; 98 virtual String removeProperty(const String& propertyName, ExceptionState&) OVERRIDE; 99 virtual String cssText() const OVERRIDE; 100 virtual void setCSSText(const String&, ExceptionState&) OVERRIDE; 101 virtual PassRefPtrWillBeRawPtr<CSSValue> getPropertyCSSValueInternal(CSSPropertyID) OVERRIDE; 102 virtual String getPropertyValueInternal(CSSPropertyID) OVERRIDE; 103 virtual void setPropertyInternal(CSSPropertyID, const String& value, bool important, ExceptionState&) OVERRIDE; 104 105 virtual bool cssPropertyMatches(CSSPropertyID, const CSSValue*) const OVERRIDE; 106 107 PassRefPtrWillBeRawPtr<CSSValue> valueForShadowData(const ShadowData&, const RenderStyle&, bool useSpread) const; 108 PassRefPtrWillBeRawPtr<CSSValue> valueForShadowList(const ShadowList*, const RenderStyle&, bool useSpread) const; 109 PassRefPtrWillBeRawPtr<CSSPrimitiveValue> currentColorOrValidColor(const RenderStyle&, const StyleColor&) const; 110 PassRefPtrWillBeRawPtr<SVGPaint> adjustSVGPaintForCurrentColor(PassRefPtrWillBeRawPtr<SVGPaint>, RenderStyle&) const; 111 112 PassRefPtrWillBeRawPtr<CSSValue> valueForFilter(const RenderObject*, const RenderStyle&) const; 113 114 PassRefPtrWillBeRawPtr<CSSValueList> valuesForShorthandProperty(const StylePropertyShorthand&) const; 115 PassRefPtrWillBeRawPtr<CSSValueList> valuesForSidesShorthand(const StylePropertyShorthand&) const; 116 PassRefPtrWillBeRawPtr<CSSValueList> valuesForBackgroundShorthand() const; 117 PassRefPtrWillBeRawPtr<CSSValueList> valuesForGridShorthand(const StylePropertyShorthand&) const; 118 119 RefPtrWillBeMember<Node> m_node; 120 PseudoId m_pseudoElementSpecifier; 121 bool m_allowVisitedStyle; 122 #if !ENABLE(OILPAN) 123 unsigned m_refCount; 124 #endif 125 }; 126 127 } // namespace WebCore 128 129 #endif // CSSComputedStyleDeclaration_h 130