Bug 869836 - Part 4: Use EqualsLiteral instead of Equals(NS_LITERAL_STRING(...)). r=ehsan

This commit is contained in:
Birunthan Mohanathas 2014-05-22 06:48:51 +03:00
parent 411a8639b4
commit 807e72372f
28 changed files with 60 additions and 60 deletions

View File

@ -745,7 +745,7 @@ HTMLCanvasElement::MozGetIPCContext(const nsAString& aContextId,
}
// We only support 2d shmem contexts for now.
if (!aContextId.Equals(NS_LITERAL_STRING("2d")))
if (!aContextId.EqualsLiteral("2d"))
return NS_ERROR_INVALID_ARG;
if (mCurrentContextId.IsEmpty()) {

View File

@ -592,7 +592,7 @@ public:
void SetType(const nsAString& aValue, ErrorResult& aRv)
{
SetHTMLAttr(nsGkAtoms::type, aValue, aRv);
if (aValue.Equals(NS_LITERAL_STRING("number"))) {
if (aValue.EqualsLiteral("number")) {
// For NS_FORM_INPUT_NUMBER we rely on having frames to process key
// events. Make sure we have them in case someone changes the type of
// this element to "number" and then expects to be able to send key

View File

@ -955,7 +955,7 @@ SpeechRecognition::GetUserMediaErrorCallback::OnError(const nsAString& aError)
{
SpeechRecognitionErrorCode errorCode;
if (aError.Equals(NS_LITERAL_STRING("PERMISSION_DENIED"))) {
if (aError.EqualsLiteral("PERMISSION_DENIED")) {
errorCode = SpeechRecognitionErrorCode::Not_allowed;
} else {
errorCode = SpeechRecognitionErrorCode::Audio_capture;

View File

@ -1201,7 +1201,7 @@ BluetoothHfpManager::HandleCallStateChanged(uint32_t aCallIndex,
GetNumberOfCalls(nsITelephonyProvider::CALL_STATE_DISCONNECTED)) {
// In order to let user hear busy tone via connected Bluetooth headset,
// we postpone the timing of dropping SCO.
if (aError.Equals(NS_LITERAL_STRING("BusyError"))) {
if (aError.EqualsLiteral("BusyError")) {
// FIXME: UpdatePhoneCIND later since it causes SCO close but
// Dialer is still playing busy tone via HF.
BT_HF_DISPATCH_MAIN(MainThreadTaskCmd::POST_TASK_CLOSE_SCO);

View File

@ -1639,7 +1639,7 @@ BluetoothHfpManager::HandleCallStateChanged(uint32_t aCallIndex,
GetNumberOfCalls(nsITelephonyProvider::CALL_STATE_DISCONNECTED)) {
// In order to let user hear busy tone via connected Bluetooth headset,
// we postpone the timing of dropping SCO.
if (!(aError.Equals(NS_LITERAL_STRING("BusyError")))) {
if (!(aError.EqualsLiteral("BusyError"))) {
DisconnectSco();
} else {
// Close Sco later since Dialer is still playing busy tone via HF.

View File

@ -356,7 +356,7 @@ DOMStorageManager::GetStorageInternal(bool aCreate,
return NS_OK;
}
} else {
if (scope.Equals(NS_LITERAL_CSTRING("knalb.:about"))) {
if (scope.EqualsLiteral("knalb.:about")) {
return NS_OK;
}
}

View File

@ -1251,7 +1251,7 @@ mozInlineSpellChecker::SkipSpellCheckForNode(nsIEditor* aEditor,
{
nsAutoString classname;
parentElement->GetAttribute(NS_LITERAL_STRING("class"),classname);
if (classname.Equals(NS_LITERAL_STRING("moz-signature")))
if (classname.EqualsLiteral("moz-signature"))
*checkSpelling = false;
}

View File

@ -138,7 +138,7 @@ nsTextBoxFrame::AlwaysAppendAccessKey()
const char* prefName = "intl.menuitems.alwaysappendaccesskeys";
nsAdoptingString val = Preferences::GetLocalizedString(prefName);
gAlwaysAppendAccessKey = val.Equals(NS_LITERAL_STRING("true"));
gAlwaysAppendAccessKey = val.EqualsLiteral("true");
}
return gAlwaysAppendAccessKey;
}

View File

@ -1161,7 +1161,7 @@ static nsresult pref_LoadPrefsInDirList(const char *listId)
path->GetNativeLeafName(leaf);
// Do we care if a file provided by this process fails to load?
if (Substring(leaf, leaf.Length() - 4).Equals(NS_LITERAL_CSTRING(".xpi")))
if (Substring(leaf, leaf.Length() - 4).EqualsLiteral(".xpi"))
ReadExtensionPrefs(path);
else
pref_LoadPrefsInDir(path, nullptr, 0);

View File

@ -522,8 +522,8 @@ GetCacheSessionNameForStoragePolicy(
MOZ_ASSERT(!isPrivate || storagePolicy == nsICache::STORE_IN_MEMORY);
// HTTP
if (scheme.Equals(NS_LITERAL_CSTRING("http")) ||
scheme.Equals(NS_LITERAL_CSTRING("https"))) {
if (scheme.EqualsLiteral("http") ||
scheme.EqualsLiteral("https")) {
switch (storagePolicy) {
case nsICache::STORE_IN_MEMORY:
if (isPrivate)
@ -542,14 +542,14 @@ GetCacheSessionNameForStoragePolicy(
}
}
// WYCIWYG
else if (scheme.Equals(NS_LITERAL_CSTRING("wyciwyg"))) {
else if (scheme.EqualsLiteral("wyciwyg")) {
if (isPrivate)
sessionName.Assign(NS_LITERAL_CSTRING("wyciwyg-private"));
else
sessionName.Assign(NS_LITERAL_CSTRING("wyciwyg"));
}
// FTP
else if (scheme.Equals(NS_LITERAL_CSTRING("ftp"))) {
else if (scheme.EqualsLiteral("ftp")) {
if (isPrivate)
sessionName.Assign(NS_LITERAL_CSTRING("FTP-private"));
else
@ -1096,8 +1096,8 @@ nsresult _OldStorage::AssembleCacheKey(nsIURI *aURI,
NS_ENSURE_SUCCESS(rv, rv);
nsAutoCString uriSpec;
if (aScheme.Equals(NS_LITERAL_CSTRING("http")) ||
aScheme.Equals(NS_LITERAL_CSTRING("https"))) {
if (aScheme.EqualsLiteral("http") ||
aScheme.EqualsLiteral("https")) {
if (mLoadInfo->IsAnonymous()) {
aCacheKey.AssignLiteral("anon&");
}
@ -1117,7 +1117,7 @@ nsresult _OldStorage::AssembleCacheKey(nsIURI *aURI,
aCacheKey.AppendLiteral("uri=");
}
}
else if (aScheme.Equals(NS_LITERAL_CSTRING("wyciwyg"))) {
else if (aScheme.EqualsLiteral("wyciwyg")) {
rv = aURI->GetSpec(uriSpec);
NS_ENSURE_SUCCESS(rv, rv);
}

View File

@ -123,9 +123,9 @@ void nsIDNService::prefsChanged(nsIPrefBranch *prefBranch, const char16_t *pref)
getter_Copies(profile)))) {
profile.Truncate();
}
if (profile.Equals(NS_LITERAL_CSTRING("moderate"))) {
if (profile.EqualsLiteral("moderate")) {
mRestrictionProfile = eModeratelyRestrictiveProfile;
} else if (profile.Equals(NS_LITERAL_CSTRING("high"))) {
} else if (profile.EqualsLiteral("high")) {
mRestrictionProfile = eHighlyRestrictiveProfile;
} else {
mRestrictionProfile = eASCIIOnlyProfile;

View File

@ -383,13 +383,13 @@ nsresult
Http2Decompressor::OutputHeader(const nsACString &name, const nsACString &value)
{
// exclusions
if (name.Equals(NS_LITERAL_CSTRING("connection")) ||
name.Equals(NS_LITERAL_CSTRING("host")) ||
name.Equals(NS_LITERAL_CSTRING("keep-alive")) ||
name.Equals(NS_LITERAL_CSTRING("proxy-connection")) ||
name.Equals(NS_LITERAL_CSTRING("te")) ||
name.Equals(NS_LITERAL_CSTRING("transfer-encoding")) ||
name.Equals(NS_LITERAL_CSTRING("upgrade")) ||
if (name.EqualsLiteral("connection") ||
name.EqualsLiteral("host") ||
name.EqualsLiteral("keep-alive") ||
name.EqualsLiteral("proxy-connection") ||
name.EqualsLiteral("te") ||
name.EqualsLiteral("transfer-encoding") ||
name.EqualsLiteral("upgrade") ||
name.Equals(("accept-encoding"))) {
nsCString toLog(name);
LOG3(("HTTP Decompressor illegal response header found : %s",
@ -421,19 +421,19 @@ Http2Decompressor::OutputHeader(const nsACString &name, const nsACString &value)
}
// Status comes first
if (name.Equals(NS_LITERAL_CSTRING(":status"))) {
if (name.EqualsLiteral(":status")) {
nsAutoCString status(NS_LITERAL_CSTRING("HTTP/2.0 "));
status.Append(value);
status.AppendLiteral("\r\n");
mOutput->Insert(status, 0);
mHeaderStatus = value;
} else if (name.Equals(NS_LITERAL_CSTRING(":authority"))) {
} else if (name.EqualsLiteral(":authority")) {
mHeaderHost = value;
} else if (name.Equals(NS_LITERAL_CSTRING(":scheme"))) {
} else if (name.EqualsLiteral(":scheme")) {
mHeaderScheme = value;
} else if (name.Equals(NS_LITERAL_CSTRING(":path"))) {
} else if (name.EqualsLiteral(":path")) {
mHeaderPath = value;
} else if (name.Equals(NS_LITERAL_CSTRING(":method"))) {
} else if (name.EqualsLiteral(":method")) {
mHeaderMethod = value;
}
@ -447,7 +447,7 @@ Http2Decompressor::OutputHeader(const nsACString &name, const nsACString &value)
mOutput->Append(name);
mOutput->AppendLiteral(": ");
// Special handling for set-cookie according to the spec
bool isSetCookie = name.Equals(NS_LITERAL_CSTRING("set-cookie"));
bool isSetCookie = name.EqualsLiteral("set-cookie");
int32_t valueLen = value.Length();
for (int32_t i = 0; i < valueLen; ++i) {
if (value[i] == '\0') {

View File

@ -916,7 +916,7 @@ Http2Stream::ConvertPushHeaders(Http2Decompressor *decompressor,
}
decompressor->GetMethod(method);
if (!method.Equals(NS_LITERAL_CSTRING("GET"))) {
if (!method.EqualsLiteral("GET")) {
LOG3(("Http2Stream::ConvertPushHeaders %p Error - method not supported: %s\n",
this, method.get()));
return NS_ERROR_NOT_IMPLEMENTED;

View File

@ -1219,7 +1219,7 @@ SpdyStream3::ConvertHeaders(nsACString &aHeadersOut)
// to look for chunked specifically because it is the only HTTP
// allowed default encoding and we did not negotiate further encodings
// via TE
if (nameString.Equals(NS_LITERAL_CSTRING("transfer-encoding"))) {
if (nameString.EqualsLiteral("transfer-encoding")) {
LOG3(("SpdyStream3::ConvertHeaders session=%p stream=%p "
"transfer-encoding found. Chunked is invalid and no TE sent.",
mSession, this));
@ -1236,8 +1236,8 @@ SpdyStream3::ConvertHeaders(nsACString &aHeadersOut)
// spdy transport level headers shouldn't be gatewayed into http/1
if (!nameString.IsEmpty() && nameString[0] != ':' &&
!nameString.Equals(NS_LITERAL_CSTRING("connection")) &&
!nameString.Equals(NS_LITERAL_CSTRING("keep-alive"))) {
!nameString.EqualsLiteral("connection") &&
!nameString.EqualsLiteral("keep-alive")) {
nsDependentCSubstring valueString =
Substring(reinterpret_cast<const char *>(nvpair) + 8 + nameLen,
reinterpret_cast<const char *>(nvpair) + 8 + nameLen +

View File

@ -1235,7 +1235,7 @@ SpdyStream31::ConvertHeaders(nsACString &aHeadersOut)
// to look for chunked specifically because it is the only HTTP
// allowed default encoding and we did not negotiate further encodings
// via TE
if (nameString.Equals(NS_LITERAL_CSTRING("transfer-encoding"))) {
if (nameString.EqualsLiteral("transfer-encoding")) {
LOG3(("SpdyStream31::ConvertHeaders session=%p stream=%p "
"transfer-encoding found. Chunked is invalid and no TE sent.",
mSession, this));
@ -1252,8 +1252,8 @@ SpdyStream31::ConvertHeaders(nsACString &aHeadersOut)
// spdy transport level headers shouldn't be gatewayed into http/1
if (!nameString.IsEmpty() && nameString[0] != ':' &&
!nameString.Equals(NS_LITERAL_CSTRING("connection")) &&
!nameString.Equals(NS_LITERAL_CSTRING("keep-alive"))) {
!nameString.EqualsLiteral("connection") &&
!nameString.EqualsLiteral("keep-alive")) {
nsDependentCSubstring valueString =
Substring(reinterpret_cast<const char *>(nvpair) + 8 + nameLen,
reinterpret_cast<const char *>(nvpair) + 8 + nameLen +

View File

@ -61,7 +61,7 @@ nsResURL::EnsureFile()
// In most cases, the scheme is jar if it's not file.
// Regardless, net_GetFileFromURLSpec should be avoided
// when the scheme isn't file.
if (!scheme.Equals(NS_LITERAL_CSTRING("file")))
if (!scheme.EqualsLiteral("file"))
return NS_ERROR_NO_INTERFACE;
rv = net_GetFileFromURLSpec(spec, getter_AddRefs(mFile));
@ -316,7 +316,7 @@ nsResProtocolHandler::SetSubstitution(const nsACString& root, nsIURI *baseURI)
nsAutoCString scheme;
nsresult rv = baseURI->GetScheme(scheme);
NS_ENSURE_SUCCESS(rv, rv);
if (!scheme.Equals(NS_LITERAL_CSTRING("resource"))) {
if (!scheme.EqualsLiteral("resource")) {
mSubstitutions.Put(root, baseURI);
return NS_OK;
}

View File

@ -2116,7 +2116,7 @@ WebSocketChannel::HandleExtensions()
NS_LITERAL_CSTRING("Sec-WebSocket-Extensions"), extensions);
if (NS_SUCCEEDED(rv)) {
if (!extensions.IsEmpty()) {
if (!extensions.Equals(NS_LITERAL_CSTRING("deflate-stream"))) {
if (!extensions.EqualsLiteral("deflate-stream")) {
LOG(("WebSocketChannel::OnStartRequest: "
"HTTP Sec-WebSocket-Exensions negotiated unknown value %s\n",
extensions.get()));
@ -2354,7 +2354,7 @@ WebSocketChannel::ReportConnectionTelemetry()
nsAutoCString proxyType;
pi->GetType(proxyType);
if (!proxyType.IsEmpty() &&
!proxyType.Equals(NS_LITERAL_CSTRING("direct")))
!proxyType.EqualsLiteral("direct"))
didProxy = true;
}

View File

@ -461,7 +461,7 @@ nsSiteSecurityService::IsSecureURI(uint32_t aType, nsIURI* aURI,
}
// Holepunch chart.apis.google.com and subdomains.
if (host.Equals(NS_LITERAL_CSTRING("chart.apis.google.com")) ||
if (host.EqualsLiteral("chart.apis.google.com") ||
StringEndsWith(host, NS_LITERAL_CSTRING(".chart.apis.google.com"))) {
return NS_OK;
}

View File

@ -997,7 +997,7 @@ nsTypeAheadFind::Find(const nsAString& aSearchString, bool aLinksOnly,
// by waiting for the first keystroke, we still get the startup time benefits.
mIsSoundInitialized = true;
mSoundInterface = do_CreateInstance("@mozilla.org/sound;1");
if (mSoundInterface && !mNotFoundSoundURL.Equals(NS_LITERAL_CSTRING("beep"))) {
if (mSoundInterface && !mNotFoundSoundURL.EqualsLiteral("beep")) {
mSoundInterface->Init();
}
}

View File

@ -491,7 +491,7 @@ LoadDirsIntoArray(nsCOMArray<nsIFile>& aSourceDirs,
nsAutoCString leaf;
appended->GetNativeLeafName(leaf);
if (!Substring(leaf, leaf.Length() - 4).Equals(NS_LITERAL_CSTRING(".xpi"))) {
if (!Substring(leaf, leaf.Length() - 4).EqualsLiteral(".xpi")) {
LoadDirIntoArray(appended,
aAppendList,
aDirectories);
@ -564,7 +564,7 @@ LoadExtensionDirectories(nsINIParser &parser,
continue;
aDirectories.AppendObject(dir);
if (Substring(path, path.Length() - 4).Equals(NS_LITERAL_CSTRING(".xpi"))) {
if (Substring(path, path.Length() - 4).EqualsLiteral(".xpi")) {
XRE_AddJarManifestLocation(aType, dir);
}
else {

View File

@ -398,7 +398,7 @@ GfxInfo::GetFeatureStatusImpl(int32_t aFeature,
return NS_OK;
}
if (mHardware.Equals(NS_LITERAL_STRING("ville"))) {
if (mHardware.EqualsLiteral("ville")) {
*aStatus = nsIGfxInfo::FEATURE_BLOCKED_DEVICE;
return NS_OK;
}

View File

@ -36,7 +36,7 @@ public:
private:
NS_IMETHOD Callback(const nsAString& aTopic, const nsAString& aState) {
bool isLocked = mLockedTopics.Contains(aTopic);
bool shouldLock = aState.Equals(NS_LITERAL_STRING("locked-foreground"));
bool shouldLock = aState.EqualsLiteral("locked-foreground");
if (isLocked == shouldLock) {
return NS_OK;
}

View File

@ -78,7 +78,7 @@ nsresult CheckValidTEXT(STGMEDIUM* pSTG)
nsCString string;
string = pText;
if (!string.Equals(NS_LITERAL_CSTRING("Mozilla can drag and drop"))) {
if (!string.EqualsLiteral("Mozilla can drag and drop")) {
fail("Text passed through drop object wrong");
return NS_ERROR_UNEXPECTED;
}
@ -103,7 +103,7 @@ nsresult CheckValidTEXTTwo(STGMEDIUM* pSTG)
nsCString string;
string = pText;
if (!string.Equals(NS_LITERAL_CSTRING("Mozilla can drag and drop twice over"))) {
if (!string.EqualsLiteral("Mozilla can drag and drop twice over")) {
fail("Text passed through drop object wrong");
return NS_ERROR_UNEXPECTED;
}
@ -128,7 +128,7 @@ nsresult CheckValidUNICODE(STGMEDIUM* pSTG)
nsString string;
string = pText;
if (!string.Equals(NS_LITERAL_STRING("Mozilla can drag and drop"))) {
if (!string.EqualsLiteral("Mozilla can drag and drop")) {
fail("Text passed through drop object wrong");
return NS_ERROR_UNEXPECTED;
}
@ -153,7 +153,7 @@ nsresult CheckValidUNICODETwo(STGMEDIUM* pSTG)
nsString string;
string = pText;
if (!string.Equals(NS_LITERAL_STRING("Mozilla can drag and drop twice over"))) {
if (!string.EqualsLiteral("Mozilla can drag and drop twice over")) {
fail("Text passed through drop object wrong");
return NS_ERROR_UNEXPECTED;
}

View File

@ -19,7 +19,7 @@ WakeLockListener::Callback(const nsAString& aTopic, const nsAString& aState)
}
}
if (aState.Equals(NS_LITERAL_STRING("locked-foreground"))) {
if (aState.EqualsLiteral("locked-foreground")) {
mDisplayRequest->RequestActive();
} else {
mDisplayRequest->RequestRelease();

View File

@ -1872,7 +1872,7 @@ nsComponentManagerImpl::AddBootstrappedManifestLocation(nsIFile* aLocation)
if (NS_FAILED(rv))
return rv;
if (Substring(path, path.Length() - 4).Equals(NS_LITERAL_STRING(".xpi"))) {
if (Substring(path, path.Length() - 4).EqualsLiteral(".xpi")) {
return XRE_AddJarManifestLocation(NS_BOOTSTRAPPED_LOCATION, aLocation);
}
@ -1897,7 +1897,7 @@ nsComponentManagerImpl::RemoveBootstrappedManifestLocation(nsIFile* aLocation)
nsComponentManagerImpl::ComponentLocation elem;
elem.type = NS_BOOTSTRAPPED_LOCATION;
if (Substring(path, path.Length() - 4).Equals(NS_LITERAL_STRING(".xpi"))) {
if (Substring(path, path.Length() - 4).EqualsLiteral(".xpi")) {
elem.location.Init(aLocation, "chrome.manifest");
} else {
nsCOMPtr<nsIFile> lf = CloneAndAppend(aLocation, NS_LITERAL_CSTRING("chrome.manifest"));

View File

@ -55,11 +55,11 @@ int testWrite() {
CHECK(begin == s.BeginWriting()) +
CHECK(end == s.EndWriting());
begin[4] = char16_t('y');
res += CHECK(s.Equals(NS_LITERAL_STRING("xyzzy")));
res += CHECK(s.EqualsLiteral("xyzzy"));
s.SetLength(4);
res += CHECK(4 == s.Length()) +
CHECK(s.Equals(NS_LITERAL_STRING("xyzz"))) +
CHECK(!s.Equals(NS_LITERAL_STRING("xyzzy"))) +
CHECK(s.EqualsLiteral("xyzz")) +
CHECK(!s.EqualsLiteral("xyzzy")) +
CHECK(!s.IsEmpty());
s.Truncate();
res += CHECK(0 == s.Length()) +

View File

@ -104,7 +104,7 @@ test_malformed8()
nsString tmp16(NS_LITERAL_STRING("string"));
AppendUTF8toUTF16(str8, tmp16);
if (!tmp16.Equals(NS_LITERAL_STRING("string")))
if (!tmp16.EqualsLiteral("string"))
return false;
if (CompareUTF8toUTF16(str8, EmptyString()) == 0)

View File

@ -557,7 +557,7 @@ static bool test_compressws()
{
nsString check(NS_LITERAL_STRING(" \tTesting \n\t1\n 2 3\n "));
CompressWhitespace(check);
return check.Equals(NS_LITERAL_STRING("Testing 1 2 3"));
return check.EqualsLiteral("Testing 1 2 3");
}
static bool test_comparisons()