| 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/CSSPropertyAPICursor.h" | 5 #include "core/css/properties/CSSPropertyAPICursor.h" |
| 6 | 6 |
| 7 #include "core/css/CSSCursorImageValue.h" | 7 #include "core/css/CSSCursorImageValue.h" |
| 8 #include "core/css/CSSValueList.h" | 8 #include "core/css/CSSValueList.h" |
| 9 #include "core/css/parser/CSSParserContext.h" | 9 #include "core/css/parser/CSSParserContext.h" |
| 10 #include "core/css/parser/CSSParserMode.h" | 10 #include "core/css/parser/CSSParserMode.h" |
| 11 #include "core/css/parser/CSSPropertyParserHelpers.h" | 11 #include "core/css/parser/CSSPropertyParserHelpers.h" |
| 12 #include "core/frame/UseCounter.h" | 12 #include "core/frame/UseCounter.h" |
| 13 | 13 |
| 14 class CSSParserLocalContext; | 14 class CSSParserLocalContext; |
| 15 namespace blink { | 15 namespace blink { |
| 16 | 16 |
| 17 using CSSCursorImageValue = cssvalue::CSSCursorImageValue; | |
| 18 | |
| 19 const CSSValue* CSSPropertyAPICursor::parseSingleValue( | 17 const CSSValue* CSSPropertyAPICursor::parseSingleValue( |
| 20 CSSParserTokenRange& range, | 18 CSSParserTokenRange& range, |
| 21 const CSSParserContext& context, | 19 const CSSParserContext& context, |
| 22 const CSSParserLocalContext&) { | 20 const CSSParserLocalContext&) { |
| 23 bool in_quirks_mode = IsQuirksModeBehavior(context.Mode()); | 21 bool in_quirks_mode = IsQuirksModeBehavior(context.Mode()); |
| 24 CSSValueList* list = nullptr; | 22 CSSValueList* list = nullptr; |
| 25 while (CSSValue* image = CSSPropertyParserHelpers::ConsumeImage( | 23 while (CSSValue* image = CSSPropertyParserHelpers::ConsumeImage( |
| 26 range, &context, | 24 range, &context, |
| 27 CSSPropertyParserHelpers::ConsumeGeneratedImagePolicy::kForbid)) { | 25 CSSPropertyParserHelpers::ConsumeGeneratedImagePolicy::kForbid)) { |
| 28 double num; | 26 double num; |
| 29 IntPoint hot_spot(-1, -1); | 27 IntPoint hot_spot(-1, -1); |
| 30 bool hot_spot_specified = false; | 28 bool hot_spot_specified = false; |
| 31 if (CSSPropertyParserHelpers::ConsumeNumberRaw(range, num)) { | 29 if (CSSPropertyParserHelpers::ConsumeNumberRaw(range, num)) { |
| 32 hot_spot.SetX(int(num)); | 30 hot_spot.SetX(int(num)); |
| 33 if (!CSSPropertyParserHelpers::ConsumeNumberRaw(range, num)) | 31 if (!CSSPropertyParserHelpers::ConsumeNumberRaw(range, num)) |
| 34 return nullptr; | 32 return nullptr; |
| 35 hot_spot.SetY(int(num)); | 33 hot_spot.SetY(int(num)); |
| 36 hot_spot_specified = true; | 34 hot_spot_specified = true; |
| 37 } | 35 } |
| 38 | 36 |
| 39 if (!list) | 37 if (!list) |
| 40 list = CSSValueList::CreateCommaSeparated(); | 38 list = CSSValueList::CreateCommaSeparated(); |
| 41 | 39 |
| 42 list->Append( | 40 list->Append(*cssvalue::CSSCursorImageValue::Create( |
| 43 *CSSCursorImageValue::Create(*image, hot_spot_specified, hot_spot)); | 41 *image, hot_spot_specified, hot_spot)); |
| 44 if (!CSSPropertyParserHelpers::ConsumeCommaIncludingWhitespace(range)) | 42 if (!CSSPropertyParserHelpers::ConsumeCommaIncludingWhitespace(range)) |
| 45 return nullptr; | 43 return nullptr; |
| 46 } | 44 } |
| 47 | 45 |
| 48 CSSValueID id = range.Peek().Id(); | 46 CSSValueID id = range.Peek().Id(); |
| 49 if (!range.AtEnd()) { | 47 if (!range.AtEnd()) { |
| 50 if (id == CSSValueWebkitZoomIn) | 48 if (id == CSSValueWebkitZoomIn) |
| 51 context.Count(WebFeature::kPrefixedCursorZoomIn); | 49 context.Count(WebFeature::kPrefixedCursorZoomIn); |
| 52 else if (id == CSSValueWebkitZoomOut) | 50 else if (id == CSSValueWebkitZoomOut) |
| 53 context.Count(WebFeature::kPrefixedCursorZoomOut); | 51 context.Count(WebFeature::kPrefixedCursorZoomOut); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 65 return nullptr; | 63 return nullptr; |
| 66 } | 64 } |
| 67 | 65 |
| 68 if (!list) | 66 if (!list) |
| 69 return cursor_type; | 67 return cursor_type; |
| 70 list->Append(*cursor_type); | 68 list->Append(*cursor_type); |
| 71 return list; | 69 return list; |
| 72 } | 70 } |
| 73 | 71 |
| 74 } // namespace blink | 72 } // namespace blink |
| OLD | NEW |