本文整理汇总了C++中nsAttrValue::SetTo方法的典型用法代码示例。如果您正苦于以下问题:C++ nsAttrValue::SetTo方法的具体用法?C++ nsAttrValue::SetTo怎么用?C++ nsAttrValue::SetTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nsAttrValue
的用法示例。
在下文中一共展示了nsAttrValue::SetTo方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SetRotate
nsresult SVGMotionSMILAnimationFunction::SetRotate(const nsAString& aRotate,
nsAttrValue& aResult) {
mHasChanged = true;
aResult.SetTo(aRotate);
if (aRotate.EqualsLiteral("auto")) {
mRotateType = eRotateType_Auto;
} else if (aRotate.EqualsLiteral("auto-reverse")) {
mRotateType = eRotateType_AutoReverse;
} else {
mRotateType = eRotateType_Explicit;
uint16_t angleUnit;
if (!SVGOrient::GetValueFromString(aRotate, mRotateAngle, &angleUnit)) {
mRotateAngle = 0.0f; // set default rotate angle
// XXX report to console?
return NS_ERROR_DOM_SYNTAX_ERR;
}
// Convert to radian units, if we're not already in radians.
if (angleUnit != SVG_ANGLETYPE_RAD) {
mRotateAngle *= SVGOrient::GetDegreesPerUnit(angleUnit) /
SVGOrient::GetDegreesPerUnit(SVG_ANGLETYPE_RAD);
}
}
return NS_OK;
}
示例2: if
nsresult
SVGMotionSMILAnimationFunction::SetRotate(const nsAString& aRotate,
nsAttrValue& aResult)
{
mHasChanged = true;
aResult.SetTo(aRotate);
if (aRotate.EqualsLiteral("auto")) {
mRotateType = eRotateType_Auto;
} else if (aRotate.EqualsLiteral("auto-reverse")) {
mRotateType = eRotateType_AutoReverse;
} else {
mRotateType = eRotateType_Explicit;
// Parse numeric angle string, with the help of a temp nsSVGAngle.
nsSVGAngle svgAngle;
svgAngle.Init();
nsresult rv = svgAngle.SetBaseValueString(aRotate, nullptr, false);
if (NS_FAILED(rv)) { // Parse error
mRotateAngle = 0.0f; // set default rotate angle
// XXX report to console?
return rv;
}
mRotateAngle = svgAngle.GetBaseValInSpecifiedUnits();
// Convert to radian units, if we're not already in radians.
uint8_t angleUnit = svgAngle.GetBaseValueUnit();
if (angleUnit != SVG_ANGLETYPE_RAD) {
mRotateAngle *= nsSVGAngle::GetDegreesPerUnit(angleUnit) /
nsSVGAngle::GetDegreesPerUnit(SVG_ANGLETYPE_RAD);
}
}
return NS_OK;
}
示例3: ArrayLength
void
SVGTests::GetAttrValue(uint8_t aAttrEnum, nsAttrValue& aValue) const
{
MOZ_ASSERT(aAttrEnum < ArrayLength(sStringListNames),
"aAttrEnum out of range");
aValue.SetTo(mStringListAttributes[aAttrEnum], nullptr);
}
示例4: MakeMappedUnique
nsresult
nsAttrAndChildArray::RemoveAttrAt(uint32_t aPos, nsAttrValue& aValue)
{
NS_ASSERTION(aPos < AttrCount(), "out-of-bounds");
uint32_t nonmapped = NonMappedAttrCount();
if (aPos < nonmapped) {
ATTRS(mImpl)[aPos].mValue.SwapValueWith(aValue);
ATTRS(mImpl)[aPos].~InternalAttr();
uint32_t slotCount = AttrSlotCount();
memmove(&ATTRS(mImpl)[aPos],
&ATTRS(mImpl)[aPos + 1],
(slotCount - aPos - 1) * sizeof(InternalAttr));
memset(&ATTRS(mImpl)[slotCount - 1], 0, sizeof(InternalAttr));
return NS_OK;
}
if (MappedAttrCount() == 1) {
// We're removing the last mapped attribute. Can't swap in this
// case; have to copy.
aValue.SetTo(*mImpl->mMappedAttrs->AttrAt(0));
NS_RELEASE(mImpl->mMappedAttrs);
return NS_OK;
}
RefPtr<nsMappedAttributes> mapped =
GetModifiableMapped(nullptr, nullptr, false);
mapped->RemoveAttrAt(aPos - nonmapped, aValue);
return MakeMappedUnique(mapped);
}
示例5:
nsresult
nsSMILAnimationFunction::SetKeySplines(const nsAString& aKeySplines,
nsAttrValue& aResult)
{
mKeySplines.Clear();
aResult.SetTo(aKeySplines);
nsTArray<double> keySplines;
nsresult rv = nsSMILParserUtils::ParseKeySplines(aKeySplines, keySplines);
if (keySplines.Length() < 1 || keySplines.Length() % 4)
rv = NS_ERROR_FAILURE;
if (NS_SUCCEEDED(rv))
{
mKeySplines.SetCapacity(keySplines.Length() % 4);
for (PRUint32 i = 0; i < keySplines.Length() && NS_SUCCEEDED(rv); i += 4)
{
if (!mKeySplines.AppendElement(nsSMILKeySpline(keySplines[i],
keySplines[i+1],
keySplines[i+2],
keySplines[i+3]))) {
rv = NS_ERROR_OUT_OF_MEMORY;
}
}
}
mHasChanged = PR_TRUE;
return rv;
}
示例6: OwnerDoc
void
nsStyledElementNotElementCSSInlineStyle::ParseStyleAttribute(const nsAString& aValue,
nsAttrValue& aResult,
bool aForceInDataDoc)
{
nsIDocument* doc = OwnerDoc();
bool isNativeAnon = IsInNativeAnonymousSubtree();
if (!isNativeAnon &&
!nsStyleUtil::CSPAllowsInlineStyle(nullptr, NodePrincipal(),
doc->GetDocumentURI(), 0, aValue,
nullptr))
return;
if (aForceInDataDoc ||
!doc->IsLoadedAsData() ||
doc->IsStaticDocument()) {
bool isCSS = true; // assume CSS until proven otherwise
if (!isNativeAnon) { // native anonymous content always assumes CSS
nsAutoString styleType;
doc->GetHeaderData(nsGkAtoms::headerContentStyleType, styleType);
if (!styleType.IsEmpty()) {
static const char textCssStr[] = "text/css";
isCSS = (styleType.EqualsIgnoreCase(textCssStr, sizeof(textCssStr) - 1));
}
}
if (isCSS && aResult.ParseStyleAttribute(aValue, this)) {
return;
}
}
aResult.SetTo(aValue);
}
示例7: SetAttr
bool SVGMotionSMILAnimationFunction::SetAttr(nsAtom* aAttribute,
const nsAString& aValue,
nsAttrValue& aResult,
nsresult* aParseResult) {
// Handle motion-specific attrs
if (aAttribute == nsGkAtoms::keyPoints) {
nsresult rv = SetKeyPoints(aValue, aResult);
if (aParseResult) {
*aParseResult = rv;
}
} else if (aAttribute == nsGkAtoms::rotate) {
nsresult rv = SetRotate(aValue, aResult);
if (aParseResult) {
*aParseResult = rv;
}
} else if (aAttribute == nsGkAtoms::path || aAttribute == nsGkAtoms::by ||
aAttribute == nsGkAtoms::from || aAttribute == nsGkAtoms::to ||
aAttribute == nsGkAtoms::values) {
aResult.SetTo(aValue);
MarkStaleIfAttributeAffectsPath(aAttribute);
if (aParseResult) {
*aParseResult = NS_OK;
}
} else {
// Defer to superclass method
return SMILAnimationFunction::SetAttr(aAttribute, aValue, aResult,
aParseResult);
}
return true;
}
示例8: ArrayLength
void
DOMSVGTests::GetAttrValue(PRUint8 aAttrEnum, nsAttrValue& aValue) const
{
MOZ_ASSERT(aAttrEnum < ArrayLength(sStringListNames),
"aAttrEnum out of range");
aValue.SetTo(*GetOrCreateStringListAttribute(aAttrEnum), nullptr);
}
示例9: sizeof
void
nsStyledElement::ParseStyleAttribute(nsIContent* aContent,
const nsAString& aValue,
nsAttrValue& aResult,
PRBool aForceInDataDoc)
{
nsresult result = NS_OK;
nsIDocument* doc = aContent->GetOwnerDoc();
if (doc && (aForceInDataDoc || !doc->IsLoadedAsData())) {
PRBool isCSS = PR_TRUE; // assume CSS until proven otherwise
if (!aContent->IsInNativeAnonymousSubtree()) { // native anonymous content
// always assumes CSS
nsAutoString styleType;
doc->GetHeaderData(nsGkAtoms::headerContentStyleType, styleType);
if (!styleType.IsEmpty()) {
static const char textCssStr[] = "text/css";
isCSS = (styleType.EqualsIgnoreCase(textCssStr, sizeof(textCssStr) - 1));
}
}
if (isCSS) {
nsICSSLoader* cssLoader = doc->CSSLoader();
nsCOMPtr<nsICSSParser> cssParser;
result = cssLoader->GetParserFor(nsnull, getter_AddRefs(cssParser));
if (cssParser) {
nsCOMPtr<nsIURI> baseURI = aContent->GetBaseURI();
nsCOMPtr<nsICSSStyleRule> rule;
result = cssParser->ParseStyleAttribute(aValue, doc->GetDocumentURI(),
baseURI,
aContent->NodePrincipal(),
getter_AddRefs(rule));
cssLoader->RecycleParser(cssParser);
if (rule) {
aResult.SetTo(rule);
return;
}
}
}
}
aResult.SetTo(aValue);
}
示例10: cssParser
void
nsStyledElementNotElementCSSInlineStyle::ParseStyleAttribute(const nsAString& aValue,
nsAttrValue& aResult,
bool aForceInDataDoc)
{
nsIDocument* doc = OwnerDoc();
if (aForceInDataDoc ||
!doc->IsLoadedAsData() ||
doc->IsStaticDocument()) {
bool isCSS = true; // assume CSS until proven otherwise
if (!IsInNativeAnonymousSubtree()) { // native anonymous content
// always assumes CSS
nsAutoString styleType;
doc->GetHeaderData(nsGkAtoms::headerContentStyleType, styleType);
if (!styleType.IsEmpty()) {
static const char textCssStr[] = "text/css";
isCSS = (styleType.EqualsIgnoreCase(textCssStr, sizeof(textCssStr) - 1));
}
}
if (isCSS) {
css::Loader* cssLoader = doc->CSSLoader();
nsCSSParser cssParser(cssLoader);
nsCOMPtr<nsIURI> baseURI = GetBaseURI();
nsRefPtr<css::StyleRule> rule;
cssParser.ParseStyleAttribute(aValue, doc->GetDocumentURI(),
baseURI,
NodePrincipal(),
getter_AddRefs(rule));
if (rule) {
aResult.SetTo(rule, &aValue);
return;
}
}
}
aResult.SetTo(aValue);
}
示例11: ParseAttribute
bool
SVGMarkerElement::ParseAttribute(int32_t aNameSpaceID, nsIAtom* aName,
const nsAString& aValue,
nsAttrValue& aResult)
{
if (aNameSpaceID == kNameSpaceID_None && aName == nsGkAtoms::orient) {
if (aValue.EqualsLiteral("auto")) {
mOrientType.SetBaseValue(SVG_MARKER_ORIENT_AUTO);
aResult.SetTo(aValue);
return true;
}
if (aValue.EqualsLiteral("auto-start-reverse") &&
MarkerImprovementsPrefEnabled()) {
mOrientType.SetBaseValue(SVG_MARKER_ORIENT_AUTO_START_REVERSE);
aResult.SetTo(aValue);
return true;
}
mOrientType.SetBaseValue(SVG_MARKER_ORIENT_ANGLE);
}
return SVGMarkerElementBase::ParseAttribute(aNameSpaceID, aName,
aValue, aResult);
}
示例12: SetKeyPoints
nsresult SVGMotionSMILAnimationFunction::SetKeyPoints(
const nsAString& aKeyPoints, nsAttrValue& aResult) {
mKeyPoints.Clear();
aResult.SetTo(aKeyPoints);
mHasChanged = true;
if (!SMILParserUtils::ParseSemicolonDelimitedProgressList(aKeyPoints, false,
mKeyPoints)) {
mKeyPoints.Clear();
return NS_ERROR_FAILURE;
}
return NS_OK;
}
示例13: ParseAttribute
PRBool
nsSVGMarkerElement::ParseAttribute(PRInt32 aNameSpaceID, nsIAtom* aName,
const nsAString& aValue,
nsAttrValue& aResult)
{
if (aNameSpaceID == kNameSpaceID_None && aName == nsGkAtoms::orient) {
if (aValue.EqualsLiteral("auto")) {
mOrientType.SetBaseValue(SVG_MARKER_ORIENT_AUTO);
aResult.SetTo(aValue);
return PR_TRUE;
}
mOrientType.SetBaseValue(SVG_MARKER_ORIENT_ANGLE);
}
return nsSVGMarkerElementBase::ParseAttribute(aNameSpaceID, aName,
aValue, aResult);
}
示例14:
nsresult
nsSMILAnimationFunction::SetKeySplines(const nsAString& aKeySplines,
nsAttrValue& aResult)
{
mKeySplines.Clear();
aResult.SetTo(aKeySplines);
mHasChanged = true;
if (!nsSMILParserUtils::ParseKeySplines(aKeySplines, mKeySplines)) {
mKeySplines.Clear();
return NS_ERROR_FAILURE;
}
return NS_OK;
}
示例15: if
PRBool
nsSMILAnimationFunction::SetAttr(nsIAtom* aAttribute, const nsAString& aValue,
nsAttrValue& aResult, nsresult* aParseResult)
{
PRBool foundMatch = PR_TRUE;
nsresult parseResult = NS_OK;
// The attributes 'by', 'from', 'to', and 'values' may be parsed differently
// depending on the element & attribute we're animating. So instead of
// parsing them now we re-parse them at every sample.
if (aAttribute == nsGkAtoms::by ||
aAttribute == nsGkAtoms::from ||
aAttribute == nsGkAtoms::to ||
aAttribute == nsGkAtoms::values) {
// We parse to, from, by, values at sample time.
// XXX Need to flag which attribute has changed and then when we parse it at
// sample time, report any errors and reset the flag
mHasChanged = PR_TRUE;
aResult.SetTo(aValue);
} else if (aAttribute == nsGkAtoms::accumulate) {
parseResult = SetAccumulate(aValue, aResult);
} else if (aAttribute == nsGkAtoms::additive) {
parseResult = SetAdditive(aValue, aResult);
} else if (aAttribute == nsGkAtoms::calcMode) {
parseResult = SetCalcMode(aValue, aResult);
} else if (aAttribute == nsGkAtoms::keyTimes) {
parseResult = SetKeyTimes(aValue, aResult);
} else if (aAttribute == nsGkAtoms::keySplines) {
parseResult = SetKeySplines(aValue, aResult);
} else {
foundMatch = PR_FALSE;
}
if (foundMatch && aParseResult) {
*aParseResult = parseResult;
}
return foundMatch;
}