# khtml Library API Documentation

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

# kjs_css.h

    00001 // -*- c-basic-offset: 2 -*-
    00002 /*
    00003  *  This file is part of the KDE libraries
    00004  *  Copyright (C) 2000 Harri Porten (porten@kde.org)
    00005  *  Copyright (C) 2001 Peter Kelly (pmk@post.com)
    00006  *
    00007  *  This library is free software; you can redistribute it and/or
    00008  *  modify it under the terms of the GNU Library General Public
    00009  *  License as published by the Free Software Foundation; either
    00010  *  version 2 of the License, or (at your option) any later version.
    00011  *
    00012  *  This library is distributed in the hope that it will be useful,
    00013  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
    00014  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    00015  *  Library General Public License for more details.
    00016  *
    00017  *  You should have received a copy of the GNU Library General Public
    00018  *  License along with this library; if not, write to the Free Software
    00019  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    00020  */
    00021
    00022 #ifndef _KJS_CSS_H_
    00023 #define _KJS_CSS_H_
    00024
    00025 #include <dom/dom_node.h>
    00026 #include <dom/dom_doc.h>
    00027 #include <kjs/object.h>
    00028 #include <dom/css_value.h>
    00029 #include <dom/css_stylesheet.h>
    00030 #include <dom/css_rule.h>
    00031 #include "kjs_binding.h"
    00032
    00033 namespace KJS {
    00034
    00035   class DOMCSSStyleDeclaration : public DOMObject {
    00036   public:
    00037     DOMCSSStyleDeclaration(ExecState *exec, const DOM::CSSStyleDeclaration& s);
    00038     virtual ~DOMCSSStyleDeclaration();
    00039     virtual Value tryGet(ExecState *exec, const UString &propertyName) const;
    00040     virtual void tryPut(ExecState *exec, const UString &propertyName, const Value& value, int attr = None);
    00041     virtual bool hasProperty(ExecState *exec, const UString &propertyName) const;
    00042     virtual const ClassInfo *classInfo() const { return &info; }
    00043     static const ClassInfo info;
    00044     enum { CssText, Length, ParentRule,
    00045            GetPropertyValue, GetPropertyCSSValue, RemoveProperty, GetPropertyPriority,
    00046            SetProperty, Item };
    00047     DOM::CSSStyleDeclaration toStyleDecl() const { return styleDecl; }
    00048   protected:
    00049     DOM::CSSStyleDeclaration styleDecl;
    00050   };
    00051
    00052   Value getDOMCSSStyleDeclaration(ExecState *exec, const DOM::CSSStyleDeclaration& n);
    00053
    00054   class DOMStyleSheet : public DOMObject {
    00055   public:
    00056     // Build a DOMStyleSheet
    00057     DOMStyleSheet(ExecState *, const DOM::StyleSheet& ss);
    00058     // Constructor for inherited classes
    00059     DOMStyleSheet(const Object& proto, const DOM::StyleSheet& ss) : DOMObject(proto), styleSheet(ss) { }
    00060     virtual ~DOMStyleSheet();
    00061     virtual Value tryGet(ExecState *exec, const UString &propertyName) const;
    00062     Value getValueProperty(ExecState *exec, int token) const;
    00063     virtual void tryPut(ExecState *exec, const UString &propertyName, const Value& value, int attr = None);
    00064     virtual bool toBoolean(ExecState *) const { return true; }
    00065     virtual const ClassInfo* classInfo() const { return &info; }
    00066     static const ClassInfo info;
    00067     enum { Type, Disabled, OwnerNode, ParentStyleSheet, Href, Title, Media };
    00068   protected:
    00069     DOM::StyleSheet styleSheet;
    00070   };
    00071
    00072   Value getDOMStyleSheet(ExecState *exec, const DOM::StyleSheet& ss);
    00073
    00074   class DOMStyleSheetList : public DOMObject {
    00075   public:
    00076     DOMStyleSheetList(ExecState *, const DOM::StyleSheetList& ssl, const DOM::Document& doc);
    00077     virtual ~DOMStyleSheetList();
    00078     virtual Value tryGet(ExecState *exec,const UString &propertyName) const;
    00079     virtual Value call(ExecState *exec, Object &thisObj, const List &args);
    00080     Value tryCall(ExecState *exec, Object &thisObj, const List &args);
    00081     virtual bool implementsCall() const { return true; }
    00082     // no put - all read-only
    00083     virtual const ClassInfo* classInfo() const { return &info; }
    00084     virtual bool toBoolean(ExecState* ) const { return true; }
    00085     static const ClassInfo info;
    00086     DOM::StyleSheetList toStyleSheetList() const { return styleSheetList; }
    00087     enum { Item, Length };
    00088   private:
    00089     DOM::StyleSheetList styleSheetList;
    00090     DOM::Document m_doc;
    00091   };
    00092
    00093   // The document is only used for get-stylesheet-by-name (make optional if necessary)
    00094   Value getDOMStyleSheetList(ExecState *exec, const DOM::StyleSheetList& ss, const DOM::Document& doc);
    00095
    00096   class DOMMediaList : public DOMObject {
    00097   public:
    00098     DOMMediaList(ExecState *, const DOM::MediaList& ml);
    00099     virtual ~DOMMediaList();
    00100     virtual Value tryGet(ExecState *exec,const UString &propertyName) const;
    00101     virtual void tryPut(ExecState *exec, const UString &propertyName, const Value& value, int attr = None);
    00102     virtual const ClassInfo* classInfo() const { return &info; }
    00103     virtual bool toBoolean(ExecState* ) const { return true; }
    00104     static const ClassInfo info;
    00105     enum { MediaText, Length,
    00106            Item, DeleteMedium, AppendMedium };
    00107     DOM::MediaList toMediaList() const { return mediaList; }
    00108   private:
    00109     DOM::MediaList mediaList;
    00110   };
    00111
    00112   Value getDOMMediaList(ExecState *exec, const DOM::MediaList& ss);
    00113
    00114   class DOMCSSStyleSheet : public DOMStyleSheet {
    00115   public:
    00116     DOMCSSStyleSheet(ExecState *exec, const DOM::CSSStyleSheet& ss);
    00117     virtual ~DOMCSSStyleSheet();
    00118     virtual Value tryGet(ExecState *exec,const UString &propertyName) const;
    00119     // no put - all read-only
    00120     virtual const ClassInfo* classInfo() const { return &info; }
    00121     static const ClassInfo info;
    00122     enum { OwnerRule, CssRules, Rules,
    00123            InsertRule, DeleteRule, AddRule, RemoveRule };
    00124     DOM::CSSStyleSheet toCSSStyleSheet() const { return static_cast<DOM::CSSStyleSheet>(styleSheet); }
    00125   };
    00126
    00127   class DOMCSSRuleList : public DOMObject {
    00128   public:
    00129     DOMCSSRuleList(ExecState *, const DOM::CSSRuleList& rl);
    00130     virtual ~DOMCSSRuleList();
    00131     virtual Value tryGet(ExecState *exec,const UString &propertyName) const;
    00132     // no put - all read-only
    00133     virtual const ClassInfo* classInfo() const { return &info; }
    00134     static const ClassInfo info;
    00135     enum { Item, Length };
    00136     DOM::CSSRuleList toCSSRuleList() const { return cssRuleList; }
    00137   protected:
    00138     DOM::CSSRuleList cssRuleList;
    00139   };
    00140
    00141   Value getDOMCSSRuleList(ExecState *exec, const DOM::CSSRuleList& rl);
    00142
    00143   class DOMCSSRule : public DOMObject {
    00144   public:
    00145     DOMCSSRule(ExecState *, const DOM::CSSRule& r);
    00146     virtual ~DOMCSSRule();
    00147     virtual Value tryGet(ExecState *exec,const UString &propertyName) const;
    00148     Value getValueProperty(ExecState *exec, int token) const;
    00149     virtual void tryPut(ExecState *exec, const UString &propertyName, const Value& value, int attr = None);
    00150     void putValueProperty(ExecState *exec, int token, const Value& value, int attr);
    00151     virtual const ClassInfo* classInfo() const;
    00152     static const ClassInfo info;
    00153     static const ClassInfo style_info, media_info, fontface_info, page_info, import_info, charset_info;
    00154     enum { ParentStyleSheet, Type, CssText, ParentRule,
    00155            Style_SelectorText, Style_Style,
    00156            Media_Media, Media_InsertRule, Media_DeleteRule, Media_CssRules,
    00157            FontFace_Style, Page_SelectorText, Page_Style,
    00158            Import_Href, Import_Media, Import_StyleSheet, Charset_Encoding };
    00159     DOM::CSSRule toCSSRule() const { return cssRule; }
    00160   protected:
    00161     DOM::CSSRule cssRule;
    00162   };
    00163
    00164   Value getDOMCSSRule(ExecState *exec, const DOM::CSSRule& r);
    00165
    00169   DOM::CSSRule toCSSRule(const Value&);
    00170
    00171   // Constructor for CSSRule - currently only used for some global values
    00172   class CSSRuleConstructor : public DOMObject {
    00173   public:
    00174     CSSRuleConstructor(ExecState *);
    00175     virtual Value tryGet(ExecState *exec,const UString &propertyName) const;
    00176     Value getValueProperty(ExecState *exec, int token) const;
    00177     // no put - all read-only
    00178     virtual const ClassInfo* classInfo() const { return &info; }
    00179     static const ClassInfo info;
    00180     enum { UNKNOWN_RULE, STYLE_RULE, CHARSET_RULE, IMPORT_RULE, MEDIA_RULE, FONT_FACE_RULE, PAGE_RULE };
    00181   };
    00182
    00183   Value getCSSRuleConstructor(ExecState *exec);
    00184
    00185   class DOMCSSValue : public DOMObject {
    00186   public:
    00187     DOMCSSValue(ExecState *, const DOM::CSSValue& v);
    00188     DOMCSSValue(const Object& proto, const DOM::CSSValue& v) : DOMObject(proto), cssValue(v) { }
    00189     virtual ~DOMCSSValue();
    00190     virtual Value tryGet(ExecState *exec,const UString &propertyName) const;
    00191     virtual void tryPut(ExecState *exec, const UString &propertyName, const Value& value, int attr = None);
    00192     virtual const ClassInfo* classInfo() const { return &info; }
    00193     static const ClassInfo info;
    00194     enum { CssText, CssValueType };
    00195   protected:
    00196     DOM::CSSValue cssValue;
    00197   };
    00198
    00199   Value getDOMCSSValue(ExecState *exec, const DOM::CSSValue& v);
    00200
    00201   // Constructor for CSSValue - currently only used for some global values
    00202   class CSSValueConstructor : public DOMObject {
    00203   public:
    00204     CSSValueConstructor(ExecState *exec);
    00205     virtual Value tryGet(ExecState *exec,const UString &propertyName) const;
    00206     Value getValueProperty(ExecState *exec, int token) const;
    00207     // no put - all read-only
    00208     virtual const ClassInfo* classInfo() const { return &info; }
    00209     static const ClassInfo info;
    00210     enum { CSS_VALUE_LIST, CSS_PRIMITIVE_VALUE, CSS_CUSTOM, CSS_INHERIT };
    00211   };
    00212
    00213   Value getCSSValueConstructor(ExecState *exec);
    00214
    00215   class DOMCSSPrimitiveValue : public DOMCSSValue {
    00216   public:
    00217     DOMCSSPrimitiveValue(ExecState *exec, const DOM::CSSPrimitiveValue& v);
    00218     virtual Value tryGet(ExecState *exec,const UString &propertyName) const;
    00219     // no put - all read-only
    00220     virtual const ClassInfo* classInfo() const { return &info; }
    00221     static const ClassInfo info;
    00222     DOM::CSSPrimitiveValue toCSSPrimitiveValue() const { return static_cast<DOM::CSSPrimitiveValue>(cssValue); }
    00223     enum { PrimitiveType, SetFloatValue, GetFloatValue, SetStringValue, GetStringValue,
    00224            GetCounterValue, GetRectValue, GetRGBColorValue };
    00225   };
    00226
    00227   // Constructor for CSSPrimitiveValue - currently only used for some global values
    00228   class CSSPrimitiveValueConstructor : public CSSValueConstructor {
    00229   public:
    00230     CSSPrimitiveValueConstructor(ExecState *exec) : CSSValueConstructor(exec) { }
    00231     virtual Value tryGet(ExecState *exec,const UString &propertyName) const;
    00232     Value getValueProperty(ExecState *exec, int token) const;
    00233     // no put - all read-only
    00234     virtual const ClassInfo* classInfo() const { return &info; }
    00235     static const ClassInfo info;
    00236   };
    00237
    00238   Value getCSSPrimitiveValueConstructor(ExecState *exec);
    00239
    00240   class DOMCSSValueList : public DOMCSSValue {
    00241   public:
    00242     DOMCSSValueList(ExecState *exec, const DOM::CSSValueList& v);
    00243     virtual Value tryGet(ExecState *exec,const UString &propertyName) const;
    00244     // no put - all read-only
    00245     virtual const ClassInfo* classInfo() const { return &info; }
    00246     static const ClassInfo info;
    00247     enum { Item, Length };
    00248     DOM::CSSValueList toValueList() const { return static_cast<DOM::CSSValueList>(cssValue); }
    00249   };
    00250
    00251   class DOMRGBColor : public DOMObject {
    00252   public:
    00253     DOMRGBColor(ExecState*, const DOM::RGBColor& c);
    00254     ~DOMRGBColor();
    00255     virtual Value tryGet(ExecState *exec,const UString &propertyName) const;
    00256     Value getValueProperty(ExecState *exec, int token) const;
    00257     // no put - all read-only
    00258     virtual const ClassInfo* classInfo() const { return &info; }
    00259     static const ClassInfo info;
    00260     enum { Red, Green, Blue };
    00261   protected:
    00262     DOM::RGBColor rgbColor;
    00263   };
    00264
    00265   Value getDOMRGBColor(ExecState *exec, const DOM::RGBColor& c);
    00266
    00267   class DOMRect : public DOMObject {
    00268   public:
    00269     DOMRect(ExecState *, const DOM::Rect& r);
    00270     ~DOMRect();
    00271     virtual Value tryGet(ExecState *exec,const UString &propertyName) const;
    00272     Value getValueProperty(ExecState *exec, int token) const;
    00273     // no put - all read-only
    00274     virtual const ClassInfo* classInfo() const { return &info; }
    00275     static const ClassInfo info;
    00276     enum { Top, Right, Bottom, Left };
    00277   protected:
    00278     DOM::Rect rect;
    00279   };
    00280
    00281   Value getDOMRect(ExecState *exec, const DOM::Rect& r);
    00282
    00283   class DOMCounter : public DOMObject {
    00284   public:
    00285     DOMCounter(ExecState *, const DOM::Counter& c);
    00286     ~DOMCounter();
    00287     virtual Value tryGet(ExecState *exec,const UString &propertyName) const;
    00288     Value getValueProperty(ExecState *exec, int token) const;
    00289     // no put - all read-only
    00290     virtual const ClassInfo* classInfo() const { return &info; }
    00291     static const ClassInfo info;
    00292     enum { _Identifier, ListStyle, Separator };
    00293   protected:
    00294     DOM::Counter counter;
    00295   };
    00296
    00297   Value getDOMCounter(ExecState *exec, const DOM::Counter& c);
    00298
    00299 } // namespace
    00300
    00301 #endif

This file is part of the documentation for kdelibs Version 3.1.5.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Wed Jan 28 13:34:13 2004 by doxygen 1.3.4 written by Dimitri van Heesch, © 1997-2001