Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(543)

Unified Diff: Source/core/css/parser/MediaQueryToken.cpp

Issue 171383002: A thread-safe Media Query Parser (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Moar rebase Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/core/css/parser/MediaQueryToken.cpp
diff --git a/Source/core/css/parser/MediaQueryToken.cpp b/Source/core/css/parser/MediaQueryToken.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..4930829388eed408e4afdb20f96381d76523ff2b
--- /dev/null
+++ b/Source/core/css/parser/MediaQueryToken.cpp
@@ -0,0 +1,62 @@
+// 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.
+
+#include "config.h"
+#include "core/css/parser/MediaQueryToken.h"
+
+#include "wtf/HashMap.h"
+#include "wtf/text/StringHash.h"
+
+namespace WebCore {
+
+
+MediaQueryToken::MediaQueryToken(MediaQueryTokenType type)
+ : m_type(type)
+ , m_delimiter(0)
+ , m_unit(CSSPrimitiveValue::CSS_UNKNOWN)
+{
+}
+
+// Just a helper used for Delimiter tokens.
+MediaQueryToken::MediaQueryToken(MediaQueryTokenType type, UChar c)
+ : m_type(type)
+ , m_delimiter(c)
+ , m_unit(CSSPrimitiveValue::CSS_UNKNOWN)
+{
+ ASSERT(m_type == DelimiterToken);
+}
+
+MediaQueryToken::MediaQueryToken(MediaQueryTokenType type, String value)
+ : m_type(type)
+ , m_value(value)
+ , m_delimiter(0)
+ , m_unit(CSSPrimitiveValue::CSS_UNKNOWN)
+{
+}
+
+MediaQueryToken::MediaQueryToken(MediaQueryTokenType type, double numericValue, NumericValueType numericValueType)
+ : m_type(type)
+ , m_delimiter(0)
+ , m_numericValueType(numericValueType)
+ , m_numericValue(numericValue)
+ , m_unit(CSSPrimitiveValue::CSS_NUMBER)
+{
+ ASSERT(type == NumberToken);
+}
+
+void MediaQueryToken::convertToDimensionWithUnit(String unit)
+{
+ ASSERT(m_type == NumberToken);
+ m_type = DimensionToken;
+ m_unit = CSSPrimitiveValue::getUnitTable().get(unit.lower());
+}
+
+void MediaQueryToken::convertToPercentage()
+{
+ ASSERT(m_type == NumberToken);
+ m_type = PercentageToken;
+ m_unit = CSSPrimitiveValue::CSS_PERCENTAGE;
+}
+
+} // namespace WebCore

Powered by Google App Engine
This is Rietveld 408576698