Bug 492520 - Optimize some Frame classes for memory usage; r+sr=roc

This commit is contained in:
Arpad Borsos 2009-05-12 12:13:09 +02:00
Родитель 1b90a2a7a4
Коммит 746f18df96
16 изменённых файлов: 181 добавлений и 176 удалений

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

@ -112,13 +112,13 @@ protected:
void GetLoadGroup(nsPresContext *aPresContext, nsILoadGroup **aLoadGroup);
PRInt32 mOrdinal;
nsMargin mPadding;
nsCOMPtr<imgIRequest> mImageRequest;
nsCOMPtr<imgIDecoderObserver> mListener;
nsSize mIntrinsicSize;
nsSize mComputedSize;
PRInt32 mOrdinal;
PRBool mTextIsRTL;
};

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

@ -164,16 +164,16 @@ protected:
virtual nscoord GetIntrinsicWidth();
virtual nscoord GetIntrinsicHeight();
// the prev and next neighbors are indexes into the row (for a horizontal border) or col (for
// a vertical border) of nsHTMLFramesetFrames or nsHTMLFrames
PRInt32 mPrevNeighbor;
PRInt32 mNextNeighbor;
nscolor mColor;
PRInt32 mWidth;
PRPackedBool mVertical;
PRPackedBool mVisibility;
PRPackedBool mVisibilityOverride;
nscolor mColor;
// the prev and next neighbors are indexes into the row (for a horizontal border) or col (for
// a vertical border) of nsHTMLFramesetFrames or nsHTMLFrames
PRInt32 mPrevNeighbor;
PRInt32 mNextNeighbor;
PRBool mCanResize;
PRPackedBool mCanResize;
friend class nsHTMLFramesetFrame;
};
/*******************************************************************************

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

@ -80,11 +80,11 @@ enum nsFrameborder {
};
struct nsFramesetDrag {
PRBool mVertical; // vertical if true, otherwise horizontal
nsHTMLFramesetFrame* mSource; // frameset whose border was dragged to cause the resize
PRInt32 mIndex; // index of left col or top row of effected area
PRInt32 mChange; // pos for left to right or top to bottom, neg otherwise
nsHTMLFramesetFrame* mSource; // frameset whose border was dragged to cause the resize
PRBool mActive;
PRPackedBool mVertical; // vertical if true, otherwise horizontal
PRPackedBool mActive;
nsFramesetDrag();
nsFramesetDrag(PRBool aVertical,
@ -238,34 +238,31 @@ protected:
static int FrameResizePrefCallback(const char* aPref, void* aClosure);
nsFramesetDrag mDrag;
nsBorderColor mEdgeColors;
nsHTMLFramesetBorderFrame* mDragger;
nsHTMLFramesetFrame* mTopLevelFrameset;
nsHTMLFramesetBorderFrame** mVerBorders; // vertical borders
nsHTMLFramesetBorderFrame** mHorBorders; // horizontal borders
PRInt32* mChildTypes; // frameset/frame distinction of children
nsFrameborder* mChildFrameborder; // the frameborder attr of children
nsBorderColor* mChildBorderColors;
nscoord* mRowSizes; // currently computed row sizes
nscoord* mColSizes; // currently computed col sizes
nsIntPoint mFirstDragPoint;
PRInt32 mNumRows;
nscoord* mRowSizes; // currently computed row sizes
PRInt32 mNumCols;
nscoord* mColSizes; // currently computed col sizes
PRInt32 mNonBorderChildCount;
PRInt32 mNonBlankChildCount;
PRInt32 mEdgeVisibility;
nsBorderColor mEdgeColors;
nsFrameborder mParentFrameborder;
nscolor mParentBorderColor;
PRInt32 mParentBorderWidth;
nsHTMLFramesetBorderFrame* mDragger;
nsFramesetDrag mDrag;
nsIntPoint mFirstDragPoint;
PRInt32 mPrevNeighborOrigSize; // used during resize
PRInt32 mNextNeighborOrigSize;
PRInt32 mMinDrag;
PRInt32 mChildCount;
nsHTMLFramesetFrame* mTopLevelFrameset;
nsHTMLFramesetBorderFrame** mVerBorders; // vertical borders
nsHTMLFramesetBorderFrame** mHorBorders; // horizontal borders
PRInt32* mChildTypes; // frameset/frame distinction of children
nsFrameborder* mChildFrameborder; // the frameborder attr of children
nsBorderColor* mChildBorderColors;
PRBool mForceFrameResizability;
PRBool mForceFrameResizability;
};
#endif

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

@ -149,28 +149,30 @@ protected:
void SetPageNumberFormat(PRUnichar * aFormatStr, PRBool aForPageNumOnly);
nsMargin mMargin;
PRBool mIsPrintingSelection;
// Asynch Printing
PRInt32 mPageNum;
PRInt32 mTotalPages;
nsIFrame * mCurrentPageFrame;
PRPackedBool mDoingPageRange;
PRInt32 mPrintRangeType;
PRInt32 mFromPageNum;
PRInt32 mToPageNum;
PRPackedBool mPrintThisPage;
// I18N date formatter service which we'll want to cache locally.
nsCOMPtr<nsIDateTimeFormat> mDateFormatter;
nsSize mSize;
nsSharedPageData* mPageData; // data shared by all the nsPageFrames
// Asynch Printing
nsIFrame * mCurrentPageFrame;
PRInt32 mPageNum;
PRInt32 mTotalPages;
PRInt32 mPrintRangeType;
PRInt32 mFromPageNum;
PRInt32 mToPageNum;
// Selection Printing Info
nscoord mSelectionHeight;
nscoord mYSelOffset;
// I18N date formatter service which we'll want to cache locally.
nsCOMPtr<nsIDateTimeFormat> mDateFormatter;
// Asynch Printing
PRPackedBool mPrintThisPage;
PRPackedBool mDoingPageRange;
PRPackedBool mIsPrintingSelection;
};
#endif /* nsSimplePageSequence_h___ */

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

@ -299,6 +299,18 @@ protected:
nsTableColFrame(nsStyleContext* aContext);
~nsTableColFrame();
nscoord mMinCoord;
nscoord mPrefCoord;
nscoord mSpanMinCoord; // XXX...
nscoord mSpanPrefCoord; // XXX...
float mPrefPercent;
float mSpanPrefPercent; // XXX...
// ...XXX the four members marked above could be allocated as part of
// a separate array allocated only during
// BasicTableLayoutStrategy::ComputeColumnIntrinsicWidths (and only
// when colspans were present).
nscoord mFinalWidth;
// the index of the column with respect to the whole tabble (starting at 0)
// it should never be smaller then the start column index of the parent
// colgroup
@ -312,17 +324,6 @@ protected:
BCPixelSize mBottomContBorderWidth;
PRPackedBool mHasSpecifiedCoord;
nscoord mMinCoord;
nscoord mPrefCoord;
nscoord mSpanMinCoord; // XXX...
nscoord mSpanPrefCoord; // XXX...
float mPrefPercent;
float mSpanPrefPercent; // XXX...
// ...XXX the four members marked above could be allocated as part of
// a separate array allocated only during
// BasicTableLayoutStrategy::ComputeColumnIntrinsicWidths (and only
// when colspans were present).
nscoord mFinalWidth;
};
inline PRInt32 nsTableColFrame::GetColIndex() const

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

@ -182,10 +182,10 @@ nsImageBoxFrame::AttributeChanged(PRInt32 aNameSpaceID,
nsImageBoxFrame::nsImageBoxFrame(nsIPresShell* aShell, nsStyleContext* aContext):
nsLeafBoxFrame(aShell, aContext),
mUseSrcAttr(PR_FALSE),
mSuppressStyleCheck(PR_FALSE),
mIntrinsicSize(0,0),
mLoadFlags(nsIRequest::LOAD_NORMAL)
mLoadFlags(nsIRequest::LOAD_NORMAL),
mUseSrcAttr(PR_FALSE),
mSuppressStyleCheck(PR_FALSE)
{
MarkIntrinsicWidthsDirty();
}

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

@ -138,18 +138,17 @@ protected:
private:
nsRect mSubRect; ///< If set, indicates that only the portion of the image specified by the rect should be used.
nsSize mIntrinsicSize;
nsSize mImageSize;
nsCOMPtr<imgIRequest> mImageRequest;
nsCOMPtr<imgIDecoderObserver> mListener;
PRPackedBool mUseSrcAttr; ///< Whether or not the image src comes from an attribute.
PRPackedBool mSuppressStyleCheck;
nsRect mSubRect; ///< If set, indicates that only the portion of the image specified by the rect should be used.
nsSize mIntrinsicSize;
PRInt32 mLoadFlags;
nsSize mImageSize;
PRPackedBool mUseSrcAttr; ///< Whether or not the image src comes from an attribute.
PRPackedBool mSuppressStyleCheck;
}; // class nsImageBoxFrame
#endif /* nsImageBoxFrame_h___ */

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

@ -173,22 +173,22 @@ nsListBoxBodyFrame::nsListBoxBodyFrame(nsIPresShell* aPresShell,
nsStyleContext* aContext,
nsIBoxLayout* aLayoutManager)
: nsBoxFrame(aPresShell, aContext, PR_FALSE, aLayoutManager),
mRowCount(-1),
mRowHeight(0),
mRowHeightWasSet(PR_FALSE),
mAvailableHeight(0),
mStringWidth(-1),
mTopFrame(nsnull),
mBottomFrame(nsnull),
mLinkupFrame(nsnull),
mScrollSmoother(nsnull),
mRowsToPrepend(0),
mRowCount(-1),
mRowHeight(0),
mAvailableHeight(0),
mStringWidth(-1),
mCurrentIndex(0),
mOldIndex(0),
mYPosition(0),
mTimePerRow(TIME_PER_ROW_INITAL),
mRowHeightWasSet(PR_FALSE),
mScrolling(PR_FALSE),
mAdjustScroll(PR_FALSE),
mYPosition(0),
mScrollSmoother(nsnull),
mTimePerRow(TIME_PER_ROW_INITAL),
mReflowCallbackPosted(PR_FALSE)
{
}

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

@ -190,33 +190,37 @@ protected:
void ComputeTotalRowCount();
void RemoveChildFrame(nsBoxLayoutState &aState, nsIFrame *aChild);
// row height
PRInt32 mRowCount;
nscoord mRowHeight;
PRPackedBool mRowHeightWasSet;
nscoord mAvailableHeight;
nscoord mStringWidth;
nsTArray< nsRefPtr<nsPositionChangedEvent> > mPendingPositionChangeEvents;
nsCOMPtr<nsPIBoxObject> mBoxObject;
// frame markers
nsWeakFrame mTopFrame;
nsIFrame* mBottomFrame;
nsIFrame* mLinkupFrame;
nsListScrollSmoother* mScrollSmoother;
PRInt32 mRowsToPrepend;
// row height
PRInt32 mRowCount;
nscoord mRowHeight;
nscoord mAvailableHeight;
nscoord mStringWidth;
// scrolling
PRInt32 mCurrentIndex; // Row-based
PRInt32 mOldIndex;
PRPackedBool mScrolling;
PRPackedBool mAdjustScroll;
PRInt32 mYPosition;
nsListScrollSmoother* mScrollSmoother;
PRInt32 mTimePerRow;
nsTArray< nsRefPtr<nsPositionChangedEvent> > mPendingPositionChangeEvents;
// row height
PRPackedBool mRowHeightWasSet;
// scrolling
PRPackedBool mScrolling;
PRPackedBool mAdjustScroll;
PRPackedBool mReflowCallbackPosted;
nsCOMPtr<nsPIBoxObject> mBoxObject;
};
};
#endif // nsListBoxBodyFrame_h

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

@ -106,10 +106,11 @@ NS_NewMenuPopupFrame(nsIPresShell* aPresShell, nsStyleContext* aContext)
nsMenuPopupFrame::nsMenuPopupFrame(nsIPresShell* aShell, nsStyleContext* aContext)
:nsBoxFrame(aShell, aContext),
mCurrentMenu(nsnull),
mPopupAlignment(POPUPALIGNMENT_NONE),
mPopupAnchor(POPUPALIGNMENT_NONE),
mPrefSize(-1, -1),
mPopupType(ePopupTypePanel),
mPopupState(ePopupClosed),
mPopupAlignment(POPUPALIGNMENT_NONE),
mPopupAnchor(POPUPALIGNMENT_NONE),
mIsOpenChanged(PR_FALSE),
mIsContextMenu(PR_FALSE),
mAdjustOffsetForContextMenu(PR_FALSE),
@ -117,8 +118,7 @@ nsMenuPopupFrame::nsMenuPopupFrame(nsIPresShell* aShell, nsStyleContext* aContex
mMenuCanOverlapOSBar(PR_FALSE),
mShouldAutoPosition(PR_TRUE),
mConsumeRollupEvent(nsIPopupBoxObject::ROLLUP_DEFAULT),
mInContentShell(PR_TRUE),
mPrefSize(-1, -1)
mInContentShell(PR_TRUE)
{
if (sDefaultLevelParent >= 0)
return;

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

@ -330,15 +330,22 @@ protected:
// Move the popup to the position specified in its |left| and |top| attributes.
void MoveToAttributePosition();
nsString mIncrementalString; // for incremental typing navigation
// the content that the popup is anchored to, if any, which may be in a
// different document than the popup.
nsCOMPtr<nsIContent> mAnchorContent;
nsMenuFrame* mCurrentMenu; // The current menu that is active.
// popup alignment relative to the anchor node
PRInt8 mPopupAlignment;
PRInt8 mPopupAnchor;
// A popup's preferred size may be different than its actual size stored in
// mRect in the case where the popup was resized because it was too large
// for the screen. The preferred size mPrefSize holds the full size the popup
// would be before resizing. Computations are performed using this size.
// The parent frame is responsible for setting the preferred size using
// SetPreferredBounds or SetPreferredSize before positioning the popup with
// SetPopupPosition.
nsSize mPrefSize;
// the position of the popup. The screen coordinates, if set to values other
// than -1, override mXPos and mYPos.
@ -350,6 +357,10 @@ protected:
nsPopupType mPopupType; // type of popup
nsPopupState mPopupState; // open state of the popup
// popup alignment relative to the anchor node
PRInt8 mPopupAlignment;
PRInt8 mPopupAnchor;
PRPackedBool mIsOpenChanged; // true if the open state changed since the last layout
PRPackedBool mIsContextMenu; // true for context menus
// true if we need to offset the popup to ensure it's not under the mouse
@ -361,17 +372,6 @@ protected:
PRPackedBool mConsumeRollupEvent; // Should the rollup event be consumed?
PRPackedBool mInContentShell; // True if the popup is in a content shell
nsString mIncrementalString; // for incremental typing navigation
// A popup's preferred size may be different than its actual size stored in
// mRect in the case where the popup was resized because it was too large
// for the screen. The preferred size mPrefSize holds the full size the popup
// would be before resizing. Computations are performed using this size.
// The parent frame is responsible for setting the preferred size using
// SetPreferredBounds or SetPreferredSize before positioning the popup with
// SetPopupPosition.
nsSize mPrefSize;
static PRInt8 sDefaultLevelParent;
}; // class nsMenuPopupFrame

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

@ -232,6 +232,9 @@ private:
(static_cast<nsSliderFrame*>(aData))->Notify();
}
nsPoint mDestinationPoint;
nsRefPtr<nsSliderMediator> mMediator;
float mRatio;
nscoord mDragStart;
@ -240,8 +243,6 @@ private:
PRInt32 mCurPos;
nscoord mChange;
nsPoint mDestinationPoint;
nsRefPtr<nsSliderMediator> mMediator;
// true if an attribute change has been caused by the user manipulating the
// slider. This allows notifications to tell how a slider's current position

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

@ -139,7 +139,7 @@ nsTextBoxFrame::AttributeChanged(PRInt32 aNameSpaceID,
}
nsTextBoxFrame::nsTextBoxFrame(nsIPresShell* aShell, nsStyleContext* aContext):
nsLeafBoxFrame(aShell, aContext), mCropType(CropRight), mAccessKeyInfo(nsnull),
nsLeafBoxFrame(aShell, aContext), mAccessKeyInfo(nsnull), mCropType(CropRight),
mNeedsReflowCallback(PR_FALSE)
{
mState |= NS_STATE_NEED_LAYOUT;

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

@ -137,17 +137,17 @@ private:
const nscolor& aForegroundColor,
const nsRect& aDirtyRect);
CroppingStyle mCropType;
nsString mTitle;
nsString mCroppedTitle;
nsString mAccessKey;
nscoord mTitleWidth;
nsSize mTextSize;
nsAccessKeyInfo* mAccessKeyInfo;
CroppingStyle mCropType;
nscoord mTitleWidth;
nscoord mAscent;
PRPackedBool mNeedsRecalc;
PRPackedBool mNeedsReflowCallback;
nsSize mTextSize;
nscoord mAscent;
static PRBool gAlwaysAppendAccessKey;
static PRBool gAccessKeyPrefInitialized;

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

@ -144,22 +144,22 @@ NS_QUERYFRAME_TAIL_INHERITING(nsLeafBoxFrame)
// Constructor
nsTreeBodyFrame::nsTreeBodyFrame(nsIPresShell* aPresShell, nsStyleContext* aContext)
:nsLeafBoxFrame(aPresShell, aContext),
mTopRowIndex(0),
mSlots(nsnull),
mTopRowIndex(0),
mHorzPosition(0),
mHorzWidth(0),
mAdjustWidth(0),
mRowHeight(0),
mIndentation(0),
mStringWidth(-1),
mUpdateBatchNest(0),
mRowCount(0),
mMouseOverRow(-1),
mFocused(PR_FALSE),
mHasFixedRowCount(PR_FALSE),
mVerticalOverflow(PR_FALSE),
mHorizontalOverflow(PR_FALSE),
mReflowCallbackPosted(PR_FALSE),
mUpdateBatchNest(0),
mRowCount(0),
mMouseOverRow(-1),
mSlots(nsnull)
mReflowCallbackPosted(PR_FALSE)
{
mColumns = new nsTreeColumns(nsnull);
NS_NewISupportsArray(getter_AddRefs(mScratchArray));

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

@ -493,70 +493,6 @@ protected:
#endif
protected: // Data Members
// The cached box object parent.
nsCOMPtr<nsITreeBoxObject> mTreeBoxObject;
// Cached column information.
nsRefPtr<nsTreeColumns> mColumns;
// The current view for this tree widget. We get all of our row and cell data
// from the view.
nsCOMPtr<nsITreeView> mView;
// A cache of all the style contexts we have seen for rows and cells of the tree. This is a mapping from
// a list of atoms to a corresponding style context. This cache stores every combination that
// occurs in the tree, so for n distinct properties, this cache could have 2 to the n entries
// (the power set of all row properties).
nsTreeStyleCache mStyleCache;
// A hashtable that maps from URLs to image request/listener pairs. The URL
// is provided by the view or by the style context. The style context
// represents a resolved :-moz-tree-cell-image (or twisty) pseudo-element.
// It maps directly to an imgIRequest.
nsDataHashtable<nsStringHashKey, nsTreeImageCacheEntry> mImageCache;
// The index of the first visible row and the # of rows visible onscreen.
// The tree only examines onscreen rows, starting from
// this index and going up to index+pageLength.
PRInt32 mTopRowIndex;
PRInt32 mPageLength;
// The horizontal scroll position
nscoord mHorzPosition;
// Our desired horizontal width (the width for which we actually have tree
// columns).
nscoord mHorzWidth;
// The amount by which to adjust the width of the last cell.
// This depends on whether or not the columnpicker and scrollbars are present.
nscoord mAdjustWidth;
// Cached heights and indent info.
nsRect mInnerBox;
PRInt32 mRowHeight;
PRInt32 mIndentation;
nscoord mStringWidth;
// A scratch array used when looking up cached style contexts.
nsCOMPtr<nsISupportsArray> mScratchArray;
// Whether or not we're currently focused.
PRPackedBool mFocused;
// Do we have a fixed number of onscreen rows?
PRPackedBool mHasFixedRowCount;
PRPackedBool mVerticalOverflow;
PRPackedBool mHorizontalOverflow;
PRPackedBool mReflowCallbackPosted;
PRInt32 mUpdateBatchNest;
// Cached row count.
PRInt32 mRowCount;
// The row the mouse is hovering over.
PRInt32 mMouseOverRow;
class Slots {
public:
@ -598,6 +534,71 @@ protected: // Data Members
Slots* mSlots;
nsRevocableEventPtr<ScrollEvent> mScrollEvent;
// The cached box object parent.
nsCOMPtr<nsITreeBoxObject> mTreeBoxObject;
// Cached column information.
nsRefPtr<nsTreeColumns> mColumns;
// The current view for this tree widget. We get all of our row and cell data
// from the view.
nsCOMPtr<nsITreeView> mView;
// A cache of all the style contexts we have seen for rows and cells of the tree. This is a mapping from
// a list of atoms to a corresponding style context. This cache stores every combination that
// occurs in the tree, so for n distinct properties, this cache could have 2 to the n entries
// (the power set of all row properties).
nsTreeStyleCache mStyleCache;
// A hashtable that maps from URLs to image request/listener pairs. The URL
// is provided by the view or by the style context. The style context
// represents a resolved :-moz-tree-cell-image (or twisty) pseudo-element.
// It maps directly to an imgIRequest.
nsDataHashtable<nsStringHashKey, nsTreeImageCacheEntry> mImageCache;
// A scratch array used when looking up cached style contexts.
nsCOMPtr<nsISupportsArray> mScratchArray;
// The index of the first visible row and the # of rows visible onscreen.
// The tree only examines onscreen rows, starting from
// this index and going up to index+pageLength.
PRInt32 mTopRowIndex;
PRInt32 mPageLength;
// The horizontal scroll position
nscoord mHorzPosition;
// Our desired horizontal width (the width for which we actually have tree
// columns).
nscoord mHorzWidth;
// The amount by which to adjust the width of the last cell.
// This depends on whether or not the columnpicker and scrollbars are present.
nscoord mAdjustWidth;
// Cached heights and indent info.
nsRect mInnerBox; // 4-byte aligned
PRInt32 mRowHeight;
PRInt32 mIndentation;
nscoord mStringWidth;
PRInt32 mUpdateBatchNest;
// Cached row count.
PRInt32 mRowCount;
// The row the mouse is hovering over.
PRInt32 mMouseOverRow;
// Whether or not we're currently focused.
PRPackedBool mFocused;
// Do we have a fixed number of onscreen rows?
PRPackedBool mHasFixedRowCount;
PRPackedBool mVerticalOverflow;
PRPackedBool mHorizontalOverflow;
PRPackedBool mReflowCallbackPosted;
}; // class nsTreeBodyFrame
#endif