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

Unified Diff: third_party/WebKit/Source/core/css/properties/CSSPropertyAPIClip.cpp

Issue 2614783003: Implements CSSPropertyAPI for the clip property. (Closed)
Patch Set: 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/CSSPropertyAPIClip.cpp
diff --git a/third_party/WebKit/Source/core/css/properties/CSSPropertyAPIClip.cpp b/third_party/WebKit/Source/core/css/properties/CSSPropertyAPIClip.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..882cf110d4ab29b308f89f80609cc37c3166525b
--- /dev/null
+++ b/third_party/WebKit/Source/core/css/properties/CSSPropertyAPIClip.cpp
@@ -0,0 +1,57 @@
+// Copyright 2016 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 "core/css/properties/CSSPropertyAPIClip.h"
+
+#include "core/css/CSSQuadValue.h"
+#include "core/css/CSSValueList.h"
+#include "core/css/parser/CSSParserTokenRange.h"
+#include "core/css/parser/CSSPropertyParser.h"
+#include "core/css/parser/CSSPropertyParserHelpers.h"
+
+namespace blink {
+
+static CSSValue* consumeClipComponent(CSSParserTokenRange& range,
meade_UTC10 2017/01/05 04:10:22 You could make this helper method more private by
+ CSSParserMode cssParserMode) {
+ if (range.peek().id() == CSSValueAuto)
+ return CSSPropertyParserHelpers::consumeIdent(range);
+ return CSSPropertyParserHelpers::consumeLength(
+ range, cssParserMode, ValueRangeAll,
+ CSSPropertyParserHelpers::UnitlessQuirk::Allow);
+}
+
+const CSSValue* CSSPropertyAPIClip::parseSingleValue(
+ CSSParserTokenRange& range,
+ const CSSParserContext& context) {
+ if (range.peek().id() == CSSValueAuto)
+ return CSSPropertyParserHelpers::consumeIdent(range);
+
+ if (range.peek().functionId() != CSSValueRect)
+ return nullptr;
+
+ CSSParserTokenRange args = CSSPropertyParserHelpers::consumeFunction(range);
+ // rect(t, r, b, l) || rect(t r b l)
+ CSSValue* top = consumeClipComponent(args, context.mode());
+ if (!top)
+ return nullptr;
+ bool needsComma =
+ CSSPropertyParserHelpers::consumeCommaIncludingWhitespace(args);
+ CSSValue* right = consumeClipComponent(args, context.mode());
+ if (!right ||
+ (needsComma &&
+ !CSSPropertyParserHelpers::consumeCommaIncludingWhitespace(args)))
+ return nullptr;
+ CSSValue* bottom = consumeClipComponent(args, context.mode());
+ if (!bottom ||
+ (needsComma &&
+ !CSSPropertyParserHelpers::consumeCommaIncludingWhitespace(args)))
+ return nullptr;
+ CSSValue* left = consumeClipComponent(args, context.mode());
+ if (!left || !args.atEnd())
+ return nullptr;
+ return CSSQuadValue::create(top, right, bottom, left,
+ CSSQuadValue::SerializeAsRect);
+}
+
+} // namespace blink
« 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