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