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