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

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: Alternative fix 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
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 412 matching lines...) Expand 10 before | Expand all | Expand 10 after
423 /* nobreak */ 423 /* nobreak */
424 case CSSPropertyBackgroundColor: // <color> | inherit 424 case CSSPropertyBackgroundColor: // <color> | inherit
425 case CSSPropertyBorderTopColor: // <color> | inherit 425 case CSSPropertyBorderTopColor: // <color> | inherit
426 case CSSPropertyBorderRightColor: 426 case CSSPropertyBorderRightColor:
427 case CSSPropertyBorderBottomColor: 427 case CSSPropertyBorderBottomColor:
428 case CSSPropertyBorderLeftColor: 428 case CSSPropertyBorderLeftColor:
429 case CSSPropertyWebkitBorderStartColor: 429 case CSSPropertyWebkitBorderStartColor:
430 case CSSPropertyWebkitBorderEndColor: 430 case CSSPropertyWebkitBorderEndColor:
431 case CSSPropertyWebkitBorderBeforeColor: 431 case CSSPropertyWebkitBorderBeforeColor:
432 case CSSPropertyWebkitBorderAfterColor: 432 case CSSPropertyWebkitBorderAfterColor:
433 case CSSPropertyTextDecorationColor: // CSS3 text decoration colors
434 case CSSPropertyWebkitColumnRuleColor: 433 case CSSPropertyWebkitColumnRuleColor:
435 case CSSPropertyWebkitTextEmphasisColor: 434 case CSSPropertyWebkitTextEmphasisColor:
436 case CSSPropertyWebkitTextStrokeColor: 435 case CSSPropertyWebkitTextStrokeColor:
437 ASSERT(propId != CSSPropertyTextDecorationColor || RuntimeEnabledFeature s::css3TextDecorationsEnabled());
438 parsedValue = parseColor(m_valueList->current(), acceptQuirkyColors(prop Id)); 436 parsedValue = parseColor(m_valueList->current(), acceptQuirkyColors(prop Id));
439 if (parsedValue) 437 if (parsedValue)
440 m_valueList->next(); 438 m_valueList->next();
441 break; 439 break;
442 440
443 case CSSPropertyCursor: { 441 case CSSPropertyCursor: {
444 // Grammar defined by CSS3 UI and modified by CSS4 images: 442 // Grammar defined by CSS3 UI and modified by CSS4 images:
445 // [ [<image> [<x> <y>]?,]* 443 // [ [<image> [<x> <y>]?,]*
446 // [ auto | crosshair | default | pointer | progress | move | e-resize | ne-resize | 444 // [ auto | crosshair | default | pointer | progress | move | e-resize | ne-resize |
447 // nw-resize | n-resize | se-resize | sw-resize | s-resize | w-resize | ew-resize | 445 // 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
652 case CSSPropertyWebkitMarginStart: 650 case CSSPropertyWebkitMarginStart:
653 case CSSPropertyWebkitMarginEnd: 651 case CSSPropertyWebkitMarginEnd:
654 case CSSPropertyWebkitMarginBefore: 652 case CSSPropertyWebkitMarginBefore:
655 case CSSPropertyWebkitMarginAfter: 653 case CSSPropertyWebkitMarginAfter:
656 if (id == CSSValueAuto) 654 if (id == CSSValueAuto)
657 validPrimitive = true; 655 validPrimitive = true;
658 else 656 else
659 validPrimitive = validUnit(value, FLength | FPercent | unitless); 657 validPrimitive = validUnit(value, FLength | FPercent | unitless);
660 break; 658 break;
661 659
662 case CSSPropertyTextDecoration:
663 // Fall through 'text-decoration-line' parsing if CSS 3 Text Decoration
664 // is disabled to match CSS 2.1 rules for parsing 'text-decoration'.
665 if (RuntimeEnabledFeatures::css3TextDecorationsEnabled()) {
666 // [ <text-decoration-line> || <text-decoration-style> || <text-deco ration-color> ] | inherit
667 return parseShorthand(CSSPropertyTextDecoration, textDecorationShort hand(), important);
668 }
669 case CSSPropertyWebkitTextDecorationsInEffect:
670 case CSSPropertyTextDecorationLine:
671 // none | [ underline || overline || line-through || blink ] | inherit
672 parsedValue = parseTextDecoration();
673 break;
674
675 case CSSPropertyTextUnderlinePosition: 660 case CSSPropertyTextUnderlinePosition:
676 // auto | [ under || [ left | right ] ], but we only support auto | unde r for now 661 // auto | [ under || [ left | right ] ], but we only support auto | unde r for now
677 ASSERT(RuntimeEnabledFeatures::css3TextDecorationsEnabled()); 662 ASSERT(RuntimeEnabledFeatures::css3TextDecorationsEnabled());
678 validPrimitive = (id == CSSValueAuto || id == CSSValueUnder); 663 validPrimitive = (id == CSSValueAuto || id == CSSValueUnder);
679 break; 664 break;
680 665
681 case CSSPropertySrc: 666 case CSSPropertySrc:
682 case CSSPropertyUnicodeRange: 667 case CSSPropertyUnicodeRange:
683 /* @font-face only descriptors */ 668 /* @font-face only descriptors */
684 break; 669 break;
(...skipping 533 matching lines...) Expand 10 before | Expand all | Expand 10 after
1218 case CSSPropertyTransitionTimingFunction: 1203 case CSSPropertyTransitionTimingFunction:
1219 case CSSPropertyTransitionProperty: 1204 case CSSPropertyTransitionProperty:
1220 case CSSPropertyOrphans: 1205 case CSSPropertyOrphans:
1221 case CSSPropertyWidows: 1206 case CSSPropertyWidows:
1222 case CSSPropertyWebkitTapHighlightColor: 1207 case CSSPropertyWebkitTapHighlightColor:
1223 case CSSPropertyWebkitTextFillColor: 1208 case CSSPropertyWebkitTextFillColor:
1224 case CSSPropertyColor: 1209 case CSSPropertyColor:
1225 case CSSPropertyZIndex: 1210 case CSSPropertyZIndex:
1226 case CSSPropertyTextShadow: 1211 case CSSPropertyTextShadow:
1227 case CSSPropertyBoxShadow: 1212 case CSSPropertyBoxShadow:
1213 case CSSPropertyTextDecorationColor:
1214 case CSSPropertyWebkitTextDecorationsInEffect:
1215 case CSSPropertyTextDecorationLine:
1216 case CSSPropertyTextDecoration:
1228 validPrimitive = false; 1217 validPrimitive = false;
1229 break; 1218 break;
1230 1219
1231 case CSSPropertyScrollSnapPointsX: 1220 case CSSPropertyScrollSnapPointsX:
1232 case CSSPropertyScrollSnapPointsY: 1221 case CSSPropertyScrollSnapPointsY:
1233 parsedValue = parseScrollSnapPoints(); 1222 parsedValue = parseScrollSnapPoints();
1234 break; 1223 break;
1235 case CSSPropertyScrollSnapCoordinate: 1224 case CSSPropertyScrollSnapCoordinate:
1236 parsedValue = parseScrollSnapCoordinate(); 1225 parsedValue = parseScrollSnapCoordinate();
1237 break; 1226 break;
(...skipping 4348 matching lines...) Expand 10 before | Expand all | Expand 10 after
5586 5575
5587 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createSpaceSeparated() ; 5576 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createSpaceSeparated() ;
5588 list->append(xValue.release()); 5577 list->append(xValue.release());
5589 if (yValue) 5578 if (yValue)
5590 list->append(yValue.release()); 5579 list->append(yValue.release());
5591 if (zValue) 5580 if (zValue)
5592 list->append(zValue.release()); 5581 list->append(zValue.release());
5593 return list.release(); 5582 return list.release();
5594 } 5583 }
5595 5584
5596 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseTextDecoration()
5597 {
5598 CSSParserValue* value = m_valueList->current();
5599 if (value && value->id == CSSValueNone) {
5600 m_valueList->next();
5601 return cssValuePool().createIdentifierValue(CSSValueNone);
5602 }
5603
5604 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createSpaceSeparated() ;
5605 bool isValid = true;
5606 while (isValid && value) {
5607 switch (value->id) {
5608 case CSSValueUnderline:
5609 case CSSValueOverline:
5610 case CSSValueLineThrough:
5611 case CSSValueBlink:
5612 // TODO(timloh): This will incorrectly accept "blink blink"
5613 list->append(cssValuePool().createIdentifierValue(value->id));
5614 break;
5615 default:
5616 isValid = false;
5617 break;
5618 }
5619 if (isValid)
5620 value = m_valueList->next();
5621 }
5622
5623 // Values are either valid or in shorthand scope.
5624 if (list->length())
5625 return list.release();
5626 return nullptr;
5627 }
5628
5629 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseTextEmphasisStyle() 5585 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseTextEmphasisStyle()
5630 { 5586 {
5631 RefPtrWillBeRawPtr<CSSPrimitiveValue> fill = nullptr; 5587 RefPtrWillBeRawPtr<CSSPrimitiveValue> fill = nullptr;
5632 RefPtrWillBeRawPtr<CSSPrimitiveValue> shape = nullptr; 5588 RefPtrWillBeRawPtr<CSSPrimitiveValue> shape = nullptr;
5633 5589
5634 for (CSSParserValue* value = m_valueList->current(); value; value = m_valueL ist->next()) { 5590 for (CSSParserValue* value = m_valueList->current(); value; value = m_valueL ist->next()) {
5635 if (value->m_unit == CSSParserValue::String) { 5591 if (value->m_unit == CSSParserValue::String) {
5636 if (fill || shape) 5592 if (fill || shape)
5637 return nullptr; 5593 return nullptr;
5638 m_valueList->next(); 5594 m_valueList->next();
(...skipping 606 matching lines...) Expand 10 before | Expand all | Expand 10 after
6245 } 6201 }
6246 } 6202 }
6247 6203
6248 if (!list->length()) 6204 if (!list->length())
6249 return nullptr; 6205 return nullptr;
6250 6206
6251 return list.release(); 6207 return list.release();
6252 } 6208 }
6253 6209
6254 } // namespace blink 6210 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698