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 * 2002 Apple Computer, Inc. 00007 * 2004 Allan Sandfeld Jensen (kde@carewolf.com) 00008 * 00009 * This library is free software; you can redistribute it and/or 00010 * modify it under the terms of the GNU Library General Public 00011 * License as published by the Free Software Foundation; either 00012 * version 2 of the License, or (at your option) any later version. 00013 * 00014 * This library is distributed in the hope that it will be useful, 00015 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00017 * Library General Public License for more details. 00018 * 00019 * You should have received a copy of the GNU Library General Public License 00020 * along with this library; see the file COPYING.LIB. If not, write to 00021 * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 00022 * Boston, MA 02111-1307, USA. 00023 * 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 DirectAdjacent, 00102 IndirectAdjacent, 00103 SubSelector 00104 }; 00105 00106 enum PseudoType 00107 { 00108 PseudoNotParsed = 0, 00109 PseudoOther, 00110 PseudoEmpty, 00111 PseudoFirstChild, 00112 PseudoLastChild, 00113 PseudoNthChild, 00114 PseudoNthLastChild, 00115 PseudoOnlyChild, 00116 PseudoFirstOfType, 00117 PseudoLastOfType, 00118 PseudoNthOfType, 00119 PseudoNthLastOfType, 00120 PseudoOnlyOfType, 00121 PseudoFirstLine, 00122 PseudoFirstLetter, 00123 PseudoLink, 00124 PseudoVisited, 00125 PseudoHover, 00126 PseudoFocus, 00127 PseudoActive, 00128 PseudoTarget, 00129 PseudoBefore, 00130 PseudoAfter, 00131 PseudoLang, 00132 PseudoNot, 00133 PseudoContains, 00134 PseudoRoot, 00135 PseudoSelection, 00136 PseudoEnabled, 00137 PseudoDisabled, 00138 PseudoChecked, 00139 PseudoIndeterminate 00140 }; 00141 00142 PseudoType pseudoType() const { 00143 if (_pseudoType == PseudoNotParsed) 00144 extractPseudoType(); 00145 return _pseudoType; 00146 } 00147 00148 mutable DOM::DOMString value; 00149 CSSSelector *tagHistory; 00150 CSSSelector* simpleSelector; // Used by :not 00151 DOM::DOMString string_arg; // Used by :contains, :lang and :nth-* 00152 DOM::NodeImpl::Id attr; 00153 DOM::NodeImpl::Id tag; 00154 00155 Relation relation : 3; 00156 Match match : 4; 00157 bool nonCSSHint : 1; 00158 unsigned int pseudoId : 3; 00159 mutable PseudoType _pseudoType : 5; 00160 00161 private: 00162 void extractPseudoType() const; 00163 }; 00164 00165 // a style class which has a parent (almost all have) 00166 class StyleBaseImpl : public khtml::TreeShared<StyleBaseImpl> 00167 { 00168 public: 00169 StyleBaseImpl() { m_parent = 0; hasInlinedDecl = false; strictParsing = true; multiLength = false; } 00170 StyleBaseImpl(StyleBaseImpl *p) { 00171 m_parent = p; hasInlinedDecl = false; 00172 strictParsing = (m_parent ? m_parent->useStrictParsing() : true); 00173 multiLength = false; 00174 } 00175 00176 virtual ~StyleBaseImpl() {} 00177 00178 // returns the url of the style sheet this object belongs to 00179 // not const 00180 KURL baseURL(); 00181 00182 virtual bool isStyleSheet() const { return false; } 00183 virtual bool isCSSStyleSheet() const { return false; } 00184 virtual bool isStyleSheetList() const { return false; } 00185 virtual bool isMediaList() const { return false; } 00186 virtual bool isRuleList() const { return false; } 00187 virtual bool isRule() const { return false; } 00188 virtual bool isStyleRule() const { return false; } 00189 virtual bool isCharetRule() const { return false; } 00190 virtual bool isImportRule() const { return false; } 00191 virtual bool isMediaRule() const { return false; } 00192 virtual bool isFontFaceRule() const { return false; } 00193 virtual bool isPageRule() const { return false; } 00194 virtual bool isUnknownRule() const { return false; } 00195 virtual bool isStyleDeclaration() const { return false; } 00196 virtual bool isValue() const { return false; } 00197 virtual bool isPrimitiveValue() const { return false; } 00198 virtual bool isValueList() const { return false; } 00199 virtual bool isValueCustom() const { return false; } 00200 00201 void setParent(StyleBaseImpl *parent) { m_parent = parent; } 00202 00203 static void setParsedValue(int propId, const CSSValueImpl *parsedValue, 00204 bool important, bool nonCSSHint, QPtrList<CSSProperty> *propList); 00205 00206 virtual bool parseString(const DOMString &/*cssString*/, bool = false) { return false; } 00207 00208 virtual void checkLoaded() const; 00209 00210 void setStrictParsing( bool b ) { strictParsing = b; } 00211 bool useStrictParsing() const { return strictParsing; } 00212 00213 // not const 00214 StyleSheetImpl* stylesheet(); 00215 00216 protected: 00217 bool hasInlinedDecl : 1; 00218 bool strictParsing : 1; 00219 bool multiLength : 1; 00220 }; 00221 00222 // a style class which has a list of children (StyleSheets for example) 00223 class StyleListImpl : public StyleBaseImpl 00224 { 00225 public: 00226 StyleListImpl() : StyleBaseImpl() { m_lstChildren = 0; } 00227 StyleListImpl(StyleBaseImpl *parent) : StyleBaseImpl(parent) { m_lstChildren = 0; } 00228 virtual ~StyleListImpl(); 00229 00230 unsigned long length() const { return m_lstChildren->count(); } 00231 StyleBaseImpl *item(unsigned long num) const { return m_lstChildren->at(num); } 00232 00233 void append(StyleBaseImpl *item) { m_lstChildren->append(item); } 00234 00235 protected: 00236 QPtrList<StyleBaseImpl> *m_lstChildren; 00237 }; 00238 00239 KDE_NO_EXPORT int getPropertyID(const char *tagStr, int len); 00240 00241 } 00242 00243 #endif
KDE Logo
This file is part of the documentation for khtml Library Version 3.4.0.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Thu Apr 14 00:38:24 2005 by doxygen 1.3.7 written by Dimitri van Heesch, © 1997-2003