| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 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 | 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/properties/CSSPropertyOffsetPathUtils.h" | 5 #include "core/css/properties/CSSPropertyOffsetPathUtils.h" |
| 6 | 6 |
| 7 #include "core/css/CSSIdentifierValue.h" | 7 #include "core/css/CSSIdentifierValue.h" |
| 8 #include "core/css/CSSPathValue.h" | 8 #include "core/css/CSSPathValue.h" |
| 9 #include "core/css/CSSPrimitiveValue.h" | 9 #include "core/css/CSSPrimitiveValue.h" |
| 10 #include "core/css/CSSRayValue.h" | 10 #include "core/css/CSSRayValue.h" |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 !function_args.AtEnd()) { | 37 !function_args.AtEnd()) { |
| 38 return nullptr; | 38 return nullptr; |
| 39 } | 39 } |
| 40 | 40 |
| 41 range = function_range; | 41 range = function_range; |
| 42 if (byte_stream->IsEmpty()) | 42 if (byte_stream->IsEmpty()) |
| 43 return CSSIdentifierValue::Create(CSSValueNone); | 43 return CSSIdentifierValue::Create(CSSValueNone); |
| 44 return CSSPathValue::Create(std::move(byte_stream)); | 44 return CSSPathValue::Create(std::move(byte_stream)); |
| 45 } | 45 } |
| 46 | 46 |
| 47 CSSValue* ConsumeRay(CSSParserTokenRange& range) { | 47 CSSValue* ConsumeRay(CSSParserTokenRange& range, |
| 48 const CSSParserContext* context) { |
| 48 DCHECK_EQ(range.Peek().FunctionId(), CSSValueRay); | 49 DCHECK_EQ(range.Peek().FunctionId(), CSSValueRay); |
| 49 CSSParserTokenRange function_range = range; | 50 CSSParserTokenRange function_range = range; |
| 50 CSSParserTokenRange function_args = | 51 CSSParserTokenRange function_args = |
| 51 CSSPropertyParserHelpers::ConsumeFunction(function_range); | 52 CSSPropertyParserHelpers::ConsumeFunction(function_range); |
| 52 | 53 |
| 53 CSSPrimitiveValue* angle = nullptr; | 54 CSSPrimitiveValue* angle = nullptr; |
| 54 CSSIdentifierValue* size = nullptr; | 55 CSSIdentifierValue* size = nullptr; |
| 55 CSSIdentifierValue* contain = nullptr; | 56 CSSIdentifierValue* contain = nullptr; |
| 56 while (!function_args.AtEnd()) { | 57 while (!function_args.AtEnd()) { |
| 57 if (!angle) { | 58 if (!angle) { |
| 58 angle = CSSPropertyParserHelpers::ConsumeAngle(function_args); | 59 angle = CSSPropertyParserHelpers::ConsumeAngle( |
| 60 function_args, *context, WTF::Optional<UseCounter::Feature>()); |
| 59 if (angle) | 61 if (angle) |
| 60 continue; | 62 continue; |
| 61 } | 63 } |
| 62 if (!size) { | 64 if (!size) { |
| 63 size = CSSPropertyParserHelpers::ConsumeIdent< | 65 size = CSSPropertyParserHelpers::ConsumeIdent< |
| 64 CSSValueClosestSide, CSSValueClosestCorner, CSSValueFarthestSide, | 66 CSSValueClosestSide, CSSValueClosestCorner, CSSValueFarthestSide, |
| 65 CSSValueFarthestCorner, CSSValueSides>(function_args); | 67 CSSValueFarthestCorner, CSSValueSides>(function_args); |
| 66 if (size) | 68 if (size) |
| 67 continue; | 69 continue; |
| 68 } | 70 } |
| (...skipping 12 matching lines...) Expand all Loading... |
| 81 } | 83 } |
| 82 | 84 |
| 83 } // namespace | 85 } // namespace |
| 84 | 86 |
| 85 CSSValue* CSSPropertyOffsetPathUtils::ConsumeOffsetPath( | 87 CSSValue* CSSPropertyOffsetPathUtils::ConsumeOffsetPath( |
| 86 CSSParserTokenRange& range, | 88 CSSParserTokenRange& range, |
| 87 const CSSParserContext* context) { | 89 const CSSParserContext* context) { |
| 88 CSSValue* value = nullptr; | 90 CSSValue* value = nullptr; |
| 89 if (RuntimeEnabledFeatures::cssOffsetPathRayEnabled() && | 91 if (RuntimeEnabledFeatures::cssOffsetPathRayEnabled() && |
| 90 range.Peek().FunctionId() == CSSValueRay) | 92 range.Peek().FunctionId() == CSSValueRay) |
| 91 value = ConsumeRay(range); | 93 value = ConsumeRay(range, context); |
| 92 else | 94 else |
| 93 value = ConsumePathOrNone(range); | 95 value = ConsumePathOrNone(range); |
| 94 | 96 |
| 95 // Count when we receive a valid path other than 'none'. | 97 // Count when we receive a valid path other than 'none'. |
| 96 if (value && !value->IsIdentifierValue()) | 98 if (value && !value->IsIdentifierValue()) |
| 97 context->Count(UseCounter::kCSSOffsetInEffect); | 99 context->Count(UseCounter::kCSSOffsetInEffect); |
| 98 return value; | 100 return value; |
| 99 } | 101 } |
| 100 | 102 |
| 101 CSSValue* CSSPropertyOffsetPathUtils::ConsumePathOrNone( | 103 CSSValue* CSSPropertyOffsetPathUtils::ConsumePathOrNone( |
| 102 CSSParserTokenRange& range) { | 104 CSSParserTokenRange& range) { |
| 103 CSSValueID id = range.Peek().Id(); | 105 CSSValueID id = range.Peek().Id(); |
| 104 if (id == CSSValueNone) | 106 if (id == CSSValueNone) |
| 105 return CSSPropertyParserHelpers::ConsumeIdent(range); | 107 return CSSPropertyParserHelpers::ConsumeIdent(range); |
| 106 | 108 |
| 107 return ConsumePath(range); | 109 return ConsumePath(range); |
| 108 } | 110 } |
| 109 | 111 |
| 110 } // namespace blink | 112 } // namespace blink |
| OLD | NEW |