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

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: Address review comments 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 411 matching lines...) Expand 10 before | Expand all | Expand 10 after
422 /* nobreak */ 422 /* nobreak */
423 case CSSPropertyBackgroundColor: // <color> | inherit 423 case CSSPropertyBackgroundColor: // <color> | inherit
424 case CSSPropertyBorderTopColor: // <color> | inherit 424 case CSSPropertyBorderTopColor: // <color> | inherit
425 case CSSPropertyBorderRightColor: 425 case CSSPropertyBorderRightColor:
426 case CSSPropertyBorderBottomColor: 426 case CSSPropertyBorderBottomColor:
427 case CSSPropertyBorderLeftColor: 427 case CSSPropertyBorderLeftColor:
428 case CSSPropertyWebkitBorderStartColor: 428 case CSSPropertyWebkitBorderStartColor:
429 case CSSPropertyWebkitBorderEndColor: 429 case CSSPropertyWebkitBorderEndColor:
430 case CSSPropertyWebkitBorderBeforeColor: 430 case CSSPropertyWebkitBorderBeforeColor:
431 case CSSPropertyWebkitBorderAfterColor: 431 case CSSPropertyWebkitBorderAfterColor:
432 case CSSPropertyTextDecorationColor: // CSS3 text decoration colors
433 case CSSPropertyWebkitColumnRuleColor: 432 case CSSPropertyWebkitColumnRuleColor:
434 case CSSPropertyWebkitTextEmphasisColor: 433 case CSSPropertyWebkitTextEmphasisColor:
435 case CSSPropertyWebkitTextStrokeColor: 434 case CSSPropertyWebkitTextStrokeColor:
436 ASSERT(propId != CSSPropertyTextDecorationColor || RuntimeEnabledFeature s::css3TextDecorationsEnabled());
437 parsedValue = parseColor(m_valueList->current(), acceptQuirkyColors(prop Id)); 435 parsedValue = parseColor(m_valueList->current(), acceptQuirkyColors(prop Id));
438 if (parsedValue) 436 if (parsedValue)
439 m_valueList->next(); 437 m_valueList->next();
440 break; 438 break;
441 439
442 case CSSPropertyCursor: { 440 case CSSPropertyCursor: {
443 // Grammar defined by CSS3 UI and modified by CSS4 images: 441 // Grammar defined by CSS3 UI and modified by CSS4 images:
444 // [ [<image> [<x> <y>]?,]* 442 // [ [<image> [<x> <y>]?,]*
445 // [ auto | crosshair | default | pointer | progress | move | e-resize | ne-resize | 443 // [ auto | crosshair | default | pointer | progress | move | e-resize | ne-resize |
446 // nw-resize | n-resize | se-resize | sw-resize | s-resize | w-resize | ew-resize | 444 // 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
651 case CSSPropertyWebkitMarginStart: 649 case CSSPropertyWebkitMarginStart:
652 case CSSPropertyWebkitMarginEnd: 650 case CSSPropertyWebkitMarginEnd:
653 case CSSPropertyWebkitMarginBefore: 651 case CSSPropertyWebkitMarginBefore:
654 case CSSPropertyWebkitMarginAfter: 652 case CSSPropertyWebkitMarginAfter:
655 if (id == CSSValueAuto) 653 if (id == CSSValueAuto)
656 validPrimitive = true; 654 validPrimitive = true;
657 else 655 else
658 validPrimitive = validUnit(value, FLength | FPercent | unitless); 656 validPrimitive = validUnit(value, FLength | FPercent | unitless);
659 break; 657 break;
660 658
661 case CSSPropertyTextDecoration:
662 // Fall through 'text-decoration-line' parsing if CSS 3 Text Decoration
663 // is disabled to match CSS 2.1 rules for parsing 'text-decoration'.
664 if (RuntimeEnabledFeatures::css3TextDecorationsEnabled()) {
665 // [ <text-decoration-line> || <text-decoration-style> || <text-deco ration-color> ] | inherit
666 return parseShorthand(CSSPropertyTextDecoration, textDecorationShort hand(), important);
667 }
668 case CSSPropertyWebkitTextDecorationsInEffect:
669 case CSSPropertyTextDecorationLine:
670 // none | [ underline || overline || line-through || blink ] | inherit
671 parsedValue = parseTextDecoration();
672 break;
673
674 case CSSPropertyTextUnderlinePosition: 659 case CSSPropertyTextUnderlinePosition:
675 // auto | [ under || [ left | right ] ], but we only support auto | unde r for now 660 // auto | [ under || [ left | right ] ], but we only support auto | unde r for now
676 ASSERT(RuntimeEnabledFeatures::css3TextDecorationsEnabled()); 661 ASSERT(RuntimeEnabledFeatures::css3TextDecorationsEnabled());
677 validPrimitive = (id == CSSValueAuto || id == CSSValueUnder); 662 validPrimitive = (id == CSSValueAuto || id == CSSValueUnder);
678 break; 663 break;
679 664
680 case CSSPropertySrc: 665 case CSSPropertySrc:
681 case CSSPropertyUnicodeRange: 666 case CSSPropertyUnicodeRange:
682 /* @font-face only descriptors */ 667 /* @font-face only descriptors */
683 break; 668 break;
(...skipping 522 matching lines...) Expand 10 before | Expand all | Expand 10 after
1206 case CSSPropertyOrphans: 1191 case CSSPropertyOrphans:
1207 case CSSPropertyWidows: 1192 case CSSPropertyWidows:
1208 case CSSPropertyWebkitTapHighlightColor: 1193 case CSSPropertyWebkitTapHighlightColor:
1209 case CSSPropertyWebkitTextFillColor: 1194 case CSSPropertyWebkitTextFillColor:
1210 case CSSPropertyColor: 1195 case CSSPropertyColor:
1211 case CSSPropertyZIndex: 1196 case CSSPropertyZIndex:
1212 case CSSPropertyTextShadow: 1197 case CSSPropertyTextShadow:
1213 case CSSPropertyBoxShadow: 1198 case CSSPropertyBoxShadow:
1214 case CSSPropertyWebkitFilter: 1199 case CSSPropertyWebkitFilter:
1215 case CSSPropertyBackdropFilter: 1200 case CSSPropertyBackdropFilter:
1201 case CSSPropertyTextDecorationColor:
1202 case CSSPropertyWebkitTextDecorationsInEffect:
1203 case CSSPropertyTextDecorationLine:
1204 case CSSPropertyTextDecoration:
1216 validPrimitive = false; 1205 validPrimitive = false;
1217 break; 1206 break;
1218 1207
1219 case CSSPropertyScrollSnapPointsX: 1208 case CSSPropertyScrollSnapPointsX:
1220 case CSSPropertyScrollSnapPointsY: 1209 case CSSPropertyScrollSnapPointsY:
1221 parsedValue = parseScrollSnapPoints(); 1210 parsedValue = parseScrollSnapPoints();
1222 break; 1211 break;
1223 case CSSPropertyScrollSnapCoordinate: 1212 case CSSPropertyScrollSnapCoordinate:
1224 parsedValue = parseScrollSnapCoordinate(); 1213 parsedValue = parseScrollSnapCoordinate();
1225 break; 1214 break;
(...skipping 4163 matching lines...) Expand 10 before | Expand all | Expand 10 after
5389 5378
5390 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createSpaceSeparated() ; 5379 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createSpaceSeparated() ;
5391 list->append(xValue.release()); 5380 list->append(xValue.release());
5392 if (yValue) 5381 if (yValue)
5393 list->append(yValue.release()); 5382 list->append(yValue.release());
5394 if (zValue) 5383 if (zValue)
5395 list->append(zValue.release()); 5384 list->append(zValue.release());
5396 return list.release(); 5385 return list.release();
5397 } 5386 }
5398 5387
5399 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseTextDecoration()
5400 {
5401 CSSParserValue* value = m_valueList->current();
5402 if (value && value->id == CSSValueNone) {
5403 m_valueList->next();
5404 return cssValuePool().createIdentifierValue(CSSValueNone);
5405 }
5406
5407 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createSpaceSeparated() ;
5408 bool isValid = true;
5409 while (isValid && value) {
5410 switch (value->id) {
5411 case CSSValueUnderline:
5412 case CSSValueOverline:
5413 case CSSValueLineThrough:
5414 case CSSValueBlink:
5415 // TODO(timloh): This will incorrectly accept "blink blink"
5416 list->append(cssValuePool().createIdentifierValue(value->id));
5417 break;
5418 default:
5419 isValid = false;
5420 break;
5421 }
5422 if (isValid)
5423 value = m_valueList->next();
5424 }
5425
5426 // Values are either valid or in shorthand scope.
5427 if (list->length())
5428 return list.release();
5429 return nullptr;
5430 }
5431
5432 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseTextEmphasisStyle() 5388 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseTextEmphasisStyle()
5433 { 5389 {
5434 RefPtrWillBeRawPtr<CSSPrimitiveValue> fill = nullptr; 5390 RefPtrWillBeRawPtr<CSSPrimitiveValue> fill = nullptr;
5435 RefPtrWillBeRawPtr<CSSPrimitiveValue> shape = nullptr; 5391 RefPtrWillBeRawPtr<CSSPrimitiveValue> shape = nullptr;
5436 5392
5437 for (CSSParserValue* value = m_valueList->current(); value; value = m_valueL ist->next()) { 5393 for (CSSParserValue* value = m_valueList->current(); value; value = m_valueL ist->next()) {
5438 if (value->m_unit == CSSParserValue::String) { 5394 if (value->m_unit == CSSParserValue::String) {
5439 if (fill || shape) 5395 if (fill || shape)
5440 return nullptr; 5396 return nullptr;
5441 m_valueList->next(); 5397 m_valueList->next();
(...skipping 606 matching lines...) Expand 10 before | Expand all | Expand 10 after
6048 } 6004 }
6049 } 6005 }
6050 6006
6051 if (!list->length()) 6007 if (!list->length())
6052 return nullptr; 6008 return nullptr;
6053 6009
6054 return list.release(); 6010 return list.release();
6055 } 6011 }
6056 6012
6057 } // namespace blink 6013 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698