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

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

Issue 1398553002: Move counter-increment/counter-reset handling into CSSPropertyParser (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Work around ::lowest problem 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
« no previous file with comments | « third_party/WebKit/Source/core/css/parser/CSSPropertyParser.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 732 matching lines...) Expand 10 before | Expand all | Expand 10 after
743 743
744 case CSSPropertyZIndex: // auto | <integer> | inherit 744 case CSSPropertyZIndex: // auto | <integer> | inherit
745 if (id == CSSValueAuto) { 745 if (id == CSSValueAuto) {
746 validPrimitive = true; 746 validPrimitive = true;
747 } else if (validUnit(value, FInteger)) { 747 } else if (validUnit(value, FInteger)) {
748 addProperty(propId, cssValuePool().createValue(value->fValue, CSSPri mitiveValue::UnitType::Integer), important); 748 addProperty(propId, cssValuePool().createValue(value->fValue, CSSPri mitiveValue::UnitType::Integer), important);
749 return true; 749 return true;
750 } 750 }
751 break; 751 break;
752 752
753 case CSSPropertyCounterIncrement:
754 if (id == CSSValueNone)
755 validPrimitive = true;
756 else
757 parsedValue = parseCounter(1);
758 break;
759 case CSSPropertyCounterReset:
760 if (id == CSSValueNone)
761 validPrimitive = true;
762 else
763 parsedValue = parseCounter(0);
764 break;
765
766 case CSSPropertyTextDecoration: 753 case CSSPropertyTextDecoration:
767 // Fall through 'text-decoration-line' parsing if CSS 3 Text Decoration 754 // Fall through 'text-decoration-line' parsing if CSS 3 Text Decoration
768 // is disabled to match CSS 2.1 rules for parsing 'text-decoration'. 755 // is disabled to match CSS 2.1 rules for parsing 'text-decoration'.
769 if (RuntimeEnabledFeatures::css3TextDecorationsEnabled()) { 756 if (RuntimeEnabledFeatures::css3TextDecorationsEnabled()) {
770 // [ <text-decoration-line> || <text-decoration-style> || <text-deco ration-color> ] | inherit 757 // [ <text-decoration-line> || <text-decoration-style> || <text-deco ration-color> ] | inherit
771 return parseShorthand(CSSPropertyTextDecoration, textDecorationShort hand(), important); 758 return parseShorthand(CSSPropertyTextDecoration, textDecorationShort hand(), important);
772 } 759 }
773 case CSSPropertyWebkitTextDecorationsInEffect: 760 case CSSPropertyWebkitTextDecorationsInEffect:
774 case CSSPropertyTextDecorationLine: 761 case CSSPropertyTextDecorationLine:
775 // none | [ underline || overline || line-through || blink ] | inherit 762 // none | [ underline || overline || line-through || blink ] | inherit
(...skipping 585 matching lines...) Expand 10 before | Expand all | Expand 10 after
1361 case CSSPropertyLetterSpacing: 1348 case CSSPropertyLetterSpacing:
1362 case CSSPropertyWordSpacing: 1349 case CSSPropertyWordSpacing:
1363 case CSSPropertyTabSize: 1350 case CSSPropertyTabSize:
1364 case CSSPropertyFontSize: 1351 case CSSPropertyFontSize:
1365 case CSSPropertyLineHeight: 1352 case CSSPropertyLineHeight:
1366 case CSSPropertyRotate: 1353 case CSSPropertyRotate:
1367 case CSSPropertyFont: 1354 case CSSPropertyFont:
1368 case CSSPropertyWebkitBorderHorizontalSpacing: 1355 case CSSPropertyWebkitBorderHorizontalSpacing:
1369 case CSSPropertyWebkitBorderVerticalSpacing: 1356 case CSSPropertyWebkitBorderVerticalSpacing:
1370 case CSSPropertyBorderSpacing: 1357 case CSSPropertyBorderSpacing:
1358 case CSSPropertyCounterIncrement:
1359 case CSSPropertyCounterReset:
1371 validPrimitive = false; 1360 validPrimitive = false;
1372 break; 1361 break;
1373 1362
1374 case CSSPropertyScrollSnapPointsX: 1363 case CSSPropertyScrollSnapPointsX:
1375 case CSSPropertyScrollSnapPointsY: 1364 case CSSPropertyScrollSnapPointsY:
1376 parsedValue = parseScrollSnapPoints(); 1365 parsedValue = parseScrollSnapPoints();
1377 break; 1366 break;
1378 case CSSPropertyScrollSnapCoordinate: 1367 case CSSPropertyScrollSnapCoordinate:
1379 parsedValue = parseScrollSnapCoordinate(); 1368 parsedValue = parseScrollSnapCoordinate();
1380 break; 1369 break;
(...skipping 3900 matching lines...) Expand 10 before | Expand all | Expand 10 after
5281 completeBorderRadii(radii[1]); 5270 completeBorderRadii(radii[1]);
5282 5271
5283 ImplicitScope implicitScope(this); 5272 ImplicitScope implicitScope(this);
5284 addProperty(CSSPropertyBorderTopLeftRadius, CSSValuePair::create(radii[0][0] .release(), radii[1][0].release(), CSSValuePair::DropIdenticalValues), important ); 5273 addProperty(CSSPropertyBorderTopLeftRadius, CSSValuePair::create(radii[0][0] .release(), radii[1][0].release(), CSSValuePair::DropIdenticalValues), important );
5285 addProperty(CSSPropertyBorderTopRightRadius, CSSValuePair::create(radii[0][1 ].release(), radii[1][1].release(), CSSValuePair::DropIdenticalValues), importan t); 5274 addProperty(CSSPropertyBorderTopRightRadius, CSSValuePair::create(radii[0][1 ].release(), radii[1][1].release(), CSSValuePair::DropIdenticalValues), importan t);
5286 addProperty(CSSPropertyBorderBottomRightRadius, CSSValuePair::create(radii[0 ][2].release(), radii[1][2].release(), CSSValuePair::DropIdenticalValues), impor tant); 5275 addProperty(CSSPropertyBorderBottomRightRadius, CSSValuePair::create(radii[0 ][2].release(), radii[1][2].release(), CSSValuePair::DropIdenticalValues), impor tant);
5287 addProperty(CSSPropertyBorderBottomLeftRadius, CSSValuePair::create(radii[0] [3].release(), radii[1][3].release(), CSSValuePair::DropIdenticalValues), import ant); 5276 addProperty(CSSPropertyBorderBottomLeftRadius, CSSValuePair::create(radii[0] [3].release(), radii[1][3].release(), CSSValuePair::DropIdenticalValues), import ant);
5288 return true; 5277 return true;
5289 } 5278 }
5290 5279
5291 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseCounter(int defaultValu e)
5292 {
5293 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createCommaSeparated() ;
5294
5295 while (m_valueList->current()) {
5296 CSSParserValue* val = m_valueList->current();
5297 if (val->m_unit != CSSParserValue::Identifier)
5298 return nullptr;
5299 RefPtrWillBeRawPtr<CSSCustomIdentValue> counterName = createPrimitiveCus tomIdentValue(val);
5300 m_valueList->next();
5301
5302 val = m_valueList->current();
5303 int i = defaultValue;
5304 if (val && validUnit(val, FInteger)) {
5305 i = clampTo<int>(val->fValue);
5306 m_valueList->next();
5307 }
5308
5309 list->append(CSSValuePair::create(counterName.release(),
5310 cssValuePool().createValue(i, CSSPrimitiveValue::UnitType::Number),
5311 CSSValuePair::DropIdenticalValues));
5312 }
5313
5314 if (!list->length())
5315 return nullptr;
5316 return list.release();
5317 }
5318
5319 // This should go away once we drop support for -webkit-gradient 5280 // This should go away once we drop support for -webkit-gradient
5320 static PassRefPtrWillBeRawPtr<CSSPrimitiveValue> parseDeprecatedGradientPoint(CS SParserValue* a, bool horizontal) 5281 static PassRefPtrWillBeRawPtr<CSSPrimitiveValue> parseDeprecatedGradientPoint(CS SParserValue* a, bool horizontal)
5321 { 5282 {
5322 RefPtrWillBeRawPtr<CSSPrimitiveValue> result = nullptr; 5283 RefPtrWillBeRawPtr<CSSPrimitiveValue> result = nullptr;
5323 if (a->m_unit == CSSParserValue::Identifier) { 5284 if (a->m_unit == CSSParserValue::Identifier) {
5324 if ((a->id == CSSValueLeft && horizontal) 5285 if ((a->id == CSSValueLeft && horizontal)
5325 || (a->id == CSSValueTop && !horizontal)) 5286 || (a->id == CSSValueTop && !horizontal))
5326 result = cssValuePool().createValue(0., CSSPrimitiveValue::UnitType: :Percentage); 5287 result = cssValuePool().createValue(0., CSSPrimitiveValue::UnitType: :Percentage);
5327 else if ((a->id == CSSValueRight && horizontal) 5288 else if ((a->id == CSSValueRight && horizontal)
5328 || (a->id == CSSValueBottom && !horizontal)) 5289 || (a->id == CSSValueBottom && !horizontal))
(...skipping 1770 matching lines...) Expand 10 before | Expand all | Expand 10 after
7099 } 7060 }
7100 } 7061 }
7101 7062
7102 if (!list->length()) 7063 if (!list->length())
7103 return nullptr; 7064 return nullptr;
7104 7065
7105 return list.release(); 7066 return list.release();
7106 } 7067 }
7107 7068
7108 } // namespace blink 7069 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/css/parser/CSSPropertyParser.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698