khtml Library API Documentation

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