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

Side by Side Diff: Source/core/css/CSSParser.cpp

Issue 17101024: Add support for CSS3 "text-decoration" shorthand (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Added missing code pointed out by Alexis Created 7 years, 6 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 | Annotate | Revision Log
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 2100 matching lines...) Expand 10 before | Expand all | Expand 10 after
2111 validPrimitive = true; 2111 validPrimitive = true;
2112 break; 2112 break;
2113 case CSSPropertyFontFamily: 2113 case CSSPropertyFontFamily:
2114 // [[ <family-name> | <generic-family> ],]* [<family-name> | <generic-fa mily>] | inherit 2114 // [[ <family-name> | <generic-family> ],]* [<family-name> | <generic-fa mily>] | inherit
2115 { 2115 {
2116 parsedValue = parseFontFamily(); 2116 parsedValue = parseFontFamily();
2117 break; 2117 break;
2118 } 2118 }
2119 2119
2120 case CSSPropertyTextDecoration: 2120 case CSSPropertyTextDecoration:
2121 // [ <text-decoration-line> || <text-decoration-style> || <text-decorati on-color> ] | inherit
2122 return parseShorthand(CSSPropertyTextDecoration, textDecorationShorthand (), important);
2123
2121 case CSSPropertyWebkitTextDecorationsInEffect: 2124 case CSSPropertyWebkitTextDecorationsInEffect:
2122 case CSSPropertyTextDecorationLine: 2125 case CSSPropertyTextDecorationLine:
2123 // none | [ underline || overline || line-through || blink ] | inherit 2126 // none | [ underline || overline || line-through || blink ] | inherit
2124 return parseTextDecoration(propId, important); 2127 return parseTextDecoration(propId, important);
2125 2128
2126 case CSSPropertyTextDecorationStyle: 2129 case CSSPropertyTextDecorationStyle:
2127 // solid | double | dotted | dashed | wavy 2130 // solid | double | dotted | dashed | wavy
2128 if (RuntimeEnabledFeatures::css3TextDecorationsEnabled() 2131 if (RuntimeEnabledFeatures::css3TextDecorationsEnabled()
2129 && (id == CSSValueSolid || id == CSSValueDouble || id == CSSValueDot ted || id == CSSValueDashed || id == CSSValueWavy)) 2132 && (id == CSSValueSolid || id == CSSValueDouble || id == CSSValueDot ted || id == CSSValueDashed || id == CSSValueWavy))
2130 validPrimitive = true; 2133 validPrimitive = true;
(...skipping 6717 matching lines...) Expand 10 before | Expand all | Expand 10 after
8848 addProperty(propId, value, important); 8851 addProperty(propId, value, important);
8849 } 8852 }
8850 8853
8851 bool CSSParser::parseTextDecoration(CSSPropertyID propId, bool important) 8854 bool CSSParser::parseTextDecoration(CSSPropertyID propId, bool important)
8852 { 8855 {
8853 if (propId == CSSPropertyTextDecorationLine 8856 if (propId == CSSPropertyTextDecorationLine
8854 && !RuntimeEnabledFeatures::css3TextDecorationsEnabled()) 8857 && !RuntimeEnabledFeatures::css3TextDecorationsEnabled())
8855 return false; 8858 return false;
8856 8859
8857 CSSParserValue* value = m_valueList->current(); 8860 CSSParserValue* value = m_valueList->current();
8858 if (value->id == CSSValueNone) { 8861 if (value && value->id == CSSValueNone) {
8859 addTextDecorationProperty(propId, cssValuePool().createIdentifierValue(C SSValueNone), important); 8862 addTextDecorationProperty(propId, cssValuePool().createIdentifierValue(C SSValueNone), important);
8860 m_valueList->next(); 8863 m_valueList->next();
8861 return true; 8864 return true;
8862 } 8865 }
8863 8866
8864 RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated(); 8867 RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
8865 bool isValid = true; 8868 bool isValid = true;
8866 while (isValid && value) { 8869 while (isValid && value) {
8867 switch (value->id) { 8870 switch (value->id) {
8868 case CSSValueUnderline: 8871 case CSSValueUnderline:
8869 case CSSValueOverline: 8872 case CSSValueOverline:
8870 case CSSValueLineThrough: 8873 case CSSValueLineThrough:
8871 case CSSValueBlink: 8874 case CSSValueBlink:
8872 list->append(cssValuePool().createIdentifierValue(value->id)); 8875 list->append(cssValuePool().createIdentifierValue(value->id));
8873 break; 8876 break;
8874 default: 8877 default:
8875 isValid = false; 8878 isValid = false;
8876 break; 8879 break;
8877 } 8880 }
8878 if (isValid) 8881 if (isValid)
8879 value = m_valueList->next(); 8882 value = m_valueList->next();
8880 } 8883 }
8881 8884
8882 if (list->length() && isValid) { 8885 // Values are either valid or in shorthand scope.
8886 if (list->length() && (isValid || inShorthand())) {
8883 addTextDecorationProperty(propId, list.release(), important); 8887 addTextDecorationProperty(propId, list.release(), important);
8884 return true; 8888 return true;
8885 } 8889 }
8886 8890
8887 return false; 8891 return false;
8888 } 8892 }
8889 8893
8890 #if ENABLE(CSS3_TEXT) 8894 #if ENABLE(CSS3_TEXT)
8891 bool CSSParser::parseTextUnderlinePosition(bool important) 8895 bool CSSParser::parseTextUnderlinePosition(bool important)
8892 { 8896 {
(...skipping 2913 matching lines...) Expand 10 before | Expand all | Expand 10 after
11806 { 11810 {
11807 // The tokenizer checks for the construct of an+b. 11811 // The tokenizer checks for the construct of an+b.
11808 // However, since the {ident} rule precedes the {nth} rule, some of those 11812 // However, since the {ident} rule precedes the {nth} rule, some of those
11809 // tokens are identified as string literal. Furthermore we need to accept 11813 // tokens are identified as string literal. Furthermore we need to accept
11810 // "odd" and "even" which does not match to an+b. 11814 // "odd" and "even" which does not match to an+b.
11811 return equalIgnoringCase(token, "odd") || equalIgnoringCase(token, "even") 11815 return equalIgnoringCase(token, "odd") || equalIgnoringCase(token, "even")
11812 || equalIgnoringCase(token, "n") || equalIgnoringCase(token, "-n"); 11816 || equalIgnoringCase(token, "n") || equalIgnoringCase(token, "-n");
11813 } 11817 }
11814 11818
11815 } 11819 }
OLDNEW
« no previous file with comments | « Source/core/css/CSSComputedStyleDeclaration.cpp ('k') | Source/core/css/StylePropertyShorthand.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698