diff options
Diffstat (limited to 'layout/tables/nsTableFrame.h')
-rw-r--r-- | layout/tables/nsTableFrame.h | 130 |
1 files changed, 49 insertions, 81 deletions
diff --git a/layout/tables/nsTableFrame.h b/layout/tables/nsTableFrame.h index 7fcdcb9d8..a6b786402 100644 --- a/layout/tables/nsTableFrame.h +++ b/layout/tables/nsTableFrame.h @@ -72,59 +72,36 @@ private: bool mDrawsBackground; }; -class nsDisplayTableBackgroundSet { - public: - nsDisplayList* ColGroupBackgrounds() { return &mColGroupBackgrounds; } - - nsDisplayList* ColBackgrounds() { return &mColBackgrounds; } - - nsDisplayTableBackgroundSet(nsDisplayListBuilder* aBuilder, nsIFrame* aTable) - : mBuilder(aBuilder) { - mPrevTableBackgroundSet = mBuilder->SetTableBackgroundSet(this); - mozilla::DebugOnly<const nsIFrame*> reference = - mBuilder->FindReferenceFrameFor(aTable, &mToReferenceFrame); - MOZ_ASSERT(nsLayoutUtils::IsAncestorFrameCrossDoc(reference, aTable)); - mDirtyRect = mBuilder->GetDirtyRect(); - } +class nsAutoPushCurrentTableItem +{ +public: + nsAutoPushCurrentTableItem() : mBuilder(nullptr) {} - ~nsDisplayTableBackgroundSet() { - mozilla::DebugOnly<nsDisplayTableBackgroundSet*> result = - mBuilder->SetTableBackgroundSet(mPrevTableBackgroundSet); - MOZ_ASSERT(result == this); + void Push(nsDisplayListBuilder* aBuilder, nsDisplayTableItem* aPushItem) + { + mBuilder = aBuilder; + mOldCurrentItem = aBuilder->GetCurrentTableItem(); + aBuilder->SetCurrentTableItem(aPushItem); +#ifdef DEBUG + mPushedItem = aPushItem; +#endif } - - /** - * Move all display items in our lists to top of the corresponding lists in - * the destination. - */ - void MoveTo(const nsDisplayListSet& aDestination) { - aDestination.BorderBackground()->AppendToTop(ColGroupBackgrounds()); - aDestination.BorderBackground()->AppendToTop(ColBackgrounds()); + ~nsAutoPushCurrentTableItem() { + if (!mBuilder) + return; +#ifdef DEBUG + NS_ASSERTION(mBuilder->GetCurrentTableItem() == mPushedItem, + "Someone messed with the current table item behind our back!"); +#endif + mBuilder->SetCurrentTableItem(mOldCurrentItem); } - void AddColumn(nsTableColFrame* aFrame) { mColumns.AppendElement(aFrame); } - - nsTableColFrame* GetColForIndex(int32_t aIndex) { return mColumns[aIndex]; } - - const nsPoint& TableToReferenceFrame() { return mToReferenceFrame; } - - const nsRect& GetDirtyRect() { return mDirtyRect; } - - private: - // This class is only used on stack, so we don't have to worry about leaking - // it. Don't let us be heap-allocated! - void* operator new(size_t sz) CPP_THROW_NEW; - - protected: +private: nsDisplayListBuilder* mBuilder; - nsDisplayTableBackgroundSet* mPrevTableBackgroundSet; - - nsDisplayList mColGroupBackgrounds; - nsDisplayList mColBackgrounds; - - nsTArray<nsTableColFrame*> mColumns; - nsPoint mToReferenceFrame; - nsRect mDirtyRect; + nsDisplayTableItem* mOldCurrentItem; +#ifdef DEBUG + nsDisplayTableItem* mPushedItem; +#endif }; /* ============================================================================ */ @@ -252,6 +229,29 @@ public: nsIFrame* aSourceFrame, bool* aDidPassThrough); + typedef void (* DisplayGenericTablePartTraversal) + (nsDisplayListBuilder* aBuilder, nsFrame* aFrame, + const nsRect& aDirtyRect, const nsDisplayListSet& aLists); + static void GenericTraversal(nsDisplayListBuilder* aBuilder, nsFrame* aFrame, + const nsRect& aDirtyRect, const nsDisplayListSet& aLists); + + /** + * Helper method to handle display common to table frames, rowgroup frames + * and row frames. It creates a background display item for handling events + * if necessary, an outline display item if necessary, and displays + * all the the frame's children. + * @param aDisplayItem the display item created for this part, or null + * if this part's border/background painting is delegated to an ancestor + * @param aTraversal a function that gets called to traverse the table + * part's child frames and add their display list items to a + * display list set. + */ + static void DisplayGenericTablePart(nsDisplayListBuilder* aBuilder, + nsFrame* aFrame, + const nsRect& aDirtyRect, + const nsDisplayListSet& aLists, + DisplayGenericTablePartTraversal aTraversal = GenericTraversal); + // Return the closest sibling of aPriorChildFrame (including aPriroChildFrame) // of type aChildType. static nsIFrame* GetFrameAtOrBefore(nsIFrame* aParentFrame, @@ -268,6 +268,7 @@ public: virtual void GetChildLists(nsTArray<ChildList>* aLists) const override; virtual void BuildDisplayList(nsDisplayListBuilder* aBuilder, + const nsRect& aDirtyRect, const nsDisplayListSet& aLists) override; /** Get the outer half (i.e., the part outside the height and width of @@ -760,13 +761,6 @@ public: bool NeedToCollapse() const; void SetNeedToCollapse(bool aValue); - bool NeedToCalcHasBCBorders() const; - void SetNeedToCalcHasBCBorders(bool aValue); - - void CalcHasBCBorders(); - bool HasBCBorders(); - void SetHasBCBorders(bool aValue); - /** The GeometryDirty bit is similar to the NS_FRAME_IS_DIRTY frame * state bit, which implies that all descendants are dirty. The * GeometryDirty still implies that all the parts of the table are @@ -876,8 +870,6 @@ protected: uint32_t mIStartContBCBorder:8; uint32_t mNeedToCollapse:1; // rows, cols that have visibility:collapse need to be collapsed uint32_t mResizedColumns:1; // have we resized columns since last reflow? - uint32_t mNeedToCalcHasBCBorders:1; - uint32_t mHasBCBorders:1; } mBits; nsTableCellMap* mCellMap; // maintains the relationships between rows, cols, and cells @@ -973,30 +965,6 @@ inline void nsTableFrame::SetNeedToCalcBCBorders(bool aValue) mBits.mNeedToCalcBCBorders = (unsigned)aValue; } -inline bool nsTableFrame::NeedToCalcHasBCBorders() const -{ - return (bool)mBits.mNeedToCalcHasBCBorders; -} - -inline void nsTableFrame::SetNeedToCalcHasBCBorders(bool aValue) -{ - mBits.mNeedToCalcHasBCBorders = (unsigned)aValue; -} - -inline bool nsTableFrame::HasBCBorders() -{ - if (NeedToCalcHasBCBorders()) { - CalcHasBCBorders(); - SetNeedToCalcHasBCBorders(false); - } - return (bool)mBits.mHasBCBorders; -} - -inline void nsTableFrame::SetHasBCBorders(bool aValue) -{ - mBits.mHasBCBorders = (unsigned)aValue; -} - inline nscoord nsTableFrame::GetContinuousIStartBCBorderWidth() const { |