]>
Commit | Line | Data |
---|---|---|
a90939db JF |
1 | /* |
2 | * (C) 1999-2003 Lars Knoll (knoll@kde.org) | |
3 | * Copyright (C) 2004, 2006, 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 MediaList_h | |
22 | #define MediaList_h | |
23 | ||
24 | #include "StyleBase.h" | |
25 | #include <wtf/PassRefPtr.h> | |
26 | #include <wtf/Vector.h> | |
27 | ||
28 | namespace WebCore { | |
29 | ||
30 | class CSSImportRule; | |
31 | class CSSStyleSheet; | |
32 | class MediaQuery; | |
33 | class String; | |
34 | ||
35 | typedef int ExceptionCode; | |
36 | ||
37 | class MediaList : public StyleBase { | |
38 | public: | |
39 | static PassRefPtr<MediaList> create() | |
40 | { | |
41 | return adoptRef(new MediaList(0, false)); | |
42 | } | |
43 | static PassRefPtr<MediaList> create(CSSImportRule* parentRule, const String& media) | |
44 | { | |
45 | return adoptRef(new MediaList(parentRule, media)); | |
46 | } | |
47 | static PassRefPtr<MediaList> create(CSSStyleSheet* parentSheet, const String& media) | |
48 | { | |
49 | return adoptRef(new MediaList(parentSheet, media, false)); | |
50 | } | |
51 | ||
52 | static PassRefPtr<MediaList> createAllowingDescriptionSyntax(const String& mediaQueryOrDescription) | |
53 | { | |
54 | return adoptRef(new MediaList(0, mediaQueryOrDescription, true)); | |
55 | } | |
56 | static PassRefPtr<MediaList> createAllowingDescriptionSyntax(CSSStyleSheet* parentSheet, const String& mediaQueryOrDescription) | |
57 | { | |
58 | return adoptRef(new MediaList(parentSheet, mediaQueryOrDescription, true)); | |
59 | } | |
60 | ||
61 | static PassRefPtr<MediaList> create(const String& media, bool allowDescriptionSyntax) | |
62 | { | |
63 | return adoptRef(new MediaList(0, media, allowDescriptionSyntax)); | |
64 | } | |
65 | ||
66 | virtual ~MediaList(); | |
67 | ||
68 | unsigned length() const { return m_queries.size(); } | |
69 | String item(unsigned index) const; | |
70 | void deleteMedium(const String& oldMedium, ExceptionCode&); | |
71 | void appendMedium(const String& newMedium, ExceptionCode&); | |
72 | ||
73 | String mediaText() const; | |
74 | void setMediaText(const String&, ExceptionCode&xo); | |
75 | ||
76 | void appendMediaQuery(MediaQuery*); | |
77 | const Vector<MediaQuery*>& mediaQueries() const { return m_queries; } | |
78 | ||
79 | private: | |
80 | MediaList(CSSStyleSheet* parentSheet, bool fallbackToDescription); | |
81 | MediaList(CSSStyleSheet* parentSheet, const String& media, bool fallbackToDescription); | |
82 | MediaList(CSSImportRule* parentRule, const String& media); | |
83 | ||
84 | void notifyChanged(); | |
85 | ||
86 | Vector<MediaQuery*> m_queries; | |
87 | bool m_fallback; // true if failed media query parsing should fallback to media description parsing | |
88 | }; | |
89 | ||
90 | } // namespace | |
91 | ||
92 | #endif |