• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * (C) 1999-2003 Lars Knoll (knoll@kde.org)
3  * Copyright (C) 2004, 2006, 2007, 2008 Apple Inc. All rights reserved.
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Library General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * Library General Public License for more details.
14  *
15  * You should have received a copy of the GNU Library General Public License
16  * along with this library; see the file COPYING.LIB.  If not, write to
17  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18  * Boston, MA 02110-1301, USA.
19  */
20 
21 #ifndef CSSStyleSheet_h
22 #define CSSStyleSheet_h
23 
24 #include "CSSRuleList.h"
25 #include "StyleSheet.h"
26 
27 namespace WebCore {
28 
29 class CSSNamespace;
30 class CSSParser;
31 class CSSRule;
32 class DocLoader;
33 class Document;
34 
35 typedef int ExceptionCode;
36 
37 class CSSStyleSheet : public StyleSheet {
38 public:
create()39     static PassRefPtr<CSSStyleSheet> create()
40     {
41         return adoptRef(new CSSStyleSheet(static_cast<CSSStyleSheet*>(0), String(), String()));
42     }
create(Node * ownerNode)43     static PassRefPtr<CSSStyleSheet> create(Node* ownerNode)
44     {
45         return adoptRef(new CSSStyleSheet(ownerNode, String(), String()));
46     }
create(Node * ownerNode,const String & href)47     static PassRefPtr<CSSStyleSheet> create(Node* ownerNode, const String& href)
48     {
49         return adoptRef(new CSSStyleSheet(ownerNode, href, String()));
50     }
create(Node * ownerNode,const String & href,const String & charset)51     static PassRefPtr<CSSStyleSheet> create(Node* ownerNode, const String& href, const String& charset)
52     {
53         return adoptRef(new CSSStyleSheet(ownerNode, href, charset));
54     }
create(CSSRule * ownerRule,const String & href,const String & charset)55     static PassRefPtr<CSSStyleSheet> create(CSSRule* ownerRule, const String& href, const String& charset)
56     {
57         return adoptRef(new CSSStyleSheet(ownerRule, href, charset));
58     }
59 
60     virtual ~CSSStyleSheet();
61 
62     CSSRule* ownerRule() const;
63     PassRefPtr<CSSRuleList> cssRules(bool omitCharsetRules = false);
64     unsigned insertRule(const String& rule, unsigned index, ExceptionCode&);
65     void deleteRule(unsigned index, ExceptionCode&);
66 
67     // IE Extensions
rules()68     PassRefPtr<CSSRuleList> rules() { return cssRules(true); }
69     int addRule(const String& selector, const String& style, int index, ExceptionCode&);
70     int addRule(const String& selector, const String& style, ExceptionCode&);
removeRule(unsigned index,ExceptionCode & ec)71     void removeRule(unsigned index, ExceptionCode& ec) { deleteRule(index, ec); }
72 
73     void addNamespace(CSSParser*, const AtomicString& prefix, const AtomicString& uri);
74     const AtomicString& determineNamespace(const AtomicString& prefix);
75 
76     virtual void styleSheetChanged();
77 
78     virtual bool parseString(const String&, bool strict = true);
79 
80     virtual bool isLoading();
81 
82     virtual void checkLoaded();
83 
doc()84     Document* doc() { return m_doc; }
85 
charset()86     const String& charset() const { return m_charset; }
87 
loadCompleted()88     bool loadCompleted() const { return m_loadCompleted; }
89 
90     virtual KURL completeURL(const String& url) const;
91     virtual void addSubresourceStyleURLs(ListHashSet<KURL>&);
92 
setStrictParsing(bool b)93     void setStrictParsing(bool b) { m_strictParsing = b; }
useStrictParsing()94     bool useStrictParsing() const { return m_strictParsing; }
95 
96 private:
97     CSSStyleSheet(Node* ownerNode, const String& href, const String& charset);
98     CSSStyleSheet(CSSStyleSheet* parentSheet, const String& href, const String& charset);
99     CSSStyleSheet(CSSRule* ownerRule, const String& href, const String& charset);
100 
isCSSStyleSheet()101     virtual bool isCSSStyleSheet() const { return true; }
type()102     virtual String type() const { return "text/css"; }
103 
104     Document* m_doc;
105     CSSNamespace* m_namespaces;
106     String m_charset;
107     bool m_loadCompleted : 1;
108     bool m_strictParsing : 1;
109 };
110 
111 } // namespace
112 
113 #endif
114