Bug 718303 - Tilt intro and outro transitions aren't very precise when page is zoomed; r=rcampbell
authorVictor Porof <vporof@mozilla.com>
Mon, 16 Jan 2012 09:00:57 +0200
changeset 86598 586448c078ef739e1009ca6739ade5c87364d877
parent 86597 397db1eba037d38be2b0e1c6b90b0b1cf6b55bfe
child 86599 b8fce88d3a66e4cc2322448dc1006397bbdccdae
push id805
push userakeybl@mozilla.com
push dateWed, 01 Feb 2012 18:17:35 +0000
treeherdermozilla-aurora@6fb3bf232436 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrcampbell
bugs718303
milestone12.0a1
Bug 718303 - Tilt intro and outro transitions aren't very precise when page is zoomed; r=rcampbell
browser/devtools/tilt/Tilt.jsm
browser/devtools/tilt/TiltUtils.jsm
browser/devtools/tilt/TiltVisualizer.jsm
browser/devtools/tilt/test/browser_tilt_zoom.js
--- a/browser/devtools/tilt/Tilt.jsm
+++ b/browser/devtools/tilt/Tilt.jsm
@@ -151,20 +151,25 @@ Tilt.prototype = {
 
       if (!aAnimateFlag) {
         finalize.call(this, aId);
         return;
       }
 
       let controller = this.visualizers[aId].controller;
       let presenter = this.visualizers[aId].presenter;
+
+      TiltUtils.setDocumentZoom(presenter.transforms.zoom);
+
       let content = presenter.contentWindow;
+      let pageXOffset = content.pageXOffset * TiltUtils.getDocumentZoom();
+      let pageYOffset = content.pageYOffset * TiltUtils.getDocumentZoom();
 
       controller.removeEventListeners();
-      controller.arcball.reset([-content.pageXOffset, -content.pageYOffset]);
+      controller.arcball.reset([-pageXOffset, -pageYOffset]);
       presenter.executeDestruction(finalize.bind(this, aId));
     }
   },
 
   /**
    * Handles any supplementary post-initialization work, done immediately
    * after a TILT_NOTIFICATIONS.INITIALIZED notification.
    */
--- a/browser/devtools/tilt/TiltUtils.jsm
+++ b/browser/devtools/tilt/TiltUtils.jsm
@@ -668,16 +668,26 @@ TiltUtils.getWindowId = function TU_getW
  * @return {Number} the zoom ammount
  */
 TiltUtils.getDocumentZoom = function TU_getDocumentZoom() {
   return TiltUtils.getBrowserWindow()
                   .gBrowser.selectedBrowser.markupDocumentViewer.fullZoom;
 };
 
 /**
+ * Sets the markup document viewer zoom for the currently selected browser.
+ *
+ * @param {Number} the zoom ammount
+ */
+TiltUtils.setDocumentZoom = function TU_getDocumentZoom(aZoom) {
+  TiltUtils.getBrowserWindow()
+           .gBrowser.selectedBrowser.markupDocumentViewer.fullZoom = aZoom;
+};
+
+/**
  * Performs a garbage collection.
  */
 TiltUtils.gc = function TU_gc()
 {
   TiltUtils.getBrowserWindow()
            .QueryInterface(Ci.nsIInterfaceRequestor)
            .getInterface(Ci.nsIDOMWindowUtils)
            .garbageCollect();
--- a/browser/devtools/tilt/TiltVisualizer.jsm
+++ b/browser/devtools/tilt/TiltVisualizer.jsm
@@ -940,16 +940,19 @@ TiltVisualizer.Controller = function TV_
   /**
    * The initial controller dimensions and offset, in pixels.
    */
   this.left = aPresenter.contentWindow.pageXOffset || 0;
   this.top = aPresenter.contentWindow.pageYOffset || 0;
   this.width = aCanvas.width;
   this.height = aCanvas.height;
 
+  this.left *= TiltUtils.getDocumentZoom();
+  this.top *= TiltUtils.getDocumentZoom();
+
   /**
    * Arcball used to control the visualization using the mouse.
    */
   this.arcball = new TiltVisualizer.Arcball(this.width, this.height, 0,
     [this.width + this.left < aPresenter.maxTextureSize ? -this.left : 0,
      this.height + this.top < aPresenter.maxTextureSize ? -this.top : 0]);
 
   /**
--- a/browser/devtools/tilt/test/browser_tilt_zoom.js
+++ b/browser/devtools/tilt/test/browser_tilt_zoom.js
@@ -13,20 +13,21 @@ function setZoom(value) {
   gBrowser.selectedBrowser.markupDocumentViewer.fullZoom = value;
 }
 
 function getZoom() {
   return gBrowser.selectedBrowser.markupDocumentViewer.fullZoom;
 }
 
 function test() {
-  setZoom(Math.random());
+  TiltUtils.setDocumentZoom(Math.random());
   is(getZoom(), TiltUtils.getDocumentZoom(),
     "The getDocumentZoom utility function didn't return the expected results.");
 
+
   if (!isTiltEnabled()) {
     info("Skipping controller test because Tilt isn't enabled.");
     return;
   }
   if (!isWebGLSupported()) {
     info("Skipping controller test because WebGL isn't supported.");
     return;
   }