Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "core/css/properties/CSSPropertyAPIClip.h" | |
| 6 | |
| 7 #include "core/css/CSSQuadValue.h" | |
| 8 #include "core/css/parser/CSSParserContext.h" | |
| 9 #include "core/css/parser/CSSPropertyParserHelpers.h" | |
| 10 | |
| 11 namespace blink { | |
| 12 | |
| 13 static CSSValue* consumeClipComponent(CSSParserTokenRange& range, | |
|
sashab
2017/01/09 03:42:21
What Eddy said - anonymous namespace ;)
ie
names
| |
| 14 CSSParserMode cssParserMode) { | |
| 15 if (range.peek().id() == CSSValueAuto) | |
| 16 return CSSPropertyParserHelpers::consumeIdent(range); | |
| 17 return CSSPropertyParserHelpers::consumeLength( | |
| 18 range, cssParserMode, ValueRangeAll, | |
| 19 CSSPropertyParserHelpers::UnitlessQuirk::Allow); | |
| 20 } | |
| 21 | |
| 22 const CSSValue* CSSPropertyAPIClip::parseSingleValue( | |
| 23 CSSParserTokenRange& range, | |
| 24 const CSSParserContext& context) { | |
| 25 if (range.peek().id() == CSSValueAuto) | |
| 26 return CSSPropertyParserHelpers::consumeIdent(range); | |
| 27 | |
| 28 if (range.peek().functionId() != CSSValueRect) | |
| 29 return nullptr; | |
| 30 | |
| 31 CSSParserTokenRange args = CSSPropertyParserHelpers::consumeFunction(range); | |
| 32 // rect(t, r, b, l) || rect(t r b l) | |
| 33 CSSValue* top = consumeClipComponent(args, context.mode()); | |
| 34 if (!top) | |
| 35 return nullptr; | |
| 36 bool needsComma = | |
| 37 CSSPropertyParserHelpers::consumeCommaIncludingWhitespace(args); | |
| 38 CSSValue* right = consumeClipComponent(args, context.mode()); | |
| 39 if (!right || | |
| 40 (needsComma && | |
| 41 !CSSPropertyParserHelpers::consumeCommaIncludingWhitespace(args))) | |
| 42 return nullptr; | |
| 43 CSSValue* bottom = consumeClipComponent(args, context.mode()); | |
| 44 if (!bottom || | |
| 45 (needsComma && | |
| 46 !CSSPropertyParserHelpers::consumeCommaIncludingWhitespace(args))) | |
| 47 return nullptr; | |
| 48 CSSValue* left = consumeClipComponent(args, context.mode()); | |
| 49 if (!left || !args.atEnd()) | |
| 50 return nullptr; | |
| 51 return CSSQuadValue::create(top, right, bottom, left, | |
| 52 CSSQuadValue::SerializeAsRect); | |
| 53 } | |
| 54 | |
| 55 } // namespace blink | |
| OLD | NEW |