本文整理汇总了C++中PropertyDescriptor::hasSyntax方法的典型用法代码示例。如果您正苦于以下问题:C++ PropertyDescriptor::hasSyntax方法的具体用法?C++ PropertyDescriptor::hasSyntax怎么用?C++ PropertyDescriptor::hasSyntax使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PropertyDescriptor
的用法示例。
在下文中一共展示了PropertyDescriptor::hasSyntax方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: registerProperty
void PropertyRegistration::registerProperty(
ExecutionContext* executionContext,
const PropertyDescriptor& descriptor,
ExceptionState& exceptionState) {
// Bindings code ensures these are set.
DCHECK(descriptor.hasName());
DCHECK(descriptor.hasInherits());
DCHECK(descriptor.hasSyntax());
String name = descriptor.name();
if (!CSSVariableParser::isValidVariableName(name)) {
exceptionState.throwDOMException(
SyntaxError, "The name provided is not a valid custom property name.");
return;
}
AtomicString atomicName(name);
Document* document = toDocument(executionContext);
PropertyRegistry& registry = *document->propertyRegistry();
if (registry.registration(atomicName)) {
exceptionState.throwDOMException(
InvalidModificationError,
"The name provided has already been registered.");
return;
}
CSSSyntaxDescriptor syntaxDescriptor(descriptor.syntax());
if (!syntaxDescriptor.isValid()) {
exceptionState.throwDOMException(
SyntaxError,
"The syntax provided is not a valid custom property syntax.");
return;
}
if (descriptor.hasInitialValue()) {
CSSTokenizer tokenizer(descriptor.initialValue());
bool isAnimationTainted = false;
const CSSValue* initial =
syntaxDescriptor.parse(tokenizer.tokenRange(), isAnimationTainted);
if (!initial) {
exceptionState.throwDOMException(
SyntaxError,
"The initial value provided does not parse for the given syntax.");
return;
}
if (!computationallyIndependent(*initial)) {
exceptionState.throwDOMException(
SyntaxError,
"The initial value provided is not computationally independent.");
return;
}
RefPtr<CSSVariableData> initialVariableData = CSSVariableData::create(
tokenizer.tokenRange(), isAnimationTainted, false);
registry.registerProperty(atomicName, syntaxDescriptor,
descriptor.inherits(), initial,
initialVariableData.release());
} else {
if (!syntaxDescriptor.isTokenStream()) {
exceptionState.throwDOMException(
SyntaxError,
"An initial value must be provided if the syntax is not '*'");
return;
}
registry.registerProperty(atomicName, syntaxDescriptor,
descriptor.inherits(), nullptr, nullptr);
}
// TODO(timloh): Invalidate only elements with this custom property set
document->setNeedsStyleRecalc(SubtreeStyleChange,
StyleChangeReasonForTracing::create(
StyleChangeReason::PropertyRegistration));
}