Bug 719877 - Tilt should use Highlighter's zoom property (screenPixelsPerCSSPixel) instead of markupDocumentViewer.fullZoom; r=rcampbell

This commit is contained in:
Victor Porof 2012-01-20 21:05:00 +02:00
parent 1a80466e19
commit b26a5f0a79
4 changed files with 27 additions and 30 deletions

View File

@ -547,18 +547,6 @@ TiltUtils.getWindowId = function TU_getWindowId(aWindow)
.currentInnerWindowID;
};
/**
* Gets the markup document viewer zoom for the currently selected browser.
*
* @param {Window} aChromeWindow
* the top-level browser window
*
* @return {Number} the zoom ammount
*/
TiltUtils.getDocumentZoom = function TU_getDocumentZoom(aChromeWindow) {
return aChromeWindow.gBrowser.selectedBrowser.markupDocumentViewer.fullZoom;
};
/**
* Sets the markup document viewer zoom for the currently selected browser.
*

View File

@ -250,7 +250,7 @@ TiltVisualizer.Presenter = function TV_Presenter(
* Modified by events in the controller through delegate functions.
*/
this.transforms = {
zoom: TiltUtils.getDocumentZoom(aChromeWindow),
zoom: 1,
offset: vec3.create(), // mesh offset, aligned to the viewport center
translation: vec3.create(), // scene translation, on the [x, y, z] axis
rotation: quat4.create() // scene rotation, expressed as a quaternion
@ -280,6 +280,7 @@ TiltVisualizer.Presenter = function TV_Presenter(
let setup = function TVP_setup()
{
let renderer = this.renderer;
let inspector = this.chromeWindow.InspectorUI;
// if the renderer was destroyed, don't continue setup
if (!renderer || !renderer.context) {
@ -294,6 +295,11 @@ TiltVisualizer.Presenter = function TV_Presenter(
uniforms: ["mvMatrix", "projMatrix", "sampler"]
});
// get the document zoom to properly scale the visualization
if (inspector.highlighter) {
this.transforms.zoom = inspector.highlighter.zoom;
}
this.setupTexture();
this.setupMeshData();
this.setupEventListeners();
@ -620,7 +626,7 @@ TiltVisualizer.Presenter.prototype = {
*/
onResize: function TVP_onResize(e)
{
let zoom = TiltUtils.getDocumentZoom(this.chromeWindow);
let zoom = this.chromeWindow.InspectorUI.highlighter.zoom;
let width = e.target.innerWidth * zoom;
let height = e.target.innerHeight * zoom;
@ -813,7 +819,7 @@ TiltVisualizer.Presenter.prototype = {
}
}, false);
let zoom = TiltUtils.getDocumentZoom(this.chromeWindow);
let zoom = this.chromeWindow.InspectorUI.highlighter.zoom;
let width = this.renderer.width * zoom;
let height = this.renderer.height * zoom;
let mesh = this.meshStacks;
@ -1256,7 +1262,7 @@ TiltVisualizer.Controller.prototype = {
*/
onResize: function TVC_onResize(e)
{
let zoom = TiltUtils.getDocumentZoom(this.presenter.chromeWindow);
let zoom = this.presenter.chromeWindow.InspectorUI.highlighter.zoom;
let width = e.target.innerWidth * zoom;
let height = e.target.innerHeight * zoom;

View File

@ -6,13 +6,6 @@ const ZOOM = 2;
const RESIZE = 50;
function test() {
let random = Math.random() * 10;
TiltUtils.setDocumentZoom(window, random);
ok(isApprox(TiltUtils.getDocumentZoom(window), random),
"The getDocumentZoom utility function didn't return the expected results.");
if (!isTiltEnabled()) {
info("Skipping controller test because Tilt isn't enabled.");
return;
@ -32,6 +25,9 @@ function test() {
},
onTiltOpen: function(instance)
{
ok(isApprox(InspectorUI.highlighter.zoom, ZOOM),
"The Highlighter zoom doesn't have the expected results.");
ok(isApprox(instance.presenter.transforms.zoom, ZOOM),
"The presenter transforms zoom wasn't initially set correctly.");
@ -74,10 +70,11 @@ function test() {
window.resizeBy(RESIZE * ZOOM, RESIZE * ZOOM);
Services.obs.addObserver(cleanup, DESTROYED, false);
InspectorUI.closeInspectorUI();
});
},
}
});
});
}

View File

@ -137,8 +137,10 @@ function createTilt(callbacks, close) {
if ("function" === typeof callbacks.onInspectorOpen) {
callbacks.onInspectorOpen();
}
Services.obs.addObserver(onTiltOpen, INITIALIZING, false);
Tilt.initialize();
executeSoon(function() {
Services.obs.addObserver(onTiltOpen, INITIALIZING, false);
Tilt.initialize();
});
});
}
@ -150,8 +152,10 @@ function createTilt(callbacks, close) {
callbacks.onTiltOpen(Tilt.visualizers[Tilt.currentWindowId]);
}
if (close) {
Services.obs.addObserver(onTiltClose, DESTROYED, false);
Tilt.destroy(Tilt.currentWindowId);
executeSoon(function() {
Services.obs.addObserver(onTiltClose, DESTROYED, false);
Tilt.destroy(Tilt.currentWindowId);
});
}
});
}
@ -164,8 +168,10 @@ function createTilt(callbacks, close) {
callbacks.onTiltClose();
}
if (close) {
Services.obs.addObserver(onInspectorClose, INSPECTOR_CLOSED, false);
InspectorUI.closeInspectorUI();
executeSoon(function() {
Services.obs.addObserver(onInspectorClose, INSPECTOR_CLOSED, false);
InspectorUI.closeInspectorUI();
});
}
});
}