Bug 1312130 - Remove nsDisplayMathMLCharBackground and use nsDisplayBackgroundColor / Image instead. r=mattwoodrow

MozReview-Commit-ID: 4htHnUIGyk3

--HG--
extra : rebase_source : d3959d1f8084c0ab73aa56d179a277ec1516ad4a
This commit is contained in:
Markus Stange 2016-10-21 21:13:28 -04:00
parent 26c4807cbe
commit c143496596
4 changed files with 11 additions and 73 deletions

View File

@ -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)

View File

@ -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();
}

View File

@ -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,

View File

@ -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<const nsDisplayItemGenericImageGeometry*>(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