| OLD | NEW |
| 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/CSSKeyframeRule.h" | 8 #include "core/css/CSSKeyframeRule.h" |
| 9 #include "core/css/StyleColor.h" | 9 #include "core/css/StyleColor.h" |
| 10 #include "core/css/StylePropertySet.h" | 10 #include "core/css/StylePropertySet.h" |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 return false; | 129 return false; |
| 130 | 130 |
| 131 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value.get()); | 131 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value.get()); |
| 132 if (!primitiveValue->isRGBColor()) | 132 if (!primitiveValue->isRGBColor()) |
| 133 return false; | 133 return false; |
| 134 | 134 |
| 135 color = primitiveValue->getRGBA32Value(); | 135 color = primitiveValue->getRGBA32Value(); |
| 136 return true; | 136 return true; |
| 137 } | 137 } |
| 138 | 138 |
| 139 StyleColor CSSParser::colorFromRGBColorString(const String& string) | |
| 140 { | |
| 141 // FIXME: Rework css parser so it is more SVG aware. | |
| 142 RGBA32 color; | |
| 143 if (parseColor(color, string.stripWhiteSpace())) | |
| 144 return StyleColor(color); | |
| 145 // FIXME: This branch catches the string currentColor, but we should error i
f we have an illegal color value. | |
| 146 return StyleColor::currentColor(); | |
| 147 } | |
| 148 | |
| 149 bool CSSParser::parseSystemColor(RGBA32& color, const String& colorString) | 139 bool CSSParser::parseSystemColor(RGBA32& color, const String& colorString) |
| 150 { | 140 { |
| 151 CSSParserString cssColor; | 141 CSSParserString cssColor; |
| 152 cssColor.init(colorString); | 142 cssColor.init(colorString); |
| 153 CSSValueID id = cssValueKeywordID(cssColor); | 143 CSSValueID id = cssValueKeywordID(cssColor); |
| 154 if (!CSSPropertyParser::isSystemColor(id)) | 144 if (!CSSPropertyParser::isSystemColor(id)) |
| 155 return false; | 145 return false; |
| 156 | 146 |
| 157 Color parsedColor = LayoutTheme::theme().systemColor(id); | 147 Color parsedColor = LayoutTheme::theme().systemColor(id); |
| 158 color = parsedColor.rgb(); | 148 color = parsedColor.rgb(); |
| 159 return true; | 149 return true; |
| 160 } | 150 } |
| 161 | 151 |
| 162 PassRefPtrWillBeRawPtr<CSSValue> CSSParser::parseFontFaceDescriptor(CSSPropertyI
D propertyID, const String& propertyValue, const CSSParserContext& context) | 152 PassRefPtrWillBeRawPtr<CSSValue> CSSParser::parseFontFaceDescriptor(CSSPropertyI
D propertyID, const String& propertyValue, const CSSParserContext& context) |
| 163 { | 153 { |
| 164 StringBuilder builder; | 154 StringBuilder builder; |
| 165 builder.appendLiteral("@font-face { "); | 155 builder.appendLiteral("@font-face { "); |
| 166 builder.append(getPropertyNameString(propertyID)); | 156 builder.append(getPropertyNameString(propertyID)); |
| 167 builder.appendLiteral(" : "); | 157 builder.appendLiteral(" : "); |
| 168 builder.append(propertyValue); | 158 builder.append(propertyValue); |
| 169 builder.appendLiteral("; }"); | 159 builder.appendLiteral("; }"); |
| 170 RefPtrWillBeRawPtr<StyleRuleBase> rule = parseRule(context, builder.toString
()); | 160 RefPtrWillBeRawPtr<StyleRuleBase> rule = parseRule(context, builder.toString
()); |
| 171 if (!rule || !rule->isFontFaceRule()) | 161 if (!rule || !rule->isFontFaceRule()) |
| 172 return nullptr; | 162 return nullptr; |
| 173 return toStyleRuleFontFace(rule.get())->properties().getPropertyCSSValue(pro
pertyID); | 163 return toStyleRuleFontFace(rule.get())->properties().getPropertyCSSValue(pro
pertyID); |
| 174 } | 164 } |
| 175 | 165 |
| 176 } // namespace blink | 166 } // namespace blink |
| OLD | NEW |