1 /*
2  * Copyright (C) 2006, 2007 Rob Buis
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Library General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public License
15  * along with this library; see the file COPYING.LIB.  If not, write to
16  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17  * Boston, MA 02110-1301, USA.
18  *
19  */
20 
21 #ifndef StyleElement_h
22 #define StyleElement_h
23 
24 #include "CSSStyleSheet.h"
25 
26 namespace WebCore {
27 
28 class Document;
29 class Element;
30 
31 class StyleElement {
32 public:
33     StyleElement(Document*, bool createdByParser);
34     virtual ~StyleElement();
35 
36 protected:
37     virtual const AtomicString& type() const = 0;
38     virtual const AtomicString& media() const = 0;
39 
sheet()40     StyleSheet* sheet() const { return m_sheet.get(); }
41 
42     bool isLoading() const;
43     bool sheetLoaded(Document*);
44 
45     void insertedIntoDocument(Document*, Element*);
46     void removedFromDocument(Document*, Element*);
47     void clearDocumentData(Document*, Element*);
48     void childrenChanged(Element*);
49     void finishParsingChildren(Element*);
50 
51     RefPtr<CSSStyleSheet> m_sheet;
52 
53 private:
54     void createSheet(Element*, int startLineNumber, const String& text = String());
55     void process(Element*);
56 
57     bool m_createdByParser;
58     bool m_loading;
59     int m_startLineNumber;
60 };
61 
62 }
63 
64 #endif
65