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/CSSPropertyAPIZoom.h" | 5 #include "core/css/properties/CSSPropertyAPIZoom.h" |
6 | 6 |
7 #include "core/css/parser/CSSParserContext.h" | 7 #include "core/css/parser/CSSParserContext.h" |
8 #include "core/css/parser/CSSPropertyParserHelpers.h" | 8 #include "core/css/parser/CSSPropertyParserHelpers.h" |
9 #include "core/frame/UseCounter.h" | 9 #include "core/frame/UseCounter.h" |
10 | 10 |
11 namespace blink { | 11 namespace blink { |
12 | 12 |
13 const CSSValue* CSSPropertyAPIZoom::parseSingleValue( | 13 const CSSValue* CSSPropertyAPIZoom::parseSingleValue( |
14 CSSParserTokenRange& range, | 14 CSSParserTokenRange& range, |
15 const CSSParserContext& context) { | 15 const CSSParserContext* context) { |
16 const CSSParserToken& token = range.peek(); | 16 const CSSParserToken& token = range.peek(); |
17 CSSValue* zoom = nullptr; | 17 CSSValue* zoom = nullptr; |
18 if (token.type() == IdentToken) { | 18 if (token.type() == IdentToken) { |
19 zoom = CSSPropertyParserHelpers::consumeIdent<CSSValueNormal, CSSValueReset, | 19 zoom = CSSPropertyParserHelpers::consumeIdent<CSSValueNormal, CSSValueReset, |
20 CSSValueDocument>(range); | 20 CSSValueDocument>(range); |
21 } else { | 21 } else { |
22 zoom = | 22 zoom = |
23 CSSPropertyParserHelpers::consumePercent(range, ValueRangeNonNegative); | 23 CSSPropertyParserHelpers::consumePercent(range, ValueRangeNonNegative); |
24 if (!zoom) { | 24 if (!zoom) { |
25 zoom = | 25 zoom = |
26 CSSPropertyParserHelpers::consumeNumber(range, ValueRangeNonNegative); | 26 CSSPropertyParserHelpers::consumeNumber(range, ValueRangeNonNegative); |
27 } | 27 } |
28 } | 28 } |
29 if (zoom && context.useCounter()) { | 29 if (zoom && context->isUseCounterRecordingEnabled()) { |
30 if (!(token.id() == CSSValueNormal || | 30 if (!(token.id() == CSSValueNormal || |
31 (token.type() == NumberToken && | 31 (token.type() == NumberToken && |
32 toCSSPrimitiveValue(zoom)->getDoubleValue() == 1) || | 32 toCSSPrimitiveValue(zoom)->getDoubleValue() == 1) || |
33 (token.type() == PercentageToken && | 33 (token.type() == PercentageToken && |
34 toCSSPrimitiveValue(zoom)->getDoubleValue() == 100))) | 34 toCSSPrimitiveValue(zoom)->getDoubleValue() == 100))) |
35 context.useCounter()->count(UseCounter::CSSZoomNotEqualToOne); | 35 context->useCounter()->count(UseCounter::CSSZoomNotEqualToOne); |
36 if (token.id() == CSSValueReset) | 36 if (token.id() == CSSValueReset) |
37 context.useCounter()->count(UseCounter::CSSZoomReset); | 37 context->useCounter()->count(UseCounter::CSSZoomReset); |
38 if (token.id() == CSSValueDocument) | 38 if (token.id() == CSSValueDocument) |
39 context.useCounter()->count(UseCounter::CSSZoomDocument); | 39 context->useCounter()->count(UseCounter::CSSZoomDocument); |
40 } | 40 } |
41 return zoom; | 41 return zoom; |
42 } | 42 } |
43 | 43 |
44 } // namespace blink | 44 } // namespace blink |
OLD | NEW |