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..53de2450641880658f6d0d8babe8ef45b085597d |
--- /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/CSSToken.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(CSSTokenType, CSSToken*); |
+ 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<CSSToken>::iterator TokenIterator; |
+ |
+ void readRestrictor(CSSTokenType, TokenIterator&); |
+ void readMediaType(CSSTokenType, TokenIterator&); |
+ void readAnd(CSSTokenType, TokenIterator&); |
+ void readFeatureStart(CSSTokenType, TokenIterator&); |
+ void readFeature(CSSTokenType, TokenIterator&); |
+ void readFeatureColon(CSSTokenType, TokenIterator&); |
+ void readFeatureValue(CSSTokenType, TokenIterator&); |
+ void readFeatureEnd(CSSTokenType, TokenIterator&); |
+ void skipTillComma(CSSTokenType, TokenIterator&); |
+ void skipTillParen(CSSTokenType, TokenIterator&); |
+ void done(CSSTokenType, TokenIterator&); |
+ |
+ typedef void (MediaQueryParser::*State)(CSSTokenType, TokenIterator&); |
+ |
+ State m_state; |
+ Vector<CSSToken> m_tokens; |
+ MediaQueryData m_mediaQueryData; |
+}; |
+ |
+} // namespace WebCore |
+ |
+#endif // MediaQueryParser_h |