Bug 1050159 - Apply correct dirty rect when AddCanvasBackgroundColorItem creates an nsDisplaySolidColor. r=mattwoodrow, a=lmandel
authorRobert O'Callahan <robert@ocallahan.org>
Sat, 06 Sep 2014 16:16:33 +1200
changeset 224857 8068c37eb8cbc238ddff9c8200f9c5c2d33fcd7b
parent 224856 bac81ffb4c16b0fbb06d599fefe13ee50d79e981
child 224858 885dcc785dd4c2b219a4a7dfa132107b3f37c8df
push id3979
push userraliiev@mozilla.com
push dateMon, 13 Oct 2014 16:35:44 +0000
treeherdermozilla-beta@30f2cc610691 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmattwoodrow, lmandel
bugs1050159
milestone34.0a2
Bug 1050159 - Apply correct dirty rect when AddCanvasBackgroundColorItem creates an nsDisplaySolidColor. r=mattwoodrow, a=lmandel
layout/generic/nsSubDocumentFrame.cpp
--- a/layout/generic/nsSubDocumentFrame.cpp
+++ b/layout/generic/nsSubDocumentFrame.cpp
@@ -425,16 +425,18 @@ nsSubDocumentFrame::BuildDisplayList(nsD
           // circuited due to us ignoring the root scroll frame, so we do it here.
           nsIScrollableFrame* rootScrollableFrame = do_QueryFrame(rootScrollFrame);
           dirty = rootScrollableFrame->ExpandRectToNearlyVisible(dirty);
         }
       }
     }
 
     aBuilder->EnterPresShell(subdocRootFrame, dirty);
+  } else {
+    dirty = aDirtyRect;
   }
 
   DisplayListClipState::AutoSaveRestore clipState(aBuilder);
   if (ShouldClipSubdocument()) {
     clipState.ClipContainingBlockDescendantsToContentBox(aBuilder, this);
   }
 
   nsIScrollableFrame *sf = presShell->GetRootScrollFrameAsScrollable();
@@ -484,23 +486,28 @@ nsSubDocumentFrame::BuildDisplayList(nsD
       // If we are in print preview/page layout we want to paint the grey
       // background behind the page, not the canvas color. The canvas color gets
       // painted on the page itself.
       if (nsLayoutUtils::NeedsPrintPreviewBackground(presContext)) {
         presShell->AddPrintPreviewBackgroundItem(
           *aBuilder, childItems, subdocRootFrame ? subdocRootFrame : this,
           bounds);
       } else {
+        // Invoke AutoBuildingDisplayList to ensure that the correct dirty rect
+        // is used to compute the visible rect if AddCanvasBackgroundColorItem
+        // creates a display item.
+        nsIFrame* frame = subdocRootFrame ? subdocRootFrame : this;
+        nsDisplayListBuilder::AutoBuildingDisplayList
+          building(aBuilder, frame, dirty, true);
         // Add the canvas background color to the bottom of the list. This
         // happens after we've built the list so that AddCanvasBackgroundColorItem
         // can monkey with the contents if necessary.
         uint32_t flags = nsIPresShell::FORCE_DRAW;
         presShell->AddCanvasBackgroundColorItem(
-          *aBuilder, childItems, subdocRootFrame ? subdocRootFrame : this,
-          bounds, NS_RGBA(0,0,0,0), flags);
+          *aBuilder, childItems, frame, bounds, NS_RGBA(0,0,0,0), flags);
       }
     }
   }
 
   if (subdocRootFrame) {
     aBuilder->LeavePresShell(subdocRootFrame, dirty);
 
     if (ignoreViewportScrolling) {