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

Side by Side Diff: Source/WebCore/css/CSSParser.cpp

Issue 13674002: Support intrinsic values for height, min-height and max-height (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: better fixme comment Created 7 years, 8 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 /* 1 /*
2 * Copyright (C) 2003 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 2003 Lars Knoll (knoll@kde.org)
3 * Copyright (C) 2005 Allan Sandfeld Jensen (kde@carewolf.com) 3 * Copyright (C) 2005 Allan Sandfeld Jensen (kde@carewolf.com)
4 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights reserved. 4 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights reserved.
5 * Copyright (C) 2007 Nicholas Shanks <webkit@nickshanks.com> 5 * Copyright (C) 2007 Nicholas Shanks <webkit@nickshanks.com>
6 * Copyright (C) 2008 Eric Seidel <eric@webkit.org> 6 * Copyright (C) 2008 Eric Seidel <eric@webkit.org>
7 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/) 7 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/)
8 * Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved. 8 * Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved.
9 * Copyright (C) 2012 Intel Corporation. All rights reserved. 9 * Copyright (C) 2012 Intel Corporation. All rights reserved.
10 * 10 *
(...skipping 1744 matching lines...) Expand 10 before | Expand all | Expand 10 after
1755 { 1755 {
1756 return value && value->unit == CSSParserValue::Operator && value->iValue == ','; 1756 return value && value->unit == CSSParserValue::Operator && value->iValue == ',';
1757 } 1757 }
1758 1758
1759 static inline bool isForwardSlashOperator(CSSParserValue* value) 1759 static inline bool isForwardSlashOperator(CSSParserValue* value)
1760 { 1760 {
1761 ASSERT(value); 1761 ASSERT(value);
1762 return value->unit == CSSParserValue::Operator && value->iValue == '/'; 1762 return value->unit == CSSParserValue::Operator && value->iValue == '/';
1763 } 1763 }
1764 1764
1765 bool CSSParser::validWidth(CSSParserValue* value) 1765 bool CSSParser::validWidthOrHeight(CSSParserValue* value)
1766 { 1766 {
1767 int id = value->id; 1767 int id = value->id;
1768 if (id == CSSValueIntrinsic || id == CSSValueMinIntrinsic || id == CSSValueW ebkitMinContent || id == CSSValueWebkitMaxContent || id == CSSValueWebkitFillAva ilable || id == CSSValueWebkitFitContent) 1768 if (id == CSSValueIntrinsic || id == CSSValueMinIntrinsic || id == CSSValueW ebkitMinContent || id == CSSValueWebkitMaxContent || id == CSSValueWebkitFillAva ilable || id == CSSValueWebkitFitContent)
1769 return true; 1769 return true;
1770 return !id && validUnit(value, FLength | FPercent | FNonNeg); 1770 return !id && validUnit(value, FLength | FPercent | FNonNeg);
1771 } 1771 }
1772 1772
1773 // FIXME: Combine this with validWidth when we support fit-content, et al, for h eights.
1774 bool CSSParser::validHeight(CSSParserValue* value)
1775 {
1776 int id = value->id;
1777 if (id == CSSValueIntrinsic || id == CSSValueMinIntrinsic)
1778 return true;
1779 return !id && validUnit(value, FLength | FPercent | FNonNeg);
1780 }
1781
1782 inline PassRefPtr<CSSPrimitiveValue> CSSParser::parseValidPrimitive(int identifi er, CSSParserValue* value) 1773 inline PassRefPtr<CSSPrimitiveValue> CSSParser::parseValidPrimitive(int identifi er, CSSParserValue* value)
1783 { 1774 {
1784 if (identifier) 1775 if (identifier)
1785 return cssValuePool().createIdentifierValue(identifier); 1776 return cssValuePool().createIdentifierValue(identifier);
1786 if (value->unit == CSSPrimitiveValue::CSS_STRING) 1777 if (value->unit == CSSPrimitiveValue::CSS_STRING)
1787 return createPrimitiveStringValue(value); 1778 return createPrimitiveStringValue(value);
1788 if (value->unit >= CSSPrimitiveValue::CSS_NUMBER && value->unit <= CSSPrimit iveValue::CSS_KHZ) 1779 if (value->unit >= CSSPrimitiveValue::CSS_NUMBER && value->unit <= CSSPrimit iveValue::CSS_KHZ)
1789 return createPrimitiveNumericValue(value); 1780 return createPrimitiveNumericValue(value);
1790 if (value->unit >= CSSPrimitiveValue::CSS_TURN && value->unit <= CSSPrimitiv eValue::CSS_CHS) 1781 if (value->unit >= CSSPrimitiveValue::CSS_TURN && value->unit <= CSSPrimitiv eValue::CSS_CHS)
1791 return createPrimitiveNumericValue(value); 1782 return createPrimitiveNumericValue(value);
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after
2202 case CSSPropertyPaddingLeft: //// 2193 case CSSPropertyPaddingLeft: ////
2203 case CSSPropertyWebkitPaddingStart: 2194 case CSSPropertyWebkitPaddingStart:
2204 case CSSPropertyWebkitPaddingEnd: 2195 case CSSPropertyWebkitPaddingEnd:
2205 case CSSPropertyWebkitPaddingBefore: 2196 case CSSPropertyWebkitPaddingBefore:
2206 case CSSPropertyWebkitPaddingAfter: 2197 case CSSPropertyWebkitPaddingAfter:
2207 validPrimitive = (!id && validUnit(value, FLength | FPercent | FNonNeg)) ; 2198 validPrimitive = (!id && validUnit(value, FLength | FPercent | FNonNeg)) ;
2208 break; 2199 break;
2209 2200
2210 case CSSPropertyMaxWidth: 2201 case CSSPropertyMaxWidth:
2211 case CSSPropertyWebkitMaxLogicalWidth: 2202 case CSSPropertyWebkitMaxLogicalWidth:
2212 validPrimitive = (id == CSSValueNone || validWidth(value)); 2203 validPrimitive = (id == CSSValueNone || validWidthOrHeight(value));
2213 break; 2204 break;
2214 2205
2215 case CSSPropertyMinWidth: 2206 case CSSPropertyMinWidth:
2216 case CSSPropertyWebkitMinLogicalWidth: 2207 case CSSPropertyWebkitMinLogicalWidth:
2217 validPrimitive = validWidth(value); 2208 validPrimitive = validWidthOrHeight(value);
2218 break; 2209 break;
2219 2210
2220 case CSSPropertyWidth: 2211 case CSSPropertyWidth:
2221 case CSSPropertyWebkitLogicalWidth: 2212 case CSSPropertyWebkitLogicalWidth:
2222 validPrimitive = (id == CSSValueAuto || validWidth(value)); 2213 validPrimitive = (id == CSSValueAuto || validWidthOrHeight(value));
2223 break; 2214 break;
2224 2215
2225 case CSSPropertyMaxHeight: 2216 case CSSPropertyMaxHeight:
2226 case CSSPropertyWebkitMaxLogicalHeight: 2217 case CSSPropertyWebkitMaxLogicalHeight:
2227 validPrimitive = (id == CSSValueNone || validHeight(value)); 2218 validPrimitive = (id == CSSValueNone || validWidthOrHeight(value));
ojan 2013/04/11 03:21:46 You can merge this with the Width equivalent case.
cbiesinger 2013/04/12 01:17:52 Done.
2228 break; 2219 break;
2229 2220
2230 case CSSPropertyMinHeight: 2221 case CSSPropertyMinHeight:
2231 case CSSPropertyWebkitMinLogicalHeight: 2222 case CSSPropertyWebkitMinLogicalHeight:
2232 validPrimitive = validHeight(value); 2223 validPrimitive = validWidthOrHeight(value);
2233 break; 2224 break;
2234 2225
2235 case CSSPropertyHeight: 2226 case CSSPropertyHeight:
2236 case CSSPropertyWebkitLogicalHeight: 2227 case CSSPropertyWebkitLogicalHeight:
2237 validPrimitive = (id == CSSValueAuto || validHeight(value)); 2228 validPrimitive = (id == CSSValueAuto || validWidthOrHeight(value));
2238 break; 2229 break;
2239 2230
2240 case CSSPropertyFontSize: 2231 case CSSPropertyFontSize:
2241 return parseFontSize(important); 2232 return parseFontSize(important);
2242 2233
2243 case CSSPropertyFontVariant: // normal | small-caps | inherit 2234 case CSSPropertyFontVariant: // normal | small-caps | inherit
2244 return parseFontVariant(important); 2235 return parseFontVariant(important);
2245 2236
2246 case CSSPropertyVerticalAlign: 2237 case CSSPropertyVerticalAlign:
2247 // baseline | sub | super | top | text-top | middle | bottom | text-bott om | 2238 // baseline | sub | super | top | text-top | middle | bottom | text-bott om |
(...skipping 9946 matching lines...) Expand 10 before | Expand all | Expand 10 after
12194 { 12185 {
12195 // The tokenizer checks for the construct of an+b. 12186 // The tokenizer checks for the construct of an+b.
12196 // However, since the {ident} rule precedes the {nth} rule, some of those 12187 // However, since the {ident} rule precedes the {nth} rule, some of those
12197 // tokens are identified as string literal. Furthermore we need to accept 12188 // tokens are identified as string literal. Furthermore we need to accept
12198 // "odd" and "even" which does not match to an+b. 12189 // "odd" and "even" which does not match to an+b.
12199 return equalIgnoringCase(token, "odd") || equalIgnoringCase(token, "even") 12190 return equalIgnoringCase(token, "odd") || equalIgnoringCase(token, "even")
12200 || equalIgnoringCase(token, "n") || equalIgnoringCase(token, "-n"); 12191 || equalIgnoringCase(token, "n") || equalIgnoringCase(token, "-n");
12201 } 12192 }
12202 12193
12203 } 12194 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698