Chromium Code Reviews| 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/PropertyRegistry.h" | |
| 11 #include "core/css/StyleRuleImport.h" | 12 #include "core/css/StyleRuleImport.h" |
| 12 #include "core/css/StyleRuleKeyframe.h" | 13 #include "core/css/StyleRuleKeyframe.h" |
| 13 #include "core/css/StyleRuleNamespace.h" | 14 #include "core/css/StyleRuleNamespace.h" |
| 14 #include "core/css/StyleSheetContents.h" | 15 #include "core/css/StyleSheetContents.h" |
| 15 #include "core/css/parser/CSSAtRuleID.h" | 16 #include "core/css/parser/CSSAtRuleID.h" |
| 16 #include "core/css/parser/CSSLazyParsingState.h" | 17 #include "core/css/parser/CSSLazyParsingState.h" |
| 17 #include "core/css/parser/CSSLazyPropertyParserImpl.h" | 18 #include "core/css/parser/CSSLazyPropertyParserImpl.h" |
| 18 #include "core/css/parser/CSSParserObserver.h" | 19 #include "core/css/parser/CSSParserObserver.h" |
| 19 #include "core/css/parser/CSSParserObserverWrapper.h" | 20 #include "core/css/parser/CSSParserObserverWrapper.h" |
| 20 #include "core/css/parser/CSSParserSelector.h" | 21 #include "core/css/parser/CSSParserSelector.h" |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 61 if (!parser.m_parsedProperties.isEmpty()) { | 62 if (!parser.m_parsedProperties.isEmpty()) { |
| 62 didParse = true; | 63 didParse = true; |
| 63 didChange = declaration->addParsedProperties(parser.m_parsedProperties); | 64 didChange = declaration->addParsedProperties(parser.m_parsedProperties); |
| 64 } | 65 } |
| 65 return MutableStylePropertySet::SetResult{didParse, didChange}; | 66 return MutableStylePropertySet::SetResult{didParse, didChange}; |
| 66 } | 67 } |
| 67 | 68 |
| 68 MutableStylePropertySet::SetResult CSSParserImpl::parseVariableValue( | 69 MutableStylePropertySet::SetResult CSSParserImpl::parseVariableValue( |
| 69 MutableStylePropertySet* declaration, | 70 MutableStylePropertySet* declaration, |
| 70 const AtomicString& propertyName, | 71 const AtomicString& propertyName, |
| 72 const PropertyRegistry* registry, | |
| 71 const String& value, | 73 const String& value, |
| 72 bool important, | 74 bool important, |
| 73 const CSSParserContext& context, | 75 const CSSParserContext& context, |
| 74 bool isAnimationTainted) { | 76 bool isAnimationTainted) { |
| 75 CSSParserImpl parser(context); | 77 CSSParserImpl parser(context); |
| 76 CSSTokenizer tokenizer(value); | 78 CSSTokenizer tokenizer(value); |
| 77 parser.consumeVariableValue(tokenizer.tokenRange(), propertyName, important, | 79 parser.consumeVariableValue(tokenizer.tokenRange(), propertyName, important, |
| 78 isAnimationTainted); | 80 isAnimationTainted); |
| 79 bool didParse = false; | 81 bool didParse = false; |
| 80 bool didChange = false; | 82 bool didChange = false; |
| 81 if (!parser.m_parsedProperties.isEmpty()) { | 83 if (!parser.m_parsedProperties.isEmpty()) { |
| 84 if (registry) { | |
| 85 const PropertyRegistry::Registration* registration = | |
| 86 registry->registration(propertyName); | |
| 87 // TODO(timloh): This is a bit wasteful, we parse the registered property | |
| 88 // to validate but throw away the result. | |
|
alancutter (OOO until 2018)
2017/01/04 01:03:42
General comment: A CSSValue cache (with a void* to
| |
| 89 if (registration && | |
| 90 !registration->syntax().parse(tokenizer.tokenRange(), | |
| 91 isAnimationTainted)) | |
| 92 return MutableStylePropertySet::SetResult{didParse, didChange}; | |
|
alancutter (OOO until 2018)
2017/01/04 01:03:42
Use braces here.
Timothy Loh
2017/01/04 02:00:59
sure
| |
| 93 } | |
| 82 didParse = true; | 94 didParse = true; |
| 83 didChange = declaration->addParsedProperties(parser.m_parsedProperties); | 95 didChange = declaration->addParsedProperties(parser.m_parsedProperties); |
| 84 } | 96 } |
| 85 return MutableStylePropertySet::SetResult{didParse, didChange}; | 97 return MutableStylePropertySet::SetResult{didParse, didChange}; |
| 86 } | 98 } |
| 87 | 99 |
| 88 static inline void filterProperties( | 100 static inline void filterProperties( |
| 89 bool important, | 101 bool important, |
| 90 const HeapVector<CSSProperty, 256>& input, | 102 const HeapVector<CSSProperty, 256>& input, |
| 91 HeapVector<CSSProperty, 256>& output, | 103 HeapVector<CSSProperty, 256>& output, |
| (...skipping 872 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 964 else | 976 else |
| 965 return nullptr; // Parser error, invalid value in keyframe selector | 977 return nullptr; // Parser error, invalid value in keyframe selector |
| 966 if (range.atEnd()) | 978 if (range.atEnd()) |
| 967 return result; | 979 return result; |
| 968 if (range.consume().type() != CommaToken) | 980 if (range.consume().type() != CommaToken) |
| 969 return nullptr; // Parser error | 981 return nullptr; // Parser error |
| 970 } | 982 } |
| 971 } | 983 } |
| 972 | 984 |
| 973 } // namespace blink | 985 } // namespace blink |
| OLD | NEW |