| 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/CSSPropertyLengthUtils.h" | 5 #include "core/css/properties/CSSPropertyLengthUtils.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 namespace { | 13 namespace { |
| 14 | 14 |
| 15 bool ValidWidthOrHeightKeyword(CSSValueID id, const CSSParserContext* context) { | 15 bool ValidWidthOrHeightKeyword(CSSValueID id, const CSSParserContext& context) { |
| 16 if (id == CSSValueWebkitMinContent || id == CSSValueWebkitMaxContent || | 16 if (id == CSSValueWebkitMinContent || id == CSSValueWebkitMaxContent || |
| 17 id == CSSValueWebkitFillAvailable || id == CSSValueWebkitFitContent || | 17 id == CSSValueWebkitFillAvailable || id == CSSValueWebkitFitContent || |
| 18 id == CSSValueMinContent || id == CSSValueMaxContent || | 18 id == CSSValueMinContent || id == CSSValueMaxContent || |
| 19 id == CSSValueFitContent) { | 19 id == CSSValueFitContent) { |
| 20 switch (id) { | 20 switch (id) { |
| 21 case CSSValueWebkitMinContent: | 21 case CSSValueWebkitMinContent: |
| 22 context->Count(UseCounter::kCSSValuePrefixedMinContent); | 22 context.Count(UseCounter::kCSSValuePrefixedMinContent); |
| 23 break; | 23 break; |
| 24 case CSSValueWebkitMaxContent: | 24 case CSSValueWebkitMaxContent: |
| 25 context->Count(UseCounter::kCSSValuePrefixedMaxContent); | 25 context.Count(UseCounter::kCSSValuePrefixedMaxContent); |
| 26 break; | 26 break; |
| 27 case CSSValueWebkitFillAvailable: | 27 case CSSValueWebkitFillAvailable: |
| 28 context->Count(UseCounter::kCSSValuePrefixedFillAvailable); | 28 context.Count(UseCounter::kCSSValuePrefixedFillAvailable); |
| 29 break; | 29 break; |
| 30 case CSSValueWebkitFitContent: | 30 case CSSValueWebkitFitContent: |
| 31 context->Count(UseCounter::kCSSValuePrefixedFitContent); | 31 context.Count(UseCounter::kCSSValuePrefixedFitContent); |
| 32 break; | 32 break; |
| 33 default: | 33 default: |
| 34 break; | 34 break; |
| 35 } | 35 } |
| 36 return true; | 36 return true; |
| 37 } | 37 } |
| 38 return false; | 38 return false; |
| 39 } | 39 } |
| 40 | 40 |
| 41 } // namespace | 41 } // namespace |
| 42 | 42 |
| 43 CSSValue* CSSPropertyLengthUtils::ConsumeMaxWidthOrHeight( | 43 CSSValue* CSSPropertyLengthUtils::ConsumeMaxWidthOrHeight( |
| 44 CSSParserTokenRange& range, | 44 CSSParserTokenRange& range, |
| 45 const CSSParserContext* context, | 45 const CSSParserContext& context, |
| 46 CSSPropertyParserHelpers::UnitlessQuirk unitless) { | 46 CSSPropertyParserHelpers::UnitlessQuirk unitless) { |
| 47 if (range.Peek().Id() == CSSValueNone || | 47 if (range.Peek().Id() == CSSValueNone || |
| 48 ValidWidthOrHeightKeyword(range.Peek().Id(), context)) | 48 ValidWidthOrHeightKeyword(range.Peek().Id(), context)) |
| 49 return CSSPropertyParserHelpers::ConsumeIdent(range); | 49 return CSSPropertyParserHelpers::ConsumeIdent(range); |
| 50 return CSSPropertyParserHelpers::ConsumeLengthOrPercent( | 50 return CSSPropertyParserHelpers::ConsumeLengthOrPercent( |
| 51 range, context->Mode(), kValueRangeNonNegative, unitless); | 51 range, context.Mode(), kValueRangeNonNegative, unitless); |
| 52 } | 52 } |
| 53 | 53 |
| 54 CSSValue* CSSPropertyLengthUtils::ConsumeWidthOrHeight( | 54 CSSValue* CSSPropertyLengthUtils::ConsumeWidthOrHeight( |
| 55 CSSParserTokenRange& range, | 55 CSSParserTokenRange& range, |
| 56 const CSSParserContext* context, | 56 const CSSParserContext& context, |
| 57 CSSPropertyParserHelpers::UnitlessQuirk unitless) { | 57 CSSPropertyParserHelpers::UnitlessQuirk unitless) { |
| 58 if (range.Peek().Id() == CSSValueAuto || | 58 if (range.Peek().Id() == CSSValueAuto || |
| 59 ValidWidthOrHeightKeyword(range.Peek().Id(), context)) | 59 ValidWidthOrHeightKeyword(range.Peek().Id(), context)) |
| 60 return CSSPropertyParserHelpers::ConsumeIdent(range); | 60 return CSSPropertyParserHelpers::ConsumeIdent(range); |
| 61 return CSSPropertyParserHelpers::ConsumeLengthOrPercent( | 61 return CSSPropertyParserHelpers::ConsumeLengthOrPercent( |
| 62 range, context->Mode(), kValueRangeNonNegative, unitless); | 62 range, context.Mode(), kValueRangeNonNegative, unitless); |
| 63 } | 63 } |
| 64 | 64 |
| 65 } // namespace blink | 65 } // namespace blink |
| OLD | NEW |