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

Side by Side Diff: third_party/WebKit/Source/core/css/properties/CSSPropertyOffsetPathUtils.cpp

Issue 2918283002: Added null safety to CSSParserContext args in CSSPropertyOffsetPathUtils (Closed)
Patch Set: Created 3 years, 6 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
« no previous file with comments | « third_party/WebKit/Source/core/css/properties/CSSPropertyOffsetPathUtils.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 27 matching lines...) Expand all
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 const CSSParserContext& context) {
49 DCHECK_EQ(range.Peek().FunctionId(), CSSValueRay); 49 DCHECK_EQ(range.Peek().FunctionId(), CSSValueRay);
50 CSSParserTokenRange function_range = range; 50 CSSParserTokenRange function_range = range;
51 CSSParserTokenRange function_args = 51 CSSParserTokenRange function_args =
52 CSSPropertyParserHelpers::ConsumeFunction(function_range); 52 CSSPropertyParserHelpers::ConsumeFunction(function_range);
53 53
54 CSSPrimitiveValue* angle = nullptr; 54 CSSPrimitiveValue* angle = nullptr;
55 CSSIdentifierValue* size = nullptr; 55 CSSIdentifierValue* size = nullptr;
56 CSSIdentifierValue* contain = nullptr; 56 CSSIdentifierValue* contain = nullptr;
57 while (!function_args.AtEnd()) { 57 while (!function_args.AtEnd()) {
58 if (!angle) { 58 if (!angle) {
59 angle = CSSPropertyParserHelpers::ConsumeAngle( 59 angle = CSSPropertyParserHelpers::ConsumeAngle(
60 function_args, *context, WTF::Optional<UseCounter::Feature>()); 60 function_args, context, WTF::Optional<UseCounter::Feature>());
61 if (angle) 61 if (angle)
62 continue; 62 continue;
63 } 63 }
64 if (!size) { 64 if (!size) {
65 size = CSSPropertyParserHelpers::ConsumeIdent< 65 size = CSSPropertyParserHelpers::ConsumeIdent<
66 CSSValueClosestSide, CSSValueClosestCorner, CSSValueFarthestSide, 66 CSSValueClosestSide, CSSValueClosestCorner, CSSValueFarthestSide,
67 CSSValueFarthestCorner, CSSValueSides>(function_args); 67 CSSValueFarthestCorner, CSSValueSides>(function_args);
68 if (size) 68 if (size)
69 continue; 69 continue;
70 } 70 }
71 if (RuntimeEnabledFeatures::cssOffsetPathRayContainEnabled() && !contain) { 71 if (RuntimeEnabledFeatures::cssOffsetPathRayContainEnabled() && !contain) {
72 contain = CSSPropertyParserHelpers::ConsumeIdent<CSSValueContain>( 72 contain = CSSPropertyParserHelpers::ConsumeIdent<CSSValueContain>(
73 function_args); 73 function_args);
74 if (contain) 74 if (contain)
75 continue; 75 continue;
76 } 76 }
77 return nullptr; 77 return nullptr;
78 } 78 }
79 if (!angle || !size) 79 if (!angle || !size)
80 return nullptr; 80 return nullptr;
81 range = function_range; 81 range = function_range;
82 return CSSRayValue::Create(*angle, *size, contain); 82 return CSSRayValue::Create(*angle, *size, contain);
83 } 83 }
84 84
85 } // namespace 85 } // namespace
86 86
87 CSSValue* CSSPropertyOffsetPathUtils::ConsumeOffsetPath( 87 CSSValue* CSSPropertyOffsetPathUtils::ConsumeOffsetPath(
88 CSSParserTokenRange& range, 88 CSSParserTokenRange& range,
89 const CSSParserContext* context) { 89 const CSSParserContext& context) {
90 CSSValue* value = nullptr; 90 CSSValue* value = nullptr;
91 if (RuntimeEnabledFeatures::cssOffsetPathRayEnabled() && 91 if (RuntimeEnabledFeatures::cssOffsetPathRayEnabled() &&
92 range.Peek().FunctionId() == CSSValueRay) 92 range.Peek().FunctionId() == CSSValueRay)
93 value = ConsumeRay(range, context); 93 value = ConsumeRay(range, context);
94 else 94 else
95 value = ConsumePathOrNone(range); 95 value = ConsumePathOrNone(range);
96 96
97 // Count when we receive a valid path other than 'none'. 97 // Count when we receive a valid path other than 'none'.
98 if (value && !value->IsIdentifierValue()) 98 if (value && !value->IsIdentifierValue())
99 context->Count(UseCounter::kCSSOffsetInEffect); 99 context.Count(UseCounter::kCSSOffsetInEffect);
100 return value; 100 return value;
101 } 101 }
102 102
103 CSSValue* CSSPropertyOffsetPathUtils::ConsumePathOrNone( 103 CSSValue* CSSPropertyOffsetPathUtils::ConsumePathOrNone(
104 CSSParserTokenRange& range) { 104 CSSParserTokenRange& range) {
105 CSSValueID id = range.Peek().Id(); 105 CSSValueID id = range.Peek().Id();
106 if (id == CSSValueNone) 106 if (id == CSSValueNone)
107 return CSSPropertyParserHelpers::ConsumeIdent(range); 107 return CSSPropertyParserHelpers::ConsumeIdent(range);
108 108
109 return ConsumePath(range); 109 return ConsumePath(range);
110 } 110 }
111 111
112 } // namespace blink 112 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/css/properties/CSSPropertyOffsetPathUtils.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698