本文整理汇总了C++中AutoInfallibleTArray::AppendElement方法的典型用法代码示例。如果您正苦于以下问题:C++ AutoInfallibleTArray::AppendElement方法的具体用法?C++ AutoInfallibleTArray::AppendElement怎么用?C++ AutoInfallibleTArray::AppendElement使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AutoInfallibleTArray
的用法示例。
在下文中一共展示了AutoInfallibleTArray::AppendElement方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: new
static nscoord
ComputeDescendantWidth(const nsHTMLReflowState& aAncestorReflowState,
nsIFrame *aDescendantFrame)
{
nsIFrame *ancestorFrame = aAncestorReflowState.frame->FirstInFlow();
if (aDescendantFrame == ancestorFrame) {
return aAncestorReflowState.ComputedWidth();
}
AutoInfallibleTArray<nsIFrame*, 16> frames;
for (nsIFrame *f = aDescendantFrame; f != ancestorFrame;
f = f->GetParent()->FirstInFlow()) {
frames.AppendElement(f);
}
// This ignores the width contributions made by scrollbars, though in
// reality we don't have any scrollbars on the sorts of devices on
// which we use font inflation, so it's not a problem. But it may
// occasionally cause problems when writing tests on desktop.
uint32_t len = frames.Length();
nsHTMLReflowState *reflowStates = static_cast<nsHTMLReflowState*>
(moz_xmalloc(sizeof(nsHTMLReflowState) * len));
nsPresContext *presContext = aDescendantFrame->PresContext();
for (uint32_t i = 0; i < len; ++i) {
const nsHTMLReflowState &parentReflowState =
(i == 0) ? aAncestorReflowState : reflowStates[i - 1];
nsIFrame *frame = frames[len - i - 1];
WritingMode wm = frame->GetWritingMode();
LogicalSize availSize = parentReflowState.ComputedSize(wm);
availSize.BSize(wm) = NS_UNCONSTRAINEDSIZE;
MOZ_ASSERT(frame->GetParent()->FirstInFlow() ==
parentReflowState.frame->FirstInFlow(),
"bad logic in this function");
new (reflowStates + i) nsHTMLReflowState(presContext, parentReflowState,
frame, availSize);
}
MOZ_ASSERT(reflowStates[len - 1].frame == aDescendantFrame,
"bad logic in this function");
nscoord result = reflowStates[len - 1].ComputedWidth();
for (uint32_t i = len; i-- != 0; ) {
reflowStates[i].~nsHTMLReflowState();
}
moz_free(reflowStates);
return result;
}
示例2: TimeStamp
void
nsAnimationManager::BuildAnimations(nsStyleContext* aStyleContext,
InfallibleTArray<ElementAnimation>& aAnimations)
{
NS_ABORT_IF_FALSE(aAnimations.IsEmpty(), "expect empty array");
ResolvedStyleCache resolvedStyles;
const nsStyleDisplay *disp = aStyleContext->StyleDisplay();
TimeStamp now = mPresContext->RefreshDriver()->MostRecentRefresh();
for (uint32_t animIdx = 0, animEnd = disp->mAnimationNameCount;
animIdx != animEnd; ++animIdx) {
const nsAnimation& aSrc = disp->mAnimations[animIdx];
ElementAnimation& aDest = *aAnimations.AppendElement();
aDest.mName = aSrc.GetName();
aDest.mIterationCount = aSrc.GetIterationCount();
aDest.mDirection = aSrc.GetDirection();
aDest.mFillMode = aSrc.GetFillMode();
aDest.mPlayState = aSrc.GetPlayState();
aDest.mDelay = TimeDuration::FromMilliseconds(aSrc.GetDelay());
aDest.mStartTime = now;
if (aDest.IsPaused()) {
aDest.mPauseStart = now;
} else {
aDest.mPauseStart = TimeStamp();
}
aDest.mIterationDuration = TimeDuration::FromMilliseconds(aSrc.GetDuration());
nsCSSKeyframesRule *rule = KeyframesRuleFor(aDest.mName);
if (!rule) {
// no segments
continue;
}
// While current drafts of css3-animations say that later keyframes
// with the same key entirely replace earlier ones (no cascading),
// this is a bad idea and contradictory to the rest of CSS. So
// we're going to keep all the keyframes for each key and then do
// the replacement on a per-property basis rather than a per-rule
// basis, just like everything else in CSS.
AutoInfallibleTArray<KeyframeData, 16> sortedKeyframes;
for (uint32_t ruleIdx = 0, ruleEnd = rule->StyleRuleCount();
ruleIdx != ruleEnd; ++ruleIdx) {
css::Rule* cssRule = rule->GetStyleRuleAt(ruleIdx);
NS_ABORT_IF_FALSE(cssRule, "must have rule");
NS_ABORT_IF_FALSE(cssRule->GetType() == css::Rule::KEYFRAME_RULE,
"must be keyframe rule");
nsCSSKeyframeRule *kfRule = static_cast<nsCSSKeyframeRule*>(cssRule);
const nsTArray<float> &keys = kfRule->GetKeys();
for (uint32_t keyIdx = 0, keyEnd = keys.Length();
keyIdx != keyEnd; ++keyIdx) {
float key = keys[keyIdx];
// FIXME (spec): The spec doesn't say what to do with
// out-of-range keyframes. We'll ignore them.
// (And PercentageHashKey currently assumes we either ignore or
// clamp them.)
if (0.0f <= key && key <= 1.0f) {
KeyframeData *data = sortedKeyframes.AppendElement();
data->mKey = key;
data->mIndex = ruleIdx;
data->mRule = kfRule;
}
}
}
sortedKeyframes.Sort(KeyframeDataComparator());
if (sortedKeyframes.Length() == 0) {
// no segments
continue;
}
// Record the properties that are present in any keyframe rules we
// are using.
nsCSSPropertySet properties;
for (uint32_t kfIdx = 0, kfEnd = sortedKeyframes.Length();
kfIdx != kfEnd; ++kfIdx) {
css::Declaration *decl = sortedKeyframes[kfIdx].mRule->Declaration();
for (uint32_t propIdx = 0, propEnd = decl->Count();
propIdx != propEnd; ++propIdx) {
properties.AddProperty(decl->OrderValueAt(propIdx));
}
}
for (nsCSSProperty prop = nsCSSProperty(0);
prop < eCSSProperty_COUNT_no_shorthands;
prop = nsCSSProperty(prop + 1)) {
if (!properties.HasProperty(prop) ||
nsCSSProps::kAnimTypeTable[prop] == eStyleAnimType_None) {
continue;
}
// Build a list of the keyframes to use for this property. This
//.........这里部分代码省略.........
示例3: KeyframeEffectReadOnly
void
nsAnimationManager::BuildAnimations(nsStyleContext* aStyleContext,
dom::Element* aTarget,
dom::DocumentTimeline* aTimeline,
AnimationPtrArray& aAnimations)
{
MOZ_ASSERT(aAnimations.IsEmpty(), "expect empty array");
ResolvedStyleCache resolvedStyles;
const nsStyleDisplay *disp = aStyleContext->StyleDisplay();
nsRefPtr<nsStyleContext> styleWithoutAnimation;
for (size_t animIdx = 0, animEnd = disp->mAnimationNameCount;
animIdx != animEnd; ++animIdx) {
const StyleAnimation& src = disp->mAnimations[animIdx];
// CSS Animations whose animation-name does not match a @keyframes rule do
// not generate animation events. This includes when the animation-name is
// "none" which is represented by an empty name in the StyleAnimation.
// Since such animations neither affect style nor dispatch events, we do
// not generate a corresponding Animation for them.
nsCSSKeyframesRule* rule =
src.GetName().IsEmpty()
? nullptr
: mPresContext->StyleSet()->KeyframesRuleForName(src.GetName());
if (!rule) {
continue;
}
nsRefPtr<CSSAnimation> dest = new CSSAnimation(aTimeline);
aAnimations.AppendElement(dest);
AnimationTiming timing;
timing.mIterationDuration =
TimeDuration::FromMilliseconds(src.GetDuration());
timing.mDelay = TimeDuration::FromMilliseconds(src.GetDelay());
timing.mIterationCount = src.GetIterationCount();
timing.mDirection = src.GetDirection();
timing.mFillMode = src.GetFillMode();
nsRefPtr<KeyframeEffectReadOnly> destEffect =
new KeyframeEffectReadOnly(mPresContext->Document(), aTarget,
aStyleContext->GetPseudoType(), timing,
src.GetName());
dest->SetEffect(destEffect);
if (src.GetPlayState() == NS_STYLE_ANIMATION_PLAY_STATE_PAUSED) {
dest->PauseFromStyle();
} else {
dest->PlayFromStyle();
}
// While current drafts of css3-animations say that later keyframes
// with the same key entirely replace earlier ones (no cascading),
// this is a bad idea and contradictory to the rest of CSS. So
// we're going to keep all the keyframes for each key and then do
// the replacement on a per-property basis rather than a per-rule
// basis, just like everything else in CSS.
AutoInfallibleTArray<KeyframeData, 16> sortedKeyframes;
for (uint32_t ruleIdx = 0, ruleEnd = rule->StyleRuleCount();
ruleIdx != ruleEnd; ++ruleIdx) {
css::Rule* cssRule = rule->GetStyleRuleAt(ruleIdx);
MOZ_ASSERT(cssRule, "must have rule");
MOZ_ASSERT(cssRule->GetType() == css::Rule::KEYFRAME_RULE,
"must be keyframe rule");
nsCSSKeyframeRule *kfRule = static_cast<nsCSSKeyframeRule*>(cssRule);
const nsTArray<float> &keys = kfRule->GetKeys();
for (uint32_t keyIdx = 0, keyEnd = keys.Length();
keyIdx != keyEnd; ++keyIdx) {
float key = keys[keyIdx];
// FIXME (spec): The spec doesn't say what to do with
// out-of-range keyframes. We'll ignore them.
if (0.0f <= key && key <= 1.0f) {
KeyframeData *data = sortedKeyframes.AppendElement();
data->mKey = key;
data->mIndex = ruleIdx;
data->mRule = kfRule;
}
}
}
sortedKeyframes.Sort(KeyframeDataComparator());
if (sortedKeyframes.Length() == 0) {
// no segments
continue;
}
// Record the properties that are present in any keyframe rules we
// are using.
nsCSSPropertySet properties;
for (uint32_t kfIdx = 0, kfEnd = sortedKeyframes.Length();
kfIdx != kfEnd; ++kfIdx) {
css::Declaration *decl = sortedKeyframes[kfIdx].mRule->Declaration();
//.........这里部分代码省略.........