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

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

Issue 1402963002: Move width/height related properties into CSSPropertyParser (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 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 "config.h" 5 #include "config.h"
6 #include "core/css/parser/CSSPropertyParser.h" 6 #include "core/css/parser/CSSPropertyParser.h"
7 7
8 #include "core/StylePropertyShorthand.h" 8 #include "core/StylePropertyShorthand.h"
9 #include "core/css/CSSCalculationValue.h" 9 #include "core/css/CSSCalculationValue.h"
10 #include "core/css/CSSCustomIdentValue.h" 10 #include "core/css/CSSCustomIdentValue.h"
(...skipping 736 matching lines...) Expand 10 before | Expand all | Expand 10 after
747 } 747 }
748 return nullptr; 748 return nullptr;
749 } while (!range.atEnd()); 749 } while (!range.atEnd());
750 750
751 if (!hasLengthOrPercentage) 751 if (!hasLengthOrPercentage)
752 return nullptr; 752 return nullptr;
753 753
754 return list.release(); 754 return list.release();
755 } 755 }
756 756
757 static bool validWidthOrHeightKeyword(CSSValueID id, const CSSParserContext& con text)
758 {
759 if (id == CSSValueIntrinsic || id == CSSValueMinIntrinsic
760 || id == CSSValueWebkitMinContent || id == CSSValueWebkitMaxContent || i d == CSSValueWebkitFillAvailable || id == CSSValueWebkitFitContent
761 || id == CSSValueMinContent || id == CSSValueMaxContent || id == CSSValu eFitContent) {
762 if (context.useCounter()) {
763 switch (id) {
764 case CSSValueIntrinsic:
765 case CSSValueMinIntrinsic:
766 // These two will be counted in StyleAdjuster because they emit a deprecation
767 // message, and we don't have access to a Document/LocalFrame he re.
768 break;
769 case CSSValueWebkitMinContent:
770 context.useCounter()->count(UseCounter::CSSValuePrefixedMinConte nt);
771 break;
772 case CSSValueWebkitMaxContent:
773 context.useCounter()->count(UseCounter::CSSValuePrefixedMaxConte nt);
774 break;
775 case CSSValueWebkitFillAvailable:
776 context.useCounter()->count(UseCounter::CSSValuePrefixedFillAvai lable);
777 break;
778 case CSSValueWebkitFitContent:
779 context.useCounter()->count(UseCounter::CSSValuePrefixedFitConte nt);
780 break;
781 default:
782 break;
783 }
784 }
785 return true;
786 }
787 return false;
788 }
789
790 static PassRefPtrWillBeRawPtr<CSSValue> consumeMaxWidthOrHeight(CSSParserTokenRa nge& range, const CSSParserContext& context, UnitlessQuirk unitless = UnitlessQu irk::Forbid)
791 {
792 if (range.peek().id() == CSSValueNone || validWidthOrHeightKeyword(range.pee k().id(), context))
793 return consumeIdent(range);
794 return consumeLengthOrPercent(range, context.mode(), ValueRangeNonNegative, unitless);
795 }
796
797 static PassRefPtrWillBeRawPtr<CSSValue> consumeWidthOrHeight(CSSParserTokenRange & range, const CSSParserContext& context, UnitlessQuirk unitless = UnitlessQuirk ::Forbid)
798 {
799 if (range.peek().id() == CSSValueAuto || validWidthOrHeightKeyword(range.pee k().id(), context))
800 return consumeIdent(range);
801 return consumeLengthOrPercent(range, context.mode(), ValueRangeNonNegative, unitless);
802 }
803
757 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseSingleValue(CSSProperty ID propId) 804 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseSingleValue(CSSProperty ID propId)
758 { 805 {
759 m_range.consumeWhitespace(); 806 m_range.consumeWhitespace();
760 switch (propId) { 807 switch (propId) {
761 case CSSPropertyWillChange: 808 case CSSPropertyWillChange:
762 return consumeWillChange(m_range); 809 return consumeWillChange(m_range);
763 case CSSPropertyPage: 810 case CSSPropertyPage:
764 return consumePage(m_range); 811 return consumePage(m_range);
765 case CSSPropertyQuotes: 812 case CSSPropertyQuotes:
766 return consumeQuotes(m_range); 813 return consumeQuotes(m_range);
(...skipping 23 matching lines...) Expand all
790 case CSSPropertyWebkitBorderHorizontalSpacing: 837 case CSSPropertyWebkitBorderHorizontalSpacing:
791 case CSSPropertyWebkitBorderVerticalSpacing: 838 case CSSPropertyWebkitBorderVerticalSpacing:
792 return consumeLength(m_range, m_context.mode(), ValueRangeNonNegative); 839 return consumeLength(m_range, m_context.mode(), ValueRangeNonNegative);
793 case CSSPropertyCounterIncrement: 840 case CSSPropertyCounterIncrement:
794 case CSSPropertyCounterReset: 841 case CSSPropertyCounterReset:
795 return consumeCounter(m_range, m_context.mode(), propId == CSSPropertyCo unterIncrement ? 1 : 0); 842 return consumeCounter(m_range, m_context.mode(), propId == CSSPropertyCo unterIncrement ? 1 : 0);
796 case CSSPropertySize: 843 case CSSPropertySize:
797 return consumeSize(m_range, m_context.mode()); 844 return consumeSize(m_range, m_context.mode());
798 case CSSPropertyTextIndent: 845 case CSSPropertyTextIndent:
799 return consumeTextIndent(m_range, m_context.mode()); 846 return consumeTextIndent(m_range, m_context.mode());
847 case CSSPropertyMaxWidth:
848 case CSSPropertyMaxHeight:
849 return consumeMaxWidthOrHeight(m_range, m_context, UnitlessQuirk::Allow) ;
850 case CSSPropertyWebkitMaxLogicalWidth:
851 case CSSPropertyWebkitMaxLogicalHeight:
852 return consumeMaxWidthOrHeight(m_range, m_context);
853 case CSSPropertyMinWidth:
854 case CSSPropertyMinHeight:
855 case CSSPropertyWidth:
856 case CSSPropertyHeight:
857 return consumeWidthOrHeight(m_range, m_context, UnitlessQuirk::Allow);
858 case CSSPropertyWebkitMinLogicalWidth:
859 case CSSPropertyWebkitMinLogicalHeight:
860 case CSSPropertyWebkitLogicalWidth:
861 case CSSPropertyWebkitLogicalHeight:
862 return consumeWidthOrHeight(m_range, m_context);
800 default: 863 default:
801 return nullptr; 864 return nullptr;
802 } 865 }
803 } 866 }
804 867
805 static PassRefPtrWillBeRawPtr<CSSValueList> consumeFontFaceUnicodeRange(CSSParse rTokenRange& range) 868 static PassRefPtrWillBeRawPtr<CSSValueList> consumeFontFaceUnicodeRange(CSSParse rTokenRange& range)
806 { 869 {
807 RefPtrWillBeRawPtr<CSSValueList> values = CSSValueList::createCommaSeparated (); 870 RefPtrWillBeRawPtr<CSSValueList> values = CSSValueList::createCommaSeparated ();
808 871
809 do { 872 do {
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after
1184 } 1247 }
1185 case CSSPropertyBorderSpacing: 1248 case CSSPropertyBorderSpacing:
1186 return consumeBorderSpacing(important); 1249 return consumeBorderSpacing(important);
1187 default: 1250 default:
1188 m_currentShorthand = oldShorthand; 1251 m_currentShorthand = oldShorthand;
1189 return false; 1252 return false;
1190 } 1253 }
1191 } 1254 }
1192 1255
1193 } // namespace blink 1256 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698