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

Side by Side Diff: third_party/WebKit/Source/core/css/parser/CSSPropertyParser.cpp

Issue 2898133002: CSS: Use count unitless 0 supplied as <angle> (Closed)
Patch Set: test 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/parser/CSSPropertyParser.h" 5 #include "core/css/parser/CSSPropertyParser.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include "core/StylePropertyShorthand.h" 8 #include "core/StylePropertyShorthand.h"
9 #include "core/css/CSSBasicShapeValues.h" 9 #include "core/css/CSSBasicShapeValues.h"
10 #include "core/css/CSSBorderImage.h" 10 #include "core/css/CSSBorderImage.h"
(...skipping 629 matching lines...) Expand 10 before | Expand all | Expand 10 after
640 if (args.AtEnd()) { 640 if (args.AtEnd()) {
641 context->Count(UseCounter::kCSSFilterFunctionNoArguments); 641 context->Count(UseCounter::kCSSFilterFunctionNoArguments);
642 return filter_value; 642 return filter_value;
643 } 643 }
644 if (filter_type == CSSValueBrightness) { 644 if (filter_type == CSSValueBrightness) {
645 // FIXME (crbug.com/397061): Support calc expressions like calc(10% + 0.5) 645 // FIXME (crbug.com/397061): Support calc expressions like calc(10% + 0.5)
646 parsed_value = ConsumePercent(args, kValueRangeAll); 646 parsed_value = ConsumePercent(args, kValueRangeAll);
647 if (!parsed_value) 647 if (!parsed_value)
648 parsed_value = ConsumeNumber(args, kValueRangeAll); 648 parsed_value = ConsumeNumber(args, kValueRangeAll);
649 } else if (filter_type == CSSValueHueRotate) { 649 } else if (filter_type == CSSValueHueRotate) {
650 parsed_value = ConsumeAngle(args); 650 parsed_value =
651 ConsumeAngle(args, *context, UseCounter::kUnitlessZeroAngleFilter);
651 } else if (filter_type == CSSValueBlur) { 652 } else if (filter_type == CSSValueBlur) {
652 parsed_value = 653 parsed_value =
653 ConsumeLength(args, kHTMLStandardMode, kValueRangeNonNegative); 654 ConsumeLength(args, kHTMLStandardMode, kValueRangeNonNegative);
654 } else { 655 } else {
655 // FIXME (crbug.com/397061): Support calc expressions like calc(10% + 0.5) 656 // FIXME (crbug.com/397061): Support calc expressions like calc(10% + 0.5)
656 parsed_value = ConsumePercent(args, kValueRangeNonNegative); 657 parsed_value = ConsumePercent(args, kValueRangeNonNegative);
657 if (!parsed_value) 658 if (!parsed_value)
658 parsed_value = ConsumeNumber(args, kValueRangeNonNegative); 659 parsed_value = ConsumeNumber(args, kValueRangeNonNegative);
659 if (parsed_value && filter_type != CSSValueSaturate && 660 if (parsed_value && filter_type != CSSValueSaturate &&
660 filter_type != CSSValueContrast) { 661 filter_type != CSSValueContrast) {
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
708 if (list->HasValue(*ident)) 709 if (list->HasValue(*ident))
709 return nullptr; 710 return nullptr;
710 list->Append(*ident); 711 list->Append(*ident);
711 } 712 }
712 713
713 if (!list->length()) 714 if (!list->length())
714 return nullptr; 715 return nullptr;
715 return list; 716 return list;
716 } 717 }
717 718
718 static CSSValue* ConsumeOffsetRotate(CSSParserTokenRange& range) { 719 static CSSValue* ConsumeOffsetRotate(CSSParserTokenRange& range,
719 CSSValue* angle = ConsumeAngle(range); 720 const CSSParserContext& context) {
721 CSSValue* angle =
722 ConsumeAngle(range, context, UseCounter::kUnitlessZeroAngleOffsetRotate);
720 CSSValue* keyword = ConsumeIdent<CSSValueAuto, CSSValueReverse>(range); 723 CSSValue* keyword = ConsumeIdent<CSSValueAuto, CSSValueReverse>(range);
721 if (!angle && !keyword) 724 if (!angle && !keyword)
722 return nullptr; 725 return nullptr;
723 726
724 if (!angle) 727 if (!angle) {
725 angle = ConsumeAngle(range); 728 angle = ConsumeAngle(range, context,
729 UseCounter::kUnitlessZeroAngleOffsetRotate);
730 }
726 731
727 CSSValueList* list = CSSValueList::CreateSpaceSeparated(); 732 CSSValueList* list = CSSValueList::CreateSpaceSeparated();
728 if (keyword) 733 if (keyword)
729 list->Append(*keyword); 734 list->Append(*keyword);
730 if (angle) 735 if (angle)
731 list->Append(*angle); 736 list->Append(*angle);
732 return list; 737 return list;
733 } 738 }
734 739
735 // offset: <offset-path> <offset-distance> <offset-rotate> 740 // offset: <offset-path> <offset-distance> <offset-rotate>
736 bool CSSPropertyParser::ConsumeOffsetShorthand(bool important) { 741 bool CSSPropertyParser::ConsumeOffsetShorthand(bool important) {
737 const CSSValue* offset_path = 742 const CSSValue* offset_path =
738 CSSPropertyOffsetPathUtils::ConsumeOffsetPath(range_, context_); 743 CSSPropertyOffsetPathUtils::ConsumeOffsetPath(range_, context_);
739 const CSSValue* offset_distance = 744 const CSSValue* offset_distance =
740 ConsumeLengthOrPercent(range_, context_->Mode(), kValueRangeAll); 745 ConsumeLengthOrPercent(range_, context_->Mode(), kValueRangeAll);
741 const CSSValue* offset_rotate = ConsumeOffsetRotate(range_); 746 const CSSValue* offset_rotate = ConsumeOffsetRotate(range_, *context_);
742 if (!offset_path || !offset_distance || !offset_rotate || !range_.AtEnd()) 747 if (!offset_path || !offset_distance || !offset_rotate || !range_.AtEnd())
743 return false; 748 return false;
744 749
745 AddProperty(CSSPropertyOffsetPath, CSSPropertyOffset, *offset_path, 750 AddProperty(CSSPropertyOffsetPath, CSSPropertyOffset, *offset_path,
746 important); 751 important);
747 AddProperty(CSSPropertyOffsetDistance, CSSPropertyOffset, *offset_distance, 752 AddProperty(CSSPropertyOffsetDistance, CSSPropertyOffset, *offset_distance,
748 important); 753 important);
749 AddProperty(CSSPropertyOffsetRotate, CSSPropertyOffset, *offset_rotate, 754 AddProperty(CSSPropertyOffsetRotate, CSSPropertyOffset, *offset_rotate,
750 important); 755 important);
751 756
(...skipping 984 matching lines...) Expand 10 before | Expand all | Expand 10 after
1736 return ConsumeFilter(range_, context_); 1741 return ConsumeFilter(range_, context_);
1737 case CSSPropertyTextDecoration: 1742 case CSSPropertyTextDecoration:
1738 DCHECK(!RuntimeEnabledFeatures::css3TextDecorationsEnabled()); 1743 DCHECK(!RuntimeEnabledFeatures::css3TextDecorationsEnabled());
1739 // fallthrough 1744 // fallthrough
1740 case CSSPropertyWebkitTextDecorationsInEffect: 1745 case CSSPropertyWebkitTextDecorationsInEffect:
1741 case CSSPropertyTextDecorationLine: 1746 case CSSPropertyTextDecorationLine:
1742 return ConsumeTextDecorationLine(range_); 1747 return ConsumeTextDecorationLine(range_);
1743 case CSSPropertyOffsetDistance: 1748 case CSSPropertyOffsetDistance:
1744 return ConsumeLengthOrPercent(range_, context_->Mode(), kValueRangeAll); 1749 return ConsumeLengthOrPercent(range_, context_->Mode(), kValueRangeAll);
1745 case CSSPropertyOffsetRotate: 1750 case CSSPropertyOffsetRotate:
1746 return ConsumeOffsetRotate(range_); 1751 return ConsumeOffsetRotate(range_, *context_);
1747 case CSSPropertyWebkitTransformOriginX: 1752 case CSSPropertyWebkitTransformOriginX:
1748 case CSSPropertyWebkitPerspectiveOriginX: 1753 case CSSPropertyWebkitPerspectiveOriginX:
1749 return CSSPropertyPositionUtils::ConsumePositionLonghand<CSSValueLeft, 1754 return CSSPropertyPositionUtils::ConsumePositionLonghand<CSSValueLeft,
1750 CSSValueRight>( 1755 CSSValueRight>(
1751 range_, context_->Mode()); 1756 range_, context_->Mode());
1752 case CSSPropertyWebkitTransformOriginY: 1757 case CSSPropertyWebkitTransformOriginY:
1753 case CSSPropertyWebkitPerspectiveOriginY: 1758 case CSSPropertyWebkitPerspectiveOriginY:
1754 return CSSPropertyPositionUtils::ConsumePositionLonghand<CSSValueTop, 1759 return CSSPropertyPositionUtils::ConsumePositionLonghand<CSSValueTop,
1755 CSSValueBottom>( 1760 CSSValueBottom>(
1756 range_, context_->Mode()); 1761 range_, context_->Mode());
(...skipping 1667 matching lines...) Expand 10 before | Expand all | Expand 10 after
3424 case CSSPropertyPlaceItems: 3429 case CSSPropertyPlaceItems:
3425 return ConsumePlaceItemsShorthand(important); 3430 return ConsumePlaceItemsShorthand(important);
3426 case CSSPropertyPlaceSelf: 3431 case CSSPropertyPlaceSelf:
3427 return ConsumePlaceSelfShorthand(important); 3432 return ConsumePlaceSelfShorthand(important);
3428 default: 3433 default:
3429 return false; 3434 return false;
3430 } 3435 }
3431 } 3436 }
3432 3437
3433 } // namespace blink 3438 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698