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

Unified Diff: Source/core/css/parser/MediaQueryCalcParser.h

Issue 252743004: A thread safe CSS calc parser for sizes (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: removed linespace Created 6 years, 8 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/MediaQueryCalcParser.h
diff --git a/Source/core/css/parser/MediaQueryCalcParser.h b/Source/core/css/parser/MediaQueryCalcParser.h
new file mode 100644
index 0000000000000000000000000000000000000000..015fc4b9b6729124c9288794ccb15ba2b7095edb
--- /dev/null
+++ b/Source/core/css/parser/MediaQueryCalcParser.h
@@ -0,0 +1,52 @@
+// 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 MediaQueryCalcParser_h
+#define MediaQueryCalcParser_h
+
+#include "core/css/parser/MediaQueryToken.h"
+#include "wtf/text/WTFString.h"
+
+namespace WebCore {
+
+struct MediaQueryCalcValue {
+ double value;
+ UChar operation;
+
+ MediaQueryCalcValue()
+ : value(0)
+ , operation(0)
+ {
+ }
+};
+
+class MediaQueryCalcParser {
+
+public:
+ static int parse(MediaQueryTokenIterator start, MediaQueryTokenIterator end, unsigned fontSize, unsigned viewportWidth, unsigned viewportHeight);
+
+private:
+ MediaQueryCalcParser(unsigned fontSize, unsigned viewportWidth, unsigned viewportHeight)
+ : m_fontSize(fontSize)
+ , m_viewportWidth(viewportWidth)
+ , m_viewportHeight(viewportHeight)
+ {
+ }
+
+ bool calcToReversePolishNotation(MediaQueryTokenIterator start, MediaQueryTokenIterator end);
+ bool calculate(int& result);
+ bool appendNumber(const MediaQueryToken&);
+ bool handleOperator(Vector<MediaQueryToken>& stack, const MediaQueryToken&);
+ void appendOperator(const MediaQueryToken&);
+
+ Vector<MediaQueryCalcValue> m_valueList;
+ unsigned m_fontSize;
+ unsigned m_viewportWidth;
+ unsigned m_viewportHeight;
+};
+
+} // namespace WebCore
+
+#endif // MediaQueryCalcParser_h
+

Powered by Google App Engine
This is Rietveld 408576698