From c143496596208a6489e5aff311bd84c248aa4fe4 Mon Sep 17 00:00:00 2001 From: Markus Stange Date: Fri, 21 Oct 2016 21:13:28 -0400 Subject: [PATCH] Bug 1312130 - Remove nsDisplayMathMLCharBackground and use nsDisplayBackgroundColor / Image instead. r=mattwoodrow MozReview-Commit-ID: 4htHnUIGyk3 --HG-- extra : rebase_source : d3959d1f8084c0ab73aa56d179a277ec1516ad4a --- layout/base/nsDisplayItemTypesList.h | 1 - layout/base/nsDisplayList.cpp | 9 ++-- layout/base/nsDisplayList.h | 3 +- layout/mathml/nsMathMLChar.cpp | 71 ++-------------------------- 4 files changed, 11 insertions(+), 73 deletions(-) diff --git a/layout/base/nsDisplayItemTypesList.h b/layout/base/nsDisplayItemTypesList.h index a5308bff021a..9865395a7912 100644 --- a/layout/base/nsDisplayItemTypesList.h +++ b/layout/base/nsDisplayItemTypesList.h @@ -84,7 +84,6 @@ DECLARE_DISPLAY_ITEM_TYPE(XUL_DEBUG) #endif DECLARE_DISPLAY_ITEM_TYPE(MATHML_BAR) -DECLARE_DISPLAY_ITEM_TYPE(MATHML_CHAR_BACKGROUND) DECLARE_DISPLAY_ITEM_TYPE(MATHML_CHAR_FOREGROUND) DECLARE_DISPLAY_ITEM_TYPE(MATHML_ERROR) DECLARE_DISPLAY_ITEM_TYPE(MATHML_MENCLOSE_NOTATION) diff --git a/layout/base/nsDisplayList.cpp b/layout/base/nsDisplayList.cpp index 318e592eb180..3d6b222ca187 100644 --- a/layout/base/nsDisplayList.cpp +++ b/layout/base/nsDisplayList.cpp @@ -2596,15 +2596,18 @@ nsDisplayBackgroundImage::AppendBackgroundItemsToTop(nsDisplayListBuilder* aBuil nsIFrame* aFrame, const nsRect& aBackgroundRect, nsDisplayList* aList, - bool aAllowWillPaintBorderOptimization) + bool aAllowWillPaintBorderOptimization, + nsStyleContext* aStyleContext) { - nsStyleContext* bgSC = nullptr; + nsStyleContext* bgSC = aStyleContext; const nsStyleBackground* bg = nullptr; nsRect bgRect = aBackgroundRect + aBuilder->ToReferenceFrame(aFrame); nsPresContext* presContext = aFrame->PresContext(); bool isThemed = aFrame->IsThemed(); if (!isThemed) { - bgSC = GetBackgroundStyleContext(aFrame); + if (!bgSC) { + bgSC = GetBackgroundStyleContext(aFrame); + } if (bgSC) { bg = bgSC->StyleBackground(); } diff --git a/layout/base/nsDisplayList.h b/layout/base/nsDisplayList.h index 9b7492293e64..886375d63020 100644 --- a/layout/base/nsDisplayList.h +++ b/layout/base/nsDisplayList.h @@ -2734,7 +2734,8 @@ public: nsIFrame* aFrame, const nsRect& aBackgroundRect, nsDisplayList* aList, - bool aAllowWillPaintBorderOptimization = true); + bool aAllowWillPaintBorderOptimization = true, + nsStyleContext* aStyleContext = nullptr); virtual LayerState GetLayerState(nsDisplayListBuilder* aBuilder, LayerManager* aManager, diff --git a/layout/mathml/nsMathMLChar.cpp b/layout/mathml/nsMathMLChar.cpp index 2edc1fa0d978..5ed95c473305 100644 --- a/layout/mathml/nsMathMLChar.cpp +++ b/layout/mathml/nsMathMLChar.cpp @@ -1860,71 +1860,6 @@ void nsDisplayMathMLSelectionRect::Paint(nsDisplayListBuilder* aBuilder, drawTarget->FillRect(rect, ColorPattern(ToDeviceColor(bgColor))); } -class nsDisplayMathMLCharBackground : public nsDisplayItem { -public: - nsDisplayMathMLCharBackground(nsDisplayListBuilder* aBuilder, - nsIFrame* aFrame, const nsRect& aRect, - nsStyleContext* aStyleContext) - : nsDisplayItem(aBuilder, aFrame), mStyleContext(aStyleContext), - mRect(aRect) { - MOZ_COUNT_CTOR(nsDisplayMathMLCharBackground); - } -#ifdef NS_BUILD_REFCNT_LOGGING - virtual ~nsDisplayMathMLCharBackground() { - MOZ_COUNT_DTOR(nsDisplayMathMLCharBackground); - } -#endif - - virtual nsDisplayItemGeometry* AllocateGeometry(nsDisplayListBuilder* aBuilder) override; - virtual void ComputeInvalidationRegion(nsDisplayListBuilder* aBuilder, - const nsDisplayItemGeometry* aGeometry, - nsRegion *aInvalidRegion) override; - virtual void Paint(nsDisplayListBuilder* aBuilder, - nsRenderingContext* aCtx) override; - NS_DISPLAY_DECL_NAME("MathMLCharBackground", TYPE_MATHML_CHAR_BACKGROUND) -private: - nsStyleContext* mStyleContext; - nsRect mRect; -}; - -nsDisplayItemGeometry* -nsDisplayMathMLCharBackground::AllocateGeometry(nsDisplayListBuilder* aBuilder) -{ - return new nsDisplayItemGenericImageGeometry(this, aBuilder); -} - -void -nsDisplayMathMLCharBackground::ComputeInvalidationRegion(nsDisplayListBuilder* aBuilder, - const nsDisplayItemGeometry* aGeometry, - nsRegion *aInvalidRegion) -{ - auto geometry = - static_cast(aGeometry); - - if (aBuilder->ShouldSyncDecodeImages() && - geometry->ShouldInvalidateToSyncDecodeImages()) { - bool snap; - aInvalidRegion->Or(*aInvalidRegion, GetBounds(aBuilder, &snap)); - } - - nsDisplayItem::ComputeInvalidationRegion(aBuilder, aGeometry, aInvalidRegion); -} - -void nsDisplayMathMLCharBackground::Paint(nsDisplayListBuilder* aBuilder, - nsRenderingContext* aCtx) -{ - const nsStyleBorder* border = mStyleContext->StyleBorder(); - nsRect rect(mRect + ToReferenceFrame()); - nsCSSRendering::PaintBGParams params = - nsCSSRendering::PaintBGParams::ForAllLayers(*mFrame->PresContext(), *aCtx, - mVisibleRect, rect, mFrame, - aBuilder->GetBackgroundPaintFlags()); - DrawResult result = - nsCSSRendering::PaintBackgroundWithSC(params, mStyleContext, *border); - - nsDisplayItemGenericImageGeometry::UpdateDrawResult(this, result); -} - class nsDisplayMathMLCharForeground : public nsDisplayItem { public: nsDisplayMathMLCharForeground(nsDisplayListBuilder* aBuilder, @@ -2058,9 +1993,9 @@ nsMathMLChar::Display(nsDisplayListBuilder* aBuilder, const nsStyleBackground* backg = styleContext->StyleBackground(); if (styleContext != parentContext && NS_GET_A(backg->mBackgroundColor) > 0) { - aLists.BorderBackground()->AppendNewToTop(new (aBuilder) - nsDisplayMathMLCharBackground(aBuilder, aForFrame, mRect, - styleContext)); + nsDisplayBackgroundImage::AppendBackgroundItemsToTop( + aBuilder, aForFrame, mRect, aLists.BorderBackground(), + /* aAllowWillPaintBorderOptimization */ true, styleContext); } //else // our container frame will take care of painting its background