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

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

Issue 14576017: Implement CSS3TextDecorations runtime flag in favor of CSS3_TEXT (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Removed updated on text-underline-position for now (to be discussed & re-added later) Created 7 years, 7 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
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 468 matching lines...) Expand 10 before | Expand all | Expand 10 after
479 case CSSPropertyBorderTopColor: 479 case CSSPropertyBorderTopColor:
480 case CSSPropertyOutlineColor: 480 case CSSPropertyOutlineColor:
481 case CSSPropertyTextLineThroughColor: 481 case CSSPropertyTextLineThroughColor:
482 case CSSPropertyTextOverlineColor: 482 case CSSPropertyTextOverlineColor:
483 case CSSPropertyTextUnderlineColor: 483 case CSSPropertyTextUnderlineColor:
484 case CSSPropertyWebkitBorderAfterColor: 484 case CSSPropertyWebkitBorderAfterColor:
485 case CSSPropertyWebkitBorderBeforeColor: 485 case CSSPropertyWebkitBorderBeforeColor:
486 case CSSPropertyWebkitBorderEndColor: 486 case CSSPropertyWebkitBorderEndColor:
487 case CSSPropertyWebkitBorderStartColor: 487 case CSSPropertyWebkitBorderStartColor:
488 case CSSPropertyWebkitColumnRuleColor: 488 case CSSPropertyWebkitColumnRuleColor:
489 #if ENABLE(CSS3_TEXT)
490 case CSSPropertyWebkitTextDecorationColor:
491 #endif // CSS3_TEXT
492 case CSSPropertyWebkitTextEmphasisColor: 489 case CSSPropertyWebkitTextEmphasisColor:
493 case CSSPropertyWebkitTextFillColor: 490 case CSSPropertyWebkitTextFillColor:
494 case CSSPropertyWebkitTextStrokeColor: 491 case CSSPropertyWebkitTextStrokeColor:
495 return true; 492 return true;
493 case CSSPropertyTextDecorationColor:
494 return RuntimeEnabledFeatures::css3TextDecorationsEnabled();
496 default: 495 default:
497 return false; 496 return false;
498 } 497 }
499 } 498 }
500 499
501 static bool parseColorValue(StylePropertySet* declaration, CSSPropertyID propert yId, const String& string, bool important, CSSParserMode cssParserMode) 500 static bool parseColorValue(StylePropertySet* declaration, CSSPropertyID propert yId, const String& string, bool important, CSSParserMode cssParserMode)
502 { 501 {
503 ASSERT(!string.isEmpty()); 502 ASSERT(!string.isEmpty());
504 bool strict = isStrictParserMode(cssParserMode); 503 bool strict = isStrictParserMode(cssParserMode);
505 if (!isColorPropertyID(propertyId)) 504 if (!isColorPropertyID(propertyId))
(...skipping 1358 matching lines...) Expand 10 before | Expand all | Expand 10 after
1864 case CSSPropertyBackgroundColor: // <color> | inherit 1863 case CSSPropertyBackgroundColor: // <color> | inherit
1865 case CSSPropertyBorderTopColor: // <color> | inherit 1864 case CSSPropertyBorderTopColor: // <color> | inherit
1866 case CSSPropertyBorderRightColor: 1865 case CSSPropertyBorderRightColor:
1867 case CSSPropertyBorderBottomColor: 1866 case CSSPropertyBorderBottomColor:
1868 case CSSPropertyBorderLeftColor: 1867 case CSSPropertyBorderLeftColor:
1869 case CSSPropertyWebkitBorderStartColor: 1868 case CSSPropertyWebkitBorderStartColor:
1870 case CSSPropertyWebkitBorderEndColor: 1869 case CSSPropertyWebkitBorderEndColor:
1871 case CSSPropertyWebkitBorderBeforeColor: 1870 case CSSPropertyWebkitBorderBeforeColor:
1872 case CSSPropertyWebkitBorderAfterColor: 1871 case CSSPropertyWebkitBorderAfterColor:
1873 case CSSPropertyColor: // <color> | inherit 1872 case CSSPropertyColor: // <color> | inherit
1873 case CSSPropertyTextDecorationColor:
1874 case CSSPropertyTextLineThroughColor: // CSS3 text decoration colors 1874 case CSSPropertyTextLineThroughColor: // CSS3 text decoration colors
1875 case CSSPropertyTextUnderlineColor: 1875 case CSSPropertyTextUnderlineColor:
1876 case CSSPropertyTextOverlineColor: 1876 case CSSPropertyTextOverlineColor:
1877 case CSSPropertyWebkitColumnRuleColor: 1877 case CSSPropertyWebkitColumnRuleColor:
1878 #if ENABLE(CSS3_TEXT)
1879 case CSSPropertyWebkitTextDecorationColor:
1880 #endif // CSS3_TEXT
1881 case CSSPropertyWebkitTextEmphasisColor: 1878 case CSSPropertyWebkitTextEmphasisColor:
1882 case CSSPropertyWebkitTextFillColor: 1879 case CSSPropertyWebkitTextFillColor:
1883 case CSSPropertyWebkitTextStrokeColor: 1880 case CSSPropertyWebkitTextStrokeColor:
1881 if (propId == CSSPropertyTextDecorationColor
1882 && !RuntimeEnabledFeatures::css3TextDecorationsEnabled())
1883 return false;
1884
1884 if (id == CSSValueWebkitText) 1885 if (id == CSSValueWebkitText)
1885 validPrimitive = true; // Always allow this, even when strict parsin g is on, 1886 validPrimitive = true; // Always allow this, even when strict parsin g is on,
1886 // since we use this in our UA sheets. 1887 // since we use this in our UA sheets.
1887 else if (id == CSSValueCurrentcolor) 1888 else if (id == CSSValueCurrentcolor)
1888 validPrimitive = true; 1889 validPrimitive = true;
1889 else if ((id >= CSSValueAqua && id <= CSSValueWindowtext) || id == CSSVa lueMenu || 1890 else if ((id >= CSSValueAqua && id <= CSSValueWindowtext) || id == CSSVa lueMenu ||
1890 (id >= CSSValueWebkitFocusRingColor && id < CSSValueWebkitText && i nQuirksMode())) { 1891 (id >= CSSValueWebkitFocusRingColor && id < CSSValueWebkitText && i nQuirksMode())) {
1891 validPrimitive = true; 1892 validPrimitive = true;
1892 } else { 1893 } else {
1893 parsedValue = parseColor(); 1894 parsedValue = parseColor();
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
2166 { 2167 {
2167 parsedValue = parseFontFamily(); 2168 parsedValue = parseFontFamily();
2168 break; 2169 break;
2169 } 2170 }
2170 2171
2171 case CSSPropertyTextDecoration: 2172 case CSSPropertyTextDecoration:
2172 case CSSPropertyWebkitTextDecorationsInEffect: 2173 case CSSPropertyWebkitTextDecorationsInEffect:
2173 // none | [ underline || overline || line-through || blink ] | inherit 2174 // none | [ underline || overline || line-through || blink ] | inherit
2174 return parseTextDecoration(propId, important); 2175 return parseTextDecoration(propId, important);
2175 2176
2176 #if ENABLE(CSS3_TEXT) 2177 case CSSPropertyTextDecorationLine:
2177 case CSSPropertyWebkitTextDecorationLine: 2178 if (!RuntimeEnabledFeatures::css3TextDecorationsEnabled())
2179 return false;
2178 // none | [ underline || overline || line-through ] | inherit 2180 // none | [ underline || overline || line-through ] | inherit
2179 return parseTextDecoration(propId, important); 2181 return parseTextDecoration(propId, important);
2180 2182
2181 case CSSPropertyWebkitTextDecorationStyle: 2183 case CSSPropertyTextDecorationStyle:
2184 if (!RuntimeEnabledFeatures::css3TextDecorationsEnabled())
2185 return false;
2182 // solid | double | dotted | dashed | wavy 2186 // solid | double | dotted | dashed | wavy
2183 if (id == CSSValueSolid || id == CSSValueDouble || id == CSSValueDotted || id == CSSValueDashed || id == CSSValueWavy) 2187 if (id == CSSValueSolid || id == CSSValueDouble || id == CSSValueDotted || id == CSSValueDashed || id == CSSValueWavy)
2184 validPrimitive = true; 2188 validPrimitive = true;
2185 break; 2189 break;
2186 2190
2191 #if ENABLE(CSS3_TEXT)
2187 case CSSPropertyWebkitTextUnderlinePosition: 2192 case CSSPropertyWebkitTextUnderlinePosition:
2188 // auto | alphabetic | under 2193 // auto | alphabetic | under
2189 return parseTextUnderlinePosition(important); 2194 return parseTextUnderlinePosition(important);
2190 #endif // CSS3_TEXT 2195 #endif // CSS3_TEXT
2191 2196
2192 case CSSPropertyZoom: // normal | reset | document | <number> | <pe rcentage> | inherit 2197 case CSSPropertyZoom: // normal | reset | document | <number> | <pe rcentage> | inherit
2193 if (id == CSSValueNormal || id == CSSValueReset || id == CSSValueDocumen t) 2198 if (id == CSSValueNormal || id == CSSValueReset || id == CSSValueDocumen t)
2194 validPrimitive = true; 2199 validPrimitive = true;
2195 else 2200 else
2196 validPrimitive = (!id && validUnit(value, FNumber | FPercent | FNonN eg, CSSStrictMode)); 2201 validPrimitive = (!id && validUnit(value, FNumber | FPercent | FNonN eg, CSSStrictMode));
(...skipping 6602 matching lines...) Expand 10 before | Expand all | Expand 10 after
8799 default: 8804 default:
8800 ASSERT_NOT_REACHED(); 8805 ASSERT_NOT_REACHED();
8801 return false; 8806 return false;
8802 } 8807 }
8803 8808
8804 return value; 8809 return value;
8805 } 8810 }
8806 8811
8807 void CSSParser::addTextDecorationProperty(CSSPropertyID propId, PassRefPtr<CSSVa lue> value, bool important) 8812 void CSSParser::addTextDecorationProperty(CSSPropertyID propId, PassRefPtr<CSSVa lue> value, bool important)
8808 { 8813 {
8809 #if ENABLE(CSS3_TEXT)
8810 // The text-decoration-line property takes priority over text-decoration, un less the latter has important priority set. 8814 // The text-decoration-line property takes priority over text-decoration, un less the latter has important priority set.
8811 if (propId == CSSPropertyTextDecoration && !important && m_currentShorthand == CSSPropertyInvalid) { 8815 if (propId == CSSPropertyTextDecoration && !important && m_currentShorthand == CSSPropertyInvalid) {
8812 for (unsigned i = 0; i < m_parsedProperties.size(); ++i) { 8816 for (unsigned i = 0; i < m_parsedProperties.size(); ++i) {
8813 if (m_parsedProperties[i].id() == CSSPropertyWebkitTextDecorationLin e) 8817 if (m_parsedProperties[i].id() == CSSPropertyTextDecorationLine)
8814 return; 8818 return;
8815 } 8819 }
8816 } 8820 }
8817 #endif // CSS3_TEXT
8818 addProperty(propId, value, important); 8821 addProperty(propId, value, important);
8819 } 8822 }
8820 8823
8821 bool CSSParser::parseTextDecoration(CSSPropertyID propId, bool important) 8824 bool CSSParser::parseTextDecoration(CSSPropertyID propId, bool important)
8822 { 8825 {
8823 CSSParserValue* value = m_valueList->current(); 8826 CSSParserValue* value = m_valueList->current();
8824 if (value->id == CSSValueNone) { 8827 if (value->id == CSSValueNone) {
8825 addTextDecorationProperty(propId, cssValuePool().createIdentifierValue(C SSValueNone), important); 8828 addTextDecorationProperty(propId, cssValuePool().createIdentifierValue(C SSValueNone), important);
8826 m_valueList->next(); 8829 m_valueList->next();
8827 return true; 8830 return true;
8828 } 8831 }
8829 8832
8830 RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated(); 8833 RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
8831 bool isValid = true; 8834 bool isValid = true;
8832 while (isValid && value) { 8835 while (isValid && value) {
8833 switch (value->id) { 8836 switch (value->id) {
8834 case CSSValueBlink: 8837 case CSSValueBlink:
8835 #if ENABLE(CSS3_TEXT) 8838 // Blink value is not accepted by text-decoration-line.
8836 // Blink value is not accepted by -webkit-text-decoration-line. 8839 isValid = propId != CSSPropertyTextDecorationLine;
8837 isValid = propId != CSSPropertyWebkitTextDecorationLine;
8838 if (isValid) 8840 if (isValid)
8839 list->append(cssValuePool().createIdentifierValue(value->id)); 8841 list->append(cssValuePool().createIdentifierValue(value->id));
8840 break; 8842 break;
8841 #endif // CSS3_TEXT
8842 case CSSValueUnderline: 8843 case CSSValueUnderline:
8843 case CSSValueOverline: 8844 case CSSValueOverline:
8844 case CSSValueLineThrough: 8845 case CSSValueLineThrough:
8845 list->append(cssValuePool().createIdentifierValue(value->id)); 8846 list->append(cssValuePool().createIdentifierValue(value->id));
8846 break; 8847 break;
8847 default: 8848 default:
8848 isValid = false; 8849 isValid = false;
8849 break; 8850 break;
8850 } 8851 }
8851 if (isValid) 8852 if (isValid)
(...skipping 20 matching lines...) Expand all
8872 case CSSValueAlphabetic: 8873 case CSSValueAlphabetic:
8873 case CSSValueUnder: 8874 case CSSValueUnder:
8874 if (m_valueList->next()) 8875 if (m_valueList->next())
8875 return false; 8876 return false;
8876 8877
8877 addProperty(CSSPropertyWebkitTextUnderlinePosition, cssValuePool().creat eIdentifierValue(value->id), important); 8878 addProperty(CSSPropertyWebkitTextUnderlinePosition, cssValuePool().creat eIdentifierValue(value->id), important);
8878 return true; 8879 return true;
8879 } 8880 }
8880 return false; 8881 return false;
8881 } 8882 }
8882 #endif // CSS3_TEXT 8883 #endif
8883 8884
8884 bool CSSParser::parseTextEmphasisStyle(bool important) 8885 bool CSSParser::parseTextEmphasisStyle(bool important)
8885 { 8886 {
8886 unsigned valueListSize = m_valueList->size(); 8887 unsigned valueListSize = m_valueList->size();
8887 8888
8888 RefPtr<CSSPrimitiveValue> fill; 8889 RefPtr<CSSPrimitiveValue> fill;
8889 RefPtr<CSSPrimitiveValue> shape; 8890 RefPtr<CSSPrimitiveValue> shape;
8890 8891
8891 for (CSSParserValue* value = m_valueList->current(); value; value = m_valueL ist->next()) { 8892 for (CSSParserValue* value = m_valueList->current(); value; value = m_valueL ist->next()) {
8892 if (value->unit == CSSPrimitiveValue::CSS_STRING) { 8893 if (value->unit == CSSPrimitiveValue::CSS_STRING) {
(...skipping 2776 matching lines...) Expand 10 before | Expand all | Expand 10 after
11669 { 11670 {
11670 // The tokenizer checks for the construct of an+b. 11671 // The tokenizer checks for the construct of an+b.
11671 // However, since the {ident} rule precedes the {nth} rule, some of those 11672 // However, since the {ident} rule precedes the {nth} rule, some of those
11672 // tokens are identified as string literal. Furthermore we need to accept 11673 // tokens are identified as string literal. Furthermore we need to accept
11673 // "odd" and "even" which does not match to an+b. 11674 // "odd" and "even" which does not match to an+b.
11674 return equalIgnoringCase(token, "odd") || equalIgnoringCase(token, "even") 11675 return equalIgnoringCase(token, "odd") || equalIgnoringCase(token, "even")
11675 || equalIgnoringCase(token, "n") || equalIgnoringCase(token, "-n"); 11676 || equalIgnoringCase(token, "n") || equalIgnoringCase(token, "-n");
11676 } 11677 }
11677 11678
11678 } 11679 }
OLDNEW
« no previous file with comments | « Source/core/css/CSSComputedStyleDeclaration.cpp ('k') | Source/core/css/CSSPrimitiveValueMappings.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698