本文整理汇总了C++中AutoTArray::AppendElement方法的典型用法代码示例。如果您正苦于以下问题:C++ AutoTArray::AppendElement方法的具体用法?C++ AutoTArray::AppendElement怎么用?C++ AutoTArray::AppendElement使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AutoTArray
的用法示例。
在下文中一共展示了AutoTArray::AppendElement方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: WritingMode
// The text that should be displayed for this counter.
void
nsCounterUseNode::GetText(nsString& aResult)
{
aResult.Truncate();
AutoTArray<nsCounterNode*, 8> stack;
stack.AppendElement(static_cast<nsCounterNode*>(this));
if (mAllCounters && mScopeStart) {
for (nsCounterNode* n = mScopeStart; n->mScopePrev; n = n->mScopeStart) {
stack.AppendElement(n->mScopePrev);
}
}
WritingMode wm = mPseudoFrame ?
mPseudoFrame->GetWritingMode() : WritingMode();
for (uint32_t i = stack.Length() - 1;; --i) {
nsCounterNode* n = stack[i];
nsAutoString text;
bool isTextRTL;
mCounterStyle->GetCounterText(n->mValueAfter, wm, text, isTextRTL);
aResult.Append(text);
if (i == 0) {
break;
}
aResult.Append(mSeparator);
}
}
示例2:
void
HTMLOptionsCollection::GetSupportedNames(nsTArray<nsString>& aNames)
{
AutoTArray<nsIAtom*, 8> atoms;
for (uint32_t i = 0; i < mElements.Length(); ++i) {
HTMLOptionElement* content = mElements.ElementAt(i);
if (content) {
// Note: HasName means the names is exposed on the document,
// which is false for options, so we don't check it here.
const nsAttrValue* val = content->GetParsedAttr(nsGkAtoms::name);
if (val && val->Type() == nsAttrValue::eAtom) {
nsIAtom* name = val->GetAtomValue();
if (!atoms.Contains(name)) {
atoms.AppendElement(name);
}
}
if (content->HasID()) {
nsIAtom* id = content->GetID();
if (!atoms.Contains(id)) {
atoms.AppendElement(id);
}
}
}
}
uint32_t atomsLen = atoms.Length();
nsString* names = aNames.AppendElements(atomsLen);
for (uint32_t i = 0; i < atomsLen; ++i) {
atoms[i]->ToString(names[i]);
}
}
示例3: lists
/* static */ void
nsFontFaceUtils::MarkDirtyForFontChange(nsIFrame* aSubtreeRoot,
const gfxUserFontEntry* aFont)
{
AutoTArray<nsIFrame*, 4> subtrees;
subtrees.AppendElement(aSubtreeRoot);
nsIPresShell* ps = aSubtreeRoot->PresContext()->PresShell();
// check descendants, iterating over subtrees that may include
// additional subtrees associated with placeholders
do {
nsIFrame* subtreeRoot = subtrees.ElementAt(subtrees.Length() - 1);
subtrees.RemoveElementAt(subtrees.Length() - 1);
// Check all descendants to see if they use the font
AutoTArray<nsIFrame*, 32> stack;
stack.AppendElement(subtreeRoot);
do {
nsIFrame* f = stack.ElementAt(stack.Length() - 1);
stack.RemoveElementAt(stack.Length() - 1);
// if this frame uses the font, mark its descendants dirty
// and skip checking its children
if (FrameUsesFont(f, aFont)) {
ScheduleReflow(ps, f);
} else {
if (f->GetType() == nsGkAtoms::placeholderFrame) {
nsIFrame* oof = nsPlaceholderFrame::GetRealFrameForPlaceholder(f);
if (!nsLayoutUtils::IsProperAncestorFrame(subtreeRoot, oof)) {
// We have another distinct subtree we need to mark.
subtrees.AppendElement(oof);
}
}
nsIFrame::ChildListIterator lists(f);
for (; !lists.IsDone(); lists.Next()) {
nsFrameList::Enumerator childFrames(lists.CurrentList());
for (; !childFrames.AtEnd(); childFrames.Next()) {
nsIFrame* kid = childFrames.get();
stack.AppendElement(kid);
}
}
}
} while (!stack.IsEmpty());
} while (!subtrees.IsEmpty());
}
示例4: aFunc
void
nsIGlobalObject::ForEachEventTargetObject(const std::function<void(DOMEventTargetHelper*, bool* aDoneOut)>& aFunc) const
{
// Protect against the function call triggering a mutation of the list
// while we are iterating by copying the DETH references to a temporary
// list.
AutoTArray<RefPtr<DOMEventTargetHelper>, 64> targetList;
for (const DOMEventTargetHelper* deth = mEventTargetObjects.getFirst();
deth; deth = deth->getNext()) {
targetList.AppendElement(const_cast<DOMEventTargetHelper*>(deth));
}
// Iterate the target list and call the function on each one.
bool done = false;
for (auto target : targetList) {
// Check to see if a previous iteration's callback triggered the removal
// of this target as a side-effect. If it did, then just ignore it.
if (target->GetOwnerGlobal() != this) {
continue;
}
aFunc(target, &done);
if (done) {
break;
}
}
}
示例5: CheckToken
bool
nsDOMTokenList::Toggle(const nsAString& aToken,
const Optional<bool>& aForce,
ErrorResult& aError)
{
aError = CheckToken(aToken);
if (aError.Failed()) {
return false;
}
const nsAttrValue* attr = GetParsedAttr();
const bool forceOn = aForce.WasPassed() && aForce.Value();
const bool forceOff = aForce.WasPassed() && !aForce.Value();
bool isPresent = attr && attr->Contains(aToken);
AutoTArray<nsString, 1> tokens;
(*tokens.AppendElement()).Rebind(aToken.Data(), aToken.Length());
if (isPresent) {
if (!forceOn) {
RemoveInternal(attr, tokens);
isPresent = false;
}
} else {
if (!forceOff) {
AddInternal(attr, tokens);
isPresent = true;
}
}
return isPresent;
}
示例6: Remove
void
nsDOMTokenList::Remove(const nsAString& aToken, mozilla::ErrorResult& aError)
{
AutoTArray<nsString, 1> tokens;
tokens.AppendElement(aToken);
Remove(tokens, aError);
}
示例7: Add
void
nsDOMTokenList::Add(const nsAString& aToken, ErrorResult& aError)
{
AutoTArray<nsString, 1> tokens;
tokens.AppendElement(aToken);
Add(tokens, aError);
}
示例8: MarkContextClean
already_AddRefed<Layer>
ImageBitmapRenderingContext::GetCanvasLayer(nsDisplayListBuilder* aBuilder,
Layer* aOldLayer,
LayerManager* aManager)
{
if (!mImage) {
// No DidTransactionCallback will be received, so mark the context clean
// now so future invalidations will be dispatched.
MarkContextClean();
return nullptr;
}
RefPtr<ImageLayer> imageLayer;
if (aOldLayer) {
imageLayer = static_cast<ImageLayer*>(aOldLayer);
} else {
imageLayer = aManager->CreateImageLayer();
}
RefPtr<ImageContainer> imageContainer = imageLayer->GetContainer();
if (!imageContainer) {
imageContainer = aManager->CreateImageContainer();
imageLayer->SetContainer(imageContainer);
}
AutoTArray<ImageContainer::NonOwningImage, 1> imageList;
RefPtr<layers::Image> image = ClipToIntrinsicSize();
imageList.AppendElement(ImageContainer::NonOwningImage(image));
imageContainer->SetCurrentImages(imageList);
return imageLayer.forget();
}
示例9: SetCurrentImagesInTransaction
void
ImageContainer::SetCurrentImageInTransaction(Image *aImage)
{
AutoTArray<NonOwningImage,1> images;
images.AppendElement(NonOwningImage(aImage));
SetCurrentImagesInTransaction(images);
}
示例10: GetUpdatedRegion
void
ContentClientRemoteBuffer::Updated(const nsIntRegion& aRegionToDraw,
const nsIntRegion& aVisibleRegion,
bool aDidSelfCopy)
{
nsIntRegion updatedRegion = GetUpdatedRegion(aRegionToDraw,
aVisibleRegion,
aDidSelfCopy);
MOZ_ASSERT(mTextureClient);
if (mTextureClientOnWhite) {
mForwarder->UseComponentAlphaTextures(this, mTextureClient,
mTextureClientOnWhite);
} else {
AutoTArray<CompositableForwarder::TimedTextureClient,1> textures;
CompositableForwarder::TimedTextureClient* t = textures.AppendElement();
t->mTextureClient = mTextureClient;
IntSize size = mTextureClient->GetSize();
t->mPictureRect = nsIntRect(0, 0, size.width, size.height);
GetForwarder()->UseTextures(this, textures);
}
mForwarder->UpdateTextureRegion(this,
ThebesBufferData(BufferRect(),
BufferRotation()),
updatedRegion);
}
示例11: calculateNormalizationScale
Reverb::Reverb(ThreadSharedFloatArrayBufferList* impulseResponse, size_t impulseResponseBufferLength, size_t maxFFTSize, bool useBackgroundThreads, bool normalize, float sampleRate)
{
float scale = 1;
AutoTArray<const float*,4> irChannels;
for (size_t i = 0; i < impulseResponse->GetChannels(); ++i) {
irChannels.AppendElement(impulseResponse->GetData(i));
}
AutoTArray<float,1024> tempBuf;
if (normalize) {
scale = calculateNormalizationScale(impulseResponse, impulseResponseBufferLength, sampleRate);
if (scale) {
tempBuf.SetLength(irChannels.Length()*impulseResponseBufferLength);
for (uint32_t i = 0; i < irChannels.Length(); ++i) {
float* buf = &tempBuf[i*impulseResponseBufferLength];
AudioBufferCopyWithScale(irChannels[i], scale, buf,
impulseResponseBufferLength);
irChannels[i] = buf;
}
}
}
initialize(irChannels, impulseResponseBufferLength,
maxFFTSize, useBackgroundThreads);
}
示例12: NS_SUCCEEDED
bool
MsgMapiListContext::DeleteMessage(nsMsgKey key)
{
if (!m_db)
return FALSE;
if ( !IsIMAPHost() )
{
return NS_SUCCEEDED((m_db->DeleteMessages(1, &key, nullptr)));
}
#if 0
else if ( m_folder->GetIMAPFolderInfoMail() )
{
AutoTArray<nsMsgKey, 1> messageKeys;
messageKeys.AppendElement(key);
(m_folder->GetIMAPFolderInfoMail())->DeleteSpecifiedMessages(pane, messageKeys, nsMsgKey_None);
m_db->DeleteMessage(key, nullptr, FALSE);
return TRUE;
}
#endif
else
{
return FALSE;
}
}
示例13:
void
nsShmImage::Put(const mozilla::LayoutDeviceIntRegion& aRegion)
{
AutoTArray<xcb_rectangle_t, 32> xrects;
xrects.SetCapacity(aRegion.GetNumRects());
for (auto iter = aRegion.RectIter(); !iter.Done(); iter.Next()) {
const mozilla::LayoutDeviceIntRect &r = iter.Get();
xcb_rectangle_t xrect = { (short)r.x, (short)r.y, (unsigned short)r.width, (unsigned short)r.height };
xrects.AppendElement(xrect);
}
if (!mGC) {
mGC = xcb_generate_id(mConnection);
xcb_create_gc(mConnection, mGC, mWindow, 0, nullptr);
}
xcb_set_clip_rectangles(mConnection, XCB_CLIP_ORDERING_YX_BANDED, mGC, 0, 0,
xrects.Length(), xrects.Elements());
if (mPixmap != XCB_NONE) {
mLastRequest = xcb_copy_area_checked(mConnection, mPixmap, mWindow, mGC,
0, 0, 0, 0, mSize.width, mSize.height);
} else {
mLastRequest = xcb_shm_put_image_checked(mConnection, mWindow, mGC,
mSize.width, mSize.height,
0, 0, mSize.width, mSize.height,
0, 0, mDepth,
XCB_IMAGE_FORMAT_Z_PIXMAP, 0,
mShmSeg, 0);
}
xcb_flush(mConnection);
}
示例14: AssertOwnerThread
void
VideoSink::RenderVideoFrames(int32_t aMaxFrames,
int64_t aClockTime,
const TimeStamp& aClockTimeStamp)
{
AssertOwnerThread();
AutoTArray<RefPtr<MediaData>,16> frames;
VideoQueue().GetFirstElements(aMaxFrames, &frames);
if (frames.IsEmpty() || !mContainer) {
return;
}
AutoTArray<ImageContainer::NonOwningImage,16> images;
TimeStamp lastFrameTime;
MediaSink::PlaybackParams params = mAudioSink->GetPlaybackParams();
for (uint32_t i = 0; i < frames.Length(); ++i) {
VideoData* frame = frames[i]->As<VideoData>();
frame->mSentToCompositor = true;
if (!frame->mImage || !frame->mImage->IsValid() ||
!frame->mImage->GetSize().width || !frame->mImage->GetSize().height) {
continue;
}
int64_t frameTime = frame->mTime;
if (frameTime < 0) {
// Frame times before the start time are invalid; drop such frames
continue;
}
TimeStamp t;
if (aMaxFrames > 1) {
MOZ_ASSERT(!aClockTimeStamp.IsNull());
int64_t delta = frame->mTime - aClockTime;
t = aClockTimeStamp +
TimeDuration::FromMicroseconds(delta / params.mPlaybackRate);
if (!lastFrameTime.IsNull() && t <= lastFrameTime) {
// Timestamps out of order; drop the new frame. In theory we should
// probably replace the previous frame with the new frame if the
// timestamps are equal, but this is a corrupt video file already so
// never mind.
continue;
}
lastFrameTime = t;
}
ImageContainer::NonOwningImage* img = images.AppendElement();
img->mTimeStamp = t;
img->mImage = frame->mImage;
img->mFrameID = frame->mFrameID;
img->mProducerID = mProducerID;
VSINK_LOG_V("playing video frame %lld (id=%x) (vq-queued=%i)",
frame->mTime, frame->mFrameID, VideoQueue().GetSize());
}
mContainer->SetCurrentFrames(frames[0]->As<VideoData>()->mDisplay, images);
}
示例15: GetAudioChannelsSuperset
void
AudioNodeStream::ObtainInputBlock(AudioBlock& aTmpChunk,
uint32_t aPortIndex)
{
uint32_t inputCount = mInputs.Length();
uint32_t outputChannelCount = 1;
AutoTArray<const AudioBlock*,250> inputChunks;
for (uint32_t i = 0; i < inputCount; ++i) {
if (aPortIndex != mInputs[i]->InputNumber()) {
// This input is connected to a different port
continue;
}
MediaStream* s = mInputs[i]->GetSource();
AudioNodeStream* a = static_cast<AudioNodeStream*>(s);
MOZ_ASSERT(a == s->AsAudioNodeStream());
if (a->IsAudioParamStream()) {
continue;
}
const AudioBlock* chunk = &a->mLastChunks[mInputs[i]->OutputNumber()];
MOZ_ASSERT(chunk);
if (chunk->IsNull() || chunk->mChannelData.IsEmpty()) {
continue;
}
inputChunks.AppendElement(chunk);
outputChannelCount =
GetAudioChannelsSuperset(outputChannelCount, chunk->ChannelCount());
}
outputChannelCount = ComputedNumberOfChannels(outputChannelCount);
uint32_t inputChunkCount = inputChunks.Length();
if (inputChunkCount == 0 ||
(inputChunkCount == 1 && inputChunks[0]->ChannelCount() == 0)) {
aTmpChunk.SetNull(WEBAUDIO_BLOCK_SIZE);
return;
}
if (inputChunkCount == 1 &&
inputChunks[0]->ChannelCount() == outputChannelCount) {
aTmpChunk = *inputChunks[0];
return;
}
if (outputChannelCount == 0) {
aTmpChunk.SetNull(WEBAUDIO_BLOCK_SIZE);
return;
}
aTmpChunk.AllocateChannels(outputChannelCount);
DownmixBufferType downmixBuffer;
ASSERT_ALIGNED16(downmixBuffer.Elements());
for (uint32_t i = 0; i < inputChunkCount; ++i) {
AccumulateInputChunk(i, *inputChunks[i], &aTmpChunk, &downmixBuffer);
}
}