b=433086, improve nsDOMWindowUtils::Redraw; r+sr=roc
authorVladimir Vukicevic <vladimir@pobox.com>
Tue, 03 Jun 2008 17:00:37 -0700
changeset 15235 be00592555a0cb37dd15f72c233b5ce3e14d4cc8
parent 15234 553480dceb262db3fa443be7000f6aa2ecf1377f
child 15236 378707d75b14eb919e39f59766f1fe3f6d0f9e26
push id69
push uservladimir@mozilla.com
push dateWed, 04 Jun 2008 00:34:07 +0000
treeherdermozilla-central@b0bc6be7db45 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs433086
milestone1.9.1a1pre
b=433086, improve nsDOMWindowUtils::Redraw; r+sr=roc
dom/public/idl/base/nsIDOMWindowUtils.idl
dom/src/base/Makefile.in
dom/src/base/nsDOMWindowUtils.cpp
--- a/dom/public/idl/base/nsIDOMWindowUtils.idl
+++ b/dom/public/idl/base/nsIDOMWindowUtils.idl
@@ -42,17 +42,17 @@
  * to the current nsIDOMWindow.  Some of the methods may require
  * elevated privileges; the method implementations should contain the
  * necessary security checks.  Access this interface by calling
  * getInterface on a DOMWindow.
  */
 
 interface nsIDOMElement;
 
-[scriptable, uuid(1cfc1a0a-e348-4b18-b61b-935c192f85c4)]
+[scriptable, uuid(993da427-2ac3-4766-8485-21a236d258e4)]
 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.
@@ -82,19 +82,22 @@ interface nsIDOMWindowUtils : nsISupport
    * @return the value of the metadata, or the empty string if it's not set
    *
    * Will throw a DOM security error if called without UniversalXPConnect
    * privileges.
    */
   AString getDocumentMetadata(in AString aName);
 
   /**
-   * Force an immediate redraw of this window.
+   * 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.
    */
-  void redraw();
+  unsigned long redraw([optional] in unsigned long aCount);
 
   /** Synthesize a mouse event for a window. The event types supported
    *  are: 
    *    mousedown, mouseup, mousemove, mouseover, mouseout, contextmenu
    *
    * Events are sent in coordinates offset by aX and aY from the window.
    *
    * Note that additional events may be fired as a result of this call. For
--- a/dom/src/base/Makefile.in
+++ b/dom/src/base/Makefile.in
@@ -140,8 +140,15 @@ CFLAGS += -F/System/Library/PrivateFrame
 LDFLAGS += -F/System/Library/PrivateFrameworks -framework CHUD
 endif
 
 ifdef MOZ_JSDEBUGGER
 DEFINES += -DMOZ_JSDEBUGGER
 endif
 
 include $(topsrcdir)/config/rules.mk
+
+ifdef MOZ_X11
+ifdef MOZ_ENABLE_GTK2
+CXXFLAGS += $(TK_CFLAGS)
+LDFLAGS += $(TK_LIBS)
+endif
+endif
--- a/dom/src/base/nsDOMWindowUtils.cpp
+++ b/dom/src/base/nsDOMWindowUtils.cpp
@@ -50,17 +50,18 @@
 #include "nsContentUtils.h"
 
 #include "nsIFrame.h"
 #include "nsIWidget.h"
 #include "nsGUIEvent.h"
 #include "nsIParser.h"
 #include "nsJSEnvironment.h"
 
-#ifdef MOZ_ENABLE_GTK2
+#if defined(MOZ_X11) && defined(MOZ_WIDGET_GTK2)
+#include <gdk/gdk.h>
 #include <gdk/gdkx.h>
 #endif
 
 NS_INTERFACE_MAP_BEGIN(nsDOMWindowUtils)
   NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDOMWindowUtils)
   NS_INTERFACE_MAP_ENTRY(nsIDOMWindowUtils)
   NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
   NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(WindowUtils)
@@ -149,35 +150,45 @@ nsDOMWindowUtils::GetDocumentMetadata(co
     }
   }
   
   aValue.Truncate();
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsDOMWindowUtils::Redraw()
+nsDOMWindowUtils::Redraw(PRUint32 aCount, PRUint32 *aDurationOut)
 {
   nsresult rv;
 
+  if (aCount == 0)
+    aCount = 1;
+
   nsCOMPtr<nsIDocShell> docShell = mWindow->GetDocShell();
   if (docShell) {
     nsCOMPtr<nsIPresShell> presShell;
 
     rv = docShell->GetPresShell(getter_AddRefs(presShell));
     if (NS_SUCCEEDED(rv) && presShell) {
       nsIFrame *rootFrame = presShell->GetRootFrame();
 
       if (rootFrame) {
         nsRect r(nsPoint(0, 0), rootFrame->GetSize());
-        rootFrame->Invalidate(r, PR_TRUE);
+
+        PRIntervalTime iStart = PR_IntervalNow();
 
-#ifdef MOZ_ENABLE_GTK2
+        for (PRUint32 i = 0; i < aCount; i++)
+          rootFrame->Invalidate(r, PR_TRUE);
+
+#if defined(MOZ_X11) && defined(MOZ_WIDGET_GTK2)
         XSync(GDK_DISPLAY(), False);
 #endif
+
+        *aDurationOut = PR_IntervalToMilliseconds(PR_IntervalNow() - iStart);
+
         return NS_OK;
       }
     }
   }
   return NS_ERROR_FAILURE;
 }
 
 NS_IMETHODIMP