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

Unified Diff: third_party/WebKit/Source/core/css/properties/CSSPropertyPositionUtils.h

Issue 2647503004: Added CSSPropertyPositionUtils which holds position parsing methods. (Closed)
Patch Set: Merged correctly Created 3 years, 11 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 | « third_party/WebKit/Source/core/css/parser/CSSPropertyParser.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/css/properties/CSSPropertyPositionUtils.h
diff --git a/third_party/WebKit/Source/core/css/properties/CSSPropertyPositionUtils.h b/third_party/WebKit/Source/core/css/properties/CSSPropertyPositionUtils.h
new file mode 100644
index 0000000000000000000000000000000000000000..354c059afcb7c6bb7d01f1fe1b436909b6a09562
--- /dev/null
+++ b/third_party/WebKit/Source/core/css/properties/CSSPropertyPositionUtils.h
@@ -0,0 +1,45 @@
+// Copyright 2017 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 CSSPropertyPositionUtils_h
+#define CSSPropertyPositionUtils_h
+
+#include "core/CSSValueKeywords.h"
+#include "core/css/parser/CSSParserMode.h"
+
+#include "wtf/Allocator.h"
+
+namespace blink {
+
+class CSSParserTokenRange;
+class CSSValue;
+
+class CSSPropertyPositionUtils {
+ STATIC_ONLY(CSSPropertyPositionUtils);
+
+ template <CSSValueID start, CSSValueID end>
+ static CSSValue* consumePositionLonghand(CSSParserTokenRange& range,
+ CSSParserMode cssParserMode) {
+ if (range.peek().type() == IdentToken) {
+ CSSValueID id = range.peek().id();
+ int percent;
+ if (id == start)
+ percent = 0;
+ else if (id == CSSValueCenter)
+ percent = 50;
+ else if (id == end)
+ percent = 100;
+ else
+ return nullptr;
+ range.consumeIncludingWhitespace();
+ return CSSPrimitiveValue::create(percent,
+ CSSPrimitiveValue::UnitType::Percentage);
+ }
+ return CSSPropertyParserHelpers::consumeLengthOrPercent(
+ range, cssParserMode, ValueRangeAll);
+ }
+};
+
+} // namespace blink
+
+#endif // CSSPropertyPositionUtils_h
« no previous file with comments | « third_party/WebKit/Source/core/css/parser/CSSPropertyParser.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698