| 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/CSSParserImpl.h" | 5 #include "core/css/parser/CSSParserImpl.h" |
| 6 | 6 |
| 7 #include "core/css/CSSCustomIdentValue.h" | 7 #include "core/css/CSSCustomIdentValue.h" |
| 8 #include "core/css/CSSCustomPropertyDeclaration.h" | 8 #include "core/css/CSSCustomPropertyDeclaration.h" |
| 9 #include "core/css/CSSKeyframesRule.h" | 9 #include "core/css/CSSKeyframesRule.h" |
| 10 #include "core/css/CSSStyleSheet.h" | 10 #include "core/css/CSSStyleSheet.h" |
| 11 #include "core/css/StylePropertySet.h" | |
| 12 #include "core/css/StyleRuleImport.h" | 11 #include "core/css/StyleRuleImport.h" |
| 13 #include "core/css/StyleRuleKeyframe.h" | 12 #include "core/css/StyleRuleKeyframe.h" |
| 14 #include "core/css/StyleRuleNamespace.h" | 13 #include "core/css/StyleRuleNamespace.h" |
| 15 #include "core/css/StyleSheetContents.h" | 14 #include "core/css/StyleSheetContents.h" |
| 16 #include "core/css/parser/CSSAtRuleID.h" | 15 #include "core/css/parser/CSSAtRuleID.h" |
| 17 #include "core/css/parser/CSSLazyParsingState.h" | 16 #include "core/css/parser/CSSLazyParsingState.h" |
| 18 #include "core/css/parser/CSSLazyPropertyParserImpl.h" | 17 #include "core/css/parser/CSSLazyPropertyParserImpl.h" |
| 19 #include "core/css/parser/CSSParserObserver.h" | 18 #include "core/css/parser/CSSParserObserver.h" |
| 20 #include "core/css/parser/CSSParserObserverWrapper.h" | 19 #include "core/css/parser/CSSParserObserverWrapper.h" |
| 21 #include "core/css/parser/CSSParserSelector.h" | 20 #include "core/css/parser/CSSParserSelector.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 35 #include <memory> | 34 #include <memory> |
| 36 | 35 |
| 37 namespace blink { | 36 namespace blink { |
| 38 | 37 |
| 39 CSSParserImpl::CSSParserImpl(const CSSParserContext& context, | 38 CSSParserImpl::CSSParserImpl(const CSSParserContext& context, |
| 40 StyleSheetContents* styleSheet) | 39 StyleSheetContents* styleSheet) |
| 41 : m_context(context), | 40 : m_context(context), |
| 42 m_styleSheet(styleSheet), | 41 m_styleSheet(styleSheet), |
| 43 m_observerWrapper(nullptr) {} | 42 m_observerWrapper(nullptr) {} |
| 44 | 43 |
| 45 bool CSSParserImpl::parseValue(MutableStylePropertySet* declaration, | 44 MutableStylePropertySet::SetResult CSSParserImpl::parseValue( |
| 46 CSSPropertyID unresolvedProperty, | 45 MutableStylePropertySet* declaration, |
| 47 const String& string, | 46 CSSPropertyID unresolvedProperty, |
| 48 bool important, | 47 const String& string, |
| 49 const CSSParserContext& context) { | 48 bool important, |
| 49 const CSSParserContext& context) { |
| 50 CSSParserImpl parser(context); | 50 CSSParserImpl parser(context); |
| 51 StyleRule::RuleType ruleType = StyleRule::Style; | 51 StyleRule::RuleType ruleType = StyleRule::Style; |
| 52 if (declaration->cssParserMode() == CSSViewportRuleMode) | 52 if (declaration->cssParserMode() == CSSViewportRuleMode) |
| 53 ruleType = StyleRule::Viewport; | 53 ruleType = StyleRule::Viewport; |
| 54 else if (declaration->cssParserMode() == CSSFontFaceRuleMode) | 54 else if (declaration->cssParserMode() == CSSFontFaceRuleMode) |
| 55 ruleType = StyleRule::FontFace; | 55 ruleType = StyleRule::FontFace; |
| 56 CSSTokenizer tokenizer(string); | 56 CSSTokenizer tokenizer(string); |
| 57 parser.consumeDeclarationValue(tokenizer.tokenRange(), unresolvedProperty, | 57 parser.consumeDeclarationValue(tokenizer.tokenRange(), unresolvedProperty, |
| 58 important, ruleType); | 58 important, ruleType); |
| 59 if (parser.m_parsedProperties.isEmpty()) | 59 bool didParse = false; |
| 60 return false; | 60 bool didChange = false; |
| 61 return declaration->addParsedProperties(parser.m_parsedProperties); | 61 if (!parser.m_parsedProperties.isEmpty()) { |
| 62 didParse = true; |
| 63 didChange = declaration->addParsedProperties(parser.m_parsedProperties); |
| 64 } |
| 65 return MutableStylePropertySet::SetResult{didParse, didChange}; |
| 62 } | 66 } |
| 63 | 67 |
| 64 bool CSSParserImpl::parseVariableValue(MutableStylePropertySet* declaration, | 68 MutableStylePropertySet::SetResult CSSParserImpl::parseVariableValue( |
| 65 const AtomicString& propertyName, | 69 MutableStylePropertySet* declaration, |
| 66 const String& value, | 70 const AtomicString& propertyName, |
| 67 bool important, | 71 const String& value, |
| 68 const CSSParserContext& context, | 72 bool important, |
| 69 bool isAnimationTainted) { | 73 const CSSParserContext& context, |
| 74 bool isAnimationTainted) { |
| 70 CSSParserImpl parser(context); | 75 CSSParserImpl parser(context); |
| 71 CSSTokenizer tokenizer(value); | 76 CSSTokenizer tokenizer(value); |
| 72 parser.consumeVariableValue(tokenizer.tokenRange(), propertyName, important, | 77 parser.consumeVariableValue(tokenizer.tokenRange(), propertyName, important, |
| 73 isAnimationTainted); | 78 isAnimationTainted); |
| 74 if (parser.m_parsedProperties.isEmpty()) | 79 bool didParse = false; |
| 75 return false; | 80 bool didChange = false; |
| 76 return declaration->addParsedProperties(parser.m_parsedProperties); | 81 if (!parser.m_parsedProperties.isEmpty()) { |
| 82 didParse = true; |
| 83 didChange = declaration->addParsedProperties(parser.m_parsedProperties); |
| 84 } |
| 85 return MutableStylePropertySet::SetResult{didParse, didChange}; |
| 77 } | 86 } |
| 78 | 87 |
| 79 static inline void filterProperties( | 88 static inline void filterProperties( |
| 80 bool important, | 89 bool important, |
| 81 const HeapVector<CSSProperty, 256>& input, | 90 const HeapVector<CSSProperty, 256>& input, |
| 82 HeapVector<CSSProperty, 256>& output, | 91 HeapVector<CSSProperty, 256>& output, |
| 83 size_t& unusedEntries, | 92 size_t& unusedEntries, |
| 84 std::bitset<numCSSProperties>& seenProperties, | 93 std::bitset<numCSSProperties>& seenProperties, |
| 85 HashSet<AtomicString>& seenCustomProperties) { | 94 HashSet<AtomicString>& seenCustomProperties) { |
| 86 // Add properties in reverse order so that highest priority definitions are | 95 // Add properties in reverse order so that highest priority definitions are |
| (...skipping 869 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 956 else | 965 else |
| 957 return nullptr; // Parser error, invalid value in keyframe selector | 966 return nullptr; // Parser error, invalid value in keyframe selector |
| 958 if (range.atEnd()) | 967 if (range.atEnd()) |
| 959 return result; | 968 return result; |
| 960 if (range.consume().type() != CommaToken) | 969 if (range.consume().type() != CommaToken) |
| 961 return nullptr; // Parser error | 970 return nullptr; // Parser error |
| 962 } | 971 } |
| 963 } | 972 } |
| 964 | 973 |
| 965 } // namespace blink | 974 } // namespace blink |
| OLD | NEW |