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

Side by Side Diff: third_party/WebKit/Source/core/css/parser/CSSPropertyParser.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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "core/css/parser/CSSPropertyParser.h" 5 #include "core/css/parser/CSSPropertyParser.h"
6 6
7 #include "core/StylePropertyShorthand.h" 7 #include "core/StylePropertyShorthand.h"
8 #include "core/css/CSSBasicShapeValues.h" 8 #include "core/css/CSSBasicShapeValues.h"
9 #include "core/css/CSSBorderImage.h" 9 #include "core/css/CSSBorderImage.h"
10 #include "core/css/CSSContentDistributionValue.h" 10 #include "core/css/CSSContentDistributionValue.h"
(...skipping 687 matching lines...) Expand 10 before | Expand all | Expand 10 after
698 698
699 if (CSSPrimitiveValue* position = consumePositiveInteger(range)) { 699 if (CSSPrimitiveValue* position = consumePositiveInteger(range)) {
700 if (position->getIntValue() > 100) 700 if (position->getIntValue() > 100)
701 return nullptr; 701 return nullptr;
702 list->append(*position); 702 list->append(*position);
703 } 703 }
704 704
705 return list; 705 return list;
706 } 706 }
707 707
708 static CSSValue* consumeTextIndent(CSSParserTokenRange& range,
709 CSSParserMode cssParserMode) {
710 // [ <length> | <percentage> ] && hanging? && each-line?
711 // Keywords only allowed when css3Text is enabled.
712 CSSValueList* list = CSSValueList::createSpaceSeparated();
713
714 bool hasLengthOrPercentage = false;
715 bool hasEachLine = false;
716 bool hasHanging = false;
717
718 do {
719 if (!hasLengthOrPercentage) {
720 if (CSSValue* textIndent = consumeLengthOrPercent(
721 range, cssParserMode, ValueRangeAll, UnitlessQuirk::Allow)) {
722 list->append(*textIndent);
723 hasLengthOrPercentage = true;
724 continue;
725 }
726 }
727
728 if (RuntimeEnabledFeatures::css3TextEnabled()) {
729 CSSValueID id = range.peek().id();
730 if (!hasEachLine && id == CSSValueEachLine) {
731 list->append(*consumeIdent(range));
732 hasEachLine = true;
733 continue;
734 }
735 if (!hasHanging && id == CSSValueHanging) {
736 list->append(*consumeIdent(range));
737 hasHanging = true;
738 continue;
739 }
740 }
741 return nullptr;
742 } while (!range.atEnd());
743
744 if (!hasLengthOrPercentage)
745 return nullptr;
746
747 return list;
748 }
749
750 static bool validWidthOrHeightKeyword(CSSValueID id, 708 static bool validWidthOrHeightKeyword(CSSValueID id,
751 const CSSParserContext* context) { 709 const CSSParserContext* context) {
752 if (id == CSSValueWebkitMinContent || id == CSSValueWebkitMaxContent || 710 if (id == CSSValueWebkitMinContent || id == CSSValueWebkitMaxContent ||
753 id == CSSValueWebkitFillAvailable || id == CSSValueWebkitFitContent || 711 id == CSSValueWebkitFillAvailable || id == CSSValueWebkitFitContent ||
754 id == CSSValueMinContent || id == CSSValueMaxContent || 712 id == CSSValueMinContent || id == CSSValueMaxContent ||
755 id == CSSValueFitContent) { 713 id == CSSValueFitContent) {
756 if (context->isUseCounterRecordingEnabled()) { 714 if (context->isUseCounterRecordingEnabled()) {
757 UseCounter* useCounter = context->useCounter(); 715 UseCounter* useCounter = context->useCounter();
758 switch (id) { 716 switch (id) {
759 case CSSValueWebkitMinContent: 717 case CSSValueWebkitMinContent:
(...skipping 2348 matching lines...) Expand 10 before | Expand all | Expand 10 after
3108 return consumeScale(m_range); 3066 return consumeScale(m_range);
3109 case CSSPropertyWebkitBorderHorizontalSpacing: 3067 case CSSPropertyWebkitBorderHorizontalSpacing:
3110 case CSSPropertyWebkitBorderVerticalSpacing: 3068 case CSSPropertyWebkitBorderVerticalSpacing:
3111 return consumeLength(m_range, m_context->mode(), ValueRangeNonNegative); 3069 return consumeLength(m_range, m_context->mode(), ValueRangeNonNegative);
3112 case CSSPropertyCounterIncrement: 3070 case CSSPropertyCounterIncrement:
3113 case CSSPropertyCounterReset: 3071 case CSSPropertyCounterReset:
3114 return consumeCounter(m_range, 3072 return consumeCounter(m_range,
3115 property == CSSPropertyCounterIncrement ? 1 : 0); 3073 property == CSSPropertyCounterIncrement ? 1 : 0);
3116 case CSSPropertySnapHeight: 3074 case CSSPropertySnapHeight:
3117 return consumeSnapHeight(m_range, m_context->mode()); 3075 return consumeSnapHeight(m_range, m_context->mode());
3118 case CSSPropertyTextIndent:
3119 return consumeTextIndent(m_range, m_context->mode());
3120 case CSSPropertyMaxWidth: 3076 case CSSPropertyMaxWidth:
3121 case CSSPropertyMaxHeight: 3077 case CSSPropertyMaxHeight:
3122 return consumeMaxWidthOrHeight(m_range, m_context, UnitlessQuirk::Allow); 3078 return consumeMaxWidthOrHeight(m_range, m_context, UnitlessQuirk::Allow);
3123 case CSSPropertyMaxInlineSize: 3079 case CSSPropertyMaxInlineSize:
3124 case CSSPropertyMaxBlockSize: 3080 case CSSPropertyMaxBlockSize:
3125 case CSSPropertyWebkitMaxLogicalWidth: 3081 case CSSPropertyWebkitMaxLogicalWidth:
3126 case CSSPropertyWebkitMaxLogicalHeight: 3082 case CSSPropertyWebkitMaxLogicalHeight:
3127 return consumeMaxWidthOrHeight(m_range, m_context); 3083 return consumeMaxWidthOrHeight(m_range, m_context);
3128 case CSSPropertyMinWidth: 3084 case CSSPropertyMinWidth:
3129 case CSSPropertyMinHeight: 3085 case CSSPropertyMinHeight:
(...skipping 1788 matching lines...) Expand 10 before | Expand all | Expand 10 after
4918 case CSSPropertyGridTemplate: 4874 case CSSPropertyGridTemplate:
4919 return consumeGridTemplateShorthand(CSSPropertyGridTemplate, important); 4875 return consumeGridTemplateShorthand(CSSPropertyGridTemplate, important);
4920 case CSSPropertyGrid: 4876 case CSSPropertyGrid:
4921 return consumeGridShorthand(important); 4877 return consumeGridShorthand(important);
4922 default: 4878 default:
4923 return false; 4879 return false;
4924 } 4880 }
4925 } 4881 }
4926 4882
4927 } // namespace blink 4883 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698