KHtml

kjs_css.h
1 /*
2  * This file is part of the KDE libraries
3  * Copyright (C) 2000 Harri Porten ([email protected])
4  * Copyright (C) 2001 Peter Kelly ([email protected])
5  * Copyright (C) 2003 Apple Computer, Inc.
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Library General Public
9  * License as published by the Free Software Foundation; either
10  * version 2 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Library General Public License for more details.
16  *
17  * You should have received a copy of the GNU Library General Public
18  * License along with this library; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20  */
21 
22 #ifndef _KJS_CSS_H_
23 #define _KJS_CSS_H_
24 
25 #include <dom/dom_node.h>
26 #include <dom/dom_doc.h>
27 #include <kjs/object.h>
28 #include "css/css_base.h"
29 #include "css/css_ruleimpl.h"
30 #include "css/css_stylesheetimpl.h"
31 #include "css/css_valueimpl.h"
32 #include "kjs_binding.h"
33 
34 namespace KJS
35 {
36 
37 class DOMCSSStyleDeclaration : public DOMObject
38 {
39 public:
40  DOMCSSStyleDeclaration(ExecState *exec, DOM::CSSStyleDeclarationImpl *s);
41  virtual ~DOMCSSStyleDeclaration();
42  using KJS::JSObject::getOwnPropertySlot;
43  bool getOwnPropertySlot(ExecState *, const Identifier &, PropertySlot &) override;
44  void getOwnPropertyNames(ExecState *, PropertyNameArray &, PropertyMap::PropertyMode mode) override;
45  using KJS::JSObject::put;
46  void put(ExecState *exec, const Identifier &propertyName, JSValue *value, int attr = None) override;
47  JSValue *getValueProperty(ExecState *exec, int token);
48 
49  const ClassInfo *classInfo() const override
50  {
51  return &info;
52  }
53  static const ClassInfo info;
54  enum { CssText, Length, ParentRule,
55  GetPropertyValue, GetPropertyCSSValue, RemoveProperty, GetPropertyPriority,
56  SetProperty, Item
57  };
58 
59  DOM::CSSStyleDeclarationImpl *impl() const
60  {
61  return m_impl.get();
62  }
63 
64  JSValue *indexGetter(ExecState *exec, unsigned index);
65 private:
66  SharedPtr<DOM::CSSStyleDeclarationImpl> m_impl;
67 };
68 
69 DEFINE_PSEUDO_CONSTRUCTOR(CSSStyleDeclarationPseudoCtor)
70 JSValue *getDOMCSSStyleDeclaration(ExecState *exec, DOM::CSSStyleDeclarationImpl *n);
71 
72 class DOMStyleSheet : public DOMObject
73 {
74 public:
75  // Build a DOMStyleSheet
76  DOMStyleSheet(ExecState *, DOM::StyleSheetImpl *ss);
77  virtual ~DOMStyleSheet();
78 
79  using KJS::JSObject::getOwnPropertySlot;
80  bool getOwnPropertySlot(ExecState *, const Identifier &, PropertySlot &) override;
81  JSValue *getValueProperty(ExecState *exec, int token) const;
82  using KJS::JSObject::put;
83  void put(ExecState *exec, const Identifier &propertyName, JSValue *value, int attr = None) override;
84  bool toBoolean(ExecState *) const override
85  {
86  return true;
87  }
88  const ClassInfo *classInfo() const override
89  {
90  return &info;
91  }
92  static const ClassInfo info;
93  enum { Type, Disabled, OwnerNode, ParentStyleSheet, Href, Title, Media };
94 protected:
95  SharedPtr<DOM::StyleSheetImpl> m_impl;
96 };
97 DEFINE_PSEUDO_CONSTRUCTOR(DOMStyleSheetPseudoCtor)
98 
99 JSValue *getDOMStyleSheet(ExecState *exec, DOM::StyleSheetImpl *ss);
100 
101 class DOMStyleSheetList : public DOMObject
102 {
103 public:
104  DOMStyleSheetList(ExecState *, DOM::StyleSheetListImpl *ssl, DOM::DocumentImpl *doc);
105  virtual ~DOMStyleSheetList();
106 
107  JSValue *getValueProperty(ExecState *exec, int token) const;
108  using KJS::JSObject::getOwnPropertySlot;
109  bool getOwnPropertySlot(ExecState *, const Identifier &, PropertySlot &) override;
110  JSValue *callAsFunction(ExecState *exec, JSObject *thisObj, const List &args) override;
111  bool implementsCall() const override
112  {
113  return true;
114  }
115  bool isFunctionType() const override
116  {
117  return false;
118  }
119  // no put - all read-only
120  const ClassInfo *classInfo() const override
121  {
122  return &info;
123  }
124  bool toBoolean(ExecState *) const override
125  {
126  return true;
127  }
128  static const ClassInfo info;
129 
130  DOM::StyleSheetListImpl *impl() const
131  {
132  return m_impl.get();
133  }
134  enum { Item, Length };
135  JSValue *indexGetter(ExecState *exec, unsigned index);
136 private:
137  static JSValue *nameGetter(ExecState *, JSObject *, const Identifier &, const PropertySlot &);
138 
139  SharedPtr<DOM::StyleSheetListImpl> m_impl;
140  SharedPtr<DOM::DocumentImpl> m_doc;
141 };
142 
143 // The document is only used for get-stylesheet-by-name (make optional if necessary)
144 JSValue *getDOMStyleSheetList(ExecState *exec, DOM::StyleSheetListImpl *ss, DOM::DocumentImpl *doc);
145 
146 class DOMMediaList : public DOMObject
147 {
148 public:
149  DOMMediaList(ExecState *, DOM::MediaListImpl *ml);
150  virtual ~DOMMediaList();
151 
152  using KJS::JSObject::getOwnPropertySlot;
153  bool getOwnPropertySlot(ExecState *, const Identifier &, PropertySlot &) override;
154  JSValue *getValueProperty(ExecState *exec, int token) const;
155  using KJS::JSObject::put;
156  void put(ExecState *exec, const Identifier &propertyName, JSValue *value, int attr = None) override;
157  const ClassInfo *classInfo() const override
158  {
159  return &info;
160  }
161  bool toBoolean(ExecState *) const override
162  {
163  return true;
164  }
165  static const ClassInfo info;
166  enum { MediaText, Length,
167  Item, DeleteMedium, AppendMedium
168  };
169  DOM::MediaListImpl *impl() const
170  {
171  return m_impl.get();
172  }
173  JSValue *indexGetter(ExecState *exec, unsigned index);
174 private:
175  SharedPtr<DOM::MediaListImpl> m_impl;
176 };
177 
178 JSValue *getDOMMediaList(ExecState *exec, DOM::MediaListImpl *ss);
179 
180 class DOMCSSStyleSheet : public DOMStyleSheet
181 {
182 public:
183  DOMCSSStyleSheet(ExecState *exec, DOM::CSSStyleSheetImpl *ss);
184  virtual ~DOMCSSStyleSheet();
185  JSValue *getValueProperty(ExecState *exec, int token);
186  using KJS::JSObject::getOwnPropertySlot;
187  bool getOwnPropertySlot(ExecState *, const Identifier &, PropertySlot &) override;
188  // no put - all read-only
189  const ClassInfo *classInfo() const override
190  {
191  return &info;
192  }
193  static const ClassInfo info;
194  enum { OwnerRule, CssRules, Rules,
195  InsertRule, DeleteRule, AddRule, RemoveRule
196  };
197  DOM::CSSStyleSheetImpl *impl() const
198  {
199  return static_cast<DOM::CSSStyleSheetImpl *>(m_impl.get());
200  }
201 };
202 
203 class DOMCSSRuleList : public DOMObject
204 {
205 public:
206  DOMCSSRuleList(ExecState *, DOM::CSSRuleListImpl *rl);
207  virtual ~DOMCSSRuleList();
208  JSValue *getValueProperty(ExecState *exec, int token) const;
209  using KJS::JSObject::getOwnPropertySlot;
210  bool getOwnPropertySlot(ExecState *, const Identifier &, PropertySlot &) override;
211  // no put - all read-only
212  const ClassInfo *classInfo() const override
213  {
214  return &info;
215  }
216  static const ClassInfo info;
217  enum { Item, Length };
218  DOM::CSSRuleListImpl *impl() const
219  {
220  return m_impl.get();
221  }
222  JSValue *indexGetter(ExecState *exec, unsigned index);
223 protected:
224  SharedPtr<DOM::CSSRuleListImpl> m_impl;
225 private:
226 };
227 
228 JSValue *getDOMCSSRuleList(ExecState *exec, DOM::CSSRuleListImpl *rl);
229 
230 class DOMCSSRule : public DOMObject
231 {
232 public:
233  DOMCSSRule(ExecState *, DOM::CSSRuleImpl *r);
234  virtual ~DOMCSSRule();
235  using KJS::JSObject::getOwnPropertySlot;
236  bool getOwnPropertySlot(ExecState *, const Identifier &, PropertySlot &) override;
237  JSValue *getValueProperty(ExecState *exec, int token) const;
238  using KJS::JSObject::put;
239  void put(ExecState *exec, const Identifier &propertyName, JSValue *value, int attr = None) override;
240  void putValueProperty(ExecState *exec, int token, JSValue *value, int attr);
241  const ClassInfo *classInfo() const override;
242  static const ClassInfo info;
243  static const ClassInfo style_info, media_info, fontface_info, page_info, import_info, charset_info, namespace_info;
244  enum { ParentStyleSheet, Type, CssText, ParentRule,
245  Style_SelectorText, Style_Style,
246  Media_Media, Media_InsertRule, Media_DeleteRule, Media_CssRules,
247  FontFace_Style, Page_SelectorText, Page_Style,
248  Import_Href, Import_Media, Import_StyleSheet, Charset_Encoding,
249  Namespace_NamespaceURI, Namespace_Prefix
250  };
251  DOM::CSSRuleImpl *impl() const
252  {
253  return m_impl.get();
254  }
255  JSValue *indexGetter(ExecState *exec, unsigned index);
256 protected:
257  SharedPtr<DOM::CSSRuleImpl> m_impl;
258 };
259 
260 JSValue *getDOMCSSRule(ExecState *exec, DOM::CSSRuleImpl *r);
261 
262 // Constructor for CSSRule - currently only used for some global values
263 class CSSRuleConstructor : public DOMObject
264 {
265 public:
266  CSSRuleConstructor(ExecState *);
267  using KJS::JSObject::getOwnPropertySlot;
268  bool getOwnPropertySlot(ExecState *, const Identifier &, PropertySlot &) override;
269  JSValue *getValueProperty(ExecState *exec, int token) const;
270  // no put - all read-only
271  const ClassInfo *classInfo() const override
272  {
273  return &info;
274  }
275  static const ClassInfo info;
276  enum { UNKNOWN_RULE, STYLE_RULE, CHARSET_RULE, IMPORT_RULE, MEDIA_RULE, FONT_FACE_RULE, PAGE_RULE };
277 };
278 
279 JSValue *getCSSRuleConstructor(ExecState *exec);
280 
281 class DOMCSSValue : public DOMObject
282 {
283 public:
284  DOMCSSValue(ExecState *, DOM::CSSValueImpl *v);
285  virtual ~DOMCSSValue();
286  JSValue *getValueProperty(ExecState *exec, int token) const;
287  using KJS::JSObject::getOwnPropertySlot;
288  bool getOwnPropertySlot(ExecState *, const Identifier &, PropertySlot &) override;
289  using KJS::JSObject::put;
290  void put(ExecState *exec, const Identifier &propertyName, JSValue *value, int attr = None) override;
291  const ClassInfo *classInfo() const override
292  {
293  return &info;
294  }
295  static const ClassInfo info;
296  enum { CssText, CssValueType };
297 protected:
298  SharedPtr<DOM::CSSValueImpl> m_impl;
299 };
300 
301 JSValue *getDOMCSSValue(ExecState *exec, DOM::CSSValueImpl *v);
302 
303 // Constructor for CSSValue - currently only used for some global values
304 class CSSValueConstructor : public DOMObject
305 {
306 public:
307  CSSValueConstructor(ExecState *exec);
308  using KJS::JSObject::getOwnPropertySlot;
309  bool getOwnPropertySlot(ExecState *, const Identifier &, PropertySlot &) override;
310  JSValue *getValueProperty(ExecState *exec, int token) const;
311  // no put - all read-only
312  const ClassInfo *classInfo() const override
313  {
314  return &info;
315  }
316  static const ClassInfo info;
317  enum { CSS_VALUE_LIST, CSS_PRIMITIVE_VALUE, CSS_CUSTOM, CSS_INHERIT };
318 };
319 
320 JSValue *getCSSValueConstructor(ExecState *exec);
321 
322 class DOMCSSPrimitiveValue : public DOMCSSValue
323 {
324 public:
325  DOMCSSPrimitiveValue(ExecState *exec, DOM::CSSPrimitiveValueImpl *v);
326  JSValue *getValueProperty(ExecState *exec, int token);
327  using KJS::JSObject::getOwnPropertySlot;
328  bool getOwnPropertySlot(ExecState *, const Identifier &, PropertySlot &) override;
329  // no put - all read-only
330  const ClassInfo *classInfo() const override
331  {
332  return &info;
333  }
334  static const ClassInfo info;
335  DOM::CSSPrimitiveValueImpl *impl() const
336  {
337  return static_cast<DOM::CSSPrimitiveValueImpl *>(m_impl.get());
338  }
339  enum { PrimitiveType, SetFloatValue, GetFloatValue, SetStringValue, GetStringValue,
340  GetCounterValue, GetRectValue, GetRGBColorValue
341  };
342 };
343 
344 // Constructor for CSSPrimitiveValue - currently only used for some global values
345 class CSSPrimitiveValueConstructor : public CSSValueConstructor
346 {
347 public:
348  CSSPrimitiveValueConstructor(ExecState *exec) : CSSValueConstructor(exec) { }
349  using KJS::JSObject::getOwnPropertySlot;
350  bool getOwnPropertySlot(ExecState *, const Identifier &, PropertySlot &) override;
351  JSValue *getValueProperty(ExecState *exec, int token) const;
352  // no put - all read-only
353  const ClassInfo *classInfo() const override
354  {
355  return &info;
356  }
357  static const ClassInfo info;
358 };
359 
360 JSValue *getCSSPrimitiveValueConstructor(ExecState *exec);
361 
362 class DOMCSSValueList : public DOMCSSValue
363 {
364 public:
365  DOMCSSValueList(ExecState *exec, DOM::CSSValueListImpl *v);
366  using KJS::JSObject::getOwnPropertySlot;
367  bool getOwnPropertySlot(ExecState *, const Identifier &, PropertySlot &) override;
368  // no put - all read-only
369  const ClassInfo *classInfo() const override
370  {
371  return &info;
372  }
373  static const ClassInfo info;
374  enum { Item, Length };
375  DOM::CSSValueListImpl *impl() const
376  {
377  return static_cast<DOM::CSSValueListImpl *>(m_impl.get());
378  }
379  JSValue *indexGetter(ExecState *exec, unsigned index);
380 };
381 
382 class DOMRGBColor : public DOMObject
383 {
384 public:
385  DOMRGBColor(ExecState *exec, QRgb color);
386  using KJS::JSObject::getOwnPropertySlot;
387  bool getOwnPropertySlot(ExecState *, const Identifier &, PropertySlot &) override;
388  JSValue *getValueProperty(ExecState *exec, int token) const;
389  // no put - all read-only
390  const ClassInfo *classInfo() const override
391  {
392  return &info;
393  }
394  static const ClassInfo info;
395  enum { Red, Green, Blue };
396 private:
397  QRgb m_color;
398 };
399 
400 JSValue *getDOMRGBColor(ExecState *exec, unsigned color);
401 
402 class DOMRect : public DOMObject
403 {
404 public:
405  DOMRect(ExecState *, DOM::RectImpl *r);
406  ~DOMRect();
407  using KJS::JSObject::getOwnPropertySlot;
408  bool getOwnPropertySlot(ExecState *, const Identifier &, PropertySlot &) override;
409  JSValue *getValueProperty(ExecState *exec, int token) const;
410  // no put - all read-only
411  const ClassInfo *classInfo() const override
412  {
413  return &info;
414  }
415  static const ClassInfo info;
416  enum { Top, Right, Bottom, Left };
417 private:
418  SharedPtr<DOM::RectImpl> m_impl;
419 };
420 
421 JSValue *getDOMRect(ExecState *exec, DOM::RectImpl *r);
422 
423 class DOMCounter : public DOMObject
424 {
425 public:
426  DOMCounter(ExecState *, DOM::CounterImpl *c);
427  ~DOMCounter();
428  using KJS::JSObject::getOwnPropertySlot;
429  bool getOwnPropertySlot(ExecState *, const Identifier &, PropertySlot &) override;
430  JSValue *getValueProperty(ExecState *exec, int token) const;
431  // no put - all read-only
432  const ClassInfo *classInfo() const override
433  {
434  return &info;
435  }
436  static const ClassInfo info;
437  enum { identifier, listStyle, separator };
438 protected:
439  SharedPtr<DOM::CounterImpl> m_impl;
440 };
441 
442 JSValue *getDOMCounter(ExecState *exec, DOM::CounterImpl *c);
443 } // namespace
444 
445 #endif
Left
KIOCORE_EXPORT TransferJob * put(const QUrl &url, int permissions, JobFlags flags=DefaultFlags)
Right
This library provides a full-featured HTML parser and widget.
Top
Title
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Mon Oct 25 2021 22:48:17 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.