本文整理汇总了C++中nsAString::IsVoid方法的典型用法代码示例。如果您正苦于以下问题:C++ nsAString::IsVoid方法的具体用法?C++ nsAString::IsVoid怎么用?C++ nsAString::IsVoid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nsAString
的用法示例。
在下文中一共展示了nsAString::IsVoid方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: newLoginInfoAttributes
GnomeKeyringResult
GnomeKeyring::findLogins(const nsAString & aHostname,
const nsAString & aActionURL,
const nsAString & aHttpRealm,
GList** found)
{
AutoAttributeList attributes;
newLoginInfoAttributes(&attributes);
addAttribute(attributes, kHostnameAttr, aHostname);
if (!aActionURL.IsVoid() && !aActionURL.IsEmpty()) {
addAttribute(attributes, kFormSubmitURLAttr, aActionURL);
}
if (!aHttpRealm.IsVoid() && !aHttpRealm.IsEmpty()) {
addAttribute(attributes, kHttpRealmAttr, aHttpRealm);
}
GnomeKeyringResult result = findLoginItems(attributes, found);
if (aActionURL.IsVoid()) {
// TODO: filter out items with a kFormSubmitURLAttr
// practically, this is not necessary since actionURL/httpRealm are
// mutually exclusive, but this is not enforced by the interface
}
if (aHttpRealm.IsVoid()) {
// TODO: filter out items with a kHttpRealmAttr
// practically, this is not necessary since actionURL/httpRealm are
// mutually exclusive, but this is not enforced by the interface
}
return result;
}
示例2: ResponsiveImageSelector
/* static */ bool
HTMLImageElement::SelectSourceForTagWithAttrs(nsIDocument *aDocument,
bool aIsSourceTag,
const nsAString& aSrcAttr,
const nsAString& aSrcsetAttr,
const nsAString& aSizesAttr,
const nsAString& aTypeAttr,
const nsAString& aMediaAttr,
nsAString& aResult)
{
MOZ_ASSERT(aIsSourceTag || (aTypeAttr.IsEmpty() && aMediaAttr.IsEmpty()),
"Passing type or media attrs makes no sense without aIsSourceTag");
MOZ_ASSERT(!aIsSourceTag || aSrcAttr.IsEmpty(),
"Passing aSrcAttr makes no sense with aIsSourceTag set");
if (aSrcsetAttr.IsEmpty()) {
if (!aIsSourceTag) {
// For an <img> with no srcset, we would always select the src attr.
aResult.Assign(aSrcAttr);
return true;
}
// Otherwise, a <source> without srcset is never selected
return false;
}
// Would not consider source tags with unsupported media or type
if (aIsSourceTag &&
((!aMediaAttr.IsVoid() &&
!HTMLSourceElement::WouldMatchMediaForDocument(aMediaAttr, aDocument)) ||
(!aTypeAttr.IsVoid() &&
!SupportedPictureSourceType(aTypeAttr)))) {
return false;
}
// Using srcset or picture <source>, build a responsive selector for this tag.
RefPtr<ResponsiveImageSelector> sel =
new ResponsiveImageSelector(aDocument);
sel->SetCandidatesFromSourceSet(aSrcsetAttr);
if (!aSizesAttr.IsEmpty()) {
sel->SetSizesFromDescriptor(aSizesAttr);
}
if (!aIsSourceTag) {
sel->SetDefaultSource(aSrcAttr);
}
if (sel->GetSelectedImageURLSpec(aResult)) {
return true;
}
if (!aIsSourceTag) {
// <img> tag with no match would definitively load nothing.
aResult.Truncate();
return true;
}
// <source> tags with no match would leave source yet-undetermined.
return false;
}
示例3: generateQueryWalletKey
QString generateQueryWalletKey( const nsAString & aHostname,
const nsAString & aActionURL,
const nsAString & aHttpRealm,
const nsAString & aUsername ) {
QString key = (aUsername.IsVoid() || aUsername.IsEmpty() ) ? "*" : NSString2QtString(aUsername);
key += ",";
key += (aActionURL.IsVoid() || aActionURL.IsEmpty() ) ? "*" : NSString2QtString(aActionURL);
key += ",";
key += (aHttpRealm.IsVoid() || aHttpRealm.IsEmpty() ) ? "*" : NSString2QtString(aHttpRealm);
key += ",";
key += (aHostname.IsVoid() || aHostname.IsEmpty() ) ? "*" : NSString2QtString(aHostname);
return key;
}
示例4:
/**
* Asks the Property Manager whether or not the value is valid for the given
* property.
*/
nsresult
sbPropertyArray::ValueIsValid(const nsAString& aID,
const nsAString& aValue,
bool* _retval)
{
NS_ASSERTION(!aID.IsEmpty(), "Don't pass an empty property id!");
NS_ASSERTION(_retval, "Don't hand me a null!");
if (aValue.IsVoid()) {
*_retval = PR_TRUE;
return NS_OK;
}
nsresult rv;
if (!mPropManager) {
mPropManager = do_GetService(SB_PROPERTYMANAGER_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv, rv);
}
// This will actually *create* a new sbIPropertyInfo if one has not been
// registered already...
nsCOMPtr<sbIPropertyInfo> propInfo;
rv = mPropManager->GetPropertyInfo(aID, getter_AddRefs(propInfo));
NS_ENSURE_SUCCESS(rv, rv);
bool valid;
rv = propInfo->Validate(aValue, &valid);
NS_ENSURE_SUCCESS(rv, rv);
*_retval = valid;
return NS_OK;
}
示例5:
static void
ConvertString(const nsAString& aUTF16String, nsACString& aUTF8String)
{
if (aUTF16String.IsVoid()) {
aUTF8String.SetIsVoid(true);
} else {
CopyUTF16toUTF8(aUTF16String, aUTF8String);
}
}
示例6:
/* If no source has been defined, compileShader() has not been called,
* or the translation has failed for shader, an empty string is
* returned; otherwise, return the translated source.
*/
void
WebGLExtensionDebugShaders::GetTranslatedShaderSource(WebGLShader* shader,
nsAString& retval)
{
mContext->GetShaderTranslatedSource(shader, retval);
if (retval.IsVoid()) {
CopyASCIItoUTF16("", retval);
}
}
示例7: autoProcessLock
nsresult
sbProcess::SetStdinString(const nsAString& aStdinString)
{
// Operate under the process lock.
NS_ENSURE_TRUE(mProcessLock, NS_ERROR_NOT_INITIALIZED);
nsAutoLock autoProcessLock(mProcessLock);
// Set the stdin string.
mStdinString.Assign(aStdinString);
mPipeStdinString = !aStdinString.IsVoid();
return NS_OK;
}
示例8: NS_SUCCEEDED
PRBool
nsXTFElementWrapper::GetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
nsAString& aResult) const
{
if (aNameSpaceID==kNameSpaceID_None && HandledByInner(aName)) {
// XXX we don't do namespaced attributes yet
nsresult rv = mAttributeHandler->GetAttribute(aName, aResult);
return NS_SUCCEEDED(rv) && !aResult.IsVoid();
}
else { // try wrapper
return nsXTFElementWrapperBase::GetAttr(aNameSpaceID, aName, aResult);
}
}
示例9:
/* If no source has been defined, compileShader() has not been called,
* or the translation has failed for shader, an empty string is
* returned; otherwise, return the translated source.
*/
void
WebGLExtensionDebugShaders::GetTranslatedShaderSource(WebGLShader* shader,
nsAString& retval)
{
if (mIsLost) {
return mContext->ErrorInvalidOperation("getTranslatedShaderSource: "
"Extension is lost.");
}
mContext->GetShaderTranslatedSource(shader, retval);
if (retval.IsVoid()) {
CopyASCIItoUTF16("", retval);
}
}
示例10:
JSBool
xpc_qsStringToJsval(JSContext *cx, const nsAString &str, jsval *rval)
{
// From the T_DOMSTRING case in XPCConvert::NativeData2JS.
if(str.IsVoid())
{
*rval = JSVAL_NULL;
return JS_TRUE;
}
jsval jsstr = XPCStringConvert::ReadableToJSVal(cx, str);
if(!jsstr)
return JS_FALSE;
*rval = jsstr;
return JS_TRUE;
}
示例11:
NS_IMETHODIMP
sbOriginPageImagePropertyInfo::GetImageSrc(const nsAString& aValue,
nsAString& _retval)
{
if(aValue.IsEmpty() ||
aValue.IsVoid() ||
aValue.EqualsLiteral("unknownOrigin") ||
aValue.EqualsLiteral("webOrigin")) {
_retval.Truncate();
return NS_OK;
}
nsCOMPtr<nsIURI> uri;
nsresult rv = NS_NewURI(getter_AddRefs(uri), aValue);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIURI> imageUri;
rv = mFaviconService->GetFaviconForPage(uri, getter_AddRefs(imageUri));
if(rv == NS_ERROR_NOT_AVAILABLE) {
_retval.Truncate();
return NS_OK;
}
NS_ENSURE_SUCCESS(rv, rv);
nsCAutoString spec;
rv = imageUri->GetSpec(spec);
NS_ENSURE_SUCCESS(rv, rv);
NS_NAMED_LITERAL_CSTRING(mozAnnoFavicon, "moz-anno:favicon:");
if(!StringBeginsWith(spec, mozAnnoFavicon)) {
_retval = NS_ConvertUTF8toUTF16(spec);
return NS_OK;
}
spec.Cut(0, mozAnnoFavicon.Length());
NS_WARNING(spec.get());
_retval = NS_ConvertUTF8toUTF16(spec);
return NS_OK;
}
示例12: StringBeginsWith
NS_IMETHODIMP
sbOriginPageImagePropertyInfo::GetCellProperties(const nsAString& aValue,
nsAString& _retval)
{
if(aValue.EqualsLiteral("unknownOrigin") ||
aValue.IsEmpty() ||
aValue.IsVoid()) {
_retval.AssignLiteral("image unknownOrigin");
return NS_OK;
}
if(aValue.EqualsLiteral("webOrigin") ||
StringBeginsWith(aValue, NS_LITERAL_STRING("http://"), CaseInsensitiveCompare) ||
StringBeginsWith(aValue, NS_LITERAL_STRING("https://"), CaseInsensitiveCompare) ||
StringBeginsWith(aValue, NS_LITERAL_STRING("ftp://"), CaseInsensitiveCompare)) {
_retval.AssignLiteral("image webOrigin");
return NS_OK;
}
_retval.AssignLiteral("image");
return NS_OK;
}
示例13: PresentationControllingInfo
NS_IMETHODIMP
PresentationService::StartSession(const nsAString& aUrl,
const nsAString& aSessionId,
const nsAString& aOrigin,
const nsAString& aDeviceId,
uint64_t aWindowId,
nsIPresentationServiceCallback* aCallback)
{
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(aCallback);
MOZ_ASSERT(!aSessionId.IsEmpty());
// Create session info and set the callback. The callback is called when the
// request is finished.
RefPtr<PresentationSessionInfo> info =
new PresentationControllingInfo(aUrl, aSessionId, aCallback);
mSessionInfoAtController.Put(aSessionId, info);
// Only track the info when an actual window ID, which would never be 0, is
// provided (for an in-process sender page).
if (aWindowId != 0) {
mRespondingSessionIds.Put(aWindowId, new nsString(aSessionId));
mRespondingWindowIds.Put(aSessionId, aWindowId);
}
nsCOMPtr<nsIPresentationDeviceRequest> request =
new PresentationDeviceRequest(aUrl, aSessionId, aOrigin);
if (aDeviceId.IsVoid()) {
// Pop up a prompt and ask user to select a device.
nsCOMPtr<nsIPresentationDevicePrompt> prompt =
do_GetService(PRESENTATION_DEVICE_PROMPT_CONTRACTID);
if (NS_WARN_IF(!prompt)) {
return info->ReplyError(NS_ERROR_DOM_OPERATION_ERR);
}
nsresult rv = prompt->PromptDeviceSelection(request);
if (NS_WARN_IF(NS_FAILED(rv))) {
return info->ReplyError(NS_ERROR_DOM_OPERATION_ERR);
}
return NS_OK;
}
// Find the designated device from available device list.
nsCOMPtr<nsIPresentationDeviceManager> deviceManager =
do_GetService(PRESENTATION_DEVICE_MANAGER_CONTRACTID);
if (NS_WARN_IF(!deviceManager)) {
return info->ReplyError(NS_ERROR_DOM_OPERATION_ERR);
}
nsCOMPtr<nsIArray> devices;
nsresult rv = deviceManager->GetAvailableDevices(getter_AddRefs(devices));
if (NS_WARN_IF(NS_FAILED(rv))) {
return info->ReplyError(NS_ERROR_DOM_OPERATION_ERR);
}
nsCOMPtr<nsISimpleEnumerator> enumerator;
rv = devices->Enumerate(getter_AddRefs(enumerator));
if (NS_WARN_IF(NS_FAILED(rv))) {
return info->ReplyError(NS_ERROR_DOM_OPERATION_ERR);
}
NS_ConvertUTF16toUTF8 utf8DeviceId(aDeviceId);
bool hasMore;
while(NS_SUCCEEDED(enumerator->HasMoreElements(&hasMore)) && hasMore){
nsCOMPtr<nsISupports> isupports;
rv = enumerator->GetNext(getter_AddRefs(isupports));
nsCOMPtr<nsIPresentationDevice> device(do_QueryInterface(isupports));
MOZ_ASSERT(device);
nsAutoCString id;
if (NS_SUCCEEDED(device->GetId(id)) && id.Equals(utf8DeviceId)) {
request->Select(device);
return NS_OK;
}
}
// Reject if designated device is not available.
return info->ReplyError(NS_ERROR_DOM_NOT_FOUND_ERR);
}
示例14:
NS_StringGetIsVoid(const nsAString& aStr)
{
return aStr.IsVoid();
}
示例15: PresentationDeviceRequest
NS_IMETHODIMP
PresentationService::StartSession(
const nsTArray<nsString>& aUrls,
const nsAString& aSessionId,
const nsAString& aOrigin,
const nsAString& aDeviceId,
uint64_t aWindowId,
nsIDOMEventTarget* aEventTarget,
nsIPrincipal* aPrincipal,
nsIPresentationServiceCallback* aCallback,
nsIPresentationTransportBuilderConstructor* aBuilderConstructor)
{
PRES_DEBUG("%s:id[%s]\n", __func__, NS_ConvertUTF16toUTF8(aSessionId).get());
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(aCallback);
MOZ_ASSERT(!aSessionId.IsEmpty());
MOZ_ASSERT(!aUrls.IsEmpty());
nsCOMPtr<nsIPresentationDeviceRequest> request =
new PresentationDeviceRequest(aUrls,
aSessionId,
aOrigin,
aWindowId,
aEventTarget,
aPrincipal,
aCallback,
aBuilderConstructor);
if (aDeviceId.IsVoid()) {
// Pop up a prompt and ask user to select a device.
nsCOMPtr<nsIPresentationDevicePrompt> prompt =
do_GetService(PRESENTATION_DEVICE_PROMPT_CONTRACTID);
if (NS_WARN_IF(!prompt)) {
return aCallback->NotifyError(NS_ERROR_DOM_OPERATION_ERR);
}
nsresult rv = prompt->PromptDeviceSelection(request);
if (NS_WARN_IF(NS_FAILED(rv))) {
return aCallback->NotifyError(NS_ERROR_DOM_OPERATION_ERR);
}
return NS_OK;
}
// Find the designated device from available device list.
nsCOMPtr<nsIPresentationDeviceManager> deviceManager =
do_GetService(PRESENTATION_DEVICE_MANAGER_CONTRACTID);
if (NS_WARN_IF(!deviceManager)) {
return aCallback->NotifyError(NS_ERROR_DOM_OPERATION_ERR);
}
nsCOMPtr<nsIArray> presentationUrls;
if (NS_WARN_IF(NS_FAILED(
ConvertURLArrayHelper(aUrls, getter_AddRefs(presentationUrls))))) {
return aCallback->NotifyError(NS_ERROR_DOM_OPERATION_ERR);
}
nsCOMPtr<nsIArray> devices;
nsresult rv = deviceManager->GetAvailableDevices(presentationUrls, getter_AddRefs(devices));
if (NS_WARN_IF(NS_FAILED(rv))) {
return aCallback->NotifyError(NS_ERROR_DOM_OPERATION_ERR);
}
nsCOMPtr<nsISimpleEnumerator> enumerator;
rv = devices->Enumerate(getter_AddRefs(enumerator));
if (NS_WARN_IF(NS_FAILED(rv))) {
return aCallback->NotifyError(NS_ERROR_DOM_OPERATION_ERR);
}
NS_ConvertUTF16toUTF8 utf8DeviceId(aDeviceId);
bool hasMore;
while (NS_SUCCEEDED(enumerator->HasMoreElements(&hasMore)) && hasMore) {
nsCOMPtr<nsISupports> isupports;
rv = enumerator->GetNext(getter_AddRefs(isupports));
nsCOMPtr<nsIPresentationDevice> device(do_QueryInterface(isupports));
MOZ_ASSERT(device);
nsAutoCString id;
if (NS_SUCCEEDED(device->GetId(id)) && id.Equals(utf8DeviceId)) {
request->Select(device);
return NS_OK;
}
}
// Reject if designated device is not available.
return aCallback->NotifyError(NS_ERROR_DOM_NOT_FOUND_ERR);
}