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

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

Issue 2610853004: Implements CSSPropertyAPI for the text-indent property. (Closed)
Patch Set: rebase 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/CSSPropertyAPITextIndent.cpp
diff --git a/third_party/WebKit/Source/core/css/properties/CSSPropertyAPITextIndent.cpp b/third_party/WebKit/Source/core/css/properties/CSSPropertyAPITextIndent.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..2935c41535dec9fcdd0859eb0dbc415eebab1aa2
--- /dev/null
+++ b/third_party/WebKit/Source/core/css/properties/CSSPropertyAPITextIndent.cpp
@@ -0,0 +1,59 @@
+// 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.
+
+#include "core/css/properties/CSSPropertyAPITextIndent.h"
+
+#include "core/css/CSSValueList.h"
+#include "core/css/parser/CSSParserContext.h"
+#include "core/css/parser/CSSPropertyParserHelpers.h"
+#include "platform/RuntimeEnabledFeatures.h"
+
+namespace blink {
+
+const CSSValue* CSSPropertyAPITextIndent::parseSingleValue(
+ CSSParserTokenRange& range,
+ const CSSParserContext* context) {
+ // [ <length> | <percentage> ] && hanging? && each-line?
+ // Keywords only allowed when css3Text is enabled.
+ CSSValueList* list = CSSValueList::createSpaceSeparated();
+
+ bool hasLengthOrPercentage = false;
+ bool hasEachLine = false;
+ bool hasHanging = false;
+
+ do {
+ if (!hasLengthOrPercentage) {
+ if (CSSValue* textIndent =
+ CSSPropertyParserHelpers::consumeLengthOrPercent(
+ range, context->mode(), ValueRangeAll,
+ CSSPropertyParserHelpers::UnitlessQuirk::Allow)) {
+ list->append(*textIndent);
+ hasLengthOrPercentage = true;
+ continue;
+ }
+ }
+
+ if (RuntimeEnabledFeatures::css3TextEnabled()) {
+ CSSValueID id = range.peek().id();
+ if (!hasEachLine && id == CSSValueEachLine) {
+ list->append(*CSSPropertyParserHelpers::consumeIdent(range));
+ hasEachLine = true;
+ continue;
+ }
+ if (!hasHanging && id == CSSValueHanging) {
+ list->append(*CSSPropertyParserHelpers::consumeIdent(range));
+ hasHanging = true;
+ continue;
+ }
+ }
+ return nullptr;
+ } while (!range.atEnd());
+
+ if (!hasLengthOrPercentage)
+ return nullptr;
+
+ return list;
+}
+
+} // 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