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

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

Issue 2622403006: Compute initial values for registered custom properties. (Closed)
Patch Set: initialise CSSToLengthConversionData nicer 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/CSSValueInterpolationType.h" 7 #include "core/animation/CSSValueInterpolationType.h"
8 #include "core/css/CSSSyntaxDescriptor.h" 8 #include "core/css/CSSSyntaxDescriptor.h"
9 #include "core/css/CSSValueList.h" 9 #include "core/css/CSSValueList.h"
10 #include "core/css/CSSVariableReferenceValue.h" 10 #include "core/css/CSSVariableReferenceValue.h"
11 #include "core/css/PropertyDescriptor.h" 11 #include "core/css/PropertyDescriptor.h"
12 #include "core/css/PropertyRegistry.h" 12 #include "core/css/PropertyRegistry.h"
13 #include "core/css/parser/CSSTokenizer.h" 13 #include "core/css/parser/CSSTokenizer.h"
14 #include "core/css/parser/CSSVariableParser.h" 14 #include "core/css/parser/CSSVariableParser.h"
15 #include "core/css/resolver/StyleBuilderConverter.h"
15 #include "core/dom/Document.h" 16 #include "core/dom/Document.h"
16 #include "core/dom/ExceptionCode.h" 17 #include "core/dom/ExceptionCode.h"
17 #include "core/dom/StyleChangeReason.h" 18 #include "core/dom/StyleChangeReason.h"
18 19
19 namespace blink { 20 namespace blink {
20 21
21 static bool computationallyIndependent(const CSSValue& value) { 22 static bool computationallyIndependent(const CSSValue& value) {
22 DCHECK(!value.isCSSWideKeyword()); 23 DCHECK(!value.isCSSWideKeyword());
23 24
24 if (value.isVariableReferenceValue()) 25 if (value.isVariableReferenceValue())
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 SyntaxError, 115 SyntaxError,
115 "The initial value provided does not parse for the given syntax."); 116 "The initial value provided does not parse for the given syntax.");
116 return; 117 return;
117 } 118 }
118 if (!computationallyIndependent(*initial)) { 119 if (!computationallyIndependent(*initial)) {
119 exceptionState.throwDOMException( 120 exceptionState.throwDOMException(
120 SyntaxError, 121 SyntaxError,
121 "The initial value provided is not computationally independent."); 122 "The initial value provided is not computationally independent.");
122 return; 123 return;
123 } 124 }
125 initial =
126 &StyleBuilderConverter::convertRegisteredPropertyInitialValue(*initial);
124 RefPtr<CSSVariableData> initialVariableData = CSSVariableData::create( 127 RefPtr<CSSVariableData> initialVariableData = CSSVariableData::create(
125 tokenizer.tokenRange(), isAnimationTainted, false); 128 tokenizer.tokenRange(), isAnimationTainted, false);
126 registry.registerProperty( 129 registry.registerProperty(
127 atomicName, syntaxDescriptor, descriptor.inherits(), initial, 130 atomicName, syntaxDescriptor, descriptor.inherits(), initial,
128 std::move(initialVariableData), std::move(interpolationTypes)); 131 std::move(initialVariableData), std::move(interpolationTypes));
129 } else { 132 } else {
130 if (!syntaxDescriptor.isTokenStream()) { 133 if (!syntaxDescriptor.isTokenStream()) {
131 exceptionState.throwDOMException( 134 exceptionState.throwDOMException(
132 SyntaxError, 135 SyntaxError,
133 "An initial value must be provided if the syntax is not '*'"); 136 "An initial value must be provided if the syntax is not '*'");
134 return; 137 return;
135 } 138 }
136 registry.registerProperty(atomicName, syntaxDescriptor, 139 registry.registerProperty(atomicName, syntaxDescriptor,
137 descriptor.inherits(), nullptr, nullptr, 140 descriptor.inherits(), nullptr, nullptr,
138 std::move(interpolationTypes)); 141 std::move(interpolationTypes));
139 } 142 }
140 143
141 // TODO(timloh): Invalidate only elements with this custom property set 144 // TODO(timloh): Invalidate only elements with this custom property set
142 document->setNeedsStyleRecalc(SubtreeStyleChange, 145 document->setNeedsStyleRecalc(SubtreeStyleChange,
143 StyleChangeReasonForTracing::create( 146 StyleChangeReasonForTracing::create(
144 StyleChangeReason::PropertyRegistration)); 147 StyleChangeReason::PropertyRegistration));
145 } 148 }
146 149
147 } // namespace blink 150 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698