| 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/CSSInterpolationTypesMap.h" | 7 #include "core/animation/CSSInterpolationTypesMap.h" |
| 8 #include "core/css/CSSStyleSheet.h" | 8 #include "core/css/CSSStyleSheet.h" |
| 9 #include "core/css/CSSSyntaxDescriptor.h" | 9 #include "core/css/CSSSyntaxDescriptor.h" |
| 10 #include "core/css/CSSValueList.h" | 10 #include "core/css/CSSValueList.h" |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 return true; | 80 return true; |
| 81 } | 81 } |
| 82 | 82 |
| 83 // TODO(timloh): Images and transform-function values can also contain | 83 // TODO(timloh): Images and transform-function values can also contain |
| 84 // lengths. | 84 // lengths. |
| 85 | 85 |
| 86 return true; | 86 return true; |
| 87 } | 87 } |
| 88 | 88 |
| 89 void PropertyRegistration::registerProperty( | 89 void PropertyRegistration::registerProperty( |
| 90 ScriptState* scriptState, | 90 ExecutionContext* executionContext, |
| 91 const PropertyDescriptor& descriptor, | 91 const PropertyDescriptor& descriptor, |
| 92 ExceptionState& exceptionState) { | 92 ExceptionState& exceptionState) { |
| 93 // Bindings code ensures these are set. | 93 // Bindings code ensures these are set. |
| 94 DCHECK(descriptor.hasName()); | 94 DCHECK(descriptor.hasName()); |
| 95 DCHECK(descriptor.hasInherits()); | 95 DCHECK(descriptor.hasInherits()); |
| 96 DCHECK(descriptor.hasSyntax()); | 96 DCHECK(descriptor.hasSyntax()); |
| 97 | 97 |
| 98 String name = descriptor.name(); | 98 String name = descriptor.name(); |
| 99 if (!CSSVariableParser::isValidVariableName(name)) { | 99 if (!CSSVariableParser::isValidVariableName(name)) { |
| 100 exceptionState.throwDOMException( | 100 exceptionState.throwDOMException( |
| 101 SyntaxError, "Custom property names must start with '--'."); | 101 SyntaxError, "Custom property names must start with '--'."); |
| 102 return; | 102 return; |
| 103 } | 103 } |
| 104 AtomicString atomicName(name); | 104 AtomicString atomicName(name); |
| 105 Document* document = toDocument(scriptState->getExecutionContext()); | 105 Document* document = toDocument(executionContext); |
| 106 PropertyRegistry& registry = *document->propertyRegistry(); | 106 PropertyRegistry& registry = *document->propertyRegistry(); |
| 107 if (registry.registration(atomicName)) { | 107 if (registry.registration(atomicName)) { |
| 108 exceptionState.throwDOMException( | 108 exceptionState.throwDOMException( |
| 109 InvalidModificationError, | 109 InvalidModificationError, |
| 110 "The name provided has already been registered."); | 110 "The name provided has already been registered."); |
| 111 return; | 111 return; |
| 112 } | 112 } |
| 113 | 113 |
| 114 CSSSyntaxDescriptor syntaxDescriptor(descriptor.syntax()); | 114 CSSSyntaxDescriptor syntaxDescriptor(descriptor.syntax()); |
| 115 if (!syntaxDescriptor.isValid()) { | 115 if (!syntaxDescriptor.isValid()) { |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 std::move(cssInterpolationTypes)); | 161 std::move(cssInterpolationTypes)); |
| 162 } | 162 } |
| 163 | 163 |
| 164 // TODO(timloh): Invalidate only elements with this custom property set | 164 // TODO(timloh): Invalidate only elements with this custom property set |
| 165 document->setNeedsStyleRecalc(SubtreeStyleChange, | 165 document->setNeedsStyleRecalc(SubtreeStyleChange, |
| 166 StyleChangeReasonForTracing::create( | 166 StyleChangeReasonForTracing::create( |
| 167 StyleChangeReason::PropertyRegistration)); | 167 StyleChangeReason::PropertyRegistration)); |
| 168 } | 168 } |
| 169 | 169 |
| 170 } // namespace blink | 170 } // namespace blink |
| OLD | NEW |