| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/PropertyRegistration.h" | 5 #include "core/css/PropertyRegistration.h" |
| 6 | 6 |
| 7 #include "core/animation/CSSValueInterpolationType.h" | |
| 8 #include "core/css/CSSStyleSheet.h" | 7 #include "core/css/CSSStyleSheet.h" |
| 9 #include "core/css/CSSSyntaxDescriptor.h" | 8 #include "core/css/CSSSyntaxDescriptor.h" |
| 10 #include "core/css/CSSValueList.h" | 9 #include "core/css/CSSValueList.h" |
| 11 #include "core/css/CSSVariableReferenceValue.h" | 10 #include "core/css/CSSVariableReferenceValue.h" |
| 12 #include "core/css/PropertyDescriptor.h" | 11 #include "core/css/PropertyDescriptor.h" |
| 13 #include "core/css/PropertyRegistry.h" | 12 #include "core/css/PropertyRegistry.h" |
| 14 #include "core/css/StyleSheetContents.h" | 13 #include "core/css/StyleSheetContents.h" |
| 15 #include "core/css/parser/CSSParserContext.h" | 14 #include "core/css/parser/CSSParserContext.h" |
| 16 #include "core/css/parser/CSSTokenizer.h" | 15 #include "core/css/parser/CSSTokenizer.h" |
| 17 #include "core/css/parser/CSSVariableParser.h" | 16 #include "core/css/parser/CSSVariableParser.h" |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 } | 53 } |
| 55 return true; | 54 return true; |
| 56 } | 55 } |
| 57 | 56 |
| 58 // TODO(timloh): Images and transform-function values can also contain | 57 // TODO(timloh): Images and transform-function values can also contain |
| 59 // lengths. | 58 // lengths. |
| 60 | 59 |
| 61 return true; | 60 return true; |
| 62 } | 61 } |
| 63 | 62 |
| 64 InterpolationTypes interpolationTypesForSyntax(const AtomicString& propertyName, | |
| 65 const CSSSyntaxDescriptor&) { | |
| 66 PropertyHandle property(propertyName); | |
| 67 InterpolationTypes interpolationTypes; | |
| 68 // TODO(alancutter): Read the syntax descriptor and add the appropriate | |
| 69 // CSSInterpolationType subclasses. | |
| 70 interpolationTypes.push_back( | |
| 71 WTF::makeUnique<CSSValueInterpolationType>(property)); | |
| 72 return interpolationTypes; | |
| 73 } | |
| 74 | |
| 75 void PropertyRegistration::registerProperty( | 63 void PropertyRegistration::registerProperty( |
| 76 ExecutionContext* executionContext, | 64 ExecutionContext* executionContext, |
| 77 const PropertyDescriptor& descriptor, | 65 const PropertyDescriptor& descriptor, |
| 78 ExceptionState& exceptionState) { | 66 ExceptionState& exceptionState) { |
| 79 // Bindings code ensures these are set. | 67 // Bindings code ensures these are set. |
| 80 DCHECK(descriptor.hasName()); | 68 DCHECK(descriptor.hasName()); |
| 81 DCHECK(descriptor.hasInherits()); | 69 DCHECK(descriptor.hasInherits()); |
| 82 DCHECK(descriptor.hasSyntax()); | 70 DCHECK(descriptor.hasSyntax()); |
| 83 | 71 |
| 84 String name = descriptor.name(); | 72 String name = descriptor.name(); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 99 | 87 |
| 100 CSSSyntaxDescriptor syntaxDescriptor(descriptor.syntax()); | 88 CSSSyntaxDescriptor syntaxDescriptor(descriptor.syntax()); |
| 101 if (!syntaxDescriptor.isValid()) { | 89 if (!syntaxDescriptor.isValid()) { |
| 102 exceptionState.throwDOMException( | 90 exceptionState.throwDOMException( |
| 103 SyntaxError, | 91 SyntaxError, |
| 104 "The syntax provided is not a valid custom property syntax."); | 92 "The syntax provided is not a valid custom property syntax."); |
| 105 return; | 93 return; |
| 106 } | 94 } |
| 107 | 95 |
| 108 InterpolationTypes interpolationTypes = | 96 InterpolationTypes interpolationTypes = |
| 109 interpolationTypesForSyntax(atomicName, syntaxDescriptor); | 97 syntaxDescriptor.createInterpolationTypes(atomicName); |
| 110 | 98 |
| 111 if (descriptor.hasInitialValue()) { | 99 if (descriptor.hasInitialValue()) { |
| 112 CSSTokenizer tokenizer(descriptor.initialValue()); | 100 CSSTokenizer tokenizer(descriptor.initialValue()); |
| 113 bool isAnimationTainted = false; | 101 bool isAnimationTainted = false; |
| 114 const CSSValue* initial = syntaxDescriptor.parse( | 102 const CSSValue* initial = syntaxDescriptor.parse( |
| 115 tokenizer.tokenRange(), | 103 tokenizer.tokenRange(), |
| 116 document->elementSheet().contents()->parserContext(), | 104 document->elementSheet().contents()->parserContext(), |
| 117 isAnimationTainted); | 105 isAnimationTainted); |
| 118 if (!initial) { | 106 if (!initial) { |
| 119 exceptionState.throwDOMException( | 107 exceptionState.throwDOMException( |
| (...skipping 26 matching lines...) Expand all Loading... |
| 146 std::move(interpolationTypes)); | 134 std::move(interpolationTypes)); |
| 147 } | 135 } |
| 148 | 136 |
| 149 // TODO(timloh): Invalidate only elements with this custom property set | 137 // TODO(timloh): Invalidate only elements with this custom property set |
| 150 document->setNeedsStyleRecalc(SubtreeStyleChange, | 138 document->setNeedsStyleRecalc(SubtreeStyleChange, |
| 151 StyleChangeReasonForTracing::create( | 139 StyleChangeReasonForTracing::create( |
| 152 StyleChangeReason::PropertyRegistration)); | 140 StyleChangeReason::PropertyRegistration)); |
| 153 } | 141 } |
| 154 | 142 |
| 155 } // namespace blink | 143 } // namespace blink |
| OLD | NEW |