本文整理汇总了C++中nsString类的典型用法代码示例。如果您正苦于以下问题:C++ nsString类的具体用法?C++ nsString怎么用?C++ nsString使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了nsString类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: ExtractType
void nsEudoraCompose::ExtractType( nsString& str)
{
nsString tStr;
PRInt32 idx = str.FindChar( ';');
if (idx != -1) {
str.Left( tStr, idx);
str = tStr;
}
str.Trim( kWhitespace);
if ((str.CharAt( 0) == '"') && (str.Length() > 2)) {
str.Mid( tStr, 1, str.Length() - 2);
str = tStr;
str.Trim( kWhitespace);
}
// if multipart then ignore it since no outlook message body is ever
// valid multipart!
if (str.Length() > 10) {
str.Left( tStr, 10);
if (tStr.LowerCaseEqualsLiteral("multipart/"))
str.Truncate();
}
}
开发者ID:binoc-software,项目名称:mozilla-cvs,代码行数:24,代码来源:nsEudoraCompose.cpp
示例2: switch
void
mozTXTToHTMLConv::ScanTXT(const PRUnichar * aInString, PRInt32 aInStringLength, PRUint32 whattodo, nsString& aOutString)
{
PRBool doURLs = 0 != (whattodo & kURLs);
PRBool doGlyphSubstitution = 0 != (whattodo & kGlyphSubstitution);
PRBool doStructPhrase = 0 != (whattodo & kStructPhrase);
PRUint32 structPhrase_strong = 0; // Number of currently open tags
PRUint32 structPhrase_underline = 0;
PRUint32 structPhrase_italic = 0;
PRUint32 structPhrase_code = 0;
nsAutoString outputHTML; // moved here for performance increase
for(PRUint32 i = 0; PRInt32(i) < aInStringLength;)
{
if (doGlyphSubstitution)
{
PRInt32 glyphTextLen;
if (GlyphHit(&aInString[i], aInStringLength - i, i == 0, aOutString, glyphTextLen))
{
i += glyphTextLen;
continue;
}
}
if (doStructPhrase)
{
const PRUnichar * newOffset = aInString;
PRInt32 newLength = aInStringLength;
if (i > 0 ) // skip the first element?
{
newOffset = &aInString[i-1];
newLength = aInStringLength - i + 1;
}
switch (aInString[i]) // Performance increase
{
case '*':
if (StructPhraseHit(newOffset, newLength, i == 0,
NS_LITERAL_STRING("*").get(), 1,
"b", "class=\"moz-txt-star\"",
aOutString, structPhrase_strong))
{
i++;
continue;
}
break;
case '/':
if (StructPhraseHit(newOffset, newLength, i == 0,
NS_LITERAL_STRING("/").get(), 1,
"i", "class=\"moz-txt-slash\"",
aOutString, structPhrase_italic))
{
i++;
continue;
}
break;
case '_':
if (StructPhraseHit(newOffset, newLength, i == 0,
NS_LITERAL_STRING("_").get(), 1,
"span" /* <u> is deprecated */,
"class=\"moz-txt-underscore\"",
aOutString, structPhrase_underline))
{
i++;
continue;
}
break;
case '|':
if (StructPhraseHit(newOffset, newLength, i == 0,
NS_LITERAL_STRING("|").get(), 1,
"code", "class=\"moz-txt-verticalline\"",
aOutString, structPhrase_code))
{
i++;
continue;
}
break;
}
}
if (doURLs)
{
switch (aInString[i])
{
case ':':
case '@':
case '.':
if ( (i == 0 || ((i > 0) && aInString[i - 1] != ' ')) && aInString[i +1] != ' ') // Performance increase
{
PRInt32 replaceBefore;
PRInt32 replaceAfter;
if (FindURL(aInString, aInStringLength, i, whattodo,
outputHTML, replaceBefore, replaceAfter)
&& structPhrase_strong + structPhrase_italic +
structPhrase_underline + structPhrase_code == 0
/* workaround for bug #19445 */ )
{
aOutString.Cut(aOutString.Length() - replaceBefore, replaceBefore);
//.........这里部分代码省略.........
开发者ID:binoc-software,项目名称:mozilla-cvs,代码行数:101,代码来源:mozTXTToHTMLConv.cpp
示例3: if
// NOTE: the converted html for the phrase is appended to aOutString
// tagHTML and attributeHTML are plain ASCII (literal strings, in fact)
PRBool
mozTXTToHTMLConv::StructPhraseHit(const PRUnichar * aInString, PRInt32 aInStringLength, PRBool col0,
const PRUnichar* tagTXT, PRInt32 aTagTXTLen,
const char* tagHTML, const char* attributeHTML,
nsString& aOutString, PRUint32& openTags)
{
/* We're searching for the following pattern:
LT_DELIMITER - "*" - ALPHA -
[ some text (maybe more "*"-pairs) - ALPHA ] "*" - LT_DELIMITER.
<strong> is only inserted, if existance of a pair could be verified
We use the first opening/closing tag, if we can choose */
const PRUnichar * newOffset = aInString;
PRInt32 newLength = aInStringLength;
if (!col0) // skip the first element?
{
newOffset = &aInString[1];
newLength = aInStringLength - 1;
}
// opening tag
if
(
ItMatchesDelimited(aInString, aInStringLength, tagTXT, aTagTXTLen,
(col0 ? LT_IGNORE : LT_DELIMITER), LT_ALPHA) // is opening tag
&& NumberOfMatches(newOffset, newLength, tagTXT, aTagTXTLen,
LT_ALPHA, LT_DELIMITER) // remaining closing tags
> openTags
)
{
openTags++;
aOutString.AppendLiteral("<");
aOutString.AppendASCII(tagHTML);
aOutString.Append(PRUnichar(' '));
aOutString.AppendASCII(attributeHTML);
aOutString.AppendLiteral("><span class=\"moz-txt-tag\">");
aOutString.Append(tagTXT);
aOutString.AppendLiteral("</span>");
return PR_TRUE;
}
// closing tag
else if (openTags > 0
&& ItMatchesDelimited(aInString, aInStringLength, tagTXT, aTagTXTLen, LT_ALPHA, LT_DELIMITER))
{
openTags--;
aOutString.AppendLiteral("<span class=\"moz-txt-tag\">");
aOutString.Append(tagTXT);
aOutString.AppendLiteral("</span></");
aOutString.AppendASCII(tagHTML);
aOutString.Append(PRUnichar('>'));
return PR_TRUE;
}
return PR_FALSE;
}
开发者ID:binoc-software,项目名称:mozilla-cvs,代码行数:58,代码来源:mozTXTToHTMLConv.cpp
示例4: ListInterestingFiles
static void
ListInterestingFiles(nsString& aAnnotation, nsIFile* aFile,
const nsTArray<nsString>& aInterestingFilenames)
{
nsString filename;
aFile->GetLeafName(filename);
for (const nsString& interestingFilename : aInterestingFilenames) {
if (interestingFilename == filename) {
nsString path;
aFile->GetPath(path);
aAnnotation.AppendLiteral(" ");
aAnnotation.Append(path);
aAnnotation.AppendLiteral(" (");
int64_t size;
if (NS_SUCCEEDED(aFile->GetFileSize(&size))) {
aAnnotation.AppendPrintf("%ld", size);
} else {
aAnnotation.AppendLiteral("???");
}
aAnnotation.AppendLiteral(" bytes, crc32 = ");
uint32_t crc;
nsresult rv = ComputeCRC32(aFile, &crc);
if (NS_SUCCEEDED(rv)) {
aAnnotation.AppendPrintf("0x%08x)\n", crc);
} else {
aAnnotation.AppendPrintf("error 0x%08x)\n", uint32_t(rv));
}
return;
}
}
bool isDir = false;
aFile->IsDirectory(&isDir);
if (!isDir) {
return;
}
nsCOMPtr<nsISimpleEnumerator> entries;
if (NS_FAILED(aFile->GetDirectoryEntries(getter_AddRefs(entries)))) {
aAnnotation.AppendLiteral(" (failed to enumerated directory)\n");
return;
}
for (;;) {
bool hasMore = false;
if (NS_FAILED(entries->HasMoreElements(&hasMore))) {
aAnnotation.AppendLiteral(" (failed during directory enumeration)\n");
return;
}
if (!hasMore) {
break;
}
nsCOMPtr<nsISupports> entry;
if (NS_FAILED(entries->GetNext(getter_AddRefs(entry)))) {
aAnnotation.AppendLiteral(" (failed during directory enumeration)\n");
return;
}
nsCOMPtr<nsIFile> file = do_QueryInterface(entry);
if (file) {
ListInterestingFiles(aAnnotation, file, aInterestingFilenames);
}
}
}
开发者ID:ollie314,项目名称:gecko-dev,代码行数:66,代码来源:nsLayoutStylesheetCache.cpp
示例5: SetOperator
static bool
SetOperator(OperatorData* aOperatorData,
nsOperatorFlags aForm,
const nsCString& aOperator,
nsString& aAttributes)
{
static const char16_t kNullCh = char16_t('\0');
// aOperator is in the expanded format \uNNNN\uNNNN ...
// First compress these Unicode points to the internal nsString format
int32_t i = 0;
nsAutoString name, value;
int32_t len = aOperator.Length();
char16_t c = aOperator[i++];
uint32_t state = 0;
char16_t uchar = 0;
while (i <= len) {
if (0 == state) {
if (c != '\\')
return false;
if (i < len)
c = aOperator[i];
i++;
if (('u' != c) && ('U' != c))
return false;
if (i < len)
c = aOperator[i];
i++;
state++;
}
else {
if (('0' <= c) && (c <= '9'))
uchar = (uchar << 4) | (c - '0');
else if (('a' <= c) && (c <= 'f'))
uchar = (uchar << 4) | (c - 'a' + 0x0a);
else if (('A' <= c) && (c <= 'F'))
uchar = (uchar << 4) | (c - 'A' + 0x0a);
else return false;
if (i < len)
c = aOperator[i];
i++;
state++;
if (5 == state) {
value.Append(uchar);
uchar = 0;
state = 0;
}
}
}
if (0 != state) return false;
// Quick return when the caller doesn't care about the attributes and just wants
// to know if this is a valid operator (this is the case at the first pass of the
// parsing of the dictionary in InitOperators())
if (!aForm) return true;
// Add operator to hash table
aOperatorData->mFlags |= aForm;
aOperatorData->mStr.Assign(value);
value.AppendInt(aForm, 10);
gOperatorTable->Put(value, aOperatorData);
#ifdef DEBUG
NS_LossyConvertUTF16toASCII str(aAttributes);
#endif
// Loop over the space-delimited list of attributes to get the name:value pairs
aAttributes.Append(kNullCh); // put an extra null at the end
char16_t* start = aAttributes.BeginWriting();
char16_t* end = start;
while ((kNullCh != *start) && (kDashCh != *start)) {
name.SetLength(0);
value.SetLength(0);
// skip leading space, the dash amounts to the end of the line
while ((kNullCh!=*start) && (kDashCh!=*start) && nsCRT::IsAsciiSpace(*start)) {
++start;
}
end = start;
// look for ':'
while ((kNullCh!=*end) && (kDashCh!=*end) && !nsCRT::IsAsciiSpace(*end) &&
(kColonCh!=*end)) {
++end;
}
// If ':' is not found, then it's a boolean property
bool IsBooleanProperty = (kColonCh != *end);
*end = kNullCh; // end segment here
// this segment is the name
if (start < end) {
name.Assign(start);
}
if (IsBooleanProperty) {
SetBooleanProperty(aOperatorData, name);
} else {
start = ++end;
// look for space or end of line
while ((kNullCh!=*end) && (kDashCh!=*end) &&
!nsCRT::IsAsciiSpace(*end)) {
++end;
}
*end = kNullCh; // end segment here
//.........这里部分代码省略.........
开发者ID:Jar-win,项目名称:Waterfox,代码行数:101,代码来源:nsMathMLOperators.cpp
示例6: ucsHost
bool
nsHttpChannelAuthProvider::ConfirmAuth(const nsString &bundleKey,
bool doYesNoPrompt)
{
// skip prompting the user if
// 1) we've already prompted the user
// 2) we're not a toplevel channel
// 3) the userpass length is less than the "phishy" threshold
uint32_t loadFlags;
nsresult rv = mAuthChannel->GetLoadFlags(&loadFlags);
if (NS_FAILED(rv))
return true;
if (mSuppressDefensiveAuth ||
!(loadFlags & nsIChannel::LOAD_INITIAL_DOCUMENT_URI))
return true;
nsAutoCString userPass;
rv = mURI->GetUserPass(userPass);
if (NS_FAILED(rv) ||
(userPass.Length() < gHttpHandler->PhishyUserPassLength()))
return true;
// we try to confirm by prompting the user. if we cannot do so, then
// assume the user said ok. this is done to keep things working in
// embedded builds, where the string bundle might not be present, etc.
nsCOMPtr<nsIStringBundleService> bundleService =
do_GetService(NS_STRINGBUNDLE_CONTRACTID);
if (!bundleService)
return true;
nsCOMPtr<nsIStringBundle> bundle;
bundleService->CreateBundle(NECKO_MSGS_URL, getter_AddRefs(bundle));
if (!bundle)
return true;
nsAutoCString host;
rv = mURI->GetHost(host);
if (NS_FAILED(rv))
return true;
nsAutoCString user;
rv = mURI->GetUsername(user);
if (NS_FAILED(rv))
return true;
NS_ConvertUTF8toUTF16 ucsHost(host), ucsUser(user);
const char16_t *strs[2] = { ucsHost.get(), ucsUser.get() };
nsXPIDLString msg;
bundle->FormatStringFromName(bundleKey.get(), strs, 2, getter_Copies(msg));
if (!msg)
return true;
nsCOMPtr<nsIInterfaceRequestor> callbacks;
rv = mAuthChannel->GetNotificationCallbacks(getter_AddRefs(callbacks));
if (NS_FAILED(rv))
return true;
nsCOMPtr<nsILoadGroup> loadGroup;
rv = mAuthChannel->GetLoadGroup(getter_AddRefs(loadGroup));
if (NS_FAILED(rv))
return true;
nsCOMPtr<nsIPrompt> prompt;
NS_QueryNotificationCallbacks(callbacks, loadGroup, NS_GET_IID(nsIPrompt),
getter_AddRefs(prompt));
if (!prompt)
return true;
// do not prompt again
mSuppressDefensiveAuth = true;
bool confirmed;
if (doYesNoPrompt) {
int32_t choice;
bool checkState = false;
rv = prompt->ConfirmEx(nullptr, msg,
nsIPrompt::BUTTON_POS_1_DEFAULT +
nsIPrompt::STD_YES_NO_BUTTONS,
nullptr, nullptr, nullptr, nullptr,
&checkState, &choice);
if (NS_FAILED(rv))
return true;
confirmed = choice == 0;
}
else {
rv = prompt->Confirm(nullptr, msg, &confirmed);
if (NS_FAILED(rv))
return true;
}
return confirmed;
}
开发者ID:paulmadore,项目名称:luckyde,代码行数:97,代码来源:nsHttpChannelAuthProvider.cpp
示例7: GetReversedHostname
void
GetReversedHostname(const nsString& aForward, nsString& aRevHost)
{
ReverseString(aForward, aRevHost);
aRevHost.Append(PRUnichar('.'));
}
开发者ID:Anachid,项目名称:mozilla-central,代码行数:6,代码来源:Helpers.cpp
示例8:
void
ApplicationAccessible::Description(nsString& aDescription)
{
aDescription.Truncate();
}
开发者ID:bebef1987,项目名称:mozilla-central,代码行数:5,代码来源:ApplicationAccessible.cpp
示例9:
ENameValueFlag
XULMenubarAccessible::NativeName(nsString& aName)
{
aName.AssignLiteral("Application");
return eNameOK;
}
开发者ID:1024kb1,项目名称:gecko-dev,代码行数:6,代码来源:XULMenuAccessible.cpp
示例10: Peek
void
nsCSSScanner::ParseAndAppendEscape(nsresult& aErrorCode, nsString& aOutput)
{
PRUint8* lexTable = gLexTable;
PRInt32 ch = Peek(aErrorCode);
if (ch < 0) {
aOutput.Append(CSS_ESCAPE);
return;
}
if ((ch <= 255) && ((lexTable[ch] & IS_HEX_DIGIT) != 0)) {
PRInt32 rv = 0;
int i;
for (i = 0; i < 6; i++) { // up to six digits
ch = Read(aErrorCode);
if (ch < 0) {
// Whoops: error or premature eof
break;
}
if (ch >= 256 || (lexTable[ch] & (IS_HEX_DIGIT | IS_WHITESPACE)) == 0) {
Unread();
break;
} else if ((lexTable[ch] & IS_HEX_DIGIT) != 0) {
if ((lexTable[ch] & IS_DIGIT) != 0) {
rv = rv * 16 + (ch - '0');
} else {
// Note: c&7 just keeps the low three bits which causes
// upper and lower case alphabetics to both yield their
// "relative to 10" value for computing the hex value.
rv = rv * 16 + ((ch & 0x7) + 9);
}
} else {
NS_ASSERTION((lexTable[ch] & IS_WHITESPACE) != 0, "bad control flow");
// single space ends escape
if (ch == '\r' && Peek(aErrorCode) == '\n') {
// if CR/LF, eat LF too
Read(aErrorCode);
}
break;
}
}
if (6 == i) { // look for trailing whitespace and eat it
ch = Peek(aErrorCode);
if ((0 <= ch) && (ch <= 255) &&
((lexTable[ch] & IS_WHITESPACE) != 0)) {
(void) Read(aErrorCode);
// special case: if trailing whitespace is CR/LF, eat both chars.
if (ch == '\r' && Peek(aErrorCode) == '\n') {
(void) Read(aErrorCode);
// if we hit the "\0" special case below, we'll push back
// only the '\r', but that's okay, because '\r' by itself
// is still a newline.
}
}
}
NS_ASSERTION(rv >= 0, "How did rv become negative?");
// "[at most six hexadecimal digits following a backslash] stand
// for the ISO 10646 character with that number, which must not be
// zero. (It is undefined in CSS 2.1 what happens if a style sheet
// does contain a character with Unicode codepoint zero.)"
// -- CSS2.1 section 4.1.3
//
// Silently deleting \0 opens a content-filtration loophole (see
// bug 228856), so what we do instead is pretend the "cancels the
// meaning of special characters" rule applied.
if (rv > 0) {
AppendUCS4ToUTF16(ENSURE_VALID_CHAR(rv), aOutput);
} else {
while (i--)
aOutput.Append('0');
if ((0 <= ch) && (ch <= 255) && ((lexTable[ch] & IS_WHITESPACE) != 0))
Pushback(ch);
}
return;
} else {
// "Any character except a hexidecimal digit can be escaped to
// remove its special meaning by putting a backslash in front"
// -- CSS1 spec section 7.1
if (!EatNewline(aErrorCode)) { // skip escaped newline
(void) Read(aErrorCode);
if (ch > 0) {
aOutput.Append(ch);
}
}
return;
}
}
开发者ID:rn10950,项目名称:RetroZilla,代码行数:86,代码来源:nsCSSScanner.cpp
示例11: Read
/**
* Returns whether an escape was succesfully parsed; if it was not,
* the backslash needs to be its own symbol token.
*/
bool
nsCSSScanner::ParseAndAppendEscape(nsString& aOutput, bool aInString)
{
int32_t ch = Read();
if (ch < 0) {
return false;
}
if (IsHexDigit(ch)) {
int32_t rv = 0;
int i;
Pushback(ch);
for (i = 0; i < 6; i++) { // up to six digits
ch = Read();
if (ch < 0) {
// Whoops: error or premature eof
break;
}
if (!IsHexDigit(ch) && !IsWhitespace(ch)) {
Pushback(ch);
break;
} else if (IsHexDigit(ch)) {
rv = rv * 16 + HexDigitValue(ch);
} else {
NS_ASSERTION(IsWhitespace(ch), "bad control flow");
// single space ends escape
break;
}
}
if (6 == i) { // look for trailing whitespace and eat it
ch = Peek();
if (IsWhitespace(ch)) {
(void) Read();
}
}
NS_ASSERTION(rv >= 0, "How did rv become negative?");
// "[at most six hexadecimal digits following a backslash] stand
// for the ISO 10646 character with that number, which must not be
// zero. (It is undefined in CSS 2.1 what happens if a style sheet
// does contain a character with Unicode codepoint zero.)"
// -- CSS2.1 section 4.1.3
//
// Silently deleting \0 opens a content-filtration loophole (see
// bug 228856), so what we do instead is pretend the "cancels the
// meaning of special characters" rule applied.
if (rv > 0) {
AppendUCS4ToUTF16(ENSURE_VALID_CHAR(rv), aOutput);
} else {
while (i--)
aOutput.Append('0');
if (IsWhitespace(ch))
Pushback(ch);
}
return true;
}
// "Any character except a hexidecimal digit can be escaped to
// remove its special meaning by putting a backslash in front"
// -- CSS1 spec section 7.1
if (ch == '\n') {
if (!aInString) {
// Outside of strings (which includes url() that contains a
// string), escaped newlines aren't special, and just tokenize as
// eCSSToken_Symbol (DELIM).
Pushback(ch);
return false;
}
// In strings (and in url() containing a string), escaped newlines
// are just dropped to allow splitting over multiple lines.
} else {
aOutput.Append(ch);
}
return true;
}
开发者ID:mikeaich,项目名称:releases-mozilla-central,代码行数:77,代码来源:nsCSSScanner.cpp
示例12: GetWidth
NS_IMETHODIMP
nsThebesRenderingContext::GetWidth(const nsString& aString, nscoord &aWidth,
PRInt32 *aFontID)
{
return GetWidth(aString.get(), aString.Length(), aWidth, aFontID);
}
开发者ID:MozillaOnline,项目名称:gecko-dev,代码行数:6,代码来源:nsThebesRenderingContext.cpp
示例13: NS_FAILED
//.........这里部分代码省略.........
if (!info[i].mModel.IsEmpty() && !info[i].mModel.Equals(Model())) {
continue;
}
if (!info[i].mProduct.IsEmpty() && !info[i].mProduct.Equals(Product())) {
continue;
}
if (!info[i].mManufacturer.IsEmpty() && !info[i].mManufacturer.Equals(Manufacturer())) {
continue;
}
#if defined(XP_WIN) || defined(ANDROID)
switch (info[i].mComparisonOp) {
case DRIVER_LESS_THAN:
match = driverVersion < info[i].mDriverVersion;
break;
case DRIVER_LESS_THAN_OR_EQUAL:
match = driverVersion <= info[i].mDriverVersion;
break;
case DRIVER_GREATER_THAN:
match = driverVersion > info[i].mDriverVersion;
break;
case DRIVER_GREATER_THAN_OR_EQUAL:
match = driverVersion >= info[i].mDriverVersion;
break;
case DRIVER_EQUAL:
match = driverVersion == info[i].mDriverVersion;
break;
case DRIVER_NOT_EQUAL:
match = driverVersion != info[i].mDriverVersion;
break;
case DRIVER_BETWEEN_EXCLUSIVE:
match = driverVersion > info[i].mDriverVersion && driverVersion < info[i].mDriverVersionMax;
break;
case DRIVER_BETWEEN_INCLUSIVE:
match = driverVersion >= info[i].mDriverVersion && driverVersion <= info[i].mDriverVersionMax;
break;
case DRIVER_BETWEEN_INCLUSIVE_START:
match = driverVersion >= info[i].mDriverVersion && driverVersion < info[i].mDriverVersionMax;
break;
case DRIVER_COMPARISON_IGNORED:
// We don't have a comparison op, so we match everything.
match = true;
break;
default:
NS_WARNING("Bogus op in GfxDriverInfo");
break;
}
#else
// We don't care what driver version it was. We only check OS version and if
// the device matches.
match = true;
#endif
if (match || info[i].mDriverVersion == GfxDriverInfo::allDriverVersions) {
if (info[i].mFeature == GfxDriverInfo::allFeatures ||
info[i].mFeature == aFeature)
{
status = info[i].mFeatureStatus;
break;
}
}
}
#if defined(XP_WIN)
// As a very special case, we block D2D on machines with an NVidia 310M GPU
// as either the primary or secondary adapter. D2D is also blocked when the
// NV 310M is the primary adapter (using the standard blocklisting mechanism).
// If the primary GPU already matched something in the blocklist then we
// ignore this special rule. See bug 1008759.
if (status == nsIGfxInfo::FEATURE_STATUS_UNKNOWN &&
(aFeature == nsIGfxInfo::FEATURE_DIRECT2D)) {
nsAutoString adapterVendorID2;
nsAutoString adapterDeviceID2;
if ((!NS_FAILED(GetAdapterVendorID2(adapterVendorID2))) &&
(!NS_FAILED(GetAdapterDeviceID2(adapterDeviceID2))))
{
nsAString &nvVendorID = (nsAString &)GfxDriverInfo::GetDeviceVendor(VendorNVIDIA);
const nsString nv310mDeviceId = NS_LITERAL_STRING("0x0A70");
if (nvVendorID.Equals(adapterVendorID2, nsCaseInsensitiveStringComparator()) &&
nv310mDeviceId.Equals(adapterDeviceID2, nsCaseInsensitiveStringComparator())) {
status = nsIGfxInfo::FEATURE_BLOCKED_DEVICE;
}
}
}
// Depends on Windows driver versioning. We don't pass a GfxDriverInfo object
// back to the Windows handler, so we must handle this here.
if (status == FEATURE_BLOCKED_DRIVER_VERSION) {
if (info[i].mSuggestedVersion) {
aSuggestedVersion.AppendPrintf("%s", info[i].mSuggestedVersion);
} else if (info[i].mComparisonOp == DRIVER_LESS_THAN &&
info[i].mDriverVersion != GfxDriverInfo::allDriverVersions)
{
aSuggestedVersion.AppendPrintf("%lld.%lld.%lld.%lld",
(info[i].mDriverVersion & 0xffff000000000000) >> 48,
(info[i].mDriverVersion & 0x0000ffff00000000) >> 32,
(info[i].mDriverVersion & 0x00000000ffff0000) >> 16,
(info[i].mDriverVersion & 0x000000000000ffff));
}
}
开发者ID:imace,项目名称:gecko-dev-speech,代码行数:101,代码来源:GfxInfoBase.cpp
示例14: DrawString
NS_IMETHODIMP
nsThebesRenderingContext::DrawString(const nsString& aString, nscoord aX, nscoord aY,
PRInt32 aFontID, const nscoord* aSpacing)
{
return DrawString(aString.get(), aString.Length(), aX, aY, aFontID, aSpacing);
}
开发者ID:MozillaOnline,项目名称:gecko-dev,代码行数:6,代码来源:nsThebesRenderingContext.cpp
示例15: GetSubjectAltNames
// returns TRUE if SAN was used to produce names
// return FALSE if nothing was produced
// names => a single name or a list of names
// multipleNames => whether multiple names were delivered
static bool
GetSubjectAltNames(CERTCertificate *nssCert,
nsINSSComponent *component,
nsString &allNames,
uint32_t &nameCount)
{
allNames.Truncate();
nameCount = 0;
SECItem altNameExtension = {siBuffer, nullptr, 0 };
CERTGeneralName *sanNameList = nullptr;
SECStatus rv = CERT_FindCertExtension(nssCert, SEC_OID_X509_SUBJECT_ALT_NAME,
&altNameExtension);
if (rv != SECSuccess) {
return false;
}
ScopedPLArenaPool arena(PORT_NewArena(DER_DEFAULT_CHUNKSIZE));
if (!arena) {
return false;
}
sanNameList = CERT_DecodeAltNameExtension(arena.get(), &altNameExtension);
if (!sanNameList) {
return false;
}
SECITEM_FreeItem(&altNameExtension, false);
CERTGeneralName *current = sanNameList;
do {
nsAutoString name;
switch (current->type) {
case certDNSName:
{
nsDependentCSubstring nameFromCert(reinterpret_cast<char*>
(current->name.other.data),
current->name.other.len);
// dNSName fields are defined as type IA5String and thus should
// be limited to ASCII characters.
if (IsASCII(nameFromCert)) {
name.Assign(NS_ConvertASCIItoUTF16(nameFromCert));
if (!allNames.IsEmpty()) {
allNames.AppendLiteral(", ");
}
++nameCount;
allNames.Append(name);
}
}
break;
case certIPAddress:
{
char buf[INET6_ADDRSTRLEN];
PRNetAddr addr;
if (current->name.other.len == 4) {
addr.inet.family = PR_AF_INET;
memcpy(&addr.inet.ip, current->name.other.data, current->name.other.len);
PR_NetAddrToString(&addr, buf, sizeof(buf));
name.AssignASCII(buf);
} else if (current->name.other.len == 16) {
addr.ipv6.family = PR_AF_INET6;
memcpy(&addr.ipv6.ip, current->name.other.data, current->name.other.len);
PR_NetAddrToString(&addr, buf, sizeof(buf));
name.AssignASCII(buf);
} else {
/* invalid IP address */
}
if (!name.IsEmpty()) {
if (!allNames.IsEmpty()) {
allNames.AppendLiteral(", ");
}
++nameCount;
allNames.Append(name);
}
break;
}
default: // all other types of names are ignored
break;
}
current = CERT_GetNextGeneralName(current);
} while (current != sanNameList); // double linked
return true;
}
开发者ID:jrmuizel,项目名称:mozilla-central-skia,代码行数:91,代码来源:TransportSecurityInfo.cpp
示例16: switch
// static
void
nsTextEditRules::HandleNewLines(nsString &aString,
int32_t aNewlineHandling)
{
if (aNewlineHandling < 0) {
int32_t caretStyle;
nsPlaintextEditor::GetDefaultEditorPrefs(aNewlineHandling, caretStyle);
}
switch(aNewlineHandling)
{
case nsIPlaintextEditor::eNewlinesReplaceWithSpaces:
// Strip trailing newlines first so we don't wind up with trailing spaces
aString.Trim(CRLF, false, true);
aString.ReplaceChar(CRLF, ' ');
break;
case nsIPlaintextEditor::eNewlinesStrip:
aString.StripChars(CRLF);
break;
case nsIPlaintextEditor::eNewlinesPasteToFirst:
default:
{
int32_t firstCRLF = aString.FindCharInSet(CRLF);
// we get first *non-empty* line.
int32_t offset = 0;
while (firstCRLF == offset)
{
offset++;
firstCRLF = aString.FindCharInSet(CRLF, offset);
}
if (firstCRLF > 0)
aString.Truncate(firstCRLF);
if (offset > 0)
aString.Cut(0, offset);
}
break;
case nsIPlaintextEditor::eNewlinesReplaceWithCommas:
aString.Trim(CRLF, true, true);
aString.ReplaceChar(CRLF, ',');
break;
case nsIPlaintextEditor::eNewlinesStripSurroundingWhitespace:
{
nsString result;
uint32_t offset = 0;
while (offset < aString.Length())
{
int32_t nextCRLF = aString.FindCharInSet(CRLF, offset);
if (nextCRLF < 0) {
result.Append(nsDependentSubstring(aString, offset));
break;
}
uint32_t wsBegin = nextCRLF;
// look backwards for the first non-whitespace char
while (wsBegin > offset && NS_IS_SPACE(aString[wsBegin - 1]))
--wsBegin;
result.Append(nsDependentSubstring(aString, offset, wsBegin - offset));
offset = nextCRLF + 1;
while (offset < aString.Length() && NS_IS_SPACE(aString[offset]))
++offset;
}
aString = result;
}
break;
case nsIPlaintextEditor::eNewlinesPasteIntact:
// even if we're pasting newlines, don't paste leading/trailing ones
aString.Trim(CRLF, true, true);
break;
}
}
开发者ID:AOSC-Dev,项目名称:Pale-Moon,代码行数:71,代码来源:nsTextEditRules.cpp
示例17: AppendErrorTextMismatch
static void
AppendErrorTextMismatch(const nsString &host,
nsIX509Cert* ix509,
nsINSSComponent *component,
bool wantsHtml,
nsString &returnedMessage)
{
const char16_t *params[1];
nsresult rv;
ScopedCERTCertificate nssCert(ix509->GetCert());
if (!nssCert) {
// We are unable to extract the valid names, say "not valid for name".
params[0] = host.get();
nsString formattedString;
rv = component->PIPBundleFormatStringFromName("certErrorMismatch",
params, 1,
formattedString);
if (NS_SUCCEEDED(rv)) {
returnedMessage.Append(formattedString);
returnedMessage.Append('\n');
}
return;
}
nsString allNames;
uint32_t nameCount = 0;
bool useSAN = false;
if (nssCert)
useSAN = GetSubjectAltNames(nssCert.get(), component, allNames, nameCount);
if (!useSAN) {
char *certName = CERT_GetCommonName(&nssCert->subject);
if (certName) {
nsDependentCSubstring commonName(certName, strlen(certName));
if (IsUTF8(commonName)) {
// Bug 1024781
// We should actually check that the common name is a valid dns name or
// ip address and not any string value before adding it to the display
// list.
++nameCount;
allNames.Assign(NS_ConvertUTF8toUTF16(commonName));
}
PORT_Free(certName);
}
}
if (nameCount > 1) {
nsString message;
rv = component->GetPIPNSSBundleString("certErrorMismatchMultiple",
message);
if (NS_SUCCEEDED(rv)) {
returnedMessage.Append(message);
returnedMessage.AppendLiteral("\n ");
returnedMessage.Append(allNames);
returnedMessage.AppendLiteral(" \n");
}
}
else if (nameCount == 1) {
const char16_t *params[1];
params[0] = allNames.get();
const char *stringID;
if (wantsHtml)
stringID = "certErrorMismatchSingle2";
else
stringID = "certErrorMismatchSinglePlain";
nsString formattedString;
rv = component->PIPBundleFormatStringFromName(stringID,
params, 1,
formattedString);
if (NS_SUCCEEDED(rv)) {
returnedMessage.Append(formattedString);
returnedMessage.Append('\n');
}
}
else { // nameCount == 0
nsString message;
nsresult rv = component->GetPIPNSSBundleString("certErrorMismatchNoNames",
message);
if (NS_SUCCEEDED(rv)) {
returnedMessage.Append(message);
returnedMessage.Append('\n');
}
}
}
开发者ID:jrmuizel,项目名称:mozilla-central-skia,代码行数:89,代码来源:TransportSecurityInfo.cpp
示例18: prefBranch
bool
nsMessengerUnixIntegration::BuildNotificationBody(nsIMsgDBHdr *aHdr,
nsIStringBundle *aBundle,
nsString &aBody)
{
nsAutoString alertBody;
bool showPreview = true;
bool showSubject = true;
bool showSender = true;
PRInt32 previewLength = SHOW_ALERT_PREVIEW_LENGTH_DEFAULT;
nsCOMPtr<nsIPrefBranch> prefBranch(do_GetService(NS_PREFSERVICE_CONTRACTID));
if (!prefBranch)
return PR_FALSE;
prefBranch->GetBoolPref(SHOW_ALERT_PREVIEW, &showPreview);
prefBranch->GetBoolPref(SHOW_ALERT_SENDER, &showSender);
prefBranch->GetBoolPref(SHOW_ALERT_SUBJECT, &showSubject);
prefBranch->GetIntPref(SHOW_ALERT_PREVIEW_LENGTH, &previewLength);
nsCOMPtr<nsIMsgHeaderParser> parser = do_GetService(NS_MAILNEWS_MIME_HEADER_PARSER_CONTRACTID);
if (!parser)
return PR_FALSE;
nsCOMPtr<nsIMsgFolder> folder;
aHdr->GetFolder(getter_AddRefs(folder));
if (!folder)
return PR_FALSE;
nsCString msgURI;
folder->GetUriForMsg(aHdr, msgURI);
bool localOnly;
PRUint32 msgURIIndex = mFetchingURIs.IndexOf(msgURI);
if (msgURIIndex == -1)
{
localOnly = PR_FALSE;
mFetchingURIs.AppendElement(msgURI);
}
else
localOnly = PR_TRUE;
PRUint32 messageKey;
if (NS_FAILED(aHdr->GetMessageKey(&messageKey)))
return PR_FALSE;
bool asyncResult = false;
nsresult rv = folder->FetchMsgPreviewText(&messageKey, 1,
localOnly, this,
&asyncResult);
// If we're still waiting on getting the message previews,
// bail early. We'll come back later when the async operation
// finishes.
if (NS_FAILED(rv) || asyncResult)
return PR_FALSE;
// If we got here, that means that we've retrieved the message preview,
// so we can stop tracking it with our mFetchingURIs array.
if (msgURIIndex != -1)
mFetchingURIs.RemoveElementAt(msgURIIndex);
nsCString utf8previewString;
if (showPreview &&
NS_FAILED(aHdr->GetStringProperty("preview", getter_Copies(utf8previewString))))
return PR_FALSE;
// need listener that mailbox is remote such as IMAP
// to generate preview message
nsString previewString;
CopyUTF8toUTF16(utf8previewString, previewString);
nsString subject;
if (showSubject && NS_FAILED(aHdr->GetMime2DecodedSubject(subject)))
return PR_FALSE;
nsString author;
if (showSender)
{
if (NS_FAILED(aHdr->GetMime2DecodedAuthor(author)))
return PR_FALSE;
PRUnichar **emails;
PRUnichar **names;
PRUnichar **fullnames;
PRUint32 num;
if (NS_FAILED(parser->ParseHeadersWithArray(author.get(),
&emails,
&names,
&fullnames, &num)))
return PR_FALSE;
if (num > 0)
{
author.Assign(names[0] ? names[0] : emails[0]);
NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY(num, emails);
NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY(num, names);
//.........这里部分代码省略.........
开发者ID:mikeconley,项目名称:comm-central,代码行数:101,代码来源:nsMessengerUnixIntegration.cpp
示例19: formatOverridableCertErrorMessage
/* Formats an error message for overridable certificate errors (of type
* OverridableCertErrorMessage). Use formatPlainErrorMessage to format
* non-overridable cert errors and non-cert-related errors.
*/
static nsresult
formatOverridableCertErrorMessage(nsISSLStatus & sslStatus,
PRErrorCode errorCodeToReport,
const nsXPIDLCString & host, int32_t port,
bool suppressPort443,
bool wantsHtml,
nsString & returnedMessage)
{
static NS_DEFINE_CID(kNSSComponentCID, NS_NSSCOMPONENT_CID);
const char16_t *params[1];
nsresult rv;
nsAutoString hostWithPort;
nsAutoString hostWithoutPort;
// For now, hide port when it's 443 and we're reporting the error.
// In the future a better mechanism should be used
// to make a decision about showing the port number, possibly by requiring
// the context object to implement a specific interface.
// The motivation is that Mozilla browser would like to hide the port number
// in error pages in the common case.
hostWithoutPort.AppendASCII(host);
if (suppressPort443 && port == 443) {
params[0] = hostWithoutPort.get();
} else {
hostWithPort.AppendASCII(host);
hostWithPort.Append(':');
hostWithPort.AppendInt(port);
params[0] = hostWithPort.get();
}
nsCOMPtr<nsINSSComponent> component = do_GetService(kNSSComponentCID, &
|
请发表评论