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

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

Issue 1412803007: Parse text-decoration shorthand in CSSPropertyParser with CSSParserTokens (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Patch for landing Created 5 years, 1 month 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 419 matching lines...) Expand 10 before | Expand all | Expand 10 after
430 /* nobreak */ 430 /* nobreak */
431 case CSSPropertyBackgroundColor: // <color> | inherit 431 case CSSPropertyBackgroundColor: // <color> | inherit
432 case CSSPropertyBorderTopColor: // <color> | inherit 432 case CSSPropertyBorderTopColor: // <color> | inherit
433 case CSSPropertyBorderRightColor: 433 case CSSPropertyBorderRightColor:
434 case CSSPropertyBorderBottomColor: 434 case CSSPropertyBorderBottomColor:
435 case CSSPropertyBorderLeftColor: 435 case CSSPropertyBorderLeftColor:
436 case CSSPropertyWebkitBorderStartColor: 436 case CSSPropertyWebkitBorderStartColor:
437 case CSSPropertyWebkitBorderEndColor: 437 case CSSPropertyWebkitBorderEndColor:
438 case CSSPropertyWebkitBorderBeforeColor: 438 case CSSPropertyWebkitBorderBeforeColor:
439 case CSSPropertyWebkitBorderAfterColor: 439 case CSSPropertyWebkitBorderAfterColor:
440 case CSSPropertyTextDecorationColor: // CSS3 text decoration colors
441 case CSSPropertyWebkitColumnRuleColor: 440 case CSSPropertyWebkitColumnRuleColor:
442 case CSSPropertyWebkitTextEmphasisColor: 441 case CSSPropertyWebkitTextEmphasisColor:
443 case CSSPropertyWebkitTextStrokeColor: 442 case CSSPropertyWebkitTextStrokeColor:
444 ASSERT(propId != CSSPropertyTextDecorationColor || RuntimeEnabledFeature s::css3TextDecorationsEnabled());
445 parsedValue = parseColor(m_valueList->current(), acceptQuirkyColors(prop Id)); 443 parsedValue = parseColor(m_valueList->current(), acceptQuirkyColors(prop Id));
446 if (parsedValue) 444 if (parsedValue)
447 m_valueList->next(); 445 m_valueList->next();
448 break; 446 break;
449 447
450 case CSSPropertyCursor: { 448 case CSSPropertyCursor: {
451 // Grammar defined by CSS3 UI and modified by CSS4 images: 449 // Grammar defined by CSS3 UI and modified by CSS4 images:
452 // [ [<image> [<x> <y>]?,]* 450 // [ [<image> [<x> <y>]?,]*
453 // [ auto | crosshair | default | pointer | progress | move | e-resize | ne-resize | 451 // [ auto | crosshair | default | pointer | progress | move | e-resize | ne-resize |
454 // nw-resize | n-resize | se-resize | sw-resize | s-resize | w-resize | ew-resize | 452 // nw-resize | n-resize | se-resize | sw-resize | s-resize | w-resize | ew-resize |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
659 case CSSPropertyWebkitMarginStart: 657 case CSSPropertyWebkitMarginStart:
660 case CSSPropertyWebkitMarginEnd: 658 case CSSPropertyWebkitMarginEnd:
661 case CSSPropertyWebkitMarginBefore: 659 case CSSPropertyWebkitMarginBefore:
662 case CSSPropertyWebkitMarginAfter: 660 case CSSPropertyWebkitMarginAfter:
663 if (id == CSSValueAuto) 661 if (id == CSSValueAuto)
664 validPrimitive = true; 662 validPrimitive = true;
665 else 663 else
666 validPrimitive = validUnit(value, FLength | FPercent | unitless); 664 validPrimitive = validUnit(value, FLength | FPercent | unitless);
667 break; 665 break;
668 666
669 case CSSPropertyTextDecoration:
670 // Fall through 'text-decoration-line' parsing if CSS 3 Text Decoration
671 // is disabled to match CSS 2.1 rules for parsing 'text-decoration'.
672 if (RuntimeEnabledFeatures::css3TextDecorationsEnabled()) {
673 // [ <text-decoration-line> || <text-decoration-style> || <text-deco ration-color> ] | inherit
674 return parseShorthand(CSSPropertyTextDecoration, textDecorationShort hand(), important);
675 }
676 case CSSPropertyWebkitTextDecorationsInEffect:
677 case CSSPropertyTextDecorationLine:
678 // none | [ underline || overline || line-through || blink ] | inherit
679 parsedValue = parseTextDecoration();
680 break;
681
682 case CSSPropertyTextUnderlinePosition: 667 case CSSPropertyTextUnderlinePosition:
683 // auto | [ under || [ left | right ] ], but we only support auto | unde r for now 668 // auto | [ under || [ left | right ] ], but we only support auto | unde r for now
684 ASSERT(RuntimeEnabledFeatures::css3TextDecorationsEnabled()); 669 ASSERT(RuntimeEnabledFeatures::css3TextDecorationsEnabled());
685 validPrimitive = (id == CSSValueAuto || id == CSSValueUnder); 670 validPrimitive = (id == CSSValueAuto || id == CSSValueUnder);
686 break; 671 break;
687 672
688 case CSSPropertySrc: 673 case CSSPropertySrc:
689 case CSSPropertyUnicodeRange: 674 case CSSPropertyUnicodeRange:
690 /* @font-face only descriptors */ 675 /* @font-face only descriptors */
691 break; 676 break;
(...skipping 522 matching lines...) Expand 10 before | Expand all | Expand 10 after
1214 case CSSPropertyOrphans: 1199 case CSSPropertyOrphans:
1215 case CSSPropertyWidows: 1200 case CSSPropertyWidows:
1216 case CSSPropertyWebkitTapHighlightColor: 1201 case CSSPropertyWebkitTapHighlightColor:
1217 case CSSPropertyWebkitTextFillColor: 1202 case CSSPropertyWebkitTextFillColor:
1218 case CSSPropertyColor: 1203 case CSSPropertyColor:
1219 case CSSPropertyZIndex: 1204 case CSSPropertyZIndex:
1220 case CSSPropertyTextShadow: 1205 case CSSPropertyTextShadow:
1221 case CSSPropertyBoxShadow: 1206 case CSSPropertyBoxShadow:
1222 case CSSPropertyWebkitFilter: 1207 case CSSPropertyWebkitFilter:
1223 case CSSPropertyBackdropFilter: 1208 case CSSPropertyBackdropFilter:
1209 case CSSPropertyTextDecorationColor:
1210 case CSSPropertyWebkitTextDecorationsInEffect:
1211 case CSSPropertyTextDecorationLine:
1212 case CSSPropertyTextDecoration:
1224 validPrimitive = false; 1213 validPrimitive = false;
1225 break; 1214 break;
1226 1215
1227 case CSSPropertyScrollSnapPointsX: 1216 case CSSPropertyScrollSnapPointsX:
1228 case CSSPropertyScrollSnapPointsY: 1217 case CSSPropertyScrollSnapPointsY:
1229 parsedValue = parseScrollSnapPoints(); 1218 parsedValue = parseScrollSnapPoints();
1230 break; 1219 break;
1231 case CSSPropertyScrollSnapCoordinate: 1220 case CSSPropertyScrollSnapCoordinate:
1232 parsedValue = parseScrollSnapCoordinate(); 1221 parsedValue = parseScrollSnapCoordinate();
1233 break; 1222 break;
(...skipping 4163 matching lines...) Expand 10 before | Expand all | Expand 10 after
5397 5386
5398 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createSpaceSeparated() ; 5387 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createSpaceSeparated() ;
5399 list->append(xValue.release()); 5388 list->append(xValue.release());
5400 if (yValue) 5389 if (yValue)
5401 list->append(yValue.release()); 5390 list->append(yValue.release());
5402 if (zValue) 5391 if (zValue)
5403 list->append(zValue.release()); 5392 list->append(zValue.release());
5404 return list.release(); 5393 return list.release();
5405 } 5394 }
5406 5395
5407 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseTextDecoration()
5408 {
5409 CSSParserValue* value = m_valueList->current();
5410 if (value && value->id == CSSValueNone) {
5411 m_valueList->next();
5412 return cssValuePool().createIdentifierValue(CSSValueNone);
5413 }
5414
5415 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createSpaceSeparated() ;
5416 bool isValid = true;
5417 while (isValid && value) {
5418 switch (value->id) {
5419 case CSSValueUnderline:
5420 case CSSValueOverline:
5421 case CSSValueLineThrough:
5422 case CSSValueBlink:
5423 // TODO(timloh): This will incorrectly accept "blink blink"
5424 list->append(cssValuePool().createIdentifierValue(value->id));
5425 break;
5426 default:
5427 isValid = false;
5428 break;
5429 }
5430 if (isValid)
5431 value = m_valueList->next();
5432 }
5433
5434 // Values are either valid or in shorthand scope.
5435 if (list->length())
5436 return list.release();
5437 return nullptr;
5438 }
5439
5440 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseTextEmphasisStyle() 5396 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseTextEmphasisStyle()
5441 { 5397 {
5442 RefPtrWillBeRawPtr<CSSPrimitiveValue> fill = nullptr; 5398 RefPtrWillBeRawPtr<CSSPrimitiveValue> fill = nullptr;
5443 RefPtrWillBeRawPtr<CSSPrimitiveValue> shape = nullptr; 5399 RefPtrWillBeRawPtr<CSSPrimitiveValue> shape = nullptr;
5444 5400
5445 for (CSSParserValue* value = m_valueList->current(); value; value = m_valueL ist->next()) { 5401 for (CSSParserValue* value = m_valueList->current(); value; value = m_valueL ist->next()) {
5446 if (value->m_unit == CSSParserValue::String) { 5402 if (value->m_unit == CSSParserValue::String) {
5447 if (fill || shape) 5403 if (fill || shape)
5448 return nullptr; 5404 return nullptr;
5449 m_valueList->next(); 5405 m_valueList->next();
(...skipping 606 matching lines...) Expand 10 before | Expand all | Expand 10 after
6056 } 6012 }
6057 } 6013 }
6058 6014
6059 if (!list->length()) 6015 if (!list->length())
6060 return nullptr; 6016 return nullptr;
6061 6017
6062 return list.release(); 6018 return list.release();
6063 } 6019 }
6064 6020
6065 } // namespace blink 6021 } // 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