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

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

Issue 1441233006: Move remaining SVG properties into CSSPropertyParser (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 5 years 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 1074 matching lines...) Expand 10 before | Expand all | Expand 10 after
1085 case CSSPropertyMarkerEnd: 1085 case CSSPropertyMarkerEnd:
1086 case CSSPropertyFlex: 1086 case CSSPropertyFlex:
1087 case CSSPropertyFlexBasis: 1087 case CSSPropertyFlexBasis:
1088 case CSSPropertyFlexGrow: 1088 case CSSPropertyFlexGrow:
1089 case CSSPropertyFlexShrink: 1089 case CSSPropertyFlexShrink:
1090 case CSSPropertyFlexFlow: 1090 case CSSPropertyFlexFlow:
1091 case CSSPropertyStrokeDasharray: 1091 case CSSPropertyStrokeDasharray:
1092 case CSSPropertyWebkitColumnRule: 1092 case CSSPropertyWebkitColumnRule:
1093 case CSSPropertyWebkitColumnRuleColor: 1093 case CSSPropertyWebkitColumnRuleColor:
1094 case CSSPropertyWebkitColumnRuleWidth: 1094 case CSSPropertyWebkitColumnRuleWidth:
1095 case CSSPropertyClipPath:
1096 case CSSPropertyFilter:
1097 case CSSPropertyMask:
1098 case CSSPropertyStrokeOpacity:
1099 case CSSPropertyFillOpacity:
1100 case CSSPropertyStopOpacity:
1101 case CSSPropertyFloodOpacity:
1102 case CSSPropertyBaselineShift:
1103 case CSSPropertyStrokeMiterlimit:
1104 case CSSPropertyStrokeWidth:
1105 case CSSPropertyStrokeDashoffset:
1106 case CSSPropertyCx:
1107 case CSSPropertyCy:
1108 case CSSPropertyX:
1109 case CSSPropertyY:
1110 case CSSPropertyR:
1111 case CSSPropertyRx:
1112 case CSSPropertyRy:
1095 validPrimitive = false; 1113 validPrimitive = false;
1096 break; 1114 break;
1097 1115
1098 case CSSPropertyScrollSnapPointsX: 1116 case CSSPropertyScrollSnapPointsX:
1099 case CSSPropertyScrollSnapPointsY: 1117 case CSSPropertyScrollSnapPointsY:
1100 parsedValue = parseScrollSnapPoints(); 1118 parsedValue = parseScrollSnapPoints();
1101 break; 1119 break;
1102 case CSSPropertyScrollSnapCoordinate: 1120 case CSSPropertyScrollSnapCoordinate:
1103 parsedValue = parseScrollSnapCoordinate(); 1121 parsedValue = parseScrollSnapCoordinate();
1104 break; 1122 break;
1105 case CSSPropertyScrollSnapDestination: 1123 case CSSPropertyScrollSnapDestination:
1106 parsedValue = parsePosition(m_valueList); 1124 parsedValue = parsePosition(m_valueList);
1107 break; 1125 break;
1108 1126
1109 default: 1127 default:
1110 return parseSVGValue(propId, important); 1128 // If you crash here, it's because you added a css property and are not handling it
1129 // in either this switch statement or the one in CSSPropertyParser::pars eValue
Timothy Loh 2015/11/30 06:09:57 probably should update this to.. ::parseSingleValu
rwlbuis 2015/11/30 22:17:43 Done.
1130 ASSERT_WITH_MESSAGE(0, "unimplemented propertyID: %d", propId);
1131 return false;
1111 } 1132 }
1112 1133
1113 if (validPrimitive) { 1134 if (validPrimitive) {
1114 parsedValue = parseValidPrimitive(id, value); 1135 parsedValue = parseValidPrimitive(id, value);
1115 m_valueList->next(); 1136 m_valueList->next();
1116 } 1137 }
1117 ASSERT(!m_parsedCalculation); 1138 ASSERT(!m_parsedCalculation);
1118 if (parsedValue) { 1139 if (parsedValue) {
1119 if (!m_valueList->current() || inShorthand()) { 1140 if (!m_valueList->current() || inShorthand()) {
1120 addProperty(propId, parsedValue.release(), important); 1141 addProperty(propId, parsedValue.release(), important);
(...skipping 4167 matching lines...) Expand 10 before | Expand all | Expand 10 after
5288 return CSSValueInvalid; 5309 return CSSValueInvalid;
5289 5310
5290 return string.is8Bit() ? cssValueKeywordID(string.characters8(), length) : c ssValueKeywordID(string.characters16(), length); 5311 return string.is8Bit() ? cssValueKeywordID(string.characters8(), length) : c ssValueKeywordID(string.characters16(), length);
5291 } 5312 }
5292 5313
5293 bool CSSPropertyParser::isSystemColor(CSSValueID id) 5314 bool CSSPropertyParser::isSystemColor(CSSValueID id)
5294 { 5315 {
5295 return (id >= CSSValueActiveborder && id <= CSSValueWindowtext) || id == CSS ValueMenu; 5316 return (id >= CSSValueActiveborder && id <= CSSValueWindowtext) || id == CSS ValueMenu;
5296 } 5317 }
5297 5318
5298 bool CSSPropertyParser::parseSVGValue(CSSPropertyID propId, bool important)
5299 {
5300 CSSParserValue* value = m_valueList->current();
5301 ASSERT(value);
5302
5303 CSSValueID id = value->id;
5304
5305 bool validPrimitive = false;
5306 RefPtrWillBeRawPtr<CSSValue> parsedValue = nullptr;
5307
5308 switch (propId) {
5309 /* The comment to the right defines all valid value of these
5310 * properties as defined in SVG 1.1, Appendix N. Property index */
5311 case CSSPropertyBaselineShift:
5312 // baseline | super | sub | <percentage> | <length> | inherit
5313 if (id == CSSValueBaseline || id == CSSValueSub || id == CSSValueSuper)
5314 validPrimitive = true;
5315 else
5316 validPrimitive = validUnit(value, FLength | FPercent, SVGAttributeMo de);
5317 break;
5318
5319 case CSSPropertyClipPath:
5320 case CSSPropertyFilter:
5321 case CSSPropertyMask:
5322 if (id == CSSValueNone) {
5323 validPrimitive = true;
5324 } else if (value->m_unit == CSSParserValue::URI) {
5325 parsedValue = CSSURIValue::create(value->string);
5326 if (parsedValue)
5327 m_valueList->next();
5328 }
5329 break;
5330
5331 case CSSPropertyStrokeMiterlimit: // <miterlimit> | inherit
5332 validPrimitive = validUnit(value, FNumber | FNonNeg, SVGAttributeMode);
5333 break;
5334
5335 case CSSPropertyStrokeOpacity: // <opacity-value> | inherit
5336 case CSSPropertyFillOpacity:
5337 case CSSPropertyStopOpacity:
5338 case CSSPropertyFloodOpacity:
5339 validPrimitive = validUnit(value, FNumber | FPercent, SVGAttributeMode);
5340 break;
5341
5342 /* Start of supported CSS properties with validation. This is needed for par seShortHand to work
5343 * correctly and allows optimization in applyRule(..)
5344 */
5345
5346 case CSSPropertyStrokeWidth: // <length> | inherit
5347 case CSSPropertyStrokeDashoffset:
5348 case CSSPropertyCx:
5349 case CSSPropertyCy:
5350 case CSSPropertyX:
5351 case CSSPropertyY:
5352 case CSSPropertyR:
5353 case CSSPropertyRx:
5354 case CSSPropertyRy:
5355 validPrimitive = validUnit(value, FLength | FPercent, SVGAttributeMode);
5356 break;
5357
5358 default:
5359 // If you crash here, it's because you added a css property and are not handling it
5360 // in either this switch statement or the one in CSSPropertyParser::pars eValue
5361 ASSERT_WITH_MESSAGE(0, "unimplemented propertyID: %d", propId);
5362 return false;
5363 }
5364
5365 if (validPrimitive) {
5366 if (id)
5367 parsedValue = CSSPrimitiveValue::createIdentifier(id);
5368 else if (value->m_unit == CSSParserValue::String)
5369 parsedValue = CSSStringValue::create(value->string);
5370 else if (value->unit() >= CSSPrimitiveValue::UnitType::Number && value-> unit() <= CSSPrimitiveValue::UnitType::Kilohertz)
5371 parsedValue = CSSPrimitiveValue::create(value->fValue, value->unit() );
5372 else if (value->unit() == CSSPrimitiveValue::UnitType::Rems || value->un it() == CSSPrimitiveValue::UnitType::Chs)
5373 parsedValue = CSSPrimitiveValue::create(value->fValue, value->unit() );
5374 else if (value->unit() == CSSPrimitiveValue::UnitType::QuirkyEms)
5375 parsedValue = CSSPrimitiveValue::create(value->fValue, CSSPrimitiveV alue::UnitType::QuirkyEms);
5376 if (isCalculation(value)) {
5377 // FIXME calc() http://webkit.org/b/16662 : actually create a CSSPri mitiveValue here, ie
5378 // parsedValue = CSSPrimitiveValue::create(m_parsedCalculation.relea se());
5379 m_parsedCalculation.release();
5380 parsedValue = nullptr;
5381 }
5382 m_valueList->next();
5383 }
5384 if (!parsedValue || (m_valueList->current() && !inShorthand()))
5385 return false;
5386
5387 addProperty(propId, parsedValue.release(), important);
5388 return true;
5389 }
5390
5391 } // namespace blink 5319 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698