Bug 1388614 - Make sure MathML display items are unique. r=karlt

FrameLayerBuilder requires the the (frame,per-frame-key) for each display item is unique. It only enforces this in certain situations though, so there's cases where we've gotten away without this.

Retained display lists introduces more situations where we rely on this, so I've found a few.

MathML nsDisplayNotation and nsDisplayMathMLBar are the two fixed by this patch.
This commit is contained in:
Matt Woodrow
2017-08-10 23:26:42 +12:00
parent 8370362323
commit adbcc9920a
5 changed files with 70 additions and 53 deletions

View File

@@ -328,8 +328,8 @@ nsMathMLFrame::DisplayBoundingMetrics(nsDisplayListBuilder* aBuilder,
class nsDisplayMathMLBar : public nsDisplayItem {
public:
nsDisplayMathMLBar(nsDisplayListBuilder* aBuilder,
nsIFrame* aFrame, const nsRect& aRect)
: nsDisplayItem(aBuilder, aFrame), mRect(aRect) {
nsIFrame* aFrame, const nsRect& aRect, uint32_t aIndex)
: nsDisplayItem(aBuilder, aFrame), mRect(aRect), mIndex(aIndex) {
MOZ_COUNT_CTOR(nsDisplayMathMLBar);
}
#ifdef NS_BUILD_REFCNT_LOGGING
@@ -338,11 +338,16 @@ public:
}
#endif
virtual uint32_t GetPerFrameKey() override {
return (mIndex << TYPE_BITS) | nsDisplayItem::GetPerFrameKey();
}
virtual void Paint(nsDisplayListBuilder* aBuilder,
gfxContext* aCtx) override;
NS_DISPLAY_DECL_NAME("MathMLBar", TYPE_MATHML_BAR)
private:
nsRect mRect;
uint32_t mIndex;
};
void nsDisplayMathMLBar::Paint(nsDisplayListBuilder* aBuilder,
@@ -362,12 +367,13 @@ void nsDisplayMathMLBar::Paint(nsDisplayListBuilder* aBuilder,
void
nsMathMLFrame::DisplayBar(nsDisplayListBuilder* aBuilder,
nsIFrame* aFrame, const nsRect& aRect,
const nsDisplayListSet& aLists) {
const nsDisplayListSet& aLists,
uint32_t aIndex) {
if (!aFrame->StyleVisibility()->IsVisible() || aRect.IsEmpty())
return;
aLists.Content()->AppendNewToTop(new (aBuilder)
nsDisplayMathMLBar(aBuilder, aFrame, aRect));
nsDisplayMathMLBar(aBuilder, aFrame, aRect, aIndex));
}
void