| 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" | |
| 11 #include "core/css/StyleRule.h" | 10 #include "core/css/StyleRule.h" |
| 12 #include "core/css/StyleSheetContents.h" | 11 #include "core/css/StyleSheetContents.h" |
| 13 #include "core/css/parser/CSSParserFastPaths.h" | 12 #include "core/css/parser/CSSParserFastPaths.h" |
| 14 #include "core/css/parser/CSSParserImpl.h" | 13 #include "core/css/parser/CSSParserImpl.h" |
| 15 #include "core/css/parser/CSSPropertyParser.h" | 14 #include "core/css/parser/CSSPropertyParser.h" |
| 16 #include "core/css/parser/CSSSelectorParser.h" | 15 #include "core/css/parser/CSSSelectorParser.h" |
| 17 #include "core/css/parser/CSSSupportsParser.h" | 16 #include "core/css/parser/CSSSupportsParser.h" |
| 18 #include "core/css/parser/CSSTokenizer.h" | 17 #include "core/css/parser/CSSTokenizer.h" |
| 19 #include "core/css/parser/CSSVariableParser.h" | 18 #include "core/css/parser/CSSVariableParser.h" |
| 20 #include "core/layout/LayoutTheme.h" | 19 #include "core/layout/LayoutTheme.h" |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 } | 68 } |
| 70 | 69 |
| 71 void CSSParser::parseSheetForInspector(const CSSParserContext& context, | 70 void CSSParser::parseSheetForInspector(const CSSParserContext& context, |
| 72 StyleSheetContents* styleSheet, | 71 StyleSheetContents* styleSheet, |
| 73 const String& text, | 72 const String& text, |
| 74 CSSParserObserver& observer) { | 73 CSSParserObserver& observer) { |
| 75 return CSSParserImpl::parseStyleSheetForInspector(text, context, styleSheet, | 74 return CSSParserImpl::parseStyleSheetForInspector(text, context, styleSheet, |
| 76 observer); | 75 observer); |
| 77 } | 76 } |
| 78 | 77 |
| 79 bool CSSParser::parseValue(MutableStylePropertySet* declaration, | 78 MutableStylePropertySet::SetResult CSSParser::parseValue( |
| 80 CSSPropertyID unresolvedProperty, | 79 MutableStylePropertySet* declaration, |
| 81 const String& string, | 80 CSSPropertyID unresolvedProperty, |
| 82 bool important, | 81 const String& string, |
| 83 StyleSheetContents* styleSheet) { | 82 bool important, |
| 84 if (string.isEmpty()) | 83 StyleSheetContents* styleSheet) { |
| 85 return false; | 84 if (string.isEmpty()) { |
| 85 bool didParse = false; |
| 86 bool didChange = false; |
| 87 return MutableStylePropertySet::SetResult{didParse, didChange}; |
| 88 } |
| 89 |
| 86 CSSPropertyID resolvedProperty = resolveCSSPropertyID(unresolvedProperty); | 90 CSSPropertyID resolvedProperty = resolveCSSPropertyID(unresolvedProperty); |
| 87 CSSParserMode parserMode = declaration->cssParserMode(); | 91 CSSParserMode parserMode = declaration->cssParserMode(); |
| 88 CSSValue* value = | 92 CSSValue* value = |
| 89 CSSParserFastPaths::maybeParseValue(resolvedProperty, string, parserMode); | 93 CSSParserFastPaths::maybeParseValue(resolvedProperty, string, parserMode); |
| 90 if (value) | 94 if (value) { |
| 91 return declaration->setProperty( | 95 bool didParse = true; |
| 96 bool didChange = declaration->setProperty( |
| 92 CSSProperty(resolvedProperty, *value, important)); | 97 CSSProperty(resolvedProperty, *value, important)); |
| 98 return MutableStylePropertySet::SetResult{didParse, didChange}; |
| 99 } |
| 93 CSSParserContext context(parserMode, nullptr); | 100 CSSParserContext context(parserMode, nullptr); |
| 94 if (styleSheet) { | 101 if (styleSheet) { |
| 95 context = styleSheet->parserContext(); | 102 context = styleSheet->parserContext(); |
| 96 context.setMode(parserMode); | 103 context.setMode(parserMode); |
| 97 } | 104 } |
| 98 return parseValue(declaration, unresolvedProperty, string, important, | 105 return parseValue(declaration, unresolvedProperty, string, important, |
| 99 context); | 106 context); |
| 100 } | 107 } |
| 101 | 108 |
| 102 bool CSSParser::parseValueForCustomProperty( | 109 MutableStylePropertySet::SetResult CSSParser::parseValueForCustomProperty( |
| 103 MutableStylePropertySet* declaration, | 110 MutableStylePropertySet* declaration, |
| 104 const AtomicString& propertyName, | 111 const AtomicString& propertyName, |
| 105 const String& value, | 112 const String& value, |
| 106 bool important, | 113 bool important, |
| 107 StyleSheetContents* styleSheet, | 114 StyleSheetContents* styleSheet, |
| 108 bool isAnimationTainted) { | 115 bool isAnimationTainted) { |
| 109 DCHECK(CSSVariableParser::isValidVariableName(propertyName)); | 116 DCHECK(CSSVariableParser::isValidVariableName(propertyName)); |
| 110 if (value.isEmpty()) | 117 if (value.isEmpty()) { |
| 111 return false; | 118 bool didParse = false; |
| 119 bool didChange = false; |
| 120 return MutableStylePropertySet::SetResult{didParse, didChange}; |
| 121 } |
| 112 CSSParserMode parserMode = declaration->cssParserMode(); | 122 CSSParserMode parserMode = declaration->cssParserMode(); |
| 113 CSSParserContext context(parserMode, nullptr); | 123 CSSParserContext context(parserMode, nullptr); |
| 114 if (styleSheet) { | 124 if (styleSheet) { |
| 115 context = styleSheet->parserContext(); | 125 context = styleSheet->parserContext(); |
| 116 context.setMode(parserMode); | 126 context.setMode(parserMode); |
| 117 } | 127 } |
| 118 return CSSParserImpl::parseVariableValue( | 128 return CSSParserImpl::parseVariableValue( |
| 119 declaration, propertyName, value, important, context, isAnimationTainted); | 129 declaration, propertyName, value, important, context, isAnimationTainted); |
| 120 } | 130 } |
| 121 | 131 |
| 122 ImmutableStylePropertySet* CSSParser::parseCustomPropertySet( | 132 ImmutableStylePropertySet* CSSParser::parseCustomPropertySet( |
| 123 CSSParserTokenRange range) { | 133 CSSParserTokenRange range) { |
| 124 return CSSParserImpl::parseCustomPropertySet(range); | 134 return CSSParserImpl::parseCustomPropertySet(range); |
| 125 } | 135 } |
| 126 | 136 |
| 127 bool CSSParser::parseValue(MutableStylePropertySet* declaration, | 137 MutableStylePropertySet::SetResult CSSParser::parseValue( |
| 128 CSSPropertyID unresolvedProperty, | 138 MutableStylePropertySet* declaration, |
| 129 const String& string, | 139 CSSPropertyID unresolvedProperty, |
| 130 bool important, | 140 const String& string, |
| 131 const CSSParserContext& context) { | 141 bool important, |
| 142 const CSSParserContext& context) { |
| 132 return CSSParserImpl::parseValue(declaration, unresolvedProperty, string, | 143 return CSSParserImpl::parseValue(declaration, unresolvedProperty, string, |
| 133 important, context); | 144 important, context); |
| 134 } | 145 } |
| 135 | 146 |
| 136 const CSSValue* CSSParser::parseSingleValue(CSSPropertyID propertyID, | 147 const CSSValue* CSSParser::parseSingleValue(CSSPropertyID propertyID, |
| 137 const String& string, | 148 const String& string, |
| 138 const CSSParserContext& context) { | 149 const CSSParserContext& context) { |
| 139 if (string.isEmpty()) | 150 if (string.isEmpty()) |
| 140 return nullptr; | 151 return nullptr; |
| 141 if (CSSValue* value = CSSParserFastPaths::maybeParseValue(propertyID, string, | 152 if (CSSValue* value = CSSParserFastPaths::maybeParseValue(propertyID, string, |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 builder.append(propertyValue); | 227 builder.append(propertyValue); |
| 217 builder.append("; }"); | 228 builder.append("; }"); |
| 218 StyleRuleBase* rule = parseRule(context, nullptr, builder.toString()); | 229 StyleRuleBase* rule = parseRule(context, nullptr, builder.toString()); |
| 219 if (!rule || !rule->isFontFaceRule()) | 230 if (!rule || !rule->isFontFaceRule()) |
| 220 return nullptr; | 231 return nullptr; |
| 221 return toStyleRuleFontFace(rule)->properties().getPropertyCSSValue( | 232 return toStyleRuleFontFace(rule)->properties().getPropertyCSSValue( |
| 222 propertyID); | 233 propertyID); |
| 223 } | 234 } |
| 224 | 235 |
| 225 } // namespace blink | 236 } // namespace blink |
| OLD | NEW |