OLD | NEW |
1 /* | 1 /* |
2 * (C) 1999-2003 Lars Knoll (knoll@kde.org) | 2 * (C) 1999-2003 Lars Knoll (knoll@kde.org) |
3 * Copyright (C) 2004, 2006, 2008, 2009, 2010, 2012 Apple Inc. All rights reserv
ed. | 3 * Copyright (C) 2004, 2006, 2008, 2009, 2010, 2012 Apple Inc. All rights reserv
ed. |
4 * | 4 * |
5 * This library is free software; you can redistribute it and/or | 5 * This library is free software; you can redistribute it and/or |
6 * modify it under the terms of the GNU Library General Public | 6 * modify it under the terms of the GNU Library General Public |
7 * License as published by the Free Software Foundation; either | 7 * License as published by the Free Software Foundation; either |
8 * version 2 of the License, or (at your option) any later version. | 8 * version 2 of the License, or (at your option) any later version. |
9 * | 9 * |
10 * This library is distributed in the hope that it will be useful, | 10 * This library is distributed in the hope that it will be useful, |
(...skipping 18 matching lines...) Expand all Loading... |
29 #include "wtf/text/WTFString.h" | 29 #include "wtf/text/WTFString.h" |
30 | 30 |
31 namespace WebCore { | 31 namespace WebCore { |
32 | 32 |
33 class CSSRule; | 33 class CSSRule; |
34 class CSSStyleSheet; | 34 class CSSStyleSheet; |
35 class Document; | 35 class Document; |
36 class MediaList; | 36 class MediaList; |
37 class MediaQuery; | 37 class MediaQuery; |
38 | 38 |
| 39 enum MediaQueryParserMode { |
| 40 MediaQueryNormalMode, |
| 41 MediaQueryForwardCompatibleSyntaxMode, |
| 42 MediaQueryStrictMode, |
| 43 }; |
| 44 |
39 class MediaQuerySet : public RefCounted<MediaQuerySet> { | 45 class MediaQuerySet : public RefCounted<MediaQuerySet> { |
40 public: | 46 public: |
41 static PassRefPtr<MediaQuerySet> create() | 47 static PassRefPtr<MediaQuerySet> create() |
42 { | 48 { |
43 return adoptRef(new MediaQuerySet()); | 49 return adoptRef(new MediaQuerySet()); |
44 } | 50 } |
45 static PassRefPtr<MediaQuerySet> create(const String& mediaString) | 51 static PassRefPtr<MediaQuerySet> create(const String& mediaString) |
46 { | 52 { |
47 return adoptRef(new MediaQuerySet(mediaString, false)); | 53 return adoptRef(new MediaQuerySet(mediaString, MediaQueryNormalMode)); |
48 } | 54 } |
49 static PassRefPtr<MediaQuerySet> createAllowingDescriptionSyntax(const Strin
g& mediaString) | 55 static PassRefPtr<MediaQuerySet> createAllowingDescriptionSyntax(const Strin
g& mediaString) |
50 { | 56 { |
51 return adoptRef(new MediaQuerySet(mediaString, true)); | 57 return adoptRef(new MediaQuerySet(mediaString, MediaQueryForwardCompatib
leSyntaxMode)); |
52 } | 58 } |
53 ~MediaQuerySet(); | 59 ~MediaQuerySet(); |
54 | 60 |
55 bool parse(const String&); | 61 bool set(const String&); |
56 bool add(const String&); | 62 bool add(const String&); |
57 bool remove(const String&); | 63 bool remove(const String&); |
58 | 64 |
59 void addMediaQuery(PassOwnPtr<MediaQuery>); | 65 void addMediaQuery(PassOwnPtr<MediaQuery>); |
60 | 66 |
61 const Vector<OwnPtr<MediaQuery> >& queryVector() const { return m_queries; } | 67 const Vector<OwnPtr<MediaQuery> >& queryVector() const { return m_queries; } |
62 | 68 |
63 int lastLine() const { return m_lastLine; } | 69 int lastLine() const { return m_lastLine; } |
64 void setLastLine(int lastLine) { m_lastLine = lastLine; } | 70 void setLastLine(int lastLine) { m_lastLine = lastLine; } |
65 | 71 |
66 String mediaText() const; | 72 String mediaText() const; |
67 | 73 |
68 PassRefPtr<MediaQuerySet> copy() const { return adoptRef(new MediaQuerySet(*
this)); } | 74 PassRefPtr<MediaQuerySet> copy() const { return adoptRef(new MediaQuerySet(*
this)); } |
69 | 75 |
70 void reportMemoryUsage(MemoryObjectInfo*) const; | 76 void reportMemoryUsage(MemoryObjectInfo*) const; |
71 | 77 |
72 private: | 78 private: |
73 MediaQuerySet(); | 79 MediaQuerySet(); |
74 MediaQuerySet(const String& mediaQuery, bool fallbackToDescription); | 80 MediaQuerySet(const String& mediaQuery, MediaQueryParserMode); |
75 MediaQuerySet(const MediaQuerySet&); | 81 MediaQuerySet(const MediaQuerySet&); |
76 | 82 |
77 PassOwnPtr<MediaQuery> parseMediaQuery(const String&); | 83 PassOwnPtr<MediaQuery> parseMediaQuery(const String&, MediaQueryParserMode); |
| 84 void parseMediaQueryList(const String&, MediaQueryParserMode, Vector<OwnPtr<
MediaQuery> >& result); |
78 | 85 |
79 unsigned m_fallbackToDescriptor : 1; // true if failed media query parsing s
hould fallback to media description parsing. | 86 MediaQueryParserMode parserMode() const { return static_cast<MediaQueryParse
rMode>(m_parserMode); } |
80 signed m_lastLine : 31; | 87 |
| 88 unsigned m_parserMode : 2; |
| 89 unsigned m_lastLine : 30; |
81 Vector<OwnPtr<MediaQuery> > m_queries; | 90 Vector<OwnPtr<MediaQuery> > m_queries; |
82 }; | 91 }; |
83 | 92 |
84 class MediaList : public RefCounted<MediaList> { | 93 class MediaList : public RefCounted<MediaList> { |
85 public: | 94 public: |
86 static PassRefPtr<MediaList> create(MediaQuerySet* mediaQueries, CSSStyleShe
et* parentSheet) | 95 static PassRefPtr<MediaList> create(MediaQuerySet* mediaQueries, CSSStyleShe
et* parentSheet) |
87 { | 96 { |
88 return adoptRef(new MediaList(mediaQueries, parentSheet)); | 97 return adoptRef(new MediaList(mediaQueries, parentSheet)); |
89 } | 98 } |
90 static PassRefPtr<MediaList> create(MediaQuerySet* mediaQueries, CSSRule* pa
rentRule) | 99 static PassRefPtr<MediaList> create(MediaQuerySet* mediaQueries, CSSRule* pa
rentRule) |
91 { | 100 { |
92 return adoptRef(new MediaList(mediaQueries, parentRule)); | 101 return adoptRef(new MediaList(mediaQueries, parentRule)); |
93 } | 102 } |
94 | 103 |
95 ~MediaList(); | 104 ~MediaList(); |
96 | 105 |
97 unsigned length() const { return m_mediaQueries->queryVector().size(); } | 106 unsigned length() const { return m_mediaQueries->queryVector().size(); } |
98 String item(unsigned index) const; | 107 String item(unsigned index) const; |
99 void deleteMedium(const String& oldMedium, ExceptionCode&); | 108 void deleteMedium(const String& oldMedium, ExceptionCode&); |
100 void appendMedium(const String& newMedium, ExceptionCode&); | 109 void appendMedium(const String& newMedium, ExceptionCode&); |
101 | 110 |
102 String mediaText() const { return m_mediaQueries->mediaText(); } | 111 String mediaText() const { return m_mediaQueries->mediaText(); } |
103 void setMediaText(const String&, ExceptionCode&); | 112 void setMediaText(const String&); |
104 | 113 |
105 // Not part of CSSOM. | 114 // Not part of CSSOM. |
106 CSSRule* parentRule() const { return m_parentRule; } | 115 CSSRule* parentRule() const { return m_parentRule; } |
107 CSSStyleSheet* parentStyleSheet() const { return m_parentStyleSheet; } | 116 CSSStyleSheet* parentStyleSheet() const { return m_parentStyleSheet; } |
108 void clearParentStyleSheet() { ASSERT(m_parentStyleSheet); m_parentStyleShee
t = 0; } | 117 void clearParentStyleSheet() { ASSERT(m_parentStyleSheet); m_parentStyleShee
t = 0; } |
109 void clearParentRule() { ASSERT(m_parentRule); m_parentRule = 0; } | 118 void clearParentRule() { ASSERT(m_parentRule); m_parentRule = 0; } |
110 const MediaQuerySet* queries() const { return m_mediaQueries.get(); } | 119 const MediaQuerySet* queries() const { return m_mediaQueries.get(); } |
111 | 120 |
112 void reattach(MediaQuerySet*); | 121 void reattach(MediaQuerySet*); |
113 | 122 |
114 void reportMemoryUsage(MemoryObjectInfo*) const; | 123 void reportMemoryUsage(MemoryObjectInfo*) const; |
115 | 124 |
116 private: | 125 private: |
117 MediaList(); | 126 MediaList(); |
118 MediaList(MediaQuerySet*, CSSStyleSheet* parentSheet); | 127 MediaList(MediaQuerySet*, CSSStyleSheet* parentSheet); |
119 MediaList(MediaQuerySet*, CSSRule* parentRule); | 128 MediaList(MediaQuerySet*, CSSRule* parentRule); |
120 | 129 |
121 RefPtr<MediaQuerySet> m_mediaQueries; | 130 RefPtr<MediaQuerySet> m_mediaQueries; |
122 CSSStyleSheet* m_parentStyleSheet; | 131 CSSStyleSheet* m_parentStyleSheet; |
123 CSSRule* m_parentRule; | 132 CSSRule* m_parentRule; |
124 }; | 133 }; |
125 | 134 |
126 // Adds message to inspector console whenever dpi or dpcm values are used for "s
creen" media. | 135 // Adds message to inspector console whenever dpi or dpcm values are used for "s
creen" media. |
127 void reportMediaQueryWarningIfNeeded(Document*, const MediaQuerySet*); | 136 void reportMediaQueryWarningIfNeeded(Document*, const MediaQuerySet*); |
128 | 137 |
129 } // namespace | 138 } // namespace |
130 | 139 |
131 #endif | 140 #endif |
OLD | NEW |