本文整理汇总了C++中SVGLengthList类的典型用法代码示例。如果您正苦于以下问题:C++ SVGLengthList类的具体用法?C++ SVGLengthList怎么用?C++ SVGLengthList使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SVGLengthList类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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);
}
示例2: InternalAnimValListWillChangeTo
void
DOMSVGAnimatedLengthList::InternalBaseValListWillChangeTo(const SVGLengthList& aNewValue)
{
// When the number of items in our internal counterpart's baseVal changes,
// we MUST keep our baseVal in sync. If we don't, script will either see a
// list that is too short and be unable to access indexes that should be
// valid, or else, MUCH WORSE, script will see a list that is too long and be
// able to access "items" at indexes that are out of bounds (read/write to
// bad memory)!!
nsRefPtr<DOMSVGAnimatedLengthList> kungFuDeathGrip;
if (mBaseVal) {
if (aNewValue.Length() < mBaseVal->Length()) {
// InternalListLengthWillChange might clear last reference to |this|.
// Retain a temporary reference to keep from dying before returning.
kungFuDeathGrip = this;
}
mBaseVal->InternalListLengthWillChange(aNewValue.Length());
}
// If our attribute is not animating, then our animVal mirrors our baseVal
// and we must sync its length too. (If our attribute is animating, then the
// SMIL engine takes care of calling InternalAnimValListWillChangeTo() if
// necessary.)
if (!IsAnimating()) {
InternalAnimValListWillChangeTo(aNewValue);
}
}
示例3:
nsresult
SVGAnimatedLengthList::SetBaseValueString(const nsAString& aValue)
{
SVGLengthList newBaseValue;
nsresult rv = newBaseValue.SetValueFromString(aValue);
if (NS_FAILED(rv)) {
return rv;
}
DOMSVGAnimatedLengthList *domWrapper =
DOMSVGAnimatedLengthList::GetDOMWrapperIfExists(this);
if (domWrapper) {
// We must send this notification *before* changing mBaseVal! If the length
// of our baseVal is being reduced, our baseVal's DOM wrapper list may have
// to remove DOM items from itself, and any removed DOM items need to copy
// their internal counterpart values *before* we change them.
//
domWrapper->InternalBaseValListWillChangeTo(newBaseValue);
}
// We don't need to call DidChange* here - we're only called by
// nsSVGElement::ParseAttribute under nsGenericElement::SetAttr,
// which takes care of notifying.
rv = mBaseVal.CopyFrom(newBaseValue);
if (NS_FAILED(rv) && domWrapper) {
// Attempting to increase mBaseVal's length failed - reduce domWrapper
// back to the same length:
domWrapper->InternalBaseValListWillChangeTo(mBaseVal);
}
return rv;
}
示例4: switch
JSValue* JSSVGLengthList::getValueProperty(ExecState* exec, int token) const
{
switch (token) {
case NumberOfItemsAttrNum: {
SVGLengthList* imp = static_cast<SVGLengthList*>(impl());
return jsNumber(imp->numberOfItems());
}
}
return 0;
}
示例5: toSVGLengthList
void SVGLengthList::add(SVGPropertyBase* other, SVGElement* contextElement) {
SVGLengthList* otherList = toSVGLengthList(other);
if (length() != otherList->length())
return;
SVGLengthContext lengthContext(contextElement);
for (size_t i = 0; i < length(); ++i)
at(i)->setValue(
at(i)->value(lengthContext) + otherList->at(i)->value(lengthContext),
lengthContext);
}
示例6: extractFloatValuesFromSVGLengthList
static inline void extractFloatValuesFromSVGLengthList(SVGElement* lengthContext, const SVGLengthList& list, Vector<float>& floatValues, unsigned textContentLength)
{
ASSERT(lengthContext);
unsigned length = list.size();
if (length > textContentLength)
length = textContentLength;
floatValues.reserveCapacity(length);
for (unsigned i = 0; i < length; ++i) {
const SVGLength& length = list.at(i);
floatValues.append(length.value(lengthContext));
}
}
示例7:
void
DOMSVGAnimatedLengthList::InternalAnimValListWillChangeTo(const SVGLengthList& aNewValue)
{
if (mAnimVal) {
mAnimVal->InternalListLengthWillChange(aNewValue.Length());
}
}
示例8:
nsresult
SVGLengthList::CopyFrom(const SVGLengthList& rhs)
{
if (!mLengths.SetCapacity(rhs.Length())) {
// Yes, we do want fallible alloc here
return NS_ERROR_OUT_OF_MEMORY;
}
mLengths = rhs.mLengths;
return NS_OK;
}
示例9:
bool SVGLengthList::operator==(const SVGLengthList& rhs) const {
if (Length() != rhs.Length()) {
return false;
}
for (uint32_t i = 0; i < Length(); ++i) {
if (!(mLengths[i] == rhs.mLengths[i])) {
return false;
}
}
return true;
}
示例10: 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);
}
示例11: ASSERT
void SVGAnimatedLengthListAnimator::calculateAnimatedValue(float percentage, unsigned repeatCount, SVGAnimatedType* from, SVGAnimatedType* to, SVGAnimatedType* toAtEndOfDuration, SVGAnimatedType* animated)
{
ASSERT(m_animationElement);
ASSERT(m_contextElement);
SVGLengthList fromLengthList = m_animationElement->animationMode() == ToAnimation ? animated->lengthList() : from->lengthList();
SVGLengthList toLengthList = to->lengthList();
const SVGLengthList& toAtEndOfDurationLengthList = toAtEndOfDuration->lengthList();
SVGLengthList& animatedLengthList = animated->lengthList();
// Apply CSS inheritance rules.
m_animationElement->adjustForInheritance<SVGLengthList>(parseLengthListFromString, m_animationElement->fromPropertyValueType(), fromLengthList, m_contextElement);
m_animationElement->adjustForInheritance<SVGLengthList>(parseLengthListFromString, m_animationElement->toPropertyValueType(), toLengthList, m_contextElement);
if (!m_animationElement->adjustFromToListValues<SVGLengthList>(fromLengthList, toLengthList, animatedLengthList, percentage))
return;
unsigned fromLengthListSize = fromLengthList.size();
unsigned toLengthListSize = toLengthList.size();
unsigned toAtEndOfDurationListSize = toAtEndOfDurationLengthList.size();
SVGLengthContext lengthContext(m_contextElement);
for (unsigned i = 0; i < toLengthListSize; ++i) {
float animatedNumber = animatedLengthList[i].value(lengthContext);
SVGLengthType unitType = toLengthList[i].unitType();
float effectiveFrom = 0;
if (fromLengthListSize) {
if (percentage < 0.5)
unitType = fromLengthList[i].unitType();
effectiveFrom = fromLengthList[i].value(lengthContext);
}
float effectiveToAtEnd = i < toAtEndOfDurationListSize ? toAtEndOfDurationLengthList[i].value(lengthContext) : 0;
m_animationElement->animateAdditiveNumber(percentage, repeatCount, effectiveFrom, toLengthList[i].value(lengthContext), effectiveToAtEnd, animatedNumber);
animatedLengthList[i].setValue(lengthContext, animatedNumber, m_lengthMode, unitType, ASSERT_NO_EXCEPTION);
}
}
示例12: jsSVGLengthListPrototypeFunctionAppendItem
JSValue JSC_HOST_CALL jsSVGLengthListPrototypeFunctionAppendItem(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args)
{
UNUSED_PARAM(args);
if (!thisValue.inherits(&JSSVGLengthList::s_info))
return throwError(exec, TypeError);
JSSVGLengthList* castedThisObj = static_cast<JSSVGLengthList*>(asObject(thisValue));
SVGLengthList* imp = static_cast<SVGLengthList*>(castedThisObj->impl());
ExceptionCode ec = 0;
SVGLength item = toSVGLength(args.at(0));
JSC::JSValue result = toJS(exec, deprecatedGlobalObjectForPrototype(exec), JSSVGStaticPODTypeWrapper<SVGLength>::create(imp->appendItem(item, ec)).get(), castedThisObj->context());
setDOMException(exec, ec);
return result;
}
示例13: 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);
}
示例14: InternalAnimValListWillChangeTo
void
DOMSVGAnimatedLengthList::InternalBaseValListWillChangeTo(const SVGLengthList& aNewValue)
{
// When the number of items in our internal counterpart's baseVal changes,
// we MUST keep our baseVal in sync. If we don't, script will either see a
// list that is too short and be unable to access indexes that should be
// valid, or else, MUCH WORSE, script will see a list that is too long and be
// able to access "items" at indexes that are out of bounds (read/write to
// bad memory)!!
if (mBaseVal) {
mBaseVal->InternalListLengthWillChange(aNewValue.Length());
}
// If our attribute is not animating, then our animVal mirrors our baseVal
// and we must sync its length too. (If our attribute is animating, then the
// SMIL engine takes care of calling InternalAnimValListWillChangeTo() if
// necessary.)
if (!IsAnimating()) {
InternalAnimValListWillChangeTo(aNewValue);
}
}
示例15: clone
SVGLengthList* SVGLengthList::clone() {
SVGLengthList* ret = SVGLengthList::create(m_mode);
ret->deepCopy(this);
return ret;
}