# khtml Library API Documentation

Overview | Class Hierarchy | Classes | Classes (annotated) | Members | Namespaces | Source Files

# 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         PseudoClass,
    00092         PseudoElement,
    00093         Contain,   // css3: E[foo*="bar"]
    00094         Begin,     // css3: E[foo^="bar"]
    00095         End        // css3: E[foo$="bar"]
    00096     };
    00097
    00098     enum Relation
    00099     {
    00100         Descendant = 0,
    00101         Child,
    00102         DirectAdjacent,
    00103             IndirectAdjacent,
    00104             SubSelector
    00105     };
    00106
    00107     enum PseudoType
    00108     {
    00109         PseudoNotParsed = 0,
    00110         PseudoOther,
    00111         PseudoEmpty,
    00112         PseudoFirstChild,
    00113             PseudoLastChild,
    00114             PseudoNthChild,
    00115             PseudoNthLastChild,
    00116             PseudoOnlyChild,
    00117             PseudoFirstOfType,
    00118             PseudoLastOfType,
    00119             PseudoNthOfType,
    00120             PseudoNthLastOfType,
    00121             PseudoOnlyOfType,
    00122             PseudoFirstLine,
    00123         PseudoFirstLetter,
    00124         PseudoLink,
    00125         PseudoVisited,
    00126         PseudoHover,
    00127         PseudoFocus,
    00128         PseudoActive,
    00129             PseudoTarget,
    00130         PseudoBefore,
    00131         PseudoAfter,
    00132             PseudoLang,
    00133             PseudoNot,
    00134             PseudoContains,
    00135             PseudoRoot,
    00136             PseudoSelection,
    00137             PseudoEnabled,
    00138             PseudoDisabled,
    00139             PseudoChecked,
    00140             PseudoIndeterminate
    00141     };
    00142
    00143     PseudoType pseudoType() const {
    00144             if (_pseudoType == PseudoNotParsed)
    00145                 extractPseudoType();
    00146             return _pseudoType;
    00147         }
    00148
    00149         mutable DOM::DOMString value;
    00150     CSSSelector *tagHistory;
    00151         CSSSelector* simpleSelector; // Used by :not
    00152         DOM::DOMString string_arg; // Used by :contains, :lang and :nth-*
    00153         DOM::NodeImpl::Id attr;
    00154         DOM::NodeImpl::Id tag;
    00155
    00156     Relation relation     : 3;
    00157     mutable Match    match         : 4;
    00158     bool    nonCSSHint : 1;
    00159     unsigned int pseudoId : 3;
    00160     mutable PseudoType _pseudoType : 5;
    00161
    00162     private:
    00163     void extractPseudoType() const;
    00164     };
    00165
    00166     // a style class which has a parent (almost all have)
    00167     class StyleBaseImpl : public khtml::TreeShared<StyleBaseImpl>
    00168     {
    00169     public:
    00170     StyleBaseImpl()  { m_parent = 0; hasInlinedDecl = false; strictParsing = true; multiLength = false; }
    00171     StyleBaseImpl(StyleBaseImpl *p) {
    00172         m_parent = p; hasInlinedDecl = false;
    00173         strictParsing = (m_parent ? m_parent->useStrictParsing() : true);
    00174         multiLength = false;
    00175     }
    00176
    00177     virtual ~StyleBaseImpl() {}
    00178
    00179     // returns the url of the style sheet this object belongs to
    00180         // not const
    00181     KURL baseURL();
    00182
    00183     virtual bool isStyleSheet() const { return false; }
    00184     virtual bool isCSSStyleSheet() const { return false; }
    00185     virtual bool isStyleSheetList() const { return false; }
    00186     virtual bool isMediaList() const { return false; }
    00187     virtual bool isRuleList() const { return false; }
    00188     virtual bool isRule() const { return false; }
    00189     virtual bool isStyleRule() const { return false; }
    00190     virtual bool isCharetRule() const { return false; }
    00191     virtual bool isImportRule() const { return false; }
    00192     virtual bool isMediaRule() const { return false; }
    00193     virtual bool isFontFaceRule() const { return false; }
    00194     virtual bool isPageRule() const { return false; }
    00195     virtual bool isUnknownRule() const { return false; }
    00196     virtual bool isStyleDeclaration() const { return false; }
    00197     virtual bool isValue() const { return false; }
    00198     virtual bool isPrimitiveValue() const { return false; }
    00199     virtual bool isValueList() const { return false; }
    00200     virtual bool isValueCustom() const { return false; }
    00201
    00202     void setParent(StyleBaseImpl *parent) { m_parent = parent; }
    00203
    00204     static void setParsedValue(int propId, const CSSValueImpl *parsedValue,
    00205                    bool important, bool nonCSSHint, QPtrList<CSSProperty> *propList);
    00206
    00207     virtual bool parseString(const DOMString &/*cssString*/, bool = false) { return false; }
    00208
    00209     virtual void checkLoaded() const;
    00210
    00211     void setStrictParsing( bool b ) { strictParsing = b; }
    00212     bool useStrictParsing() const { return strictParsing; }
    00213
    00214         // not const
    00215     StyleSheetImpl* stylesheet();
    00216
    00217     protected:
    00218     bool hasInlinedDecl : 1;
    00219     bool strictParsing : 1;
    00220     bool multiLength : 1;
    00221     };
    00222
    00223     // a style class which has a list of children (StyleSheets for example)
    00224     class StyleListImpl : public StyleBaseImpl
    00225     {
    00226     public:
    00227     StyleListImpl() : StyleBaseImpl() { m_lstChildren = 0; }
    00228     StyleListImpl(StyleBaseImpl *parent) : StyleBaseImpl(parent) { m_lstChildren = 0; }
    00229     virtual ~StyleListImpl();
    00230
    00231     unsigned long length() const { return m_lstChildren->count(); }
    00232     StyleBaseImpl *item(unsigned long num) const { return m_lstChildren->at(num); }
    00233
    00234     void append(StyleBaseImpl *item) { m_lstChildren->append(item); }
    00235
    00236     protected:
    00237     QPtrList<StyleBaseImpl> *m_lstChildren;
    00238     };
    00239
    00240     KDE_NO_EXPORT int getPropertyID(const char *tagStr, int len);
    00241
    00242 }
    00243
    00244 #endif

This file is part of the documentation for khtml Library Version 3.4.1.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Sat Jun 11 20:33:06 2005 by doxygen 1.4.1 written by Dimitri van Heesch, © 1997-2003