本文整理汇总了C++中nsTArray::ElementAt方法的典型用法代码示例。如果您正苦于以下问题:C++ nsTArray::ElementAt方法的具体用法?C++ nsTArray::ElementAt怎么用?C++ nsTArray::ElementAt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nsTArray
的用法示例。
在下文中一共展示了nsTArray::ElementAt方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: nsPersistentProperties
already_AddRefed<nsIPersistentProperties>
AccessibleWrap::AttributeArrayToProperties(
const nsTArray<Attribute>& aAttributes) {
RefPtr<nsPersistentProperties> props = new nsPersistentProperties();
nsAutoString unused;
for (size_t i = 0; i < aAttributes.Length(); i++) {
props->SetStringProperty(aAttributes.ElementAt(i).Name(),
aAttributes.ElementAt(i).Value(), unused);
}
return props.forget();
}
示例2:
NS_IMETHODIMP
nsDOMMultipartBlob::GetSize(PRUint64* aLength)
{
nsresult rv;
*aLength = 0;
if (mLength) {
*aLength = mLength;
return NS_OK;
}
CheckedUint64 length = 0;
PRUint32 i;
PRUint32 len = mBlobs.Length();
for (i = 0; i < len; i++) {
nsIDOMBlob* blob = mBlobs.ElementAt(i).get();
PRUint64 l = 0;
rv = blob->GetSize(&l);
NS_ENSURE_SUCCESS(rv, rv);
length += l;
}
if (!length.valid())
return NS_ERROR_FAILURE;
mLength = length.value();
*aLength = mLength;
return NS_OK;
}
示例3: LOG
bool
AndroidGraphicBuffer::IsBlacklisted()
{
nsAutoString board;
if (!AndroidBridge::Bridge()->GetStaticStringField("android/os/Build", "BOARD", board))
return true;
NS_ConvertUTF16toUTF8 boardUtf8(board);
if (Preferences::GetBool("direct-texture.force.enabled", false)) {
LOG("allowing board '%s' due to prefs override", boardUtf8.get());
return false;
}
if (Preferences::GetBool("direct-texture.force.disabled", false)) {
LOG("disallowing board '%s' due to prefs override", boardUtf8.get());
return true;
}
static nsTArray<nsString> sListAllowed;
if (sListAllowed.Length() == 0) {
InitWhiteList(sListAllowed);
}
int i = -1;
if ((i = sListAllowed.BinaryIndexOf(board)) >= 0) {
nsString name = sListAllowed.ElementAt(i);
LOG("allowing board '%s' based on '%s'\n", boardUtf8.get(), NS_ConvertUTF16toUTF8(name).get());
return false;
}
LOG("disallowing board: %s\n", boardUtf8.get());
return true;
}
示例4: DumpLayerList
static void DumpLayerList(nsTArray<Layer*>& aLayers)
{
for (PRUint32 i = 0; i < aLayers.Length(); i++) {
fprintf(stderr, "%p, ", aLayers.ElementAt(i));
}
fprintf(stderr, "\n");
}
示例5:
NS_IMETHODIMP
nsDOMMultipartFile::GetSize(PRUint64* aLength)
{
if (mLength == PR_UINT64_MAX) {
CheckedUint64 length = 0;
PRUint32 i;
PRUint32 len = mBlobs.Length();
for (i = 0; i < len; i++) {
nsIDOMBlob* blob = mBlobs.ElementAt(i).get();
PRUint64 l = 0;
nsresult rv = blob->GetSize(&l);
NS_ENSURE_SUCCESS(rv, rv);
length += l;
}
NS_ENSURE_TRUE(length.valid(), NS_ERROR_FAILURE);
mLength = length.value();
}
*aLength = mLength;
return NS_OK;
}
示例6: dictStr
// Helper function that iterates over the list of dictionaries and sets the one
// that matches based on a given comparison type.
nsresult
nsEditorSpellCheck::TryDictionary(const nsAString& aDictName,
nsTArray<nsString>& aDictList,
enum dictCompare aCompareType)
{
nsresult rv = NS_ERROR_NOT_AVAILABLE;
for (uint32_t i = 0; i < aDictList.Length(); i++) {
nsAutoString dictStr(aDictList.ElementAt(i));
bool equals = false;
switch (aCompareType) {
case DICT_NORMAL_COMPARE:
equals = aDictName.Equals(dictStr);
break;
case DICT_COMPARE_CASE_INSENSITIVE:
equals = aDictName.Equals(dictStr, nsCaseInsensitiveStringComparator());
break;
case DICT_COMPARE_DASHMATCH:
equals = nsStyleUtil::DashMatchCompare(dictStr, aDictName, nsCaseInsensitiveStringComparator());
break;
}
if (equals) {
rv = mSpellChecker->SetCurrentDictionary(dictStr);
#ifdef DEBUG_DICT
if (NS_SUCCEEDED(rv))
printf("***** Set |%s|.\n", NS_ConvertUTF16toUTF8(dictStr).get());
#endif
// We always break here. We tried to set the dictionary to an existing
// dictionary from the list. This must work, if it doesn't, there is
// no point trying another one.
break;
}
}
return rv;
}
示例7: DumpLayerList
static void DumpLayerList(nsTArray<Layer*>& aLayers)
{
for (uint32_t i = 0; i < aLayers.Length(); i++) {
print_layer(stderr, aLayers.ElementAt(i));
fprintf(stderr, " ");
}
fprintf(stderr, "\n");
}
示例8:
NS_IMETHODIMP
WorkerDebuggerEnumerator::GetNext(nsISupports** aResult)
{
if (mIndex == mDebuggers.Length()) {
return NS_ERROR_FAILURE;
}
mDebuggers.ElementAt(mIndex++).forget(aResult);
return NS_OK;
};
示例9: argvRooter
bool
JetpackActorCommon::RecvMessage(JSContext* cx,
const nsString& messageName,
const nsTArray<Variant>& data,
nsTArray<Variant>* results)
{
if (results)
results->Clear();
RecList* list;
if (!mReceivers.Get(messageName, &list))
return true;
nsAutoTArray<jsval, 4> snapshot;
list->copyTo(snapshot);
if (!snapshot.Length())
return true;
nsAutoTArray<jsval, 4> args;
PRUint32 argc = data.Length() + 1;
jsval* argv = args.AppendElements(argc);
if (!argv)
return false;
for (PRUint32 i = 0; i < argc; ++i)
argv[i] = JSVAL_VOID;
js::AutoArrayRooter argvRooter(cx, argc, argv);
JSString* msgNameStr =
JS_NewUCStringCopyN(cx,
messageName.get(),
messageName.Length());
if (!msgNameStr)
return false;
argv[0] = STRING_TO_JSVAL(msgNameStr);
for (PRUint32 i = 0; i < data.Length(); ++i)
if (!jsval_from_Variant(cx, data.ElementAt(i), argv + i + 1))
return false;
JSObject* implGlobal = JS_GetGlobalObject(cx);
js::AutoValueRooter rval(cx);
for (PRUint32 i = 0; i < snapshot.Length(); ++i) {
Variant* vp = results ? results->AppendElement() : NULL;
rval.set(JSVAL_VOID);
if (!JS_CallFunctionValue(cx, implGlobal, snapshot[i], argc, argv,
rval.jsval_addr())) {
(void) JS_ReportPendingException(cx);
if (vp)
*vp = void_t();
} else if (vp && !jsval_to_Variant(cx, rval.jsval_value(), vp))
*vp = void_t();
}
return true;
}
示例10:
nsresult
nsXPathEvaluatorParseContext::resolveFunctionCall(nsIAtom* aName,
int32_t aID,
FunctionCall** aFn)
{
nsresult rv = NS_ERROR_XPATH_UNKNOWN_FUNCTION;
uint32_t i, count = mNamespaceIDs ? mNamespaceIDs->Length() : 0;
for (i = 0; i < count; ++i) {
if (mNamespaceIDs->ElementAt(i) == aID) {
nsISupports *state = mState ? mState->SafeObjectAt(i) : nullptr;
rv = TX_ResolveFunctionCallXPCOM(mContractIDs->ElementAt(i), aID,
aName, state, aFn);
if (NS_SUCCEEDED(rv)) {
break;
}
}
}
return rv;
}
示例11:
nsresult
NameSpaceManagerImpl::GetNameSpaceURI(PRInt32 aNameSpaceID, nsAString& aURI)
{
NS_PRECONDITION(aNameSpaceID >= 0, "Bogus namespace ID");
PRInt32 index = aNameSpaceID - 1; // id is index + 1
if (index < 0 || index >= PRInt32(mURIArray.Length())) {
aURI.Truncate();
return NS_ERROR_ILLEGAL_VALUE;
}
aURI = *mURIArray.ElementAt(index);
return NS_OK;
}
示例12:
// Helper function for notifying permission granted
static nsresult
NotifyPermissionAllow(const nsAString &aCallID, nsTArray<nsCOMPtr<nsIMediaDevice> > &aDevices)
{
nsresult rv;
nsCOMPtr<nsISupportsArray> array;
rv = NS_NewISupportsArray(getter_AddRefs(array));
NS_ENSURE_SUCCESS(rv, rv);
for (uint32_t i = 0; i < aDevices.Length(); ++i) {
rv = array->AppendElement(aDevices.ElementAt(i));
NS_ENSURE_SUCCESS(rv, rv);
}
nsCOMPtr<nsIObserverService> obs = services::GetObserverService();
NS_ENSURE_TRUE(obs, NS_ERROR_FAILURE);
return obs->NotifyObservers(array, "getUserMedia:response:allow",
aCallID.BeginReading());
}
示例13: family
void
gfxFontFeatureValueSet::AddFontFeatureValues(const nsAString& aFamily,
const nsTArray<gfxFontFeatureValueSet::FeatureValues>& aValues)
{
nsAutoString family(aFamily);
ToLowerCase(family);
uint32_t i, numFeatureValues = aValues.Length();
for (i = 0; i < numFeatureValues; i++) {
const FeatureValues& fv = aValues.ElementAt(i);
uint32_t alternate = fv.alternate;
uint32_t j, numValues = fv.valuelist.Length();
for (j = 0; j < numValues; j++) {
const ValueList& v = fv.valuelist.ElementAt(j);
auto* array = AppendFeatureValueHashEntry(family, v.name, alternate);
*array = v.featureSelectors;
}
}
}
示例14: while
nsresult
BluetoothDaemonConnectionIO::SendPendingData(int aFd)
{
while (HasPendingData()) {
BluetoothDaemonPDU* outgoing = mOutgoingQ.ElementAt(0);
MOZ_ASSERT(outgoing);
ssize_t res = outgoing->Send(aFd);
if (res < 0) {
/* an I/O error occured */
return NS_ERROR_FAILURE;
} else if (!res) {
/* I/O is currently blocked; try again later */
return NS_OK;
}
MOZ_ASSERT(!outgoing->GetSize());
mOutgoingQ.RemoveElementAt(0);
delete outgoing;
}
return NS_OK;
}
示例15: CallQueryInterface
NS_IMETHODIMP
nsDOMMultipartBlob::GetInternalStream(nsIInputStream** aStream)
{
nsresult rv;
*aStream = nsnull;
nsCOMPtr<nsIMultiplexInputStream> stream =
do_CreateInstance("@mozilla.org/io/multiplex-input-stream;1");
NS_ENSURE_TRUE(stream, NS_ERROR_FAILURE);
PRUint32 i;
for (i = 0; i < mBlobs.Length(); i++) {
nsCOMPtr<nsIInputStream> scratchStream;
nsIDOMBlob* blob = mBlobs.ElementAt(i).get();
rv = blob->GetInternalStream(getter_AddRefs(scratchStream));
NS_ENSURE_SUCCESS(rv, rv);
rv = stream->AppendStream(scratchStream);
NS_ENSURE_SUCCESS(rv, rv);
}
return CallQueryInterface(stream, aStream);
}