| 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 "core/css/parser/CSSParser.h" | 5 #include "core/css/parser/CSSParser.h" |
| 6 | 6 |
| 7 #include "core/css/CSSColorValue.h" | 7 #include "core/css/CSSColorValue.h" |
| 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 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 return toStyleRuleKeyframe(keyframe.get()); | 125 return toStyleRuleKeyframe(keyframe.get()); |
| 126 } | 126 } |
| 127 | 127 |
| 128 bool CSSParser::parseSupportsCondition(const String& condition) | 128 bool CSSParser::parseSupportsCondition(const String& condition) |
| 129 { | 129 { |
| 130 CSSTokenizer::Scope scope(condition); | 130 CSSTokenizer::Scope scope(condition); |
| 131 CSSParserImpl parser(strictCSSParserContext()); | 131 CSSParserImpl parser(strictCSSParserContext()); |
| 132 return CSSSupportsParser::supportsCondition(scope.tokenRange(), parser) == C
SSSupportsParser::Supported; | 132 return CSSSupportsParser::supportsCondition(scope.tokenRange(), parser) == C
SSSupportsParser::Supported; |
| 133 } | 133 } |
| 134 | 134 |
| 135 bool CSSParser::parseColor(Color& color, const String& string, bool strict) | 135 bool CSSParser::parseColor(Color& color, const String& string, CSSValuePool* loc
alCssValuePool, bool strict) |
| 136 { | 136 { |
| 137 if (string.isEmpty()) | 137 if (string.isEmpty()) |
| 138 return false; | 138 return false; |
| 139 | 139 |
| 140 // The regular color parsers don't resolve named colors, so explicitly | 140 // The regular color parsers don't resolve named colors, so explicitly |
| 141 // handle these first. | 141 // handle these first. |
| 142 Color namedColor; | 142 Color namedColor; |
| 143 if (namedColor.setNamedColor(string)) { | 143 if (namedColor.setNamedColor(string)) { |
| 144 color = namedColor; | 144 color = namedColor; |
| 145 return true; | 145 return true; |
| 146 } | 146 } |
| 147 | 147 |
| 148 RawPtr<CSSValue> value = CSSParserFastPaths::parseColor(string, strict ? HTM
LStandardMode : HTMLQuirksMode); | 148 RawPtr<CSSValue> value; |
| 149 if (!localCssValuePool) { |
| 150 value = CSSParserFastPaths::parseColor(string, strict ? HTMLStandardMode
: HTMLQuirksMode, &cssValuePool()); |
| 151 } else { |
| 152 value = CSSParserFastPaths::parseColor(string, strict ? HTMLStandardMode
: HTMLQuirksMode, localCssValuePool); |
| 153 } |
| 154 |
| 149 // TODO(timloh): Why is this always strict mode? | 155 // TODO(timloh): Why is this always strict mode? |
| 150 if (!value) | 156 if (!value) |
| 151 value = parseSingleValue(CSSPropertyColor, string, strictCSSParserContex
t()); | 157 value = parseSingleValue(CSSPropertyColor, string, strictCSSParserContex
t()); |
| 152 | 158 |
| 153 if (!value || !value->isColorValue()) | 159 if (!value || !value->isColorValue()) |
| 154 return false; | 160 return false; |
| 155 color = toCSSColorValue(*value).value(); | 161 color = toCSSColorValue(*value).value(); |
| 156 return true; | 162 return true; |
| 157 } | 163 } |
| 158 | 164 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 176 builder.appendLiteral(" : "); | 182 builder.appendLiteral(" : "); |
| 177 builder.append(propertyValue); | 183 builder.append(propertyValue); |
| 178 builder.appendLiteral("; }"); | 184 builder.appendLiteral("; }"); |
| 179 RawPtr<StyleRuleBase> rule = parseRule(context, nullptr, builder.toString())
; | 185 RawPtr<StyleRuleBase> rule = parseRule(context, nullptr, builder.toString())
; |
| 180 if (!rule || !rule->isFontFaceRule()) | 186 if (!rule || !rule->isFontFaceRule()) |
| 181 return nullptr; | 187 return nullptr; |
| 182 return toStyleRuleFontFace(rule.get())->properties().getPropertyCSSValue(pro
pertyID); | 188 return toStyleRuleFontFace(rule.get())->properties().getPropertyCSSValue(pro
pertyID); |
| 183 } | 189 } |
| 184 | 190 |
| 185 } // namespace blink | 191 } // namespace blink |
| OLD | NEW |