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

Side by Side Diff: third_party/WebKit/Source/core/css/parser/CSSPropertyParser.cpp

Issue 2612783003: Implements CSSPropertyAPI for the shape-margin 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 797 matching lines...) Expand 10 before | Expand all | Expand 10 after
808 } 808 }
809 809
810 static CSSValue* consumeMarginOrOffset(CSSParserTokenRange& range, 810 static CSSValue* consumeMarginOrOffset(CSSParserTokenRange& range,
811 CSSParserMode cssParserMode, 811 CSSParserMode cssParserMode,
812 UnitlessQuirk unitless) { 812 UnitlessQuirk unitless) {
813 if (range.peek().id() == CSSValueAuto) 813 if (range.peek().id() == CSSValueAuto)
814 return consumeIdent(range); 814 return consumeIdent(range);
815 return consumeLengthOrPercent(range, cssParserMode, ValueRangeAll, unitless); 815 return consumeLengthOrPercent(range, cssParserMode, ValueRangeAll, unitless);
816 } 816 }
817 817
818 static CSSValue* consumeClipComponent(CSSParserTokenRange& range,
819 CSSParserMode cssParserMode) {
820 if (range.peek().id() == CSSValueAuto)
821 return consumeIdent(range);
822 return consumeLength(range, cssParserMode, ValueRangeAll,
823 UnitlessQuirk::Allow);
824 }
825
826 static CSSValue* consumeClip(CSSParserTokenRange& range,
827 CSSParserMode cssParserMode) {
828 if (range.peek().id() == CSSValueAuto)
829 return consumeIdent(range);
830
831 if (range.peek().functionId() != CSSValueRect)
832 return nullptr;
833
834 CSSParserTokenRange args = consumeFunction(range);
835 // rect(t, r, b, l) || rect(t r b l)
836 CSSValue* top = consumeClipComponent(args, cssParserMode);
837 if (!top)
838 return nullptr;
839 bool needsComma = consumeCommaIncludingWhitespace(args);
840 CSSValue* right = consumeClipComponent(args, cssParserMode);
841 if (!right || (needsComma && !consumeCommaIncludingWhitespace(args)))
842 return nullptr;
843 CSSValue* bottom = consumeClipComponent(args, cssParserMode);
844 if (!bottom || (needsComma && !consumeCommaIncludingWhitespace(args)))
845 return nullptr;
846 CSSValue* left = consumeClipComponent(args, cssParserMode);
847 if (!left || !args.atEnd())
848 return nullptr;
849 return CSSQuadValue::create(top, right, bottom, left,
850 CSSQuadValue::SerializeAsRect);
851 }
852
853 static bool consumePan(CSSParserTokenRange& range, 818 static bool consumePan(CSSParserTokenRange& range,
854 CSSValue*& panX, 819 CSSValue*& panX,
855 CSSValue*& panY, 820 CSSValue*& panY,
856 CSSValue*& pinchZoom) { 821 CSSValue*& pinchZoom) {
857 CSSValueID id = range.peek().id(); 822 CSSValueID id = range.peek().id();
858 if ((id == CSSValuePanX || id == CSSValuePanRight || id == CSSValuePanLeft) && 823 if ((id == CSSValuePanX || id == CSSValuePanRight || id == CSSValuePanLeft) &&
859 !panX) { 824 !panX) {
860 if (id != CSSValuePanX && 825 if (id != CSSValuePanX &&
861 !RuntimeEnabledFeatures::cssTouchActionPanDirectionsEnabled()) 826 !RuntimeEnabledFeatures::cssTouchActionPanDirectionsEnabled())
862 return false; 827 return false;
(...skipping 2353 matching lines...) Expand 10 before | Expand all | Expand 10 after
3216 case CSSPropertyWebkitMarginAfter: 3181 case CSSPropertyWebkitMarginAfter:
3217 return consumeMarginOrOffset(m_range, m_context->mode(), 3182 return consumeMarginOrOffset(m_range, m_context->mode(),
3218 UnitlessQuirk::Forbid); 3183 UnitlessQuirk::Forbid);
3219 case CSSPropertyPaddingTop: 3184 case CSSPropertyPaddingTop:
3220 case CSSPropertyPaddingRight: 3185 case CSSPropertyPaddingRight:
3221 case CSSPropertyPaddingBottom: 3186 case CSSPropertyPaddingBottom:
3222 case CSSPropertyPaddingLeft: 3187 case CSSPropertyPaddingLeft:
3223 return consumeLengthOrPercent(m_range, m_context->mode(), 3188 return consumeLengthOrPercent(m_range, m_context->mode(),
3224 ValueRangeNonNegative, 3189 ValueRangeNonNegative,
3225 UnitlessQuirk::Allow); 3190 UnitlessQuirk::Allow);
3226 case CSSPropertyClip:
3227 return consumeClip(m_range, m_context->mode());
3228 case CSSPropertyTouchAction: 3191 case CSSPropertyTouchAction:
3229 return consumeTouchAction(m_range); 3192 return consumeTouchAction(m_range);
3230 case CSSPropertyScrollSnapDestination: 3193 case CSSPropertyScrollSnapDestination:
3231 case CSSPropertyObjectPosition: 3194 case CSSPropertyObjectPosition:
3232 case CSSPropertyPerspectiveOrigin: 3195 case CSSPropertyPerspectiveOrigin:
3233 return consumePosition(m_range, m_context->mode(), UnitlessQuirk::Forbid); 3196 return consumePosition(m_range, m_context->mode(), UnitlessQuirk::Forbid);
3234 case CSSPropertyWebkitLineClamp: 3197 case CSSPropertyWebkitLineClamp:
3235 return consumeLineClamp(m_range); 3198 return consumeLineClamp(m_range);
3236 case CSSPropertyWebkitFontSizeDelta: 3199 case CSSPropertyWebkitFontSizeDelta:
3237 return consumeLength(m_range, m_context->mode(), ValueRangeAll, 3200 return consumeLength(m_range, m_context->mode(), ValueRangeAll,
(...skipping 19 matching lines...) Expand all
3257 case CSSPropertyTransitionProperty: 3220 case CSSPropertyTransitionProperty:
3258 case CSSPropertyAnimationTimingFunction: 3221 case CSSPropertyAnimationTimingFunction:
3259 case CSSPropertyTransitionTimingFunction: 3222 case CSSPropertyTransitionTimingFunction:
3260 return consumeAnimationPropertyList( 3223 return consumeAnimationPropertyList(
3261 property, m_range, m_context, 3224 property, m_range, m_context,
3262 unresolvedProperty == CSSPropertyAliasWebkitAnimationName); 3225 unresolvedProperty == CSSPropertyAliasWebkitAnimationName);
3263 case CSSPropertyGridColumnGap: 3226 case CSSPropertyGridColumnGap:
3264 case CSSPropertyGridRowGap: 3227 case CSSPropertyGridRowGap:
3265 return consumeLengthOrPercent(m_range, m_context->mode(), 3228 return consumeLengthOrPercent(m_range, m_context->mode(),
3266 ValueRangeNonNegative); 3229 ValueRangeNonNegative);
3267 case CSSPropertyShapeMargin:
3268 return consumeLengthOrPercent(m_range, m_context->mode(),
3269 ValueRangeNonNegative);
3270 case CSSPropertyShapeImageThreshold: 3230 case CSSPropertyShapeImageThreshold:
3271 return consumeNumber(m_range, ValueRangeAll); 3231 return consumeNumber(m_range, ValueRangeAll);
3272 case CSSPropertyWebkitBoxOrdinalGroup: 3232 case CSSPropertyWebkitBoxOrdinalGroup:
3273 case CSSPropertyOrphans: 3233 case CSSPropertyOrphans:
3274 case CSSPropertyWidows: 3234 case CSSPropertyWidows:
3275 return consumePositiveInteger(m_range); 3235 return consumePositiveInteger(m_range);
3276 case CSSPropertyWebkitTextStrokeWidth: 3236 case CSSPropertyWebkitTextStrokeWidth:
3277 return consumeTextStrokeWidth(m_range, m_context->mode()); 3237 return consumeTextStrokeWidth(m_range, m_context->mode());
3278 case CSSPropertyWebkitTextFillColor: 3238 case CSSPropertyWebkitTextFillColor:
3279 case CSSPropertyWebkitTapHighlightColor: 3239 case CSSPropertyWebkitTapHighlightColor:
(...skipping 1706 matching lines...) Expand 10 before | Expand all | Expand 10 after
4986 case CSSPropertyGridTemplate: 4946 case CSSPropertyGridTemplate:
4987 return consumeGridTemplateShorthand(CSSPropertyGridTemplate, important); 4947 return consumeGridTemplateShorthand(CSSPropertyGridTemplate, important);
4988 case CSSPropertyGrid: 4948 case CSSPropertyGrid:
4989 return consumeGridShorthand(important); 4949 return consumeGridShorthand(important);
4990 default: 4950 default:
4991 return false; 4951 return false;
4992 } 4952 }
4993 } 4953 }
4994 4954
4995 } // namespace blink 4955 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698