diff options
Diffstat (limited to 'layout/tables/nsTableFrame.h')
-rw-r--r-- | layout/tables/nsTableFrame.h | 130 |
1 files changed, 81 insertions, 49 deletions
diff --git a/layout/tables/nsTableFrame.h b/layout/tables/nsTableFrame.h index a6b786402..7fcdcb9d8 100644 --- a/layout/tables/nsTableFrame.h +++ b/layout/tables/nsTableFrame.h @@ -72,36 +72,59 @@ private: bool mDrawsBackground; }; -class nsAutoPushCurrentTableItem -{ -public: - nsAutoPushCurrentTableItem() : mBuilder(nullptr) {} +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(); + } - void Push(nsDisplayListBuilder* aBuilder, nsDisplayTableItem* aPushItem) - { - mBuilder = aBuilder; - mOldCurrentItem = aBuilder->GetCurrentTableItem(); - aBuilder->SetCurrentTableItem(aPushItem); -#ifdef DEBUG - mPushedItem = aPushItem; -#endif + ~nsDisplayTableBackgroundSet() { + mozilla::DebugOnly<nsDisplayTableBackgroundSet*> result = + mBuilder->SetTableBackgroundSet(mPrevTableBackgroundSet); + MOZ_ASSERT(result == this); } - ~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); + + /** + * 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()); } -private: + 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: nsDisplayListBuilder* mBuilder; - nsDisplayTableItem* mOldCurrentItem; -#ifdef DEBUG - nsDisplayTableItem* mPushedItem; -#endif + nsDisplayTableBackgroundSet* mPrevTableBackgroundSet; + + nsDisplayList mColGroupBackgrounds; + nsDisplayList mColBackgrounds; + + nsTArray<nsTableColFrame*> mColumns; + nsPoint mToReferenceFrame; + nsRect mDirtyRect; }; /* ============================================================================ */ @@ -229,29 +252,6 @@ 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,7 +268,6 @@ 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 @@ -761,6 +760,13 @@ 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 @@ -870,6 +876,8 @@ 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 @@ -965,6 +973,30 @@ 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 { |