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

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

Issue 1399853005: Changed CSSColorValue to return a Color (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@split_color
Patch Set: Rebase 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 // 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/CSSColorValue.h"
9 #include "core/css/CSSKeyframeRule.h" 9 #include "core/css/CSSKeyframeRule.h"
10 #include "core/css/StyleColor.h" 10 #include "core/css/StyleColor.h"
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 return toStyleRuleKeyframe(keyframe.get()); 102 return toStyleRuleKeyframe(keyframe.get());
103 } 103 }
104 104
105 bool CSSParser::parseSupportsCondition(const String& condition) 105 bool CSSParser::parseSupportsCondition(const String& condition)
106 { 106 {
107 CSSTokenizer::Scope scope(condition); 107 CSSTokenizer::Scope scope(condition);
108 CSSParserImpl parser(strictCSSParserContext()); 108 CSSParserImpl parser(strictCSSParserContext());
109 return CSSSupportsParser::supportsCondition(scope.tokenRange(), parser) == C SSSupportsParser::Supported; 109 return CSSSupportsParser::supportsCondition(scope.tokenRange(), parser) == C SSSupportsParser::Supported;
110 } 110 }
111 111
112 bool CSSParser::parseColor(RGBA32& color, const String& string, bool strict) 112 bool CSSParser::parseColor(Color& color, const String& string, bool strict)
113 { 113 {
114 if (string.isEmpty()) 114 if (string.isEmpty())
115 return false; 115 return false;
116 116
117 // The regular color parsers don't resolve named colors, so explicitly 117 // The regular color parsers don't resolve named colors, so explicitly
118 // handle these first. 118 // handle these first.
119 Color namedColor; 119 Color namedColor;
120 if (namedColor.setNamedColor(string)) { 120 if (namedColor.setNamedColor(string)) {
121 color = namedColor.rgb(); 121 color = namedColor;
122 return true; 122 return true;
123 } 123 }
124 124
125 RefPtrWillBeRawPtr<CSSValue> value = CSSParserFastPaths::parseColor(string, strict ? HTMLStandardMode : HTMLQuirksMode); 125 RefPtrWillBeRawPtr<CSSValue> value = CSSParserFastPaths::parseColor(string, strict ? HTMLStandardMode : HTMLQuirksMode);
126 // TODO(timloh): Why is this always strict mode? 126 // TODO(timloh): Why is this always strict mode?
127 if (!value) 127 if (!value)
128 value = parseSingleValue(CSSPropertyColor, string, strictCSSParserContex t()); 128 value = parseSingleValue(CSSPropertyColor, string, strictCSSParserContex t());
129 129
130 if (!value || !value->isColorValue()) 130 if (!value || !value->isColorValue())
131 return false; 131 return false;
132 color = toCSSColorValue(*value).value(); 132 color = toCSSColorValue(*value).value();
133 return true; 133 return true;
134 } 134 }
135 135
136 bool CSSParser::parseSystemColor(RGBA32& color, const String& colorString) 136 bool CSSParser::parseSystemColor(Color& color, const String& colorString)
137 { 137 {
138 CSSParserString cssColor; 138 CSSParserString cssColor;
139 cssColor.init(colorString); 139 cssColor.init(colorString);
140 CSSValueID id = cssValueKeywordID(cssColor); 140 CSSValueID id = cssValueKeywordID(cssColor);
141 if (!CSSPropertyParser::isSystemColor(id)) 141 if (!CSSPropertyParser::isSystemColor(id))
142 return false; 142 return false;
143 143
144 Color parsedColor = LayoutTheme::theme().systemColor(id); 144 color = LayoutTheme::theme().systemColor(id);
145 color = parsedColor.rgb();
146 return true; 145 return true;
147 } 146 }
148 147
149 PassRefPtrWillBeRawPtr<CSSValue> CSSParser::parseFontFaceDescriptor(CSSPropertyI D propertyID, const String& propertyValue, const CSSParserContext& context) 148 PassRefPtrWillBeRawPtr<CSSValue> CSSParser::parseFontFaceDescriptor(CSSPropertyI D propertyID, const String& propertyValue, const CSSParserContext& context)
150 { 149 {
151 StringBuilder builder; 150 StringBuilder builder;
152 builder.appendLiteral("@font-face { "); 151 builder.appendLiteral("@font-face { ");
153 builder.append(getPropertyNameString(propertyID)); 152 builder.append(getPropertyNameString(propertyID));
154 builder.appendLiteral(" : "); 153 builder.appendLiteral(" : ");
155 builder.append(propertyValue); 154 builder.append(propertyValue);
156 builder.appendLiteral("; }"); 155 builder.appendLiteral("; }");
157 RefPtrWillBeRawPtr<StyleRuleBase> rule = parseRule(context, nullptr, builder .toString()); 156 RefPtrWillBeRawPtr<StyleRuleBase> rule = parseRule(context, nullptr, builder .toString());
158 if (!rule || !rule->isFontFaceRule()) 157 if (!rule || !rule->isFontFaceRule())
159 return nullptr; 158 return nullptr;
160 return toStyleRuleFontFace(rule.get())->properties().getPropertyCSSValue(pro pertyID); 159 return toStyleRuleFontFace(rule.get())->properties().getPropertyCSSValue(pro pertyID);
161 } 160 }
162 161
163 } // namespace blink 162 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/css/parser/CSSParser.h ('k') | third_party/WebKit/Source/core/dom/Document.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698