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

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: Revert last patch, will include it in a separate commit 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/SizesCalcParser.h
diff --git a/Source/core/css/parser/SizesCalcParser.h b/Source/core/css/parser/SizesCalcParser.h
new file mode 100644
index 0000000000000000000000000000000000000000..8b17680279c39f8aaa499aefc838ecb9477240f5
--- /dev/null
+++ b/Source/core/css/parser/SizesCalcParser.h
@@ -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.
+
+#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 lengthValue)
+ : value(lengthValue)
+ , isLength(true)
+ , operation(0)
+ {
+ }
+};
+
+class SizesCalcParser {
+
+public:
+ static bool parse(MediaQueryTokenIterator start,
eseidel 2014/04/29 17:30:37 We don't wrap to 80c in blink, I wouldn't bother d
+ 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
+

Powered by Google App Engine
This is Rietveld 408576698