1 /* 2 * Copyright (C) 1999-2003 Lars Knoll (knoll@kde.org) 3 * Copyright (C) 1999 Waldo Bastian (bastian@kde.org) 4 * Copyright (C) 2006 Samuel Weinig (sam.weinig@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: ~StyleBase()41 virtual ~StyleBase() { } 42 parent()43 StyleBase* parent() const { return m_parent; } setParent(StyleBase * 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 isCSSStyleSheet()49 virtual bool isCSSStyleSheet() const { return false; } isCharsetRule()50 virtual bool isCharsetRule() { return false; } isFontFaceRule()51 virtual bool isFontFaceRule() { return false; } isImportRule()52 virtual bool isImportRule() { return false; } isKeyframeRule()53 virtual bool isKeyframeRule() { return false; } isKeyframesRule()54 virtual bool isKeyframesRule() { return false; } isMediaRule()55 virtual bool isMediaRule() { return false; } isPageRule()56 virtual bool isPageRule() { return false; } 57 isRule()58 virtual bool isRule() { return false; } isStyleRule()59 virtual bool isStyleRule() { return false; } isStyleSheet()60 virtual bool isStyleSheet() const { return false; } isXSLStyleSheet()61 virtual bool isXSLStyleSheet() const { return false; } 62 isMutableStyleDeclaration()63 virtual bool isMutableStyleDeclaration() const { return false; } 64 65 virtual String cssText() const; 66 67 virtual void checkLoaded(); 68 useStrictParsing()69 bool useStrictParsing() const { return !m_parent || m_parent->useStrictParsing(); } 70 insertedIntoParent()71 virtual void insertedIntoParent() { } 72 73 StyleSheet* stylesheet(); 74 75 #ifdef ANDROID_INSTRUMENT 76 // Overridden to prevent the normal new from being called. 77 void* operator new(size_t size); 78 void* operator new[](size_t size); 79 80 // Overridden to prevent the normal delete from being called. 81 void operator delete(void* p, size_t size); 82 void operator delete[](void* p, size_t size); 83 84 static size_t reportStyleSize(); 85 #endif 86 87 protected: StyleBase(StyleBase * parent)88 StyleBase(StyleBase* parent) 89 : m_parent(parent) 90 { 91 } 92 93 private: 94 StyleBase* m_parent; 95 }; 96 } 97 98 #endif 99