| 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" |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 important, ruleType); | 54 important, ruleType); |
| 55 if (parser.m_parsedProperties.isEmpty()) | 55 if (parser.m_parsedProperties.isEmpty()) |
| 56 return false; | 56 return false; |
| 57 return declaration->addParsedProperties(parser.m_parsedProperties); | 57 return declaration->addParsedProperties(parser.m_parsedProperties); |
| 58 } | 58 } |
| 59 | 59 |
| 60 bool CSSParserImpl::parseVariableValue(MutableStylePropertySet* declaration, | 60 bool CSSParserImpl::parseVariableValue(MutableStylePropertySet* declaration, |
| 61 const AtomicString& propertyName, | 61 const AtomicString& propertyName, |
| 62 const String& value, | 62 const String& value, |
| 63 bool important, | 63 bool important, |
| 64 const CSSParserContext& context) { | 64 const CSSParserContext& context, |
| 65 bool isAnimationTainted) { |
| 65 CSSParserImpl parser(context); | 66 CSSParserImpl parser(context); |
| 66 CSSTokenizer::Scope scope(value); | 67 CSSTokenizer::Scope scope(value); |
| 67 parser.consumeVariableValue(scope.tokenRange(), propertyName, important); | 68 parser.consumeVariableValue(scope.tokenRange(), propertyName, important, |
| 69 isAnimationTainted); |
| 68 if (parser.m_parsedProperties.isEmpty()) | 70 if (parser.m_parsedProperties.isEmpty()) |
| 69 return false; | 71 return false; |
| 70 return declaration->addParsedProperties(parser.m_parsedProperties); | 72 return declaration->addParsedProperties(parser.m_parsedProperties); |
| 71 } | 73 } |
| 72 | 74 |
| 73 static inline void filterProperties( | 75 static inline void filterProperties( |
| 74 bool important, | 76 bool important, |
| 75 const HeapVector<CSSProperty, 256>& input, | 77 const HeapVector<CSSProperty, 256>& input, |
| 76 HeapVector<CSSProperty, 256>& output, | 78 HeapVector<CSSProperty, 256>& output, |
| 77 size_t& unusedEntries, | 79 size_t& unusedEntries, |
| (...skipping 769 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 847 --last; | 849 --last; |
| 848 while (last->type() == WhitespaceToken) | 850 while (last->type() == WhitespaceToken) |
| 849 --last; | 851 --last; |
| 850 if (last->type() == DelimiterToken && last->delimiter() == '!') { | 852 if (last->type() == DelimiterToken && last->delimiter() == '!') { |
| 851 important = true; | 853 important = true; |
| 852 declarationValueEnd = last; | 854 declarationValueEnd = last; |
| 853 } | 855 } |
| 854 } | 856 } |
| 855 | 857 |
| 856 size_t propertiesCount = m_parsedProperties.size(); | 858 size_t propertiesCount = m_parsedProperties.size(); |
| 857 // TODO(timloh): This only be for StyleRule::Style, crbug.com/641873. | 859 // TODO(timloh): This should only be for StyleRule::Style/Keyframe, crbug.com/
641873. |
| 858 if (unresolvedProperty == CSSPropertyVariable) { | 860 if (unresolvedProperty == CSSPropertyVariable) { |
| 859 AtomicString variableName = token.value().toAtomicString(); | 861 AtomicString variableName = token.value().toAtomicString(); |
| 862 bool isAnimationTainted = ruleType == StyleRule::Keyframe; |
| 860 consumeVariableValue(range.makeSubRange(&range.peek(), declarationValueEnd), | 863 consumeVariableValue(range.makeSubRange(&range.peek(), declarationValueEnd), |
| 861 variableName, important); | 864 variableName, important, isAnimationTainted); |
| 862 } | 865 } |
| 863 | 866 |
| 867 // TODO(timloh): Should this check occur before the call to consumeVariableVal
ue()? |
| 864 if (important && | 868 if (important && |
| 865 (ruleType == StyleRule::FontFace || ruleType == StyleRule::Keyframe)) | 869 (ruleType == StyleRule::FontFace || ruleType == StyleRule::Keyframe)) |
| 866 return; | 870 return; |
| 867 | 871 |
| 868 if (unresolvedProperty != CSSPropertyInvalid && | 872 if (unresolvedProperty != CSSPropertyInvalid && |
| 869 unresolvedProperty != CSSPropertyVariable) { | 873 unresolvedProperty != CSSPropertyVariable) { |
| 870 if (m_styleSheet && m_styleSheet->singleOwnerDocument()) | 874 if (m_styleSheet && m_styleSheet->singleOwnerDocument()) |
| 871 Deprecation::warnOnDeprecatedProperties( | 875 Deprecation::warnOnDeprecatedProperties( |
| 872 m_styleSheet->singleOwnerDocument()->frame(), unresolvedProperty); | 876 m_styleSheet->singleOwnerDocument()->frame(), unresolvedProperty); |
| 873 consumeDeclarationValue( | 877 consumeDeclarationValue( |
| 874 range.makeSubRange(&range.peek(), declarationValueEnd), | 878 range.makeSubRange(&range.peek(), declarationValueEnd), |
| 875 unresolvedProperty, important, ruleType); | 879 unresolvedProperty, important, ruleType); |
| 876 } | 880 } |
| 877 | 881 |
| 878 if (m_observerWrapper && | 882 if (m_observerWrapper && |
| 879 (ruleType == StyleRule::Style || ruleType == StyleRule::Keyframe)) { | 883 (ruleType == StyleRule::Style || ruleType == StyleRule::Keyframe)) { |
| 880 m_observerWrapper->observer().observeProperty( | 884 m_observerWrapper->observer().observeProperty( |
| 881 m_observerWrapper->startOffset(rangeCopy), | 885 m_observerWrapper->startOffset(rangeCopy), |
| 882 m_observerWrapper->endOffset(rangeCopy), important, | 886 m_observerWrapper->endOffset(rangeCopy), important, |
| 883 m_parsedProperties.size() != propertiesCount); | 887 m_parsedProperties.size() != propertiesCount); |
| 884 } | 888 } |
| 885 } | 889 } |
| 886 | 890 |
| 887 void CSSParserImpl::consumeVariableValue(CSSParserTokenRange range, | 891 void CSSParserImpl::consumeVariableValue(CSSParserTokenRange range, |
| 888 const AtomicString& variableName, | 892 const AtomicString& variableName, |
| 889 bool important) { | 893 bool important, |
| 894 bool isAnimationTainted) { |
| 890 if (CSSCustomPropertyDeclaration* value = | 895 if (CSSCustomPropertyDeclaration* value = |
| 891 CSSVariableParser::parseDeclarationValue(variableName, range)) | 896 CSSVariableParser::parseDeclarationValue(variableName, range, |
| 897 isAnimationTainted)) |
| 892 m_parsedProperties.append( | 898 m_parsedProperties.append( |
| 893 CSSProperty(CSSPropertyVariable, *value, important)); | 899 CSSProperty(CSSPropertyVariable, *value, important)); |
| 894 } | 900 } |
| 895 | 901 |
| 896 void CSSParserImpl::consumeDeclarationValue(CSSParserTokenRange range, | 902 void CSSParserImpl::consumeDeclarationValue(CSSParserTokenRange range, |
| 897 CSSPropertyID unresolvedProperty, | 903 CSSPropertyID unresolvedProperty, |
| 898 bool important, | 904 bool important, |
| 899 StyleRule::RuleType ruleType) { | 905 StyleRule::RuleType ruleType) { |
| 900 CSSPropertyParser::parseValue(unresolvedProperty, important, range, m_context, | 906 CSSPropertyParser::parseValue(unresolvedProperty, important, range, m_context, |
| 901 m_parsedProperties, ruleType); | 907 m_parsedProperties, ruleType); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 919 else | 925 else |
| 920 return nullptr; // Parser error, invalid value in keyframe selector | 926 return nullptr; // Parser error, invalid value in keyframe selector |
| 921 if (range.atEnd()) | 927 if (range.atEnd()) |
| 922 return result; | 928 return result; |
| 923 if (range.consume().type() != CommaToken) | 929 if (range.consume().type() != CommaToken) |
| 924 return nullptr; // Parser error | 930 return nullptr; // Parser error |
| 925 } | 931 } |
| 926 } | 932 } |
| 927 | 933 |
| 928 } // namespace blink | 934 } // namespace blink |
| OLD | NEW |