mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-28 23:31:56 +00:00
Bug 1733727 part 3: Use StaticAutoPtr to manage lifetime of various "gFoo" static global variables in layout. r=jfkthame
This patch doesn't change any user-observable behavior. StaticAutoPtr lets us remove a handful of explicit 'delete' statements, by making deletion happen automatically when these variables are cleared. Differential Revision: https://phabricator.services.mozilla.com/D127337
This commit is contained in:
parent
b5c0f07b29
commit
f913735c40
@ -51,6 +51,7 @@
|
||||
#include "mozilla/ScrollbarPreferences.h"
|
||||
#include "mozilla/ScrollingMetrics.h"
|
||||
#include "mozilla/StaticPrefs_browser.h"
|
||||
#include "mozilla/StaticPtr.h"
|
||||
#include "mozilla/SVGOuterSVGFrame.h"
|
||||
#include "mozilla/ViewportUtils.h"
|
||||
#include "mozilla/LookAndFeel.h"
|
||||
@ -2178,7 +2179,7 @@ class ScrollFrameActivityTracker final
|
||||
}
|
||||
};
|
||||
|
||||
static ScrollFrameActivityTracker* gScrollFrameActivityTracker = nullptr;
|
||||
static StaticAutoPtr<ScrollFrameActivityTracker> gScrollFrameActivityTracker;
|
||||
|
||||
ScrollFrameHelper::ScrollFrameHelper(nsContainerFrame* aOuter, bool aIsRoot)
|
||||
: mHScrollbarBox(nullptr),
|
||||
@ -4325,9 +4326,9 @@ nsRect ScrollFrameHelper::RestrictToRootDisplayPort(
|
||||
}
|
||||
|
||||
/* static */ bool ScrollFrameHelper::ShouldActivateAllScrollFrames() {
|
||||
return (StaticPrefs::apz_wr_activate_all_scroll_frames() ||
|
||||
(StaticPrefs::apz_wr_activate_all_scroll_frames_when_fission() &&
|
||||
FissionAutostart()));
|
||||
return (StaticPrefs::apz_wr_activate_all_scroll_frames() ||
|
||||
(StaticPrefs::apz_wr_activate_all_scroll_frames_when_fission() &&
|
||||
FissionAutostart()));
|
||||
}
|
||||
|
||||
bool ScrollFrameHelper::DecideScrollableLayer(
|
||||
@ -5563,7 +5564,6 @@ void ScrollFrameHelper::Destroy(PostDestroyData& aPostDestroyData) {
|
||||
gScrollFrameActivityTracker->RemoveObject(this);
|
||||
}
|
||||
if (gScrollFrameActivityTracker && gScrollFrameActivityTracker->IsEmpty()) {
|
||||
delete gScrollFrameActivityTracker;
|
||||
gScrollFrameActivityTracker = nullptr;
|
||||
}
|
||||
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include "mozilla/EffectSet.h"
|
||||
#include "mozilla/MotionPathUtils.h"
|
||||
#include "mozilla/PodOperations.h"
|
||||
#include "mozilla/StaticPtr.h"
|
||||
#include "gfx2DGlue.h"
|
||||
#include "nsExpirationTracker.h"
|
||||
#include "nsContainerFrame.h"
|
||||
@ -163,7 +164,7 @@ class LayerActivityTracker final
|
||||
bool mDestroying;
|
||||
};
|
||||
|
||||
static LayerActivityTracker* gLayerActivityTracker = nullptr;
|
||||
static StaticAutoPtr<LayerActivityTracker> gLayerActivityTracker;
|
||||
|
||||
LayerActivity::~LayerActivity() {
|
||||
if (mFrame || mContent) {
|
||||
@ -606,9 +607,6 @@ void ActiveLayerTracker::SetCurrentScrollHandlerFrame(nsIFrame* aFrame) {
|
||||
}
|
||||
|
||||
/* static */
|
||||
void ActiveLayerTracker::Shutdown() {
|
||||
delete gLayerActivityTracker;
|
||||
gLayerActivityTracker = nullptr;
|
||||
}
|
||||
void ActiveLayerTracker::Shutdown() { gLayerActivityTracker = nullptr; }
|
||||
|
||||
} // namespace mozilla
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include "mozilla/gfx/2D.h"
|
||||
#include "mozilla/gfx/PathHelpers.h"
|
||||
#include "mozilla/layers/StackingContextHelper.h"
|
||||
#include "mozilla/StaticPtr.h"
|
||||
#include "mozilla/webrender/WebRenderTypes.h"
|
||||
#include "nsPresContext.h"
|
||||
#include "nsCSSRendering.h"
|
||||
@ -446,7 +447,7 @@ void DisplayItemClip::MoveBy(const nsPoint& aPoint) {
|
||||
}
|
||||
}
|
||||
|
||||
static DisplayItemClip* gNoClip;
|
||||
static StaticAutoPtr<DisplayItemClip> gNoClip;
|
||||
|
||||
const DisplayItemClip& DisplayItemClip::NoClip() {
|
||||
if (!gNoClip) {
|
||||
@ -455,10 +456,7 @@ const DisplayItemClip& DisplayItemClip::NoClip() {
|
||||
return *gNoClip;
|
||||
}
|
||||
|
||||
void DisplayItemClip::Shutdown() {
|
||||
delete gNoClip;
|
||||
gNoClip = nullptr;
|
||||
}
|
||||
void DisplayItemClip::Shutdown() { gNoClip = nullptr; }
|
||||
|
||||
nsCString DisplayItemClip::ToString() const {
|
||||
nsAutoCString str;
|
||||
|
@ -5,6 +5,8 @@
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "HitTestInfo.h"
|
||||
|
||||
#include "mozilla/StaticPtr.h"
|
||||
#include "mozilla/webrender/WebRenderAPI.h"
|
||||
#include "nsDisplayList.h"
|
||||
#include "nsIFrame.h"
|
||||
@ -12,7 +14,7 @@
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
static const HitTestInfo* gEmptyHitTestInfo = nullptr;
|
||||
static StaticAutoPtr<const HitTestInfo> gEmptyHitTestInfo;
|
||||
|
||||
const HitTestInfo& HitTestInfo::Empty() {
|
||||
if (gEmptyHitTestInfo) {
|
||||
@ -22,10 +24,7 @@ const HitTestInfo& HitTestInfo::Empty() {
|
||||
return *gEmptyHitTestInfo;
|
||||
}
|
||||
|
||||
void HitTestInfo::Shutdown() {
|
||||
delete gEmptyHitTestInfo;
|
||||
gEmptyHitTestInfo = nullptr;
|
||||
}
|
||||
void HitTestInfo::Shutdown() { gEmptyHitTestInfo = nullptr; }
|
||||
|
||||
using ViewID = layers::ScrollableLayerGuid::ViewID;
|
||||
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include "mozilla/HashFunctions.h"
|
||||
#include "mozilla/MathAlgorithms.h"
|
||||
#include "mozilla/PresShell.h"
|
||||
#include "mozilla/StaticPtr.h"
|
||||
#include "mozilla/SVGImageContext.h"
|
||||
#include "gfxFont.h"
|
||||
#include "ScaledFontBase.h"
|
||||
@ -426,7 +427,7 @@ struct InlineBackgroundData {
|
||||
}
|
||||
};
|
||||
|
||||
static InlineBackgroundData* gInlineBGData = nullptr;
|
||||
static StaticAutoPtr<InlineBackgroundData> gInlineBGData;
|
||||
|
||||
// Initialize any static variables used by nsCSSRendering.
|
||||
void nsCSSRendering::Init() {
|
||||
@ -435,10 +436,7 @@ void nsCSSRendering::Init() {
|
||||
}
|
||||
|
||||
// Clean up any global variables used by nsCSSRendering.
|
||||
void nsCSSRendering::Shutdown() {
|
||||
delete gInlineBGData;
|
||||
gInlineBGData = nullptr;
|
||||
}
|
||||
void nsCSSRendering::Shutdown() { gInlineBGData = nullptr; }
|
||||
|
||||
/**
|
||||
* Make a bevel color
|
||||
|
@ -30,13 +30,15 @@
|
||||
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "mozilla/StaticPrefs_layout.h"
|
||||
#include "mozilla/StaticPtr.h"
|
||||
|
||||
using namespace mozilla;
|
||||
|
||||
static int32_t gPropertyTableRefCount;
|
||||
static nsStaticCaseInsensitiveNameTable* gFontDescTable;
|
||||
static nsStaticCaseInsensitiveNameTable* gCounterDescTable;
|
||||
static nsTHashMap<nsCStringHashKey, nsCSSPropertyID>* gPropertyIDLNameTable;
|
||||
static StaticAutoPtr<nsStaticCaseInsensitiveNameTable> gFontDescTable;
|
||||
static StaticAutoPtr<nsStaticCaseInsensitiveNameTable> gCounterDescTable;
|
||||
static StaticAutoPtr<nsTHashMap<nsCStringHashKey, nsCSSPropertyID>>
|
||||
gPropertyIDLNameTable;
|
||||
|
||||
static const char* const kCSSRawFontDescs[] = {
|
||||
#define CSS_FONT_DESC(name_, method_) #name_,
|
||||
@ -121,13 +123,8 @@ void nsCSSProps::AddRefTable(void) {
|
||||
|
||||
void nsCSSProps::ReleaseTable(void) {
|
||||
if (0 == --gPropertyTableRefCount) {
|
||||
delete gFontDescTable;
|
||||
gFontDescTable = nullptr;
|
||||
|
||||
delete gCounterDescTable;
|
||||
gCounterDescTable = nullptr;
|
||||
|
||||
delete gPropertyIDLNameTable;
|
||||
gPropertyIDLNameTable = nullptr;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user