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

Unified Diff: Source/core/css/parser/SizesCalcParser.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 CSSCalc tests that assert 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
« no previous file with comments | « Source/core/css/parser/SizesAttributeParser.cpp ('k') | Source/core/css/parser/SizesCalcParser.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/css/parser/SizesCalcParser.h
diff --git a/Source/core/css/parser/SizesCalcParser.h b/Source/core/css/parser/SizesCalcParser.h
new file mode 100644
index 0000000000000000000000000000000000000000..4e040c6cee66bfef06805c6ce8133258ff524140
--- /dev/null
+++ b/Source/core/css/parser/SizesCalcParser.h
@@ -0,0 +1,59 @@
+// 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 SizesCalcParser_h
+#define SizesCalcParser_h
+
+#include "core/css/MediaValues.h"
+#include "core/css/parser/MediaQueryToken.h"
+#include "wtf/text/WTFString.h"
+
+namespace WebCore {
+
+struct SizesCalcValue {
+ double value;
+ bool isLength;
+ UChar operation;
+
+ SizesCalcValue()
+ : value(0)
+ , isLength(false)
+ , operation(0)
+ {
+ }
+
+ SizesCalcValue(double numericValue, bool length)
+ : value(numericValue)
+ , isLength(length)
+ , operation(0)
+ {
+ }
+};
+
+class SizesCalcParser {
+
+public:
+ static bool parse(MediaQueryTokenIterator start, MediaQueryTokenIterator end, PassRefPtr<MediaValues>, unsigned& result);
+
+private:
+ SizesCalcParser(PassRefPtr<MediaValues> mediaValues)
+ : m_mediaValues(mediaValues)
+ {
+ }
+
+ bool calcToReversePolishNotation(MediaQueryTokenIterator start, MediaQueryTokenIterator end);
+ bool calculate(unsigned& result);
+ void appendNumber(const MediaQueryToken&);
+ bool appendLength(const MediaQueryToken&);
+ bool handleOperator(Vector<MediaQueryToken>& stack, const MediaQueryToken&);
+ void appendOperator(const MediaQueryToken&);
+
+ Vector<SizesCalcValue> m_valueList;
+ RefPtr<MediaValues> m_mediaValues;
+};
+
+} // namespace WebCore
+
+#endif // SizesCalcParser_h
+
« no previous file with comments | « Source/core/css/parser/SizesAttributeParser.cpp ('k') | Source/core/css/parser/SizesCalcParser.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698