Index: Source/core/css/parser/MediaQueryParser.h |
diff --git a/Source/core/css/parser/MediaQueryParser.h b/Source/core/css/parser/MediaQueryParser.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..12ed25592e023fbf3df0e176220aec1ab2f3ad91 |
--- /dev/null |
+++ b/Source/core/css/parser/MediaQueryParser.h |
@@ -0,0 +1,97 @@ |
+// Copyright 2014 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef MediaQueryParser_h |
+#define MediaQueryParser_h |
+ |
+#include "core/css/CSSParserValues.h" |
+#include "core/css/MediaList.h" |
+#include "core/css/MediaQuery.h" |
+#include "core/css/MediaQueryExp.h" |
+#include "core/css/parser/MediaQueryToken.h" |
+#include "wtf/Vector.h" |
+#include "wtf/text/WTFString.h" |
+ |
+namespace WebCore { |
+ |
+class MediaQuerySet; |
+ |
+class MediaQueryData { |
+private: |
+ RefPtrWillBeMember<MediaQuerySet> m_querySet; |
+ MediaQuery::Restrictor m_restrictor; |
+ String m_mediaType; |
+ OwnPtr<ExpressionHeapVector> m_expressions; |
+ String m_mediaFeature; |
+ CSSParserValueList m_valueList; |
+ bool m_mediaTypeSet; |
+ |
+public: |
+ MediaQueryData(); |
+ void resetCurrentQuery(); |
+ void addCurrentMediaQuery(); |
+ bool addExpression(); |
+ void addParserValue(MediaQueryTokenType, MediaQueryToken*); |
+ void setMediaType(const String&); |
+ |
+ inline PassRefPtrWillBeRawPtr<MediaQuerySet> querySet() |
+ { |
+ return m_querySet; |
+ } |
+ |
+ inline unsigned querySetSize() |
+ { |
+ return m_querySet->queryVector().size(); |
+ } |
+ |
+ inline bool currentMediaQueryChanged() |
+ { |
+ return (m_restrictor != MediaQuery::None || m_mediaTypeSet || m_expressions->size() > 0); |
+ } |
+ |
+ inline void addNotAllMediaQuery() |
+ { |
+ m_querySet->addMediaQuery(adoptPtr(new MediaQuery(MediaQuery::Not, "all", nullptr))); |
+ } |
+ |
+ inline void setRestrictor(MediaQuery::Restrictor restrictor) { m_restrictor = restrictor; } |
+ |
+ inline void setMediaFeature(const String& str) { m_mediaFeature = str; } |
+}; |
+ |
+class MediaQueryParser { |
+public: |
+ static PassRefPtrWillBeRawPtr<MediaQuerySet> parse(String); |
+ |
+private: |
+ MediaQueryParser(String); |
+ virtual ~MediaQueryParser() { }; |
+ |
+ PassRefPtrWillBeRawPtr<MediaQuerySet> parseImpl(); |
+ |
+ |
+ typedef Vector<MediaQueryToken>::iterator TokenIterator; |
+ |
+ void readRestrictor(MediaQueryTokenType, TokenIterator&); |
+ void readMediaType(MediaQueryTokenType, TokenIterator&); |
+ void readAnd(MediaQueryTokenType, TokenIterator&); |
+ void readFeatureStart(MediaQueryTokenType, TokenIterator&); |
+ void readFeature(MediaQueryTokenType, TokenIterator&); |
+ void readFeatureColon(MediaQueryTokenType, TokenIterator&); |
+ void readFeatureValue(MediaQueryTokenType, TokenIterator&); |
+ void readFeatureEnd(MediaQueryTokenType, TokenIterator&); |
+ void skipTillComma(MediaQueryTokenType, TokenIterator&); |
+ void skipTillParen(MediaQueryTokenType, TokenIterator&); |
+ void done(MediaQueryTokenType, TokenIterator&); |
+ |
+ typedef void (MediaQueryParser::*State)(MediaQueryTokenType, TokenIterator&); |
+ |
+ State m_state; |
+ Vector<MediaQueryToken> m_tokens; |
+ MediaQueryData m_mediaQueryData; |
+}; |
+ |
+} // namespace WebCore |
+ |
+#endif // MediaQueryParser_h |