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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/css/parser/CSSPropertyParser.cpp
diff --git a/third_party/WebKit/Source/core/css/parser/CSSPropertyParser.cpp b/third_party/WebKit/Source/core/css/parser/CSSPropertyParser.cpp
index 74823b2295cd23ee6631267c0b8f68aa2298ac43..175315f01de8f1819bf41d823dc94fdb2843718b 100644
--- a/third_party/WebKit/Source/core/css/parser/CSSPropertyParser.cpp
+++ b/third_party/WebKit/Source/core/css/parser/CSSPropertyParser.cpp
@@ -754,6 +754,53 @@ static PassRefPtrWillBeRawPtr<CSSValue> consumeTextIndent(CSSParserTokenRange& r
return list.release();
}
+static bool validWidthOrHeightKeyword(CSSValueID id, const CSSParserContext& context)
+{
+ if (id == CSSValueIntrinsic || id == CSSValueMinIntrinsic
+ || id == CSSValueWebkitMinContent || id == CSSValueWebkitMaxContent || id == CSSValueWebkitFillAvailable || id == CSSValueWebkitFitContent
+ || id == CSSValueMinContent || id == CSSValueMaxContent || id == CSSValueFitContent) {
+ if (context.useCounter()) {
+ switch (id) {
+ case CSSValueIntrinsic:
+ case CSSValueMinIntrinsic:
+ // These two will be counted in StyleAdjuster because they emit a deprecation
+ // message, and we don't have access to a Document/LocalFrame here.
+ break;
+ case CSSValueWebkitMinContent:
+ context.useCounter()->count(UseCounter::CSSValuePrefixedMinContent);
+ break;
+ case CSSValueWebkitMaxContent:
+ context.useCounter()->count(UseCounter::CSSValuePrefixedMaxContent);
+ break;
+ case CSSValueWebkitFillAvailable:
+ context.useCounter()->count(UseCounter::CSSValuePrefixedFillAvailable);
+ break;
+ case CSSValueWebkitFitContent:
+ context.useCounter()->count(UseCounter::CSSValuePrefixedFitContent);
+ break;
+ default:
+ break;
+ }
+ }
+ return true;
+ }
+ return false;
+}
+
+static PassRefPtrWillBeRawPtr<CSSValue> consumeMaxWidthOrHeight(CSSParserTokenRange& range, const CSSParserContext& context, UnitlessQuirk unitless = UnitlessQuirk::Forbid)
+{
+ if (range.peek().id() == CSSValueNone || validWidthOrHeightKeyword(range.peek().id(), context))
+ return consumeIdent(range);
+ return consumeLengthOrPercent(range, context.mode(), ValueRangeNonNegative, unitless);
+}
+
+static PassRefPtrWillBeRawPtr<CSSValue> consumeWidthOrHeight(CSSParserTokenRange& range, const CSSParserContext& context, UnitlessQuirk unitless = UnitlessQuirk::Forbid)
+{
+ if (range.peek().id() == CSSValueAuto || validWidthOrHeightKeyword(range.peek().id(), context))
+ return consumeIdent(range);
+ return consumeLengthOrPercent(range, context.mode(), ValueRangeNonNegative, unitless);
+}
+
PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseSingleValue(CSSPropertyID propId)
{
m_range.consumeWhitespace();
@@ -797,6 +844,22 @@ PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseSingleValue(CSSProperty
return consumeSize(m_range, m_context.mode());
case CSSPropertyTextIndent:
return consumeTextIndent(m_range, m_context.mode());
+ case CSSPropertyMaxWidth:
+ case CSSPropertyMaxHeight:
+ return consumeMaxWidthOrHeight(m_range, m_context, UnitlessQuirk::Allow);
+ case CSSPropertyWebkitMaxLogicalWidth:
+ case CSSPropertyWebkitMaxLogicalHeight:
+ return consumeMaxWidthOrHeight(m_range, m_context);
+ case CSSPropertyMinWidth:
+ case CSSPropertyMinHeight:
+ case CSSPropertyWidth:
+ case CSSPropertyHeight:
+ return consumeWidthOrHeight(m_range, m_context, UnitlessQuirk::Allow);
+ case CSSPropertyWebkitMinLogicalWidth:
+ case CSSPropertyWebkitMinLogicalHeight:
+ case CSSPropertyWebkitLogicalWidth:
+ case CSSPropertyWebkitLogicalHeight:
+ return consumeWidthOrHeight(m_range, m_context);
default:
return nullptr;
}

Powered by Google App Engine
This is Rietveld 408576698