本文整理汇总了C++中nsTArray::Clear方法的典型用法代码示例。如果您正苦于以下问题:C++ nsTArray::Clear方法的具体用法?C++ nsTArray::Clear怎么用?C++ nsTArray::Clear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nsTArray
的用法示例。
在下文中一共展示了nsTArray::Clear方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
nsresult
MockMediaResource::GetCachedRanges(nsTArray<MediaByteRange>& aRanges)
{
aRanges.Clear();
aRanges.AppendElements(mRanges);
return NS_OK;
}
示例2: GetNumberOfChars
void
nsSVGTextContainerFrame::CopyRotateList(nsTArray<float> *parentList,
const SVGNumberList *selfList,
nsTArray<float> &dstList,
PRUint32 aOffset)
{
dstList.Clear();
PRUint32 strLength = GetNumberOfChars();
PRUint32 parentCount = 0;
if (parentList && parentList->Length() > aOffset) {
parentCount = NS_MIN(parentList->Length() - aOffset, strLength);
}
PRUint32 selfCount = NS_MIN(selfList ? selfList->Length() : 0, strLength);
PRUint32 count = NS_MAX(parentCount, selfCount);
if (count > 0) {
if (!dstList.SetLength(count))
return;
for (PRUint32 i = 0; i < selfCount; i++) {
dstList[i] = (*selfList)[i];
}
for (PRUint32 i = selfCount; i < parentCount; i++) {
dstList[i] = (*parentList)[aOffset + i];
}
} else if (parentList && !parentList->IsEmpty()) {
// rotate is applied to extra characters too
dstList.AppendElement((*parentList)[parentList->Length() - 1]);
}
}
示例3: BuildDocShellArray
nsresult nsDocShellEnumerator::BuildDocShellArray(nsTArray<nsWeakPtr>& inItemArray)
{
NS_ENSURE_TRUE(mRootItem, NS_ERROR_NOT_INITIALIZED);
inItemArray.Clear();
nsCOMPtr<nsIDocShellTreeItem> item = do_QueryReferent(mRootItem);
return BuildArrayRecursive(item, inItemArray);
}
示例4:
void
FileDescriptorSetChild::ForgetFileDescriptors(
nsTArray<FileDescriptor>& aFileDescriptors)
{
aFileDescriptors.Clear();
mFileDescriptors.SwapElements(aFileDescriptors);
}
示例5:
void
LayerManager::StopFrameTimeRecording(uint32_t aStartIndex,
nsTArray<float>& aFrameIntervals)
{
uint32_t bufferSize = mRecording.mIntervals.Length();
uint32_t length = mRecording.mNextIndex - aStartIndex;
if (mRecording.mIsPaused || length > bufferSize || aStartIndex < mRecording.mCurrentRunStartIndex) {
// aStartIndex is too old. Also if aStartIndex was issued before mRecordingNextIndex overflowed (uint32_t)
// and stopped after the overflow (would happen once every 828 days of constant 60fps).
length = 0;
}
if (!length) {
aFrameIntervals.Clear();
return; // empty recording, return empty arrays.
}
// Set length in advance to avoid possibly repeated reallocations
aFrameIntervals.SetLength(length);
uint32_t cyclicPos = aStartIndex % bufferSize;
for (uint32_t i = 0; i < length; i++, cyclicPos++) {
if (cyclicPos == bufferSize) {
cyclicPos = 0;
}
aFrameIntervals[i] = mRecording.mIntervals[cyclicPos];
}
}
示例6: GetNumberOfChars
void
nsSVGTextContainerFrame::CopyPositionList(nsTArray<float> *parentList,
SVGUserUnitList *selfList,
nsTArray<float> &dstList,
uint32_t aOffset)
{
dstList.Clear();
uint32_t strLength = GetNumberOfChars();
uint32_t parentCount = 0;
if (parentList && parentList->Length() > aOffset) {
parentCount = std::min(parentList->Length() - aOffset, strLength);
}
uint32_t selfCount = std::min(selfList->Length(), strLength);
uint32_t count = std::max(parentCount, selfCount);
if (!dstList.SetLength(count))
return;
for (uint32_t i = 0; i < selfCount; i++) {
dstList[i] = (*selfList)[i];
}
for (uint32_t i = selfCount; i < parentCount; i++) {
dstList[i] = (*parentList)[aOffset + i];
}
}
示例7: defined
static void
FillPBufferAttribs_ByBits(nsTArray<EGLint>& aAttrs,
int redBits, int greenBits,
int blueBits, int alphaBits,
int depthBits, int stencilBits)
{
aAttrs.Clear();
#if defined(A1) || defined(A2)
#error The temp-macro names we want are already defined.
#endif
#define A1(_x) do { aAttrs.AppendElement(_x); } while (0)
#define A2(_x,_y) do { A1(_x); A1(_y); } while (0)
A2(LOCAL_EGL_RENDERABLE_TYPE, LOCAL_EGL_OPENGL_ES2_BIT);
A2(LOCAL_EGL_SURFACE_TYPE, LOCAL_EGL_PBUFFER_BIT);
A2(LOCAL_EGL_RED_SIZE, redBits);
A2(LOCAL_EGL_GREEN_SIZE, greenBits);
A2(LOCAL_EGL_BLUE_SIZE, blueBits);
A2(LOCAL_EGL_ALPHA_SIZE, alphaBits);
A2(LOCAL_EGL_DEPTH_SIZE, depthBits);
A2(LOCAL_EGL_STENCIL_SIZE, stencilBits);
A1(LOCAL_EGL_NONE);
#undef A1
#undef A2
}
示例8:
void
PerformanceObserverEntryList::GetEntries(
const PerformanceEntryFilterOptions& aFilter,
nsTArray<RefPtr<PerformanceEntry>>& aRetval)
{
aRetval.Clear();
for (const RefPtr<PerformanceEntry>& entry : mEntries) {
if (aFilter.mInitiatorType.WasPassed()) {
const PerformanceResourceTiming* resourceEntry =
entry->ToResourceTiming();
if (!resourceEntry) {
continue;
}
nsAutoString initiatorType;
resourceEntry->GetInitiatorType(initiatorType);
if (!initiatorType.Equals(aFilter.mInitiatorType.Value())) {
continue;
}
}
if (aFilter.mName.WasPassed() &&
!entry->GetName().Equals(aFilter.mName.Value())) {
continue;
}
if (aFilter.mEntryType.WasPassed() &&
!entry->GetEntryType().Equals(aFilter.mEntryType.Value())) {
continue;
}
aRetval.AppendElement(entry);
}
}
示例9: ReleaseShmems
// static
void IpcResourceUpdateQueue::ReleaseShmems(ipc::IProtocol* aShmAllocator,
nsTArray<ipc::Shmem>& aShms) {
for (auto& shm : aShms) {
aShmAllocator->DeallocShmem(shm);
}
aShms.Clear();
}
示例10:
nsresult
nsGonkCameraControl::GetVideoSizes(nsTArray<CameraSize>& aVideoSizes)
{
aVideoSizes.Clear();
Vector<Size> sizes;
mParams.getSupportedVideoSizes(sizes);
if (sizes.size() == 0) {
DOM_CAMERA_LOGI("Camera doesn't support video independent of the preview\n");
mParams.getSupportedPreviewSizes(sizes);
}
if (sizes.size() == 0) {
DOM_CAMERA_LOGW("Camera doesn't report any supported video sizes at all\n");
return NS_OK;
}
for (size_t i = 0; i < sizes.size(); ++i) {
CameraSize size;
size.width = sizes[i].width;
size.height = sizes[i].height;
aVideoSizes.AppendElement(size);
}
return NS_OK;
}
示例11:
void
JetpackActorCommon::RecList::copyTo(nsTArray<jsval>& dst) const
{
dst.Clear();
for (RecNode* node = mHead; node; node = node->down)
dst.AppendElement(node->value());
}
示例12: SpeechSynthesisVoice
void
SpeechSynthesis::GetVoices(nsTArray< nsRefPtr<SpeechSynthesisVoice> >& aResult)
{
aResult.Clear();
uint32_t voiceCount = 0;
nsresult rv = nsSynthVoiceRegistry::GetInstance()->GetVoiceCount(&voiceCount);
NS_ENSURE_SUCCESS_VOID(rv);
for (uint32_t i = 0; i < voiceCount; i++) {
nsAutoString uri;
rv = nsSynthVoiceRegistry::GetInstance()->GetVoice(i, uri);
if (NS_FAILED(rv)) {
NS_WARNING("Failed to retrieve voice from registry");
continue;
}
SpeechSynthesisVoice* voice = mVoiceCache.GetWeak(uri);
if (!voice) {
voice = new SpeechSynthesisVoice(this, uri);
}
aResult.AppendElement(voice);
}
mVoiceCache.Clear();
for (uint32_t i = 0; i < aResult.Length(); i++) {
SpeechSynthesisVoice* voice = aResult[i];
mVoiceCache.Put(voice->mUri, voice);
}
}
示例13: Flush
void IpcResourceUpdateQueue::Flush(
nsTArray<layers::OpUpdateResource>& aUpdates,
nsTArray<layers::RefCountedShmem>& aSmallAllocs,
nsTArray<ipc::Shmem>& aLargeAllocs) {
aUpdates.Clear();
mUpdates.SwapElements(aUpdates);
mWriter.Flush(aSmallAllocs, aLargeAllocs);
}
示例14: LOG
bool
DBusThread::TearDownData()
{
LOG("Removing DBus Sockets\n");
if (mControlFdW.get()) {
mControlFdW.dispose();
}
if (mControlFdR.get()) {
mControlFdR.dispose();
}
mPollData.Clear();
// DBusWatch pointers are maintained by DBus, so we won't leak by
// clearing.
mWatchData.Clear();
return true;
}
示例15:
void
WindowsGamepadService::Cleanup()
{
if (mXInputPollTimer) {
mXInputPollTimer->Cancel();
}
mGamepads.Clear();
}