Home | History | Annotate | Download | only in css
      1 /*
      2  * Copyright (C) 1999-2003 Lars Knoll (knoll (at) kde.org)
      3  * Copyright (C) 1999 Waldo Bastian (bastian (at) kde.org)
      4  * Copyright (C) 2006 Samuel Weinig (sam.weinig (at) gmial.com)
      5  * Copyright (C) 2004, 2006, 2008 Apple Inc. All rights reserved.
      6  *
      7  * This library is free software; you can redistribute it and/or
      8  * modify it under the terms of the GNU Library General Public
      9  * License as published by the Free Software Foundation; either
     10  * version 2 of the License, or (at your option) any later version.
     11  *
     12  * This library is distributed in the hope that it will be useful,
     13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
     14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     15  * Library General Public License for more details.
     16  *
     17  * You should have received a copy of the GNU Library General Public License
     18  * along with this library; see the file COPYING.LIB.  If not, write to
     19  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
     20  * Boston, MA 02110-1301, USA.
     21  */
     22 
     23 #ifndef StyleBase_h
     24 #define StyleBase_h
     25 
     26 #include <wtf/Forward.h>
     27 #include <wtf/RefCounted.h>
     28 
     29 namespace WebCore {
     30 
     31     class StyleSheet;
     32     class KURL;
     33 
     34     // Base class for most CSS DOM objects.
     35 
     36     // FIXME: We don't need these to all share one base class.
     37     // Refactor so they don't any more.
     38 
     39     class StyleBase : public RefCounted<StyleBase> {
     40     public:
     41         virtual ~StyleBase() { }
     42 
     43         StyleBase* parent() const { return m_parent; }
     44         void setParent(StyleBase* parent) { m_parent = parent; }
     45 
     46         // returns the url of the style sheet this object belongs to
     47         KURL baseURL() const;
     48 
     49         virtual bool isCSSStyleSheet() const { return false; }
     50         virtual bool isCharsetRule() { return false; }
     51         virtual bool isFontFaceRule() { return false; }
     52         virtual bool isImportRule() { return false; }
     53         virtual bool isKeyframeRule() { return false; }
     54         virtual bool isKeyframesRule() { return false; }
     55         virtual bool isMediaRule() { return false; }
     56         virtual bool isPageRule() { return false; }
     57 
     58         virtual bool isRule() { return false; }
     59         virtual bool isStyleRule() { return false; }
     60         virtual bool isStyleSheet() const { return false; }
     61         virtual bool isXSLStyleSheet() const { return false; }
     62 
     63         virtual bool isMutableStyleDeclaration() const { return false; }
     64 
     65         virtual String cssText() const;
     66 
     67         virtual void checkLoaded();
     68 
     69         bool useStrictParsing() const { return !m_parent || m_parent->useStrictParsing(); }
     70 
     71         virtual void insertedIntoParent() { }
     72 
     73         StyleSheet* stylesheet();
     74 
     75     protected:
     76         StyleBase(StyleBase* parent)
     77             : m_parent(parent)
     78         {
     79         }
     80 
     81     private:
     82         StyleBase* m_parent;
     83     };
     84 }
     85 
     86 #endif
     87