本文整理汇总了C++中SVGLength::SetValueFromString方法的典型用法代码示例。如果您正苦于以下问题:C++ SVGLength::SetValueFromString方法的具体用法?C++ SVGLength::SetValueFromString怎么用?C++ SVGLength::SetValueFromString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SVGLength
的用法示例。
在下文中一共展示了SVGLength::SetValueFromString方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: notifier
void
DOMSVGLength::SetValueAsString(const nsAString& aValue, ErrorResult& aRv)
{
if (mIsAnimValItem) {
aRv.Throw(NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR);
return;
}
if (mVal) {
aRv = mVal->SetBaseValueString(aValue, mSVGElement, true);
return;
}
SVGLength value;
if (!value.SetValueFromString(aValue)) {
aRv.Throw(NS_ERROR_DOM_SYNTAX_ERR);
return;
}
if (HasOwner()) {
if (InternalItem() == value) {
return;
}
AutoChangeLengthNotifier notifier(this);
InternalItem() = value;
return;
}
mValue = value.GetValueInCurrentUnits();
mUnit = value.GetUnit();
}
示例2: value
nsresult
SVGLengthList::SetValueFromString(const nsAString& aValue)
{
SVGLengthList temp;
NS_ConvertUTF16toUTF8 value(aValue);
char* start = SkipWhitespace(value.BeginWriting());
// We can't use strtok with SVG_COMMA_WSP_DELIM because to correctly handle
// invalid input in the form of two commas without a value between them, we
// would need to know if strtok overwrote a comma or not.
while (*start != '\0') {
int end = strcspn(start, SVG_COMMA_WSP_DELIM);
if (end == 0) {
// found comma in an invalid location
return NS_ERROR_DOM_SYNTAX_ERR;
}
SVGLength length;
if (!length.SetValueFromString(NS_ConvertUTF8toUTF16(start, PRUint32(end)))) {
return NS_ERROR_DOM_SYNTAX_ERR;
}
if (!temp.AppendItem(length)) {
return NS_ERROR_OUT_OF_MEMORY;
}
start = SkipWhitespace(start + end);
if (*start == ',') {
start = SkipWhitespace(start + 1);
}
}
return CopyFrom(temp);
}
示例3: SetValueFromString
nsresult SVGLengthList::SetValueFromString(const nsAString& aValue) {
SVGLengthList temp;
nsCharSeparatedTokenizerTemplate<nsContentUtils::IsHTMLWhitespace> tokenizer(
aValue, ',', nsCharSeparatedTokenizer::SEPARATOR_OPTIONAL);
while (tokenizer.hasMoreTokens()) {
SVGLength length;
if (!length.SetValueFromString(tokenizer.nextToken())) {
return NS_ERROR_DOM_SYNTAX_ERR;
}
if (!temp.AppendItem(length)) {
return NS_ERROR_OUT_OF_MEMORY;
}
}
if (tokenizer.separatorAfterCurrentToken()) {
return NS_ERROR_DOM_SYNTAX_ERR; // trailing comma
}
return CopyFrom(temp);
}
示例4: CopyFrom
nsresult
SVGLengthList::SetValueFromString(const nsAString& aValue)
{
SVGLengthList temp;
nsCharSeparatedTokenizerTemplate<IsSVGWhitespace>
tokenizer(aValue, ',', nsCharSeparatedTokenizer::SEPARATOR_OPTIONAL);
nsCAutoString str; // outside loop to minimize memory churn
while (tokenizer.hasMoreTokens()) {
SVGLength length;
if (!length.SetValueFromString(tokenizer.nextToken())) {
return NS_ERROR_DOM_SYNTAX_ERR;
}
if (!temp.AppendItem(length)) {
return NS_ERROR_OUT_OF_MEMORY;
}
}
if (tokenizer.lastTokenEndedWithSeparator()) {
return NS_ERROR_DOM_SYNTAX_ERR; // trailing comma
}
return CopyFrom(temp);
}