Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(282)

Side by Side Diff: third_party/WebKit/Source/core/css/parser/CSSParserImpl.cpp

Issue 2323633002: Implement animation tainted custom property values (Closed)
Patch Set: Rebased Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 important, ruleType); 56 important, ruleType);
57 if (parser.m_parsedProperties.isEmpty()) 57 if (parser.m_parsedProperties.isEmpty())
58 return false; 58 return false;
59 return declaration->addParsedProperties(parser.m_parsedProperties); 59 return declaration->addParsedProperties(parser.m_parsedProperties);
60 } 60 }
61 61
62 bool CSSParserImpl::parseVariableValue(MutableStylePropertySet* declaration, 62 bool CSSParserImpl::parseVariableValue(MutableStylePropertySet* declaration,
63 const AtomicString& propertyName, 63 const AtomicString& propertyName,
64 const String& value, 64 const String& value,
65 bool important, 65 bool important,
66 const CSSParserContext& context) { 66 const CSSParserContext& context,
67 bool isAnimationTainted) {
67 CSSParserImpl parser(context); 68 CSSParserImpl parser(context);
68 CSSTokenizer::Scope scope(value); 69 CSSTokenizer::Scope scope(value);
69 parser.consumeVariableValue(scope.tokenRange(), propertyName, important); 70 parser.consumeVariableValue(scope.tokenRange(), propertyName, important,
71 isAnimationTainted);
70 if (parser.m_parsedProperties.isEmpty()) 72 if (parser.m_parsedProperties.isEmpty())
71 return false; 73 return false;
72 return declaration->addParsedProperties(parser.m_parsedProperties); 74 return declaration->addParsedProperties(parser.m_parsedProperties);
73 } 75 }
74 76
75 static inline void filterProperties( 77 static inline void filterProperties(
76 bool important, 78 bool important,
77 const HeapVector<CSSProperty, 256>& input, 79 const HeapVector<CSSProperty, 256>& input,
78 HeapVector<CSSProperty, 256>& output, 80 HeapVector<CSSProperty, 256>& output,
79 size_t& unusedEntries, 81 size_t& unusedEntries,
(...skipping 769 matching lines...) Expand 10 before | Expand all | Expand 10 after
849 --last; 851 --last;
850 while (last->type() == WhitespaceToken) 852 while (last->type() == WhitespaceToken)
851 --last; 853 --last;
852 if (last->type() == DelimiterToken && last->delimiter() == '!') { 854 if (last->type() == DelimiterToken && last->delimiter() == '!') {
853 important = true; 855 important = true;
854 declarationValueEnd = last; 856 declarationValueEnd = last;
855 } 857 }
856 } 858 }
857 859
858 size_t propertiesCount = m_parsedProperties.size(); 860 size_t propertiesCount = m_parsedProperties.size();
859 // TODO(timloh): This only be for StyleRule::Style, crbug.com/641873. 861 // TODO(timloh): This should only be for StyleRule::Style/Keyframe,
862 // crbug.com/641873.
860 if (unresolvedProperty == CSSPropertyVariable) { 863 if (unresolvedProperty == CSSPropertyVariable) {
861 AtomicString variableName = token.value().toAtomicString(); 864 AtomicString variableName = token.value().toAtomicString();
865 bool isAnimationTainted = ruleType == StyleRule::Keyframe;
862 consumeVariableValue(range.makeSubRange(&range.peek(), declarationValueEnd), 866 consumeVariableValue(range.makeSubRange(&range.peek(), declarationValueEnd),
863 variableName, important); 867 variableName, important, isAnimationTainted);
864 } 868 }
865 869
870 // TODO(timloh): Should this check occur before the call to
871 // consumeVariableValue()?
866 if (important && 872 if (important &&
867 (ruleType == StyleRule::FontFace || ruleType == StyleRule::Keyframe)) 873 (ruleType == StyleRule::FontFace || ruleType == StyleRule::Keyframe))
868 return; 874 return;
869 875
870 if (unresolvedProperty != CSSPropertyInvalid && 876 if (unresolvedProperty != CSSPropertyInvalid &&
871 unresolvedProperty != CSSPropertyVariable) { 877 unresolvedProperty != CSSPropertyVariable) {
872 if (m_styleSheet && m_styleSheet->singleOwnerDocument()) 878 if (m_styleSheet && m_styleSheet->singleOwnerDocument())
873 Deprecation::warnOnDeprecatedProperties( 879 Deprecation::warnOnDeprecatedProperties(
874 m_styleSheet->singleOwnerDocument()->frame(), unresolvedProperty); 880 m_styleSheet->singleOwnerDocument()->frame(), unresolvedProperty);
875 consumeDeclarationValue( 881 consumeDeclarationValue(
876 range.makeSubRange(&range.peek(), declarationValueEnd), 882 range.makeSubRange(&range.peek(), declarationValueEnd),
877 unresolvedProperty, important, ruleType); 883 unresolvedProperty, important, ruleType);
878 } 884 }
879 885
880 if (m_observerWrapper && 886 if (m_observerWrapper &&
881 (ruleType == StyleRule::Style || ruleType == StyleRule::Keyframe)) { 887 (ruleType == StyleRule::Style || ruleType == StyleRule::Keyframe)) {
882 m_observerWrapper->observer().observeProperty( 888 m_observerWrapper->observer().observeProperty(
883 m_observerWrapper->startOffset(rangeCopy), 889 m_observerWrapper->startOffset(rangeCopy),
884 m_observerWrapper->endOffset(rangeCopy), important, 890 m_observerWrapper->endOffset(rangeCopy), important,
885 m_parsedProperties.size() != propertiesCount); 891 m_parsedProperties.size() != propertiesCount);
886 } 892 }
887 } 893 }
888 894
889 void CSSParserImpl::consumeVariableValue(CSSParserTokenRange range, 895 void CSSParserImpl::consumeVariableValue(CSSParserTokenRange range,
890 const AtomicString& variableName, 896 const AtomicString& variableName,
891 bool important) { 897 bool important,
898 bool isAnimationTainted) {
892 if (CSSCustomPropertyDeclaration* value = 899 if (CSSCustomPropertyDeclaration* value =
893 CSSVariableParser::parseDeclarationValue(variableName, range)) 900 CSSVariableParser::parseDeclarationValue(variableName, range,
901 isAnimationTainted))
894 m_parsedProperties.append( 902 m_parsedProperties.append(
895 CSSProperty(CSSPropertyVariable, *value, important)); 903 CSSProperty(CSSPropertyVariable, *value, important));
896 } 904 }
897 905
898 void CSSParserImpl::consumeDeclarationValue(CSSParserTokenRange range, 906 void CSSParserImpl::consumeDeclarationValue(CSSParserTokenRange range,
899 CSSPropertyID unresolvedProperty, 907 CSSPropertyID unresolvedProperty,
900 bool important, 908 bool important,
901 StyleRule::RuleType ruleType) { 909 StyleRule::RuleType ruleType) {
902 CSSPropertyParser::parseValue(unresolvedProperty, important, range, m_context, 910 CSSPropertyParser::parseValue(unresolvedProperty, important, range, m_context,
903 m_parsedProperties, ruleType); 911 m_parsedProperties, ruleType);
(...skipping 17 matching lines...) Expand all
921 else 929 else
922 return nullptr; // Parser error, invalid value in keyframe selector 930 return nullptr; // Parser error, invalid value in keyframe selector
923 if (range.atEnd()) 931 if (range.atEnd())
924 return result; 932 return result;
925 if (range.consume().type() != CommaToken) 933 if (range.consume().type() != CommaToken)
926 return nullptr; // Parser error 934 return nullptr; // Parser error
927 } 935 }
928 } 936 }
929 937
930 } // namespace blink 938 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698