KHtml

css_rule.h
1 /*
2  * This file is part of the DOM implementation for KDE.
3  *
4  * Copyright 1999 Lars Knoll ([email protected])
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Library General Public
8  * License as published by the Free Software Foundation; either
9  * version 2 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Library General Public License for more details.
15  *
16  * You should have received a copy of the GNU Library General Public License
17  * along with this library; see the file COPYING.LIB. If not, write to
18  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19  * Boston, MA 02110-1301, USA.
20  *
21  * This file includes excerpts from the Document Object Model (DOM)
22  * Level 2 Specification (Candidate Recommendation)
23  * https://www.w3.org/TR/2000/CR-DOM-Level-2-20000510/
24  * Copyright © 2000 W3C® (MIT, INRIA, Keio), All Rights Reserved.
25  *
26  */
27 #ifndef _CSS_css_rule_h_
28 #define _CSS_css_rule_h_
29 
30 #include <dom/dom_string.h>
31 #include <dom/css_stylesheet.h>
32 #include <dom/css_value.h>
33 
34 namespace DOM
35 {
36 
37 class CSSRuleImpl;
38 
39 /**
40  * The \c CSSRule interface is the abstract base interface
41  * for any type of CSS <a
42  * href="https://www.w3.org/TR/CSS2/syndata.html#q5"> statement
43  * </a> . This includes both <a
44  * href="https://www.w3.org/TR/CSS2/syndata.html#q8"> rule sets
45  * </a> and <a
46  * href="https://www.w3.org/TR/CSS2/syndata.html#at-rules">
47  * at-rules </a> . An implementation is expected to preserve all rules
48  * specified in a CSS style sheet, even if it is not recognized.
49  * Unrecognized rules are represented using the \c CSSUnknownRule
50  * interface.
51  *
52  */
53 class KHTML_EXPORT CSSRule
54 {
55 public:
56  CSSRule();
57  CSSRule(const CSSRule &other);
58  CSSRule(CSSRuleImpl *impl);
59 public:
60 
61  CSSRule &operator = (const CSSRule &other);
62 
63  ~CSSRule();
64  /**
65  * An integer indicating which type of rule this is.
66  *
67  */
68  enum RuleType {
69  UNKNOWN_RULE = 0,
70  STYLE_RULE = 1,
71  CHARSET_RULE = 2,
72  IMPORT_RULE = 3,
73  MEDIA_RULE = 4,
74  FONT_FACE_RULE = 5,
75  PAGE_RULE = 6,
76  NAMESPACE_RULE = 10, ///< CSSOM, @since 4.6.0
77  QUIRKS_RULE = 100 // KHTML CSS Extension
78  };
79 
80  /**
81  * The type of the rule, as defined above. The expectation is that
82  * binding-specific casting methods can be used to cast down from
83  * an instance of the \c CSSRule interface to the
84  * specific derived interface implied by the \c type .
85  *
86  */
87  unsigned short type() const;
88 
89  /**
90  * The parsable textual representation of the rule. This reflects
91  * the current state of the rule and not its initial value.
92  *
93  */
94  DOM::DOMString cssText() const;
95 
96  /**
97  * see cssText
98  * @exception DOMException
99  *
100  * HIERARCHY_REQUEST_ERR: Raised if the rule cannot be inserted
101  * at this point in the style sheet.
102  *
103  * NO_MODIFICATION_ALLOWED_ERR: Raised if this style sheet is
104  * readonly.
105  *
106  * @exception CSSException
107  * SYNTAX_ERR: Raised if the specified CSS string value has a
108  * syntax error and is unparsable.
109  *
110  * INVALID_MODIFICATION_ERR: Raised if the specified CSS string value
111  * represents a different type of rule than the current one.
112  */
113  void setCssText(const DOM::DOMString &);
114 
115  /**
116  * The style sheet that contains this rule.
117  *
118  */
119  CSSStyleSheet parentStyleSheet() const;
120 
121  /**
122  * If this rule is contained inside another rule (e.g. a style
123  * rule inside an \@media block), this is the containing rule. If
124  * this rule is not nested inside any other rules, this returns
125  * \c null .
126  *
127  */
128  CSSRule parentRule() const;
129 
130  /**
131  * @internal
132  * not part of the DOM
133  */
134  CSSRuleImpl *handle() const;
135  bool isNull() const;
136 
137 protected:
138  CSSRuleImpl *impl;
139 
140  void assignOther(const CSSRule &other, RuleType thisType);
141 };
142 
143 class CSSCharsetRuleImpl;
144 
145 /**
146  * The \c CSSCharsetRule interface a <a href=""> \@charset
147  * rule </a> in a CSS style sheet. A \c \@charset rule can
148  * be used to define the encoding of the style sheet.
149  *
150  */
151 class KHTML_EXPORT CSSCharsetRule : public CSSRule
152 {
153 public:
154  CSSCharsetRule();
155  CSSCharsetRule(const CSSCharsetRule &other);
156  CSSCharsetRule(const CSSRule &other);
157  CSSCharsetRule(CSSCharsetRuleImpl *impl);
158 public:
159 
160  CSSCharsetRule &operator = (const CSSCharsetRule &other);
161  CSSCharsetRule &operator = (const CSSRule &other);
162 
163  ~CSSCharsetRule();
164 
165  /**
166  * The encoding information used in this \c \@charset
167  * rule.
168  *
169  */
170  DOM::DOMString encoding() const;
171 
172  /**
173  * see encoding
174  * @exception CSSException
175  * SYNTAX_ERR: Raised if the specified encoding value has a syntax
176  * error and is unparsable.
177  *
178  * @exception DOMException
179  * NO_MODIFICATION_ALLOWED_ERR: Raised if this encoding rule is
180  * readonly.
181  *
182  */
183  void setEncoding(const DOM::DOMString &);
184 };
185 
186 class CSSFontFaceRuleImpl;
187 /**
188  * The \c CSSFontFaceRule interface represents a <a
189  * href="https://www.w3.org/TR/CSS2/fonts.html#font-descriptions">
190  * \c \@font-face rule </a> in a CSS style sheet. The \c \@font-face
191  * rule is used to hold a set of font descriptions.
192  *
193  */
194 class KHTML_EXPORT CSSFontFaceRule : public CSSRule
195 {
196 public:
197  CSSFontFaceRule();
198  CSSFontFaceRule(const CSSFontFaceRule &other);
199  CSSFontFaceRule(const CSSRule &other);
200  CSSFontFaceRule(CSSFontFaceRuleImpl *impl);
201 public:
202 
203  CSSFontFaceRule &operator = (const CSSFontFaceRule &other);
204  CSSFontFaceRule &operator = (const CSSRule &other);
205 
206  ~CSSFontFaceRule();
207 
208  /**
209  * The <a href="https://www.w3.org/TR/CSS2/syndata.html#q8">
210  * declaration-block </a> of this rule.
211  *
212  */
213  CSSStyleDeclaration style() const;
214 };
215 
216 class CSSImportRuleImpl;
217 /**
218  * The \c CSSImportRule interface represents a <a
219  * href="https://www.w3.org/TR/CSS2/cascade.html#at-import">
220  * \c \@import rule </a> within a CSS style sheet. The \c \@import
221  * rule is used to import style rules from other style sheets.
222  *
223  */
224 class KHTML_EXPORT CSSImportRule : public CSSRule
225 {
226 public:
227  CSSImportRule();
228  CSSImportRule(const CSSImportRule &other);
229  CSSImportRule(const CSSRule &other);
230  CSSImportRule(CSSImportRuleImpl *impl);
231 public:
232 
233  CSSImportRule &operator = (const CSSImportRule &other);
234  CSSImportRule &operator = (const CSSRule &other);
235 
236  ~CSSImportRule();
237 
238  /**
239  * The location of the style sheet to be imported. The attribute
240  * will not contain the \c "url(...)" specifier around
241  * the URI.
242  *
243  */
244  DOM::DOMString href() const;
245 
246  /**
247  * A list of media types for which this style sheet may be used.
248  *
249  */
250  MediaList media() const;
251 
252  /**
253  * The style sheet referred to by this rule, if it has been
254  * loaded. The value of this attribute is null if the style sheet
255  * has not yet been loaded or if it will not be loaded (e.g. if
256  * the style sheet is for a media type not supported by the user
257  * agent).
258  *
259  */
260  CSSStyleSheet styleSheet() const;
261 };
262 
263 class CSSMediaRuleImpl;
264 /**
265  * The \c CSSMediaRule interface represents a <a
266  * href="https://www.w3.org/TR/CSS2/media.html#at-media-rule">
267  * \@media rule </a> in a CSS style sheet. A \c \@media rule
268  * can be used to delimit style rules for specific media types.
269  *
270  */
271 class KHTML_EXPORT CSSMediaRule : public CSSRule
272 {
273 public:
274  CSSMediaRule();
275  CSSMediaRule(const CSSMediaRule &other);
276  CSSMediaRule(const CSSRule &other);
277  CSSMediaRule(CSSMediaRuleImpl *impl);
278 public:
279 
280  CSSMediaRule &operator = (const CSSMediaRule &other);
281  CSSMediaRule &operator = (const CSSRule &other);
282 
283  ~CSSMediaRule();
284 
285  /**
286  * A list of <a
287  * href="https://www.w3.org/TR/CSS2/media.html#media-types">
288  * media types </a> for this rule.
289  *
290  */
291  MediaList media() const;
292 
293  /**
294  * A list of all CSS rules contained within the media block.
295  *
296  */
297  CSSRuleList cssRules() const;
298 
299  /**
300  * Used to insert a new rule into the media block.
301  *
302  * @param rule The parsable text representing the rule. For rule
303  * sets this contains both the selector and the style declaration.
304  * For at-rules, this specifies both the at-identifier and the
305  * rule content.
306  *
307  * @param index The index within the media block's rule collection
308  * of the rule before which to insert the specified rule. If the
309  * specified index is equal to the length of the media blocks's
310  * rule collection, the rule will be added to the end of the media
311  * block.
312  *
313  * @return The index within the media block's rule collection of
314  * the newly inserted rule.
315  *
316  * \exception DOMException
317  * HIERARCHY_REQUEST_ERR: Raised if the rule cannot be inserted at
318  * the specified index. e.g. if an \c \@import rule is
319  * inserted after a standard rule set or other at-rule.
320  *
321  * INDEX_SIZE_ERR: Raised if the specified index is not a valid
322  * insertion point.
323  *
324  * NO_MODIFICATION_ALLOWED_ERR: Raised if this media rule is
325  * readonly.
326  *
327  * \exception CSSException
328  * SYNTAX_ERR: Raised if the specified rule has a syntax error
329  * and is unparsable.
330  *
331  */
332  unsigned long insertRule(const DOM::DOMString &rule, unsigned long index);
333 
334  /**
335  * Used to delete a rule from the media block.
336  *
337  * @param index The index within the media block's rule collection
338  * of the rule to remove.
339  *
340  * @return
341  *
342  * \exception DOMException
343  * INDEX_SIZE_ERR: Raised if the specified index does not
344  * correspond to a rule in the media rule list.
345  *
346  * NO_MODIFICATION_ALLOWED_ERR: Raised if this media rule is
347  * readonly.
348  *
349  */
350  void deleteRule(unsigned long index);
351 };
352 
353 class CSSPageRuleImpl;
354 /**
355  * The \c CSSPageRule interface represents a <a
356  * href="https://www.w3.org/TR/CSS2/page.html#page-box"> page rule
357  * </a> within a CSS style sheet. The \c @page rule is
358  * used to specify the dimensions, orientation, margins, etc. of a
359  * page box for paged media.
360  *
361  */
362 class KHTML_EXPORT CSSPageRule : public CSSRule
363 {
364 public:
365  CSSPageRule();
366  CSSPageRule(const CSSPageRule &other);
367  CSSPageRule(const CSSRule &other);
368  CSSPageRule(CSSPageRuleImpl *impl);
369 public:
370 
371  CSSPageRule &operator = (const CSSPageRule &other);
372  CSSPageRule &operator = (const CSSRule &other);
373 
374  ~CSSPageRule();
375 
376  /**
377  * The parsable textual representation of the page selector for
378  * the rule.
379  *
380  */
381  DOM::DOMString selectorText() const;
382 
383  /**
384  * see selectorText
385  * @exception CSSException
386  * SYNTAX_ERR: Raised if the specified CSS string value has a
387  * syntax error and is unparsable.
388  *
389  * @exception DOMException
390  * NO_MODIFICATION_ALLOWED_ERR: Raised if this style sheet is
391  * readonly.
392  *
393  */
394  void setSelectorText(const DOM::DOMString &);
395 
396  /**
397  * The <a href="https://www.w3.org/TR/CSS2/syndata.html#q8">
398  * declaration-block </a> of this rule.
399  *
400  */
401  CSSStyleDeclaration style() const;
402 };
403 
404 class CSSStyleRuleImpl;
405 /**
406  * The \c CSSStyleRule interface represents a single <a
407  * href="https://www.w3.org/TR/CSS2/syndata.html#q8"> rule set </a>
408  * in a CSS style sheet.
409  *
410  */
411 class KHTML_EXPORT CSSStyleRule : public CSSRule
412 {
413 public:
414  CSSStyleRule();
415  CSSStyleRule(const CSSStyleRule &other);
416  CSSStyleRule(const CSSRule &other);
417  CSSStyleRule(CSSStyleRuleImpl *impl);
418 public:
419 
420  CSSStyleRule &operator = (const CSSStyleRule &other);
421  CSSStyleRule &operator = (const CSSRule &other);
422 
423  ~CSSStyleRule();
424 
425  /**
426  * The textual representation of the <a
427  * href="https://www.w3.org/TR/CSS2/selector.html"> selector
428  * </a> for the rule set. The implementation may have stripped out
429  * insignificant whitespace while parsing the selector.
430  *
431  */
432  DOM::DOMString selectorText() const;
433 
434  /**
435  * see selectorText
436  * @exception CSSException
437  * SYNTAX_ERR: Raised if the specified CSS string value has a
438  * syntax error and is unparsable.
439  *
440  * @exception DOMException
441  * NO_MODIFICATION_ALLOWED_ERR: Raised if this style sheet is
442  * readonly.
443  *
444  */
445  void setSelectorText(const DOM::DOMString &);
446 
447  /**
448  * The <a href="https://www.w3.org/TR/CSS2/syndata.html#q8">
449  * declaration-block </a> of this rule set.
450  *
451  */
452  CSSStyleDeclaration style() const;
453 };
454 
455 class CSSNamespaceRuleImpl;
456 /**
457  * The \c CSSNamespaceRule interface represents an @namespace rule
458  * @since 4.6.0
459  *
460  */
461 class KHTML_EXPORT CSSNamespaceRule : public CSSRule
462 {
463 public:
464  CSSNamespaceRule();
465  CSSNamespaceRule(const CSSNamespaceRule &other);
466  CSSNamespaceRule(const CSSRule &other);
467  CSSNamespaceRule(CSSNamespaceRuleImpl *impl);
468 
469  DOMString namespaceURI() const;
470  DOMString prefix() const;
471 public:
472 
473  CSSNamespaceRule &operator = (const CSSNamespaceRule &other);
474  CSSNamespaceRule &operator = (const CSSRule &other);
475 
476  ~CSSNamespaceRule();
477 };
478 
479 class CSSUnknownRuleImpl;
480 /**
481  * The \c CSSUnkownRule interface represents an at-rule
482  * not supported by this user agent.
483  *
484  */
485 class KHTML_EXPORT CSSUnknownRule : public CSSRule
486 {
487 public:
488  CSSUnknownRule();
489  CSSUnknownRule(const CSSUnknownRule &other);
490  CSSUnknownRule(const CSSRule &other);
491  CSSUnknownRule(CSSUnknownRuleImpl *impl);
492 public:
493 
494  CSSUnknownRule &operator = (const CSSUnknownRule &other);
495  CSSUnknownRule &operator = (const CSSRule &other);
496 
497  ~CSSUnknownRule();
498 };
499 
500 class CSSRuleListImpl;
501 class StyleListImpl;
502 /**
503  * The \c CSSRuleList interface provides the abstraction
504  * of an ordered collection of CSS rules.
505  *
506  */
507 class KHTML_EXPORT CSSRuleList
508 {
509 public:
510  CSSRuleList();
511  CSSRuleList(const CSSRuleList &other);
512  CSSRuleList(CSSRuleListImpl *i);
513  CSSRuleList(StyleListImpl *i);
514 public:
515 
516  CSSRuleList &operator = (const CSSRuleList &other);
517 
518  ~CSSRuleList();
519 
520  /**
521  * The number of \c CSSRule s in the list. The range
522  * of valid child rule indices is \c 0 to
523  * \c length-1 inclusive.
524  *
525  */
526  unsigned long length() const;
527 
528  /**
529  * Used to retrieve a CSS rule by ordinal index. The order in this
530  * collection represents the order of the rules in the CSS style
531  * sheet.
532  *
533  * @param index Index into the collection
534  *
535  * @return The style rule at the \c index position in
536  * the \c CSSRuleList , or \c null if that
537  * is not a valid index.
538  *
539  */
540  CSSRule item(unsigned long index);
541 
542  /**
543  * @internal
544  * not part of the DOM
545  */
546  CSSRuleListImpl *handle() const;
547  bool isNull() const;
548 
549 protected:
550  // we just need a pointer to an implementation here.
551  CSSRuleListImpl *impl;
552 };
553 
554 } // namespace
555 
556 #endif
The CSSNamespaceRule interface represents an.
Definition: css_rule.h:455
The CSSStyleDeclaration interface represents a single CSS declaration block .
Definition: css_value.h:59
RuleType
An integer indicating which type of rule this is.
Definition: css_rule.h:68
The CSSImportRule interface represents a @import rule within a CSS style sheet.
Definition: css_rule.h:224
The CSSFontFaceRule interface represents a @font-face rule in a CSS style sheet. ...
Definition: css_rule.h:194
The CSSStyleSheet interface is a concrete interface used to represent a CSS style sheet i...
The CSSUnkownRule interface represents an at-rule not supported by this user agent.
Definition: css_rule.h:485
The MediaList interface provides the abstraction of an ordered collection of media, without defining or constraining how this collection is implemented.
The CSSStyleRule interface represents a single rule set in a CSS style sheet.
Definition: css_rule.h:411
This class implements the basic string we use in the DOM.
Definition: dom_string.h:44
This library provides a full-featured HTML parser and widget.
The CSSRuleList interface provides the abstraction of an ordered collection of CSS rules...
Definition: css_rule.h:507
The CSSRule interface is the abstract base interface for any type of CSS statement ...
Definition: css_rule.h:53
The CSSCharsetRule interface a @charset rule in a CSS style sheet.
Definition: css_rule.h:151
The CSSMediaRule interface represents a @media rule in a CSS style sheet.
Definition: css_rule.h:271
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Thu Mar 4 2021 22:47:15 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.