Bug 1710988 - Apply linter fixes to nsDOMWindowUtils.cpp r=smaug

Differential Revision: https://phabricator.services.mozilla.com/D115327
This commit is contained in:
Paul Bone 2021-05-19 02:47:59 +00:00
Родитель 6477eef4a5
Коммит d0098f25b6
3 изменённых файлов: 24 добавлений и 22 удалений

Просмотреть файл

@ -2639,7 +2639,7 @@ nsDOMWindowUtils::AudioDevices(uint16_t aSide, nsIArray** aDevices) {
enumerator->EnumerateAudioOutputDevices(collection);
}
for (auto device : collection) {
for (const auto& device : collection) {
devices->AppendElement(device);
}
@ -3162,8 +3162,9 @@ static bool CheckLeafLayers(Layer* aLayer, const nsIntPoint& aOffset,
nsIntRegion* aCoveredRegion) {
gfx::Matrix transform;
if (!aLayer->GetTransform().Is2D(&transform) ||
transform.HasNonIntegerTranslation())
transform.HasNonIntegerTranslation()) {
return false;
}
transform.NudgeToIntegers();
IntPoint offset = aOffset + IntPoint::Truncate(transform._31, transform._32);
@ -3761,7 +3762,7 @@ nsDOMWindowUtils::AddSheet(nsIPreloadedStyleSheet* aSheet,
NS_ENSURE_TRUE(doc, NS_ERROR_FAILURE);
StyleSheet* sheet = nullptr;
auto preloadedSheet = static_cast<PreloadedStyleSheet*>(aSheet);
auto* preloadedSheet = static_cast<PreloadedStyleSheet*>(aSheet);
nsresult rv = preloadedSheet->GetSheet(&sheet);
NS_ENSURE_SUCCESS(rv, rv);
NS_ENSURE_TRUE(sheet, NS_ERROR_FAILURE);

Просмотреть файл

@ -366,7 +366,7 @@ class AutoFree {
~AutoFree() {
if (mPtr) free(mPtr);
}
void Invalidate() { mPtr = 0; }
void Invalidate() { mPtr = nullptr; }
private:
void* mPtr;
@ -2514,9 +2514,8 @@ nsJSArgArray::nsJSArgArray(JSContext* aContext, uint32_t argc,
nsJSArgArray::~nsJSArgArray() { ReleaseJSObjects(); }
void nsJSArgArray::ReleaseJSObjects() {
if (mArgv) {
delete[] mArgv;
}
delete[] mArgv;
if (mArgc > 0) {
mArgc = 0;
mozilla::DropJSObjects(this);

Просмотреть файл

@ -258,8 +258,9 @@ static bool TryParseLocationURICandidate(
if (aLocationHint == RealmPrivate::LocationHintAddon) {
// Blacklist some known locations which are clearly not add-on related.
if (StringBeginsWith(uristr, kGRE) || StringBeginsWith(uristr, kToolkit) ||
StringBeginsWith(uristr, kBrowser))
StringBeginsWith(uristr, kBrowser)) {
return false;
}
// -- GROSS HACK ALERT --
// The Yandex Elements 8.10.2 extension implements its own "xb://" URL
@ -338,8 +339,9 @@ bool RealmPrivate::TryParseLocationURI(RealmPrivate::LocationHint aLocationHint,
// When parsing we're looking for the right-most URI. This URI may be in
// <sandboxName>, so we try this first.
if (TryParseLocationURICandidate(Substring(location, 0, idx), aLocationHint,
aURI))
aURI)) {
return true;
}
// Not in <sandboxName> so we need to inspect <js-stack-frame-filename> and
// the chain that is potentially contained within and grab the rightmost
@ -361,8 +363,9 @@ bool RealmPrivate::TryParseLocationURI(RealmPrivate::LocationHint aLocationHint,
// Try to parse current chain item
if (TryParseLocationURICandidate(Substring(chain, idx + arrowLength),
aLocationHint, aURI))
aLocationHint, aURI)) {
return true;
}
// Current chain item couldn't be parsed.
// Strip current item and continue.
@ -378,7 +381,7 @@ static bool PrincipalImmuneToScriptPolicy(nsIPrincipal* aPrincipal) {
return true;
}
auto principal = BasePrincipal::Cast(aPrincipal);
auto* principal = BasePrincipal::Cast(aPrincipal);
// ExpandedPrincipal gets a free pass.
if (principal->Is<ExpandedPrincipal>()) {
@ -686,7 +689,7 @@ bool XPCJSRuntime::UsefulToMergeZones() const {
void XPCJSRuntime::TraceNativeBlackRoots(JSTracer* trc) {
if (CycleCollectedJSContext* ccx = GetContext()) {
auto* cx = static_cast<const XPCJSContext*>(ccx);
const auto* cx = static_cast<const XPCJSContext*>(ccx);
if (AutoMarkingPtr* roots = cx->mAutoRoots) {
roots->TraceJSAll(trc);
}
@ -856,7 +859,7 @@ void XPCJSRuntime::FinalizeCallback(JSFreeOp* fop, JSFinalizeStatus status,
self->mGCIsRunning = true;
if (CycleCollectedJSContext* ccx = self->GetContext()) {
auto* cx = static_cast<const XPCJSContext*>(ccx);
const auto* cx = static_cast<const XPCJSContext*>(ccx);
if (AutoMarkingPtr* roots = cx->mAutoRoots) {
roots->MarkAfterJSFinalizeAll();
}
@ -907,7 +910,7 @@ void XPCJSRuntime::FinalizeCallback(JSFreeOp* fop, JSFinalizeStatus status,
for (auto i = self->mDyingWrappedNativeProtoMap->Iter(); !i.Done();
i.Next()) {
auto entry = static_cast<XPCWrappedNativeProtoMap::Entry*>(i.Get());
auto* entry = static_cast<XPCWrappedNativeProtoMap::Entry*>(i.Get());
delete static_cast<const XPCWrappedNativeProto*>(entry->key);
i.Remove();
}
@ -1852,15 +1855,13 @@ void ReportJSRuntimeExplicitTreeStats(const JS::RuntimeStats& rtStats,
size_t* rtTotalOut) {
size_t gcTotal = 0;
for (size_t i = 0; i < rtStats.zoneStatsVector.length(); i++) {
const JS::ZoneStats& zStats = rtStats.zoneStatsVector[i];
for (const auto& zStats : rtStats.zoneStatsVector) {
const xpc::ZoneStatsExtras* extras =
static_cast<const xpc::ZoneStatsExtras*>(zStats.extra);
ReportZoneStats(zStats, *extras, handleReport, data, anonymize, &gcTotal);
}
for (size_t i = 0; i < rtStats.realmStatsVector.length(); i++) {
const JS::RealmStats& realmStats = rtStats.realmStatsVector[i];
for (const auto& realmStats : rtStats.realmStatsVector) {
const xpc::RealmStatsExtras* extras =
static_cast<const xpc::RealmStatsExtras*>(realmStats.extra);
@ -2057,8 +2058,8 @@ class JSMainRuntimeRealmsReporter final : public nsIMemoryReporter {
d.anonymizeID = anonymize ? 1 : 0;
JS::IterateRealms(XPCJSContext::Get()->Context(), &d, RealmCallback);
for (size_t i = 0; i < d.paths.length(); i++) {
REPORT(nsCString(d.paths[i]), KIND_OTHER, UNITS_COUNT, 1,
for (auto& path : d.paths) {
REPORT(nsCString(path), KIND_OTHER, UNITS_COUNT, 1,
"A live realm in the main JSRuntime.");
}
@ -2152,8 +2153,9 @@ class XPCJSRuntimeStats : public JS::RuntimeStats {
if (NS_SUCCEEDED(UNWRAP_NON_WRAPPER_OBJECT(Window, global, window))) {
// The global is a |window| object. Use the path prefix that
// we should have already created for it.
if (mTopWindowPaths->Get(window->WindowID(), &extras->pathPrefix))
if (mTopWindowPaths->Get(window->WindowID(), &extras->pathPrefix)) {
extras->pathPrefix.AppendLiteral("/js-");
}
}
}
}
@ -3097,7 +3099,7 @@ void XPCJSRuntime::DebugDump(int16_t depth) {
if (depth && mNativeSetMap->Count()) {
XPC_LOG_INDENT();
for (auto i = mNativeSetMap->Iter(); !i.Done(); i.Next()) {
auto entry = static_cast<NativeSetMap::Entry*>(i.Get());
auto* entry = static_cast<NativeSetMap::Entry*>(i.Get());
entry->key_value->DebugDump(depth);
}
XPC_LOG_OUTDENT();