Bug 1462742 - Don't build display items for the custom content container frame twice during the same paint. r?emilio draft
authorMarkus Stange <mstange@themasta.com>
Fri, 08 Jun 2018 17:17:19 -0400
changeset 807230 0f4b2eb406714b3e105fcf283441447a5614360d
parent 807229 0279ff7f910939df333e3a532f0339f705bf126a
child 807512 83c7478bbca6b2cd4ca0b9f796eb9997362ebf53
push id113048
push userbmo:mstange@themasta.com
push dateWed, 13 Jun 2018 22:07:35 +0000
reviewersemilio
bugs1462742
milestone62.0a1
Bug 1462742 - Don't build display items for the custom content container frame twice during the same paint. r?emilio MozReview-Commit-ID: 6L2fygc1JCv
layout/generic/ViewportFrame.cpp
--- 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,