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

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

Issue 2618673003: Store registered property InterpolationTypes in PropertyRegistration (Closed)
Patch Set: Created 3 years, 11 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 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/CSSColorInterpolationType.h"
Timothy Loh 2017/01/09 05:07:23 not used yet
alancutter (OOO until 2018) 2017/01/16 00:23:52 Removed
8 #include "core/animation/CSSValueInterpolationType.h"
7 #include "core/css/CSSSyntaxDescriptor.h" 9 #include "core/css/CSSSyntaxDescriptor.h"
8 #include "core/css/CSSValueList.h" 10 #include "core/css/CSSValueList.h"
9 #include "core/css/CSSVariableReferenceValue.h" 11 #include "core/css/CSSVariableReferenceValue.h"
10 #include "core/css/PropertyDescriptor.h" 12 #include "core/css/PropertyDescriptor.h"
11 #include "core/css/PropertyRegistry.h" 13 #include "core/css/PropertyRegistry.h"
12 #include "core/css/parser/CSSTokenizer.h" 14 #include "core/css/parser/CSSTokenizer.h"
13 #include "core/css/parser/CSSVariableParser.h" 15 #include "core/css/parser/CSSVariableParser.h"
14 #include "core/dom/Document.h" 16 #include "core/dom/Document.h"
15 #include "core/dom/ExceptionCode.h" 17 #include "core/dom/ExceptionCode.h"
16 #include "core/dom/StyleChangeReason.h" 18 #include "core/dom/StyleChangeReason.h"
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 } 51 }
50 return true; 52 return true;
51 } 53 }
52 54
53 // TODO(timloh): Images and transform-function values can also contain 55 // TODO(timloh): Images and transform-function values can also contain
54 // lengths. 56 // lengths.
55 57
56 return true; 58 return true;
57 } 59 }
58 60
61 InterpolationTypes interpolationTypesForSyntax(const AtomicString& propertyName,
62 const CSSSyntaxDescriptor&) {
63 PropertyHandle property(propertyName);
64 InterpolationTypes interpolationTypes;
65 // TODO(alancutter): Read the syntax descriptor and add the appropriate
66 // CSSInterpolationType subclasses.
67 interpolationTypes.append(
68 WTF::makeUnique<CSSValueInterpolationType>(property));
69 return interpolationTypes;
70 }
71
59 void PropertyRegistration::registerProperty( 72 void PropertyRegistration::registerProperty(
60 ExecutionContext* executionContext, 73 ExecutionContext* executionContext,
61 const PropertyDescriptor& descriptor, 74 const PropertyDescriptor& descriptor,
62 ExceptionState& exceptionState) { 75 ExceptionState& exceptionState) {
63 // Bindings code ensures these are set. 76 // Bindings code ensures these are set.
64 DCHECK(descriptor.hasName()); 77 DCHECK(descriptor.hasName());
65 DCHECK(descriptor.hasInherits()); 78 DCHECK(descriptor.hasInherits());
66 DCHECK(descriptor.hasSyntax()); 79 DCHECK(descriptor.hasSyntax());
67 80
68 String name = descriptor.name(); 81 String name = descriptor.name();
(...skipping 13 matching lines...) Expand all
82 } 95 }
83 96
84 CSSSyntaxDescriptor syntaxDescriptor(descriptor.syntax()); 97 CSSSyntaxDescriptor syntaxDescriptor(descriptor.syntax());
85 if (!syntaxDescriptor.isValid()) { 98 if (!syntaxDescriptor.isValid()) {
86 exceptionState.throwDOMException( 99 exceptionState.throwDOMException(
87 SyntaxError, 100 SyntaxError,
88 "The syntax provided is not a valid custom property syntax."); 101 "The syntax provided is not a valid custom property syntax.");
89 return; 102 return;
90 } 103 }
91 104
105 InterpolationTypes interpolationTypes =
106 interpolationTypesForSyntax(atomicName, syntaxDescriptor);
107
92 if (descriptor.hasInitialValue()) { 108 if (descriptor.hasInitialValue()) {
93 CSSTokenizer tokenizer(descriptor.initialValue()); 109 CSSTokenizer tokenizer(descriptor.initialValue());
94 bool isAnimationTainted = false; 110 bool isAnimationTainted = false;
95 const CSSValue* initial = 111 const CSSValue* initial =
96 syntaxDescriptor.parse(tokenizer.tokenRange(), isAnimationTainted); 112 syntaxDescriptor.parse(tokenizer.tokenRange(), isAnimationTainted);
97 if (!initial) { 113 if (!initial) {
98 exceptionState.throwDOMException( 114 exceptionState.throwDOMException(
99 SyntaxError, 115 SyntaxError,
100 "The initial value provided does not parse for the given syntax."); 116 "The initial value provided does not parse for the given syntax.");
101 return; 117 return;
102 } 118 }
103 if (!computationallyIndependent(*initial)) { 119 if (!computationallyIndependent(*initial)) {
104 exceptionState.throwDOMException( 120 exceptionState.throwDOMException(
105 SyntaxError, 121 SyntaxError,
106 "The initial value provided is not computationally independent."); 122 "The initial value provided is not computationally independent.");
107 return; 123 return;
108 } 124 }
109 RefPtr<CSSVariableData> initialVariableData = CSSVariableData::create( 125 RefPtr<CSSVariableData> initialVariableData = CSSVariableData::create(
110 tokenizer.tokenRange(), isAnimationTainted, false); 126 tokenizer.tokenRange(), isAnimationTainted, false);
111 registry.registerProperty(atomicName, syntaxDescriptor, 127 registry.registerProperty(
112 descriptor.inherits(), initial, 128 atomicName, syntaxDescriptor, descriptor.inherits(), initial,
113 initialVariableData.release()); 129 initialVariableData.release(), std::move(interpolationTypes));
114 } else { 130 } else {
115 if (!syntaxDescriptor.isTokenStream()) { 131 if (!syntaxDescriptor.isTokenStream()) {
116 exceptionState.throwDOMException( 132 exceptionState.throwDOMException(
117 SyntaxError, 133 SyntaxError,
118 "An initial value must be provided if the syntax is not '*'"); 134 "An initial value must be provided if the syntax is not '*'");
119 return; 135 return;
120 } 136 }
121 registry.registerProperty(atomicName, syntaxDescriptor, 137 registry.registerProperty(atomicName, syntaxDescriptor,
122 descriptor.inherits(), nullptr, nullptr); 138 descriptor.inherits(), nullptr, nullptr,
139 std::move(interpolationTypes));
123 } 140 }
124 141
125 // TODO(timloh): Invalidate only elements with this custom property set 142 // TODO(timloh): Invalidate only elements with this custom property set
126 document->setNeedsStyleRecalc(SubtreeStyleChange, 143 document->setNeedsStyleRecalc(SubtreeStyleChange,
127 StyleChangeReasonForTracing::create( 144 StyleChangeReasonForTracing::create(
128 StyleChangeReason::PropertyRegistration)); 145 StyleChangeReason::PropertyRegistration));
129 } 146 }
130 147
131 } // namespace blink 148 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698