Bug 1462742 - Don't build display items for the custom content container frame twice during the same paint. r?emilio
MozReview-Commit-ID: 6L2fygc1JCv
--- a/layout/generic/ViewportFrame.cpp
+++ b/layout/generic/ViewportFrame.cpp
@@ -179,17 +179,29 @@ ViewportFrame::BuildDisplayListForTopLay
BuildDisplayListForTopLayerFrame(aBuilder, frame, aList);
}
}
nsIPresShell* shell = PresShell();
if (nsCanvasFrame* canvasFrame = shell->GetCanvasFrame()) {
if (Element* container = canvasFrame->GetCustomContentContainer()) {
if (nsIFrame* frame = container->GetPrimaryFrame()) {
- BuildDisplayListForTopLayerFrame(aBuilder, frame, aList);
+ // Enter this frame for display list building, but only if it is
+ // actually a top layer frame. There is a bug affecting SVG documents
+ // that makes the custom content container not be a top layer frame in
+ // them, because SVG documents don't load `ua.css` when the custom
+ // content container is created. `ua.css` contains the rule that makes
+ // this a top layer frame. This bug is being fixed in bug 1157592.
+ // We have to do this workaround because otherwise we risk building
+ // display items for this frame twice; if the custom content container
+ // frame is not a top layer frame, it's not out-of-flow, so we'll have
+ // built display items for it already when we entered its parent frame.
+ if (frame->StyleDisplay()->mTopLayer != NS_STYLE_TOP_LAYER_NONE) {
+ BuildDisplayListForTopLayerFrame(aBuilder, frame, aList);
+ }
}
}
}
}
#ifdef DEBUG
void
ViewportFrame::AppendFrames(ChildListID aListID,