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

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

Issue 1376573004: Split out Color from CSSPrimitiveValue (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@split_property
Patch Set: Rebase and review feedback Created 5 years, 2 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 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "config.h" 5 #include "config.h"
6 #include "core/css/parser/CSSParser.h" 6 #include "core/css/parser/CSSParser.h"
7 7
8 #include "core/css/CSSColorValue.h"
8 #include "core/css/CSSKeyframeRule.h" 9 #include "core/css/CSSKeyframeRule.h"
9 #include "core/css/StyleColor.h" 10 #include "core/css/StyleColor.h"
10 #include "core/css/StylePropertySet.h" 11 #include "core/css/StylePropertySet.h"
11 #include "core/css/StyleRule.h" 12 #include "core/css/StyleRule.h"
12 #include "core/css/StyleSheetContents.h" 13 #include "core/css/StyleSheetContents.h"
13 #include "core/css/parser/CSSParserFastPaths.h" 14 #include "core/css/parser/CSSParserFastPaths.h"
14 #include "core/css/parser/CSSParserImpl.h" 15 #include "core/css/parser/CSSParserImpl.h"
15 #include "core/css/parser/CSSPropertyParser.h" 16 #include "core/css/parser/CSSPropertyParser.h"
16 #include "core/css/parser/CSSSelectorParser.h" 17 #include "core/css/parser/CSSSelectorParser.h"
17 #include "core/css/parser/CSSSupportsParser.h" 18 #include "core/css/parser/CSSSupportsParser.h"
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 if (namedColor.setNamedColor(string)) { 120 if (namedColor.setNamedColor(string)) {
120 color = namedColor.rgb(); 121 color = namedColor.rgb();
121 return true; 122 return true;
122 } 123 }
123 124
124 RefPtrWillBeRawPtr<CSSValue> value = CSSParserFastPaths::parseColor(string, strict ? HTMLStandardMode : HTMLQuirksMode); 125 RefPtrWillBeRawPtr<CSSValue> value = CSSParserFastPaths::parseColor(string, strict ? HTMLStandardMode : HTMLQuirksMode);
125 // TODO(timloh): Why is this always strict mode? 126 // TODO(timloh): Why is this always strict mode?
126 if (!value) 127 if (!value)
127 value = parseSingleValue(CSSPropertyColor, string, strictCSSParserContex t()); 128 value = parseSingleValue(CSSPropertyColor, string, strictCSSParserContex t());
128 129
129 if (!value || !value->isPrimitiveValue()) 130 if (!value || !value->isColorValue())
130 return false; 131 return false;
131 132 color = toCSSColorValue(*value).value();
132 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value.get());
133 if (!primitiveValue->isRGBColor())
134 return false;
135
136 color = primitiveValue->getRGBA32Value();
137 return true; 133 return true;
138 } 134 }
139 135
140 bool CSSParser::parseSystemColor(RGBA32& color, const String& colorString) 136 bool CSSParser::parseSystemColor(RGBA32& color, const String& colorString)
141 { 137 {
142 CSSParserString cssColor; 138 CSSParserString cssColor;
143 cssColor.init(colorString); 139 cssColor.init(colorString);
144 CSSValueID id = cssValueKeywordID(cssColor); 140 CSSValueID id = cssValueKeywordID(cssColor);
145 if (!CSSPropertyParser::isSystemColor(id)) 141 if (!CSSPropertyParser::isSystemColor(id))
146 return false; 142 return false;
(...skipping 11 matching lines...) Expand all
158 builder.appendLiteral(" : "); 154 builder.appendLiteral(" : ");
159 builder.append(propertyValue); 155 builder.append(propertyValue);
160 builder.appendLiteral("; }"); 156 builder.appendLiteral("; }");
161 RefPtrWillBeRawPtr<StyleRuleBase> rule = parseRule(context, nullptr, builder .toString()); 157 RefPtrWillBeRawPtr<StyleRuleBase> rule = parseRule(context, nullptr, builder .toString());
162 if (!rule || !rule->isFontFaceRule()) 158 if (!rule || !rule->isFontFaceRule())
163 return nullptr; 159 return nullptr;
164 return toStyleRuleFontFace(rule.get())->properties().getPropertyCSSValue(pro pertyID); 160 return toStyleRuleFontFace(rule.get())->properties().getPropertyCSSValue(pro pertyID);
165 } 161 }
166 162
167 } // namespace blink 163 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698