Bug 1302071 - Part 1: Remove AddPresShellToInvalidateIfHidden since it doesn't appear to be necessary. r?tnikkel
We added this so that MozAfterPaint events would be delivered to hidden documents as part of
bug 539356, but I don't remember what needed it.
It doesn't appear to be necessary for any tests any more, so let's just get rid of it
MozReview-Commit-ID: HcmIjstZyLQ
--- a/layout/base/PresShell.cpp
+++ b/layout/base/PresShell.cpp
@@ -654,43 +654,16 @@ nsIPresShell::GetVerifyReflowEnable()
printf("\n");
}
}
#endif
return gVerifyReflowEnabled;
}
void
-PresShell::AddInvalidateHiddenPresShellObserver(nsRefreshDriver *aDriver)
-{
- if (!mHiddenInvalidationObserverRefreshDriver && !mIsDestroying && !mHaveShutDown) {
- aDriver->AddPresShellToInvalidateIfHidden(this);
- mHiddenInvalidationObserverRefreshDriver = aDriver;
- }
-}
-
-void
-nsIPresShell::InvalidatePresShellIfHidden()
-{
- if (!IsVisible() && mPresContext) {
- mPresContext->NotifyInvalidation(0);
- }
- mHiddenInvalidationObserverRefreshDriver = nullptr;
-}
-
-void
-nsIPresShell::CancelInvalidatePresShellIfHidden()
-{
- if (mHiddenInvalidationObserverRefreshDriver) {
- mHiddenInvalidationObserverRefreshDriver->RemovePresShellToInvalidateIfHidden(this);
- mHiddenInvalidationObserverRefreshDriver = nullptr;
- }
-}
-
-void
nsIPresShell::SetVerifyReflowEnable(bool aEnabled)
{
gVerifyReflowEnabled = aEnabled;
}
/* virtual */ void
nsIPresShell::AddWeakFrameExternal(nsWeakFrame* aWeakFrame)
{
@@ -766,17 +739,16 @@ PresShell::AccessibleCaretEnabled(nsIDoc
// Otherwise, disabled.
return false;
}
nsIPresShell::nsIPresShell()
: mFrameConstructor(nullptr)
, mViewManager(nullptr)
, mFrameManager(nullptr)
- , mHiddenInvalidationObserverRefreshDriver(nullptr)
#ifdef ACCESSIBILITY
, mDocAccessible(nullptr)
#endif
#ifdef DEBUG
, mDrawEventTargetFrame(nullptr)
#endif
, mPaintCount(0)
, mWeakFrames(nullptr)
@@ -1363,19 +1335,16 @@ PresShell::Destroy()
mPresContext->AnimationManager()->ClearEventQueue();
mPresContext->TransitionManager()->ClearEventQueue();
}
// Revoke any pending events. We need to do this and cancel pending reflows
// before we destroy the frame manager, since apparently frame destruction
// sometimes spins the event queue when plug-ins are involved(!).
rd->RemoveLayoutFlushObserver(this);
- if (mHiddenInvalidationObserverRefreshDriver) {
- mHiddenInvalidationObserverRefreshDriver->RemovePresShellToInvalidateIfHidden(this);
- }
if (rd->GetPresContext() == GetPresContext()) {
rd->RevokeViewManagerFlush();
}
mResizeEvent.Revoke();
if (mAsyncResizeTimerIsActive) {
mAsyncResizeEventTimer->Cancel();
@@ -3705,17 +3674,16 @@ class PaintTimerCallBack final : public
public:
explicit PaintTimerCallBack(PresShell* aShell) : mShell(aShell) {}
NS_DECL_ISUPPORTS
NS_IMETHOD Notify(nsITimer* aTimer) final
{
mShell->SetNextPaintCompressed();
- mShell->AddInvalidateHiddenPresShellObserver(mShell->GetPresContext()->RefreshDriver());
mShell->ScheduleViewManagerFlush();
return NS_OK;
}
private:
~PaintTimerCallBack() {}
PresShell* mShell;
--- a/layout/base/PresShell.h
+++ b/layout/base/PresShell.h
@@ -373,18 +373,16 @@ public:
void AddSizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf,
nsArenaMemoryStats *aArenaObjectsSize,
size_t *aPresShellSize,
size_t *aStyleSetsSize,
size_t *aTextRunsSize,
size_t *aPresContextSize) override;
size_t SizeOfTextRuns(mozilla::MallocSizeOf aMallocSizeOf) const;
- virtual void AddInvalidateHiddenPresShellObserver(nsRefreshDriver *aDriver) override;
-
// This data is stored as a content property (nsGkAtoms::scrolling) on
// mContentToScrollTo when we have a pending ScrollIntoView.
struct ScrollIntoViewData {
ScrollAxis mContentScrollVAxis;
ScrollAxis mContentScrollHAxis;
uint32_t mContentToScrollToFlags;
};
--- a/layout/base/nsIPresShell.h
+++ b/layout/base/nsIPresShell.h
@@ -1591,22 +1591,16 @@ public:
* whether font size inflation is enabled on the next call to
* FontSizeInflationEnabled().
*/
void NotifyFontSizeInflationEnabledIsDirty()
{
mFontSizeInflationEnabledIsDirty = true;
}
- virtual void AddInvalidateHiddenPresShellObserver(nsRefreshDriver *aDriver) = 0;
-
- void InvalidatePresShellIfHidden();
- void CancelInvalidatePresShellIfHidden();
-
-
//////////////////////////////////////////////////////////////////////////////
// Approximate frame visibility tracking public API.
//////////////////////////////////////////////////////////////////////////////
/// Schedule an update of the list of approximately visible frames "soon".
/// This lets the refresh driver know that we want a visibility update in the
/// near future. The refresh driver applies its own heuristics and throttling
/// to decide when to actually perform the visibility update.
@@ -1756,20 +1750,16 @@ protected:
nsCSSFrameConstructor* mFrameConstructor; // [OWNS]
nsViewManager* mViewManager; // [WEAK] docViewer owns it so I don't have to
nsPresArena mFrameArena;
RefPtr<nsFrameSelection> mSelection;
// Pointer into mFrameConstructor - this is purely so that FrameManager() and
// GetRootFrame() can be inlined:
nsFrameManagerBase* mFrameManager;
mozilla::WeakPtr<nsDocShell> mForwardingContainer;
- nsRefreshDriver* MOZ_UNSAFE_REF("These two objects hold weak references "
- "to each other, and the validity of this "
- "member is ensured by the logic in nsIPresShell.")
- mHiddenInvalidationObserverRefreshDriver;
#ifdef ACCESSIBILITY
mozilla::a11y::DocAccessible* mDocAccessible;
#endif
// At least on Win32 and Mac after interupting a reflow we need to post
// the resume reflow event off a timer to avoid event starvation because
// posted messages are processed before other messages when the modal
// moving/sizing loop is running, see bug 491700 for details.
--- a/layout/base/nsPresContext.cpp
+++ b/layout/base/nsPresContext.cpp
@@ -262,17 +262,16 @@ nsPresContext::nsPresContext(nsIDocument
mPrefBidiDirection(false),
mPrefScrollbarSide(0),
mPendingSysColorChanged(false),
mPendingThemeChanged(false),
mPendingUIResolutionChanged(false),
mPendingMediaFeatureValuesChanged(false),
mPrefChangePendingNeedsReflow(false),
mIsEmulatingMedia(false),
- mAllInvalidated(false),
mIsGlyph(false),
mUsesRootEMUnits(false),
mUsesExChUnits(false),
mUsesViewportUnits(false),
mPendingViewportChange(false),
mCounterStylesDirty(true),
mPostedFlushCounterStyles(false),
mSuppressResizeReflow(false),
@@ -1551,19 +1550,16 @@ nsPresContext::GetDocShell() const
return mContainer;
}
/* virtual */ void
nsPresContext::Detach()
{
SetContainer(nullptr);
SetLinkHandler(nullptr);
- if (mShell) {
- mShell->CancelInvalidatePresShellIfHidden();
- }
}
bool
nsPresContext::BidiEnabledExternal() const
{
return BidiEnabledInternal();
}
@@ -2444,24 +2440,16 @@ nsPresContext::MayHavePaintEventListener
}
bool result = false;
mDocument->EnumerateSubDocuments(MayHavePaintEventListenerSubdocumentCallback, &result);
return result;
}
void
-nsPresContext::NotifyInvalidation(uint32_t aFlags)
-{
- nsIFrame* rootFrame = PresShell()->FrameManager()->GetRootFrame();
- NotifyInvalidation(rootFrame->GetVisualOverflowRect(), aFlags);
- mAllInvalidated = true;
-}
-
-void
nsPresContext::NotifyInvalidation(const nsIntRect& aRect, uint32_t aFlags)
{
// Prevent values from overflow after DevPixelsToAppUnits().
//
// DevPixelsTopAppUnits() will multiple a factor (60) to the value,
// it may make the result value over the edge (overflow) of max or
// min value of int32_t. Compute the max sized dev pixel rect that
// we can support and intersect with it.
@@ -2483,20 +2471,16 @@ nsPresContext::NotifyInvalidation(const
MOZ_ASSERT(GetContainerWeak(), "Invalidation in detached pres context");
// If there is no paint event listener, then we don't need to fire
// the asynchronous event. We don't even need to record invalidation.
// MayHavePaintEventListener is pretty cheap and we could make it
// even cheaper by providing a more efficient
// nsPIDOMWindow::GetListenerManager.
- if (mAllInvalidated) {
- return;
- }
-
nsPresContext* pc;
for (pc = this; pc; pc = pc->GetParentPresContext()) {
if (pc->mFireAfterPaintEvents)
break;
pc->mFireAfterPaintEvents = true;
}
if (!pc) {
nsRootPresContext* rpc = GetRootPresContext();
@@ -2626,17 +2610,16 @@ nsPresContext::NotifyDidPaintForSubtree(
// unconditionally, even if no invalidations have been collected. This is
// because we don't want to eat the cost of collecting invalidations for
// every subdocument (which would require putting every subdocument in its
// own layer).
if (aFlags & nsIPresShell::PAINT_LAYERS) {
mUndeliveredInvalidateRequestsBeforeLastPaint.TakeFrom(
&mInvalidateRequestsSinceLastPaint);
- mAllInvalidated = false;
}
if (aFlags & nsIPresShell::PAINT_COMPOSITE) {
nsCOMPtr<nsIRunnable> ev =
new DelayedFireDOMPaintEvent(this, &mUndeliveredInvalidateRequestsBeforeLastPaint,
aTransactionId, aTimeStamp);
nsContentUtils::AddScriptRunner(ev);
}
--- a/layout/base/nsPresContext.h
+++ b/layout/base/nsPresContext.h
@@ -966,17 +966,16 @@ public:
void FlushCounterStyles();
void RebuildCounterStyles(); // asynchronously
// Ensure that it is safe to hand out CSS rules outside the layout
// engine by ensuring that all CSS style sheets have unique inners
// and, if necessary, synchronously rebuilding all style data.
void EnsureSafeToHandOutCSSRules();
- void NotifyInvalidation(uint32_t aFlags);
void NotifyInvalidation(const nsRect& aRect, uint32_t aFlags);
// aRect is in device pixels
void NotifyInvalidation(const nsIntRect& aRect, uint32_t aFlags);
// aFlags are nsIPresShell::PAINT_ flags
void NotifyDidPaintForSubtree(uint32_t aFlags, uint64_t aTransactionId = 0,
const mozilla::TimeStamp& aTimeStamp = mozilla::TimeStamp());
void FireDOMPaintEvent(nsInvalidateRequestList* aList, uint64_t aTransactionId,
mozilla::TimeStamp aTimeStamp = mozilla::TimeStamp());
@@ -986,17 +985,16 @@ public:
static void NotifySubDocInvalidation(mozilla::layers::ContainerLayer* aContainer,
const nsIntRegion& aRegion);
void SetNotifySubDocInvalidationData(mozilla::layers::ContainerLayer* aContainer);
static void ClearNotifySubDocInvalidationData(mozilla::layers::ContainerLayer* aContainer);
bool IsDOMPaintEventPending();
void ClearMozAfterPaintEvents() {
mInvalidateRequestsSinceLastPaint.mRequests.Clear();
mUndeliveredInvalidateRequestsBeforeLastPaint.mRequests.Clear();
- mAllInvalidated = false;
}
/**
* Returns the RestyleManager's restyle generation counter.
*/
uint64_t GetRestyleGeneration() const;
/**
@@ -1394,19 +1392,16 @@ protected:
unsigned mPrefBidiDirection : 1;
unsigned mPrefScrollbarSide : 2;
unsigned mPendingSysColorChanged : 1;
unsigned mPendingThemeChanged : 1;
unsigned mPendingUIResolutionChanged : 1;
unsigned mPendingMediaFeatureValuesChanged : 1;
unsigned mPrefChangePendingNeedsReflow : 1;
unsigned mIsEmulatingMedia : 1;
- // True if the requests in mInvalidateRequestsSinceLastPaint cover the
- // entire viewport
- unsigned mAllInvalidated : 1;
// Are we currently drawing an SVG glyph?
unsigned mIsGlyph : 1;
// Does the associated document use root-em (rem) units?
unsigned mUsesRootEMUnits : 1;
// Does the associated document use ex or ch units?
unsigned mUsesExChUnits : 1;
--- a/layout/base/nsRefreshDriver.cpp
+++ b/layout/base/nsRefreshDriver.cpp
@@ -1179,20 +1179,16 @@ nsRefreshDriver::~nsRefreshDriver()
MOZ_ASSERT(!mPresContext,
"Should have called Disconnect() and decremented "
"sRefreshDriverCount!");
if (mRootRefresh) {
mRootRefresh->RemoveRefreshObserver(this, FlushType::Style);
mRootRefresh = nullptr;
}
- for (nsIPresShell* shell : mPresShellsToInvalidateIfHidden) {
- shell->InvalidatePresShellIfHidden();
- }
- mPresShellsToInvalidateIfHidden.Clear();
}
// Method for testing. See nsIDOMWindowUtils.advanceTimeAndRefresh
// for description.
void
nsRefreshDriver::AdvanceTimeAndRefresh(int64_t aMilliseconds)
{
// ensure that we're removed from our driver
@@ -2000,21 +1996,16 @@ nsRefreshDriver::Tick(int64_t aNowEpoch,
}
}
for (uint32_t i = 0; i < imagesToRefresh.Length(); i++) {
imagesToRefresh[i]->RequestRefresh(aNowTime);
}
}
- for (nsIPresShell* shell : mPresShellsToInvalidateIfHidden) {
- shell->InvalidatePresShellIfHidden();
- }
- mPresShellsToInvalidateIfHidden.Clear();
-
bool notifyGC = false;
if (mViewManagerFlushIsPending) {
RefPtr<TimelineConsumers> timelines = TimelineConsumers::Get();
nsTArray<nsDocShell*> profilingDocShells;
GetProfileTimelineSubDocShells(GetDocShell(mPresContext), profilingDocShells);
for (nsDocShell* docShell : profilingDocShells) {
// For the sake of the profile timeline's simplicity, this is flagged as
--- a/layout/base/nsRefreshDriver.h
+++ b/layout/base/nsRefreshDriver.h
@@ -185,26 +185,16 @@ public:
return appended;
}
void RemoveLayoutFlushObserver(nsIPresShell* aShell) {
mLayoutFlushObservers.RemoveElement(aShell);
}
bool IsLayoutFlushObserver(nsIPresShell* aShell) {
return mLayoutFlushObservers.Contains(aShell);
}
- bool AddPresShellToInvalidateIfHidden(nsIPresShell* aShell) {
- NS_ASSERTION(!mPresShellsToInvalidateIfHidden.Contains(aShell),
- "Double-adding style flush observer");
- bool appended = mPresShellsToInvalidateIfHidden.AppendElement(aShell) != nullptr;
- EnsureTimerStarted();
- return appended;
- }
- void RemovePresShellToInvalidateIfHidden(nsIPresShell* aShell) {
- mPresShellsToInvalidateIfHidden.RemoveElement(aShell);
- }
/**
* Remember whether our presshell's view manager needs a flush
*/
void ScheduleViewManagerFlush();
void RevokeViewManagerFlush() {
mViewManagerFlushIsPending = false;
}
@@ -480,17 +470,16 @@ private:
struct PendingEvent {
nsCOMPtr<nsINode> mTarget;
nsCOMPtr<nsIDOMEvent> mEvent;
};
AutoTArray<nsIPresShell*, 16> mStyleFlushObservers;
AutoTArray<nsIPresShell*, 16> mLayoutFlushObservers;
- AutoTArray<nsIPresShell*, 16> mPresShellsToInvalidateIfHidden;
// nsTArray on purpose, because we want to be able to swap.
nsTArray<nsIDocument*> mFrameRequestCallbackDocs;
nsTArray<nsIDocument*> mThrottledFrameRequestCallbackDocs;
nsTObserverArray<nsAPostRefreshObserver*> mPostRefreshObservers;
nsTArray<PendingEvent> mPendingEvents;
void BeginRefreshingImages(RequestTable& aEntries,
mozilla::TimeStamp aDesired);
--- a/layout/generic/nsFrame.cpp
+++ b/layout/generic/nsFrame.cpp
@@ -6176,20 +6176,16 @@ SchedulePaintInternal(nsIFrame* aFrame,
if (aType == nsIFrame::PAINT_DELAYED_COMPRESS) {
return;
}
if (aType == nsIFrame::PAINT_DEFAULT) {
displayRoot->AddStateBits(NS_FRAME_UPDATE_LAYER_TREE);
}
- nsIPresShell* shell = aFrame->PresContext()->PresShell();
- if (shell) {
- shell->AddInvalidateHiddenPresShellObserver(pres->RefreshDriver());
- }
}
static void InvalidateFrameInternal(nsIFrame *aFrame, bool aHasDisplayItem = true)
{
if (aHasDisplayItem) {
aFrame->AddStateBits(NS_FRAME_NEEDS_PAINT);
}
nsSVGEffects::InvalidateDirectRenderingObservers(aFrame);