Bug 754480 - Sort members in size order. Use narrower types where possible. part=2/3 r=bz

This commit is contained in:
Mats Palmgren 2012-05-16 19:32:40 +02:00
parent a416336ebc
commit 7268272a07
3 changed files with 180 additions and 194 deletions

View File

@ -197,10 +197,11 @@ class nsIPresShell : public nsIPresShell_base
protected:
typedef mozilla::layers::LayerManager LayerManager;
enum {
enum eRenderFlag {
STATE_IGNORING_VIEWPORT_SCROLLING = 0x1,
STATE_USING_DISPLAYPORT = 0x2
};
typedef PRUint8 RenderFlags; // for storing the above flags
public:
virtual NS_HIDDEN_(nsresult) Init(nsIDocument* aDocument,
@ -594,7 +595,7 @@ public:
};
typedef struct ScrollAxis {
PRInt16 mWhereToScroll;
WhenToScroll mWhenToScroll;
WhenToScroll mWhenToScroll : 16;
/**
* @param aWhere: Either a percentage or a special value.
* nsIPresShell defines:
@ -1333,7 +1334,7 @@ protected:
// has been explicitly checked. If you add any members to this class,
// please make the ownership explicit (pinkerton, scc).
// these are the same Document and PresContext owned by the DocViewer.
// These are the same Document and PresContext owned by the DocViewer.
// we must share ownership.
nsIDocument* mDocument; // [STRONG]
nsPresContext* mPresContext; // [STRONG]
@ -1353,33 +1354,10 @@ protected:
PRUint32 mPresArenaAllocCount;
#endif
// Count of the number of times this presshell has been painted to
// a window
// Count of the number of times this presshell has been painted to a window.
PRUint64 mPaintCount;
PRInt16 mSelectionFlags;
bool mStylesHaveChanged;
bool mDidInitialReflow;
bool mIsDestroying;
bool mIsReflowing;
bool mPaintingSuppressed; // For all documents we initially lock down painting.
bool mIsThemeSupportDisabled; // Whether or not form controls should use nsITheme in this shell.
bool mIsActive;
bool mFrozen;
bool mIsFirstPaint;
bool mObservesMutationsForPrint;
bool mReflowScheduled; // If true, we have a reflow
// scheduled. Guaranteed to be
// false if mReflowContinueTimer
// is non-null.
bool mSuppressInterruptibleReflows;
bool mScrollPositionClampingScrollPortSizeSet;
nsSize mScrollPositionClampingScrollPortSize;
// A list of weak frames. This is a pointer to the last item in the list.
nsWeakFrame* mWeakFrames;
@ -1387,19 +1365,42 @@ protected:
// Most recent canvas background color.
nscolor mCanvasBackgroundColor;
// Flags controlling how our document is rendered. These persist
// between paints and so are tied with retained layer pixels.
// PresShell flushes retained layers when the rendering state
// changes in a way that prevents us from being able to (usefully)
// re-use old pixels.
PRUint32 mRenderFlags;
// Used to force allocation and rendering of proportionally more or
// less pixels in the given dimension.
float mXResolution;
float mYResolution;
nsSize mScrollPositionClampingScrollPortSize;
PRInt16 mSelectionFlags;
// Flags controlling how our document is rendered. These persist
// between paints and so are tied with retained layer pixels.
// PresShell flushes retained layers when the rendering state
// changes in a way that prevents us from being able to (usefully)
// re-use old pixels.
RenderFlags mRenderFlags;
bool mStylesHaveChanged : 1;
bool mDidInitialReflow : 1;
bool mIsDestroying : 1;
bool mIsReflowing : 1;
// For all documents we initially lock down painting.
bool mPaintingSuppressed : 1;
// Whether or not form controls should use nsITheme in this shell.
bool mIsThemeSupportDisabled : 1;
bool mIsActive : 1;
bool mFrozen : 1;
bool mIsFirstPaint : 1;
bool mObservesMutationsForPrint : 1;
// If true, we have a reflow scheduled. Guaranteed to be false if
// mReflowContinueTimer is non-null.
bool mReflowScheduled : 1;
bool mSuppressInterruptibleReflows : 1;
bool mScrollPositionClampingScrollPortSizeSet : 1;
static nsIContent* gKeyDownTarget;
};

View File

@ -235,18 +235,6 @@ nsIContent* nsIPresShell::gKeyDownTarget;
nsInterfaceHashtable<nsUint32HashKey, nsIDOMTouch> nsIPresShell::gCaptureTouchList;
bool nsIPresShell::gPreventMouseEvents = false;
static PRUint32
ChangeFlag(PRUint32 aFlags, bool aOnOff, PRUint32 aFlag)
{
PRUint32 flags;
if (aOnOff) {
flags = (aFlags | aFlag);
} else {
flags = (aFlag & ~aFlag);
}
return flags;
}
// convert a color value to a string, in the CSS format #RRGGBB
// * - initially created for bugs 31816, 20760, 22963
static void ColorToString(nscolor aColor, nsAutoString &aString);

View File

@ -87,6 +87,10 @@ class ReflowCountMgr;
class nsPresShellEventCB;
class nsAutoCauseReflowNotifier;
// 250ms. This is actually pref-controlled, but we use this value if we fail
// to get the pref for any reason.
#define PAINTLOCK_EVENT_DELAY 250
class PresShell : public nsIPresShell,
public nsStubDocumentObserver,
public nsISelectionController, public nsIObserver,
@ -351,6 +355,13 @@ public:
IsLayoutFlushObserver(this);
}
void SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf,
size_t *aArenasSize,
size_t *aStyleSetsSize,
size_t *aTextRunsSize,
size_t *aPresContextSize) const;
size_t SizeOfTextRuns(nsMallocSizeOfFun aMallocSizeOf) const;
protected:
virtual ~PresShell();
@ -407,13 +418,13 @@ protected:
struct RenderingState {
RenderingState(PresShell* aPresShell)
: mRenderFlags(aPresShell->mRenderFlags)
, mXResolution(aPresShell->mXResolution)
: mXResolution(aPresShell->mXResolution)
, mYResolution(aPresShell->mYResolution)
, mRenderFlags(aPresShell->mRenderFlags)
{ }
PRUint32 mRenderFlags;
float mXResolution;
float mYResolution;
RenderFlags mRenderFlags;
};
struct AutoSaveRestoreRenderingState {
@ -432,6 +443,12 @@ protected:
PresShell* mPresShell;
RenderingState mOldState;
};
static RenderFlags ChangeFlag(RenderFlags aFlags, bool aOnOff,
eRenderFlag aFlag)
{
return aOnOff ? (aFlags | aFlag) : (aFlag & ~aFlag);
}
void SetRenderingState(const RenderingState& aState);
@ -526,58 +543,6 @@ protected:
return rv;
}
nsRefPtr<nsCSSStyleSheet> mPrefStyleSheet; // mStyleSet owns it but we
// maintain a ref, may be null
#ifdef DEBUG
PRUint32 mUpdateCount;
#endif
// reflow roots that need to be reflowed, as both a queue and a hashtable
nsTArray<nsIFrame*> mDirtyRoots;
bool mDocumentLoading;
bool mIgnoreFrameDestruction;
bool mHaveShutDown;
bool mViewportOverridden;
bool mLastRootReflowHadUnconstrainedHeight;
// This is used to protect ourselves from triggering reflow while in the
// middle of frame construction and the like... it really shouldn't be
// needed, one hopes, but it is for now.
PRUint32 mChangeNestCount;
nsIFrame* mCurrentEventFrame;
nsCOMPtr<nsIContent> mCurrentEventContent;
nsTArray<nsIFrame*> mCurrentEventFrameStack;
nsCOMArray<nsIContent> mCurrentEventContentStack;
nsCOMPtr<nsIContent> mLastAnchorScrolledTo;
nscoord mLastAnchorScrollPositionY;
nsRefPtr<nsCaret> mCaret;
nsRefPtr<nsCaret> mOriginalCaret;
#ifdef DEBUG
// The reflow root under which we're currently reflowing. Null when
// not in reflow.
nsIFrame* mCurrentReflowRoot;
#endif
// Set of frames that we should mark with NS_FRAME_HAS_DIRTY_CHILDREN after
// we finish reflowing mCurrentReflowRoot.
nsTHashtable< nsPtrHashKey<nsIFrame> > mFramesToDirty;
// Information needed to properly handle scrolling content into view if the
// pre-scroll reflow flush can be interrupted. mContentToScrollTo is
// non-null between the initial scroll attempt and the first time we finish
// processing all our dirty roots. mContentScrollVPosition and
// mContentScrollHPosition are only used when it's non-null.
nsCOMPtr<nsIContent> mContentToScrollTo;
ScrollAxis mContentScrollVAxis;
ScrollAxis mContentScrollHAxis;
PRUint32 mContentToScrollToFlags;
class nsDelayedEvent
{
public:
@ -653,58 +618,49 @@ protected:
}
};
bool mNoDelayedMouseEvents;
bool mNoDelayedKeyEvents;
nsTArray<nsAutoPtr<nsDelayedEvent> > mDelayedEvents;
// Check if aEvent is a mouse event and record the mouse location for later
// synth mouse moves.
void RecordMouseLocation(nsGUIEvent* aEvent);
class nsSynthMouseMoveEvent : public nsARefreshObserver {
public:
nsSynthMouseMoveEvent(PresShell* aPresShell, bool aFromScroll)
: mPresShell(aPresShell), mFromScroll(aFromScroll) {
NS_ASSERTION(mPresShell, "null parameter");
}
~nsSynthMouseMoveEvent() {
Revoke();
}
nsCallbackEventRequest* mFirstCallbackEventRequest;
nsCallbackEventRequest* mLastCallbackEventRequest;
NS_INLINE_DECL_REFCOUNTING(nsSynthMouseMoveEvent)
bool mIsDocumentGone; // We've been disconnected from the document.
// We will refuse to paint the document until either
// (a) our timer fires or (b) all frames are constructed.
bool mShouldUnsuppressPainting; // Indicates that it is safe to unlock painting once all pending
// reflows have been processed.
nsCOMPtr<nsITimer> mPaintSuppressionTimer; // This timer controls painting suppression. Until it fires
// or all frames are constructed, we won't paint anything but
// our <body> background and scrollbars.
#define PAINTLOCK_EVENT_DELAY 250 // 250ms. This is actually
// pref-controlled, but we use this
// value if we fail to get the pref
// for any reason.
static void sPaintSuppressionCallback(nsITimer* aTimer, void* aPresShell); // A callback for the timer.
// 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.
nsCOMPtr<nsITimer> mReflowContinueTimer;
static void sReflowContinueCallback(nsITimer* aTimer, void* aPresShell);
bool ScheduleReflowOffTimer();
#ifdef MOZ_REFLOW_PERF
ReflowCountMgr * mReflowCountMgr;
#endif
static bool sDisableNonTestMouseEvents;
private:
void Revoke() {
if (mPresShell) {
mPresShell->GetPresContext()->RefreshDriver()->
RemoveRefreshObserver(this, Flush_Display);
mPresShell = nsnull;
}
}
virtual void WillRefresh(mozilla::TimeStamp aTime) {
if (mPresShell)
mPresShell->ProcessSynthMouseMoveEvent(mFromScroll);
}
private:
PresShell* mPresShell;
bool mFromScroll;
};
void ProcessSynthMouseMoveEvent(bool aFromScroll);
void QueryIsActive();
nsresult UpdateImageLockingState();
#ifdef ANDROID
nsIDocument* GetTouchEventTargetDocument();
#endif
bool InZombieDocument(nsIContent *aContent);
already_AddRefed<nsIPresShell> GetParentPresShell();
nsIFrame* GetCurrentEventFrame();
nsresult RetargetEventToParent(nsGUIEvent* aEvent,
nsEventStatus* aEventStatus);
//helper funcs for event handling
protected:
//protected because nsPresShellEventCB needs this.
nsIFrame* GetCurrentEventFrame();
private:
void PushCurrentEventInfo(nsIFrame* aFrame, nsIContent* aContent);
void PopCurrentEventInfo();
nsresult HandleEventInternal(nsEvent* aEvent, nsEventStatus *aStatus);
@ -745,16 +701,31 @@ private:
void FireResizeEvent();
void FireBeforeResizeEvent();
static void AsyncResizeEventCallback(nsITimer* aTimer, void* aPresShell);
nsRevocableEventPtr<nsRunnableMethod<PresShell> > mResizeEvent;
nsCOMPtr<nsITimer> mAsyncResizeEventTimer;
bool mAsyncResizeTimerIsActive;
bool mInResize;
virtual void SynthesizeMouseMove(bool aFromScroll);
// Check if aEvent is a mouse event and record the mouse location for later
// synth mouse moves.
void RecordMouseLocation(nsGUIEvent* aEvent);
PresShell* GetRootPresShell();
nscolor GetDefaultBackgroundColorToDraw();
// The callback for the mPaintSuppressionTimer timer.
static void sPaintSuppressionCallback(nsITimer* aTimer, void* aPresShell);
// The callback for the mReflowContinueTimer timer.
static void sReflowContinueCallback(nsITimer* aTimer, void* aPresShell);
bool ScheduleReflowOffTimer();
#ifdef DEBUG
// The reflow root under which we're currently reflowing. Null when
// not in reflow.
nsIFrame* mCurrentReflowRoot;
PRUint32 mUpdateCount;
#endif
#ifdef MOZ_REFLOW_PERF
ReflowCountMgr* mReflowCountMgr;
#endif
// This is used for synthetic mouse events that are sent when what is under
// the mouse pointer may have changed without the mouse moving (eg scrolling,
// change to the document contents).
@ -764,53 +735,79 @@ private:
// over our window or there is no last observed mouse location for some
// reason.
nsPoint mMouseLocation;
class nsSynthMouseMoveEvent : public nsARefreshObserver {
public:
nsSynthMouseMoveEvent(PresShell* aPresShell, bool aFromScroll)
: mPresShell(aPresShell), mFromScroll(aFromScroll) {
NS_ASSERTION(mPresShell, "null parameter");
}
~nsSynthMouseMoveEvent() {
Revoke();
}
NS_INLINE_DECL_REFCOUNTING(nsSynthMouseMoveEvent)
// mStyleSet owns it but we maintain a ref, may be null
nsRefPtr<nsCSSStyleSheet> mPrefStyleSheet;
void Revoke() {
if (mPresShell) {
mPresShell->GetPresContext()->RefreshDriver()->
RemoveRefreshObserver(this, Flush_Display);
mPresShell = nsnull;
}
}
virtual void WillRefresh(mozilla::TimeStamp aTime) {
if (mPresShell)
mPresShell->ProcessSynthMouseMoveEvent(mFromScroll);
}
private:
PresShell* mPresShell;
bool mFromScroll;
};
// Set of frames that we should mark with NS_FRAME_HAS_DIRTY_CHILDREN after
// we finish reflowing mCurrentReflowRoot.
nsTHashtable<nsPtrHashKey<nsIFrame> > mFramesToDirty;
// Reflow roots that need to be reflowed.
nsTArray<nsIFrame*> mDirtyRoots;
nsTArray<nsAutoPtr<nsDelayedEvent> > mDelayedEvents;
nsRevocableEventPtr<nsRunnableMethod<PresShell> > mResizeEvent;
nsCOMPtr<nsITimer> mAsyncResizeEventTimer;
nsIFrame* mCurrentEventFrame;
nsCOMPtr<nsIContent> mCurrentEventContent;
nsTArray<nsIFrame*> mCurrentEventFrameStack;
nsCOMArray<nsIContent> mCurrentEventContentStack;
nsRevocableEventPtr<nsSynthMouseMoveEvent> mSynthMouseMoveEvent;
void ProcessSynthMouseMoveEvent(bool aFromScroll);
nsCOMPtr<nsIContent> mLastAnchorScrolledTo;
nsRefPtr<nsCaret> mCaret;
nsRefPtr<nsCaret> mOriginalCaret;
nsCallbackEventRequest* mFirstCallbackEventRequest;
nsCallbackEventRequest* mLastCallbackEventRequest;
PresShell* GetRootPresShell();
// This timer controls painting suppression. Until it fires
// or all frames are constructed, we won't paint anything but
// our <body> background and scrollbars.
nsCOMPtr<nsITimer> mPaintSuppressionTimer;
public:
// 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.
nsCOMPtr<nsITimer> mReflowContinueTimer;
void SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf,
size_t *aArenasSize,
size_t *aStyleSetsSize,
size_t *aTextRunsSize,
size_t *aPresContextSize) const;
size_t SizeOfTextRuns(nsMallocSizeOfFun aMallocSizeOf) const;
// Information needed to properly handle scrolling content into view if the
// pre-scroll reflow flush can be interrupted. mContentToScrollTo is
// non-null between the initial scroll attempt and the first time we finish
// processing all our dirty roots. mContentScrollVPosition and
// mContentScrollHPosition are only used when it's non-null.
nsCOMPtr<nsIContent> mContentToScrollTo;
ScrollAxis mContentScrollVAxis;
ScrollAxis mContentScrollHAxis;
PRUint32 mContentToScrollToFlags;
protected:
void QueryIsActive();
nsresult UpdateImageLockingState();
nscoord mLastAnchorScrollPositionY;
private:
nscolor GetDefaultBackgroundColorToDraw();
// This is used to protect ourselves from triggering reflow while in the
// middle of frame construction and the like... it really shouldn't be
// needed, one hopes, but it is for now.
PRUint16 mChangeNestCount;
bool mDocumentLoading : 1;
bool mIgnoreFrameDestruction : 1;
bool mHaveShutDown : 1;
bool mViewportOverridden : 1;
bool mLastRootReflowHadUnconstrainedHeight : 1;
bool mNoDelayedMouseEvents : 1;
bool mNoDelayedKeyEvents : 1;
// We've been disconnected from the document. We will refuse to paint the
// document until either our timer fires or all frames are constructed.
bool mIsDocumentGone : 1;
// Indicates that it is safe to unlock painting once all pending reflows
// have been processed.
bool mShouldUnsuppressPainting : 1;
bool mAsyncResizeTimerIsActive : 1;
bool mInResize : 1;
static bool sDisableNonTestMouseEvents;
};
#endif /* !defined(nsPresShell_h_) */