khtml Library API Documentation

css_base.h

00001 /* 00002 * This file is part of the CSS implementation for KDE. 00003 * 00004 * Copyright (C) 1999-2003 Lars Knoll (knoll@kde.org) 00005 * 1999 Waldo Bastian (bastian@kde.org) 00006 * Copyright (C) 2002 Apple Computer, Inc. 00007 * 00008 * This library is free software; you can redistribute it and/or 00009 * modify it under the terms of the GNU Library General Public 00010 * License as published by the Free Software Foundation; either 00011 * version 2 of the License, or (at your option) any later version. 00012 * 00013 * This library is distributed in the hope that it will be useful, 00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00016 * Library General Public License for more details. 00017 * 00018 * You should have received a copy of the GNU Library General Public License 00019 * along with this library; see the file COPYING.LIB. If not, write to 00020 * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 00021 * Boston, MA 02111-1307, USA. 00022 * 00023 * $Id: css_base.h,v 1.13 2004/01/14 21:20:30 mueller Exp $ 00024 */ 00025 #ifndef _CSS_BASE_H 00026 #define _CSS_BASE_H 00027 00028 #include "dom/dom_string.h" 00029 #include "dom/dom_misc.h" 00030 #include "xml/dom_nodeimpl.h" 00031 #include "misc/shared.h" 00032 #include <kdemacros.h> 00033 #include <qdatetime.h> 00034 #include <qptrlist.h> 00035 00036 namespace DOM { 00037 00038 class StyleSheetImpl; 00039 class MediaList; 00040 00041 class CSSSelector; 00042 class CSSProperty; 00043 class CSSValueImpl; 00044 class CSSPrimitiveValueImpl; 00045 class CSSStyleDeclarationImpl; 00046 class CSSRuleImpl; 00047 class CSSStyleRuleImpl; 00048 00049 class DocumentImpl; 00050 00051 // this class represents a selector for a StyleRule 00052 class CSSSelector 00053 { 00054 public: 00055 CSSSelector() 00056 : tagHistory(0), simpleSelector(0), attr(0), tag(0xffff), relation( Descendant ), 00057 match( None ), nonCSSHint( false ), pseudoId( 0 ), _pseudoType(PseudoNotParsed) 00058 {} 00059 00060 ~CSSSelector() { 00061 delete tagHistory; 00062 delete simpleSelector; 00063 } 00064 00068 void print(); 00069 00073 DOMString selectorText() const; 00074 00075 // checks if the 2 selectors (including sub selectors) agree. 00076 bool operator == ( const CSSSelector &other ) const; 00077 00078 // tag == -1 means apply to all elements (Selector = *) 00079 00080 unsigned int specificity() const; 00081 00082 /* how the attribute value has to match.... Default is Exact */ 00083 enum Match 00084 { 00085 None = 0, 00086 Id, 00087 Exact, 00088 Set, 00089 List, 00090 Hyphen, 00091 Pseudo, 00092 Contain, // css3: E[foo*="bar"] 00093 Begin, // css3: E[foo^="bar"] 00094 End // css3: E[foo$="bar"] 00095 }; 00096 00097 enum Relation 00098 { 00099 Descendant = 0, 00100 Child, 00101 Sibling, 00102 SubSelector 00103 }; 00104 00105 enum PseudoType 00106 { 00107 PseudoNotParsed = 0, 00108 PseudoOther, 00109 PseudoEmpty, 00110 PseudoFirstChild, 00111 PseudoLastChild, 00112 PseudoOnlyChild, 00113 PseudoFirstLine, 00114 PseudoFirstLetter, 00115 PseudoLink, 00116 PseudoVisited, 00117 PseudoHover, 00118 PseudoFocus, 00119 PseudoActive, 00120 PseudoTarget, 00121 PseudoBefore, 00122 PseudoAfter, 00123 PseudoLang, 00124 PseudoNot, 00125 PseudoRoot, 00126 PseudoSelection 00127 }; 00128 00129 PseudoType pseudoType() const { 00130 if (_pseudoType == PseudoNotParsed) 00131 extractPseudoType(); 00132 return _pseudoType; 00133 } 00134 00135 mutable DOM::DOMString value; 00136 CSSSelector *tagHistory; 00137 CSSSelector* simpleSelector; // Used for :not. 00138 DOM::NodeImpl::Id attr; 00139 DOM::NodeImpl::Id tag; 00140 00141 Relation relation : 2; 00142 Match match : 4; 00143 bool nonCSSHint : 1; 00144 unsigned int pseudoId : 3; 00145 mutable PseudoType _pseudoType : 5; 00146 00147 private: 00148 void extractPseudoType() const; 00149 }; 00150 00151 // a style class which has a parent (almost all have) 00152 class StyleBaseImpl : public khtml::TreeShared<StyleBaseImpl> 00153 { 00154 public: 00155 StyleBaseImpl() { m_parent = 0; hasInlinedDecl = false; strictParsing = true; multiLength = false; } 00156 StyleBaseImpl(StyleBaseImpl *p) { 00157 m_parent = p; hasInlinedDecl = false; 00158 strictParsing = (m_parent ? m_parent->useStrictParsing() : true); 00159 multiLength = false; 00160 } 00161 00162 virtual ~StyleBaseImpl() {} 00163 00164 // returns the url of the style sheet this object belongs to 00165 // not const 00166 KURL baseURL(); 00167 00168 virtual bool isStyleSheet() const { return false; } 00169 virtual bool isCSSStyleSheet() const { return false; } 00170 virtual bool isStyleSheetList() const { return false; } 00171 virtual bool isMediaList() const { return false; } 00172 virtual bool isRuleList() const { return false; } 00173 virtual bool isRule() const { return false; } 00174 virtual bool isStyleRule() const { return false; } 00175 virtual bool isCharetRule() const { return false; } 00176 virtual bool isImportRule() const { return false; } 00177 virtual bool isMediaRule() const { return false; } 00178 virtual bool isFontFaceRule() const { return false; } 00179 virtual bool isPageRule() const { return false; } 00180 virtual bool isUnknownRule() const { return false; } 00181 virtual bool isStyleDeclaration() const { return false; } 00182 virtual bool isValue() const { return false; } 00183 virtual bool isPrimitiveValue() const { return false; } 00184 virtual bool isValueList() const { return false; } 00185 virtual bool isValueCustom() const { return false; } 00186 00187 void setParent(StyleBaseImpl *parent) { m_parent = parent; } 00188 00189 static void setParsedValue(int propId, const CSSValueImpl *parsedValue, 00190 bool important, bool nonCSSHint, QPtrList<CSSProperty> *propList); 00191 00192 virtual bool parseString(const DOMString &/*cssString*/, bool = false) { return false; } 00193 00194 virtual void checkLoaded() const; 00195 00196 void setStrictParsing( bool b ) { strictParsing = b; } 00197 bool useStrictParsing() const { return strictParsing; } 00198 00199 // not const 00200 StyleSheetImpl* stylesheet(); 00201 00202 protected: 00203 bool hasInlinedDecl : 1; 00204 bool strictParsing : 1; 00205 bool multiLength : 1; 00206 }; 00207 00208 // a style class which has a list of children (StyleSheets for example) 00209 class StyleListImpl : public StyleBaseImpl 00210 { 00211 public: 00212 StyleListImpl() : StyleBaseImpl() { m_lstChildren = 0; } 00213 StyleListImpl(StyleBaseImpl *parent) : StyleBaseImpl(parent) { m_lstChildren = 0; } 00214 virtual ~StyleListImpl(); 00215 00216 unsigned long length() const { return m_lstChildren->count(); } 00217 StyleBaseImpl *item(unsigned long num) const { return m_lstChildren->at(num); } 00218 00219 void append(StyleBaseImpl *item) { m_lstChildren->append(item); } 00220 00221 protected: 00222 QPtrList<StyleBaseImpl> *m_lstChildren; 00223 }; 00224 00225 KDE_NO_EXPORT int getPropertyID(const char *tagStr, int len); 00226 00227 } 00228 00229 #endif
KDE Logo
This file is part of the documentation for khtml Library Version 3.3.0.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Wed Sep 29 09:44:52 2004 by doxygen 1.3.8 written by Dimitri van Heesch, © 1997-2003