Bug 1083635. Part 4.2: Create nsDOMWindowUtils::UpdateLayerTree and use it to flush layers in reftest content processes instead of doing a DRAW_WIDGET_LAYERS drawWindow. r=mattwoodrow
authorRobert O'Callahan <robert@ocallahan.org>
Tue, 04 Nov 2014 17:05:44 +1300
changeset 214032 80142bab0f14848a458fa9142529682a2382f4bd
parent 214031 0af9b31d714c5776756f03bafcc2ee9742985903
child 214033 346924e6e44de3759bc5b1a66af0150f67a3fba2
push id27771
push userryanvm@gmail.com
push dateWed, 05 Nov 2014 19:04:24 +0000
treeherdermozilla-central@305b4fecce99 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmattwoodrow
bugs1083635
milestone36.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1083635. Part 4.2: Create nsDOMWindowUtils::UpdateLayerTree and use it to flush layers in reftest content processes instead of doing a DRAW_WIDGET_LAYERS drawWindow. r=mattwoodrow
dom/base/nsDOMWindowUtils.cpp
dom/interfaces/base/nsIDOMWindowUtils.idl
layout/base/nsIPresShell.h
layout/tools/reftest/reftest-content.js
--- a/dom/base/nsDOMWindowUtils.cpp
+++ b/dom/base/nsDOMWindowUtils.cpp
@@ -267,16 +267,26 @@ nsDOMWindowUtils::Redraw(uint32_t aCount
 
       return NS_OK;
     }
   }
   return NS_ERROR_FAILURE;
 }
 
 NS_IMETHODIMP
+nsDOMWindowUtils::UpdateLayerTree()
+{
+  if (nsIPresShell* presShell = GetPresShell()) {
+    nsRefPtr<nsViewManager> vm = presShell->GetViewManager();
+    vm->ProcessPendingUpdates();
+  }
+  return NS_OK;
+}
+
+NS_IMETHODIMP
 nsDOMWindowUtils::SetCSSViewport(float aWidthPx, float aHeightPx)
 {
   if (!nsContentUtils::IsCallerChrome()) {
     return NS_ERROR_DOM_SECURITY_ERR;
   }
 
   if (!(aWidthPx >= 0.0 && aHeightPx >= 0.0)) {
     return NS_ERROR_ILLEGAL_VALUE;
--- a/dom/interfaces/base/nsIDOMWindowUtils.idl
+++ b/dom/interfaces/base/nsIDOMWindowUtils.idl
@@ -46,17 +46,17 @@ interface nsIDOMClientRect;
 interface nsIURI;
 interface nsIDOMEventTarget;
 interface nsIRunnable;
 interface nsICompositionStringSynthesizer;
 interface nsITranslationNodeList;
 interface nsIJSRAIIHelper;
 interface nsIContentPermissionRequest;
 
-[scriptable, uuid(f7e4d5da-4dd0-455a-b448-d0224c17fd10)]
+[scriptable, uuid(01e0c3ca-37e7-4ab4-bd22-3e99d8d23336)]
 interface nsIDOMWindowUtils : nsISupports {
 
   /**
    * Image animation mode of the window. When this attribute's value
    * is changed, the implementation should set all images in the window
    * to the given value. That is, when set to kDontAnimMode, all images
    * will stop animating. The attribute's value must be one of the
    * animationMode values from imgIContainer.
@@ -99,16 +99,21 @@ interface nsIDOMWindowUtils : nsISupport
    * Force an immediate redraw of this window.  The parameter specifies
    * the number of times to redraw, and the return value is the length,
    * in milliseconds, that the redraws took.  If aCount is not specified
    * or is 0, it is taken to be 1.
    */
   unsigned long redraw([optional] in unsigned long aCount);
 
   /**
+   * Force a synchronous layer transaction for this window if necessary.
+   */
+  void updateLayerTree();
+
+  /**
    * Set the CSS viewport to be |widthPx| x |heightPx| in units of CSS
    * pixels, regardless of the size of the enclosing widget/view.
    * This will trigger reflow.
    *
    * The caller of this method must have chrome privileges.
    */
   void setCSSViewport(in float aWidthPx, in float aHeightPx);
 
--- a/layout/base/nsIPresShell.h
+++ b/layout/base/nsIPresShell.h
@@ -1097,18 +1097,18 @@ public:
     RENDER_IGNORE_VIEWPORT_SCROLLING = 0x02,
     RENDER_CARET = 0x04,
     RENDER_USE_WIDGET_LAYERS = 0x08,
     RENDER_ASYNC_DECODE_IMAGES = 0x10,
     RENDER_DOCUMENT_RELATIVE = 0x20,
     RENDER_DRAWWINDOW_NOT_FLUSHING = 0x40
   };
   virtual nsresult RenderDocument(const nsRect& aRect, uint32_t aFlags,
-                                              nscolor aBackgroundColor,
-                                              gfxContext* aRenderedContext) = 0;
+                                  nscolor aBackgroundColor,
+                                  gfxContext* aRenderedContext) = 0;
 
   /**
    * Renders a node aNode to a surface and returns it. The aRegion may be used
    * to clip the rendering. This region is measured in CSS pixels from the
    * edge of the presshell area. The aPoint, aScreenRect and aSurface
    * arguments function in a similar manner as RenderSelection.
    */
   virtual mozilla::TemporaryRef<SourceSurface>
--- a/layout/tools/reftest/reftest-content.js
+++ b/layout/tools/reftest/reftest-content.js
@@ -779,23 +779,17 @@ function SynchronizeForSnapshot(flags)
     if (flags & SYNC_ALLOW_DISABLE) {
         var docElt = content.document.documentElement;
         if (docElt && docElt.hasAttribute("reftest-no-sync-layers")) {
             LogInfo("Test file chose to skip SynchronizeForSnapshot");
             return;
         }
     }
 
-    var dummyCanvas = content.document.createElementNS(XHTML_NS, "canvas");
-    dummyCanvas.setAttribute("width", 1);
-    dummyCanvas.setAttribute("height", 1);
-
-    var ctx = dummyCanvas.getContext("2d");
-    var flags = ctx.DRAWWINDOW_DRAW_CARET | ctx.DRAWWINDOW_DRAW_VIEW | ctx.DRAWWINDOW_USE_WIDGET_LAYERS;
-    ctx.drawWindow(content, 0, 0, 1, 1, "rgb(255,255,255)", flags);
+    windowUtils().updateLayerTree();
 
     // Setup async scroll offsets now, because any scrollable layers should
     // have had their AsyncPanZoomControllers created.
     setupAsyncScrollOffsets({allowFailure:false});
 }
 
 function RegisterMessageListeners()
 {