Bug 630027 - replace mozRequestAnimationFrame() with mozRequestAnimationFrame(callback) in AnimatedZoom.js [r=stechz]
authorMark Finkle <mfinkle@mozilla.com>
Mon, 31 Jan 2011 18:10:01 -0500
changeset 67337 80fccacc47dbc40985b3c40ddf505b100cd66f4b
parent 67336 8b0e4ac2b00160478fc0239fd5a9ce0d562de8e6
child 67338 2d7f9e4f2d77398b19bf5ac726df088b0101b50b
push id1
push userroot
push dateTue, 26 Apr 2011 22:38:44 +0000
treeherdermozilla-beta@bfdb6e623a36 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersstechz
bugs630027
Bug 630027 - replace mozRequestAnimationFrame() with mozRequestAnimationFrame(callback) in AnimatedZoom.js [r=stechz]
mobile/chrome/content/AnimatedZoom.js
--- a/mobile/chrome/content/AnimatedZoom.js
+++ b/mobile/chrome/content/AnimatedZoom.js
@@ -61,18 +61,17 @@ const AnimatedZoom = {
 
     // Check if zooming animations were occuring before.
     if (this.zoomRect) {
       this.zoomFrom = this.zoomRect;
     } else {
       this.zoomFrom = this.getStartRect();
       this.updateTo(this.zoomFrom);
 
-      window.addEventListener("MozBeforePaint", this, false);
-      mozRequestAnimationFrame();
+      mozRequestAnimationFrame(this);
 
       let event = document.createEvent("Events");
       event.initEvent("AnimatedZoomBegin", true, true);
       window.dispatchEvent(event);
     }
   },
 
   /** Get the visible rect, in device pixels relative to the content origin. */
@@ -96,41 +95,40 @@ const AnimatedZoom = {
     if ("_contentView" in contentView)
       contentView._contentView.scrollTo(nextRect.left * zoomRatio, nextRect.top * zoomRatio);
 
     this.zoomRect = nextRect;
   },
 
   /** Stop animation, zoom to point, and clean up. */
   finish: function() {
-    window.removeEventListener("MozBeforePaint", this, false);
     Browser.setVisibleRect(this.zoomTo || this.zoomRect);
     this.beginTime = null;
     this.zoomTo = null;
     this.zoomFrom = null;
     this.zoomRect = null;
 
     let event = document.createEvent("Events");
     event.initEvent("AnimatedZoomEnd", true, true);
     window.dispatchEvent(event);
   },
 
   isZooming: function isZooming() {
     return this.beginTime != null;
   },
 
-  handleEvent: function(aEvent) {
+  onBeforePaint: function(aTimeStamp) {
     try {
-      let tdiff = aEvent.timeStamp - this.beginTime;
+      let tdiff = aTimeStamp - this.beginTime;
       let counter = tdiff / this.animationDuration;
       if (counter < 1) {
         // update browser to interpolated rectangle
         let rect = this.zoomFrom.blend(this.zoomTo, counter);
         this.updateTo(rect);
-        mozRequestAnimationFrame();
+        mozRequestAnimationFrame(this);
       } else {
         // last cycle already rendered final scaled image, now clean up
         this.finish();
       }
     } catch(e) {
       this.finish();
       throw e;
     }