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/CSSSyntaxDescriptor.h" | 7 #include "core/css/CSSSyntaxDescriptor.h" |
9 #include "core/css/CSSValueList.h" | 8 #include "core/css/CSSValueList.h" |
10 #include "core/css/CSSVariableReferenceValue.h" | 9 #include "core/css/CSSVariableReferenceValue.h" |
11 #include "core/css/PropertyDescriptor.h" | 10 #include "core/css/PropertyDescriptor.h" |
12 #include "core/css/PropertyRegistry.h" | 11 #include "core/css/PropertyRegistry.h" |
13 #include "core/css/parser/CSSTokenizer.h" | 12 #include "core/css/parser/CSSTokenizer.h" |
14 #include "core/css/parser/CSSVariableParser.h" | 13 #include "core/css/parser/CSSVariableParser.h" |
15 #include "core/dom/Document.h" | 14 #include "core/dom/Document.h" |
16 #include "core/dom/ExceptionCode.h" | 15 #include "core/dom/ExceptionCode.h" |
17 #include "core/dom/StyleChangeReason.h" | 16 #include "core/dom/StyleChangeReason.h" |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 } | 49 } |
51 return true; | 50 return true; |
52 } | 51 } |
53 | 52 |
54 // TODO(timloh): Images and transform-function values can also contain | 53 // TODO(timloh): Images and transform-function values can also contain |
55 // lengths. | 54 // lengths. |
56 | 55 |
57 return true; | 56 return true; |
58 } | 57 } |
59 | 58 |
60 InterpolationTypes interpolationTypesForSyntax(const AtomicString& propertyName, | |
61 const CSSSyntaxDescriptor&) { | |
62 PropertyHandle property(propertyName); | |
63 InterpolationTypes interpolationTypes; | |
64 // TODO(alancutter): Read the syntax descriptor and add the appropriate | |
65 // CSSInterpolationType subclasses. | |
66 interpolationTypes.append( | |
67 WTF::makeUnique<CSSValueInterpolationType>(property)); | |
68 return interpolationTypes; | |
69 } | |
70 | |
71 void PropertyRegistration::registerProperty( | 59 void PropertyRegistration::registerProperty( |
72 ExecutionContext* executionContext, | 60 ExecutionContext* executionContext, |
73 const PropertyDescriptor& descriptor, | 61 const PropertyDescriptor& descriptor, |
74 ExceptionState& exceptionState) { | 62 ExceptionState& exceptionState) { |
75 // Bindings code ensures these are set. | 63 // Bindings code ensures these are set. |
76 DCHECK(descriptor.hasName()); | 64 DCHECK(descriptor.hasName()); |
77 DCHECK(descriptor.hasInherits()); | 65 DCHECK(descriptor.hasInherits()); |
78 DCHECK(descriptor.hasSyntax()); | 66 DCHECK(descriptor.hasSyntax()); |
79 | 67 |
80 String name = descriptor.name(); | 68 String name = descriptor.name(); |
(...skipping 14 matching lines...) Expand all Loading... |
95 | 83 |
96 CSSSyntaxDescriptor syntaxDescriptor(descriptor.syntax()); | 84 CSSSyntaxDescriptor syntaxDescriptor(descriptor.syntax()); |
97 if (!syntaxDescriptor.isValid()) { | 85 if (!syntaxDescriptor.isValid()) { |
98 exceptionState.throwDOMException( | 86 exceptionState.throwDOMException( |
99 SyntaxError, | 87 SyntaxError, |
100 "The syntax provided is not a valid custom property syntax."); | 88 "The syntax provided is not a valid custom property syntax."); |
101 return; | 89 return; |
102 } | 90 } |
103 | 91 |
104 InterpolationTypes interpolationTypes = | 92 InterpolationTypes interpolationTypes = |
105 interpolationTypesForSyntax(atomicName, syntaxDescriptor); | 93 syntaxDescriptor.createInterpolationTypes(atomicName); |
106 | 94 |
107 if (descriptor.hasInitialValue()) { | 95 if (descriptor.hasInitialValue()) { |
108 CSSTokenizer tokenizer(descriptor.initialValue()); | 96 CSSTokenizer tokenizer(descriptor.initialValue()); |
109 bool isAnimationTainted = false; | 97 bool isAnimationTainted = false; |
110 const CSSValue* initial = | 98 const CSSValue* initial = |
111 syntaxDescriptor.parse(tokenizer.tokenRange(), isAnimationTainted); | 99 syntaxDescriptor.parse(tokenizer.tokenRange(), isAnimationTainted); |
112 if (!initial) { | 100 if (!initial) { |
113 exceptionState.throwDOMException( | 101 exceptionState.throwDOMException( |
114 SyntaxError, | 102 SyntaxError, |
115 "The initial value provided does not parse for the given syntax."); | 103 "The initial value provided does not parse for the given syntax."); |
(...skipping 22 matching lines...) Expand all Loading... |
138 std::move(interpolationTypes)); | 126 std::move(interpolationTypes)); |
139 } | 127 } |
140 | 128 |
141 // TODO(timloh): Invalidate only elements with this custom property set | 129 // TODO(timloh): Invalidate only elements with this custom property set |
142 document->setNeedsStyleRecalc(SubtreeStyleChange, | 130 document->setNeedsStyleRecalc(SubtreeStyleChange, |
143 StyleChangeReasonForTracing::create( | 131 StyleChangeReasonForTracing::create( |
144 StyleChangeReason::PropertyRegistration)); | 132 StyleChangeReason::PropertyRegistration)); |
145 } | 133 } |
146 | 134 |
147 } // namespace blink | 135 } // namespace blink |
OLD | NEW |