Bug 715518 - WASD controls don't work in 3D view if typeaheadfind is active; r=rcampbell

This commit is contained in:
Victor Porof 2012-01-16 09:00:56 +02:00
Родитель 9f16cb5df8
Коммит 0e5a9fda69
4 изменённых файлов: 143 добавлений и 11 удалений

Просмотреть файл

@ -994,14 +994,12 @@ TiltVisualizer.Controller.prototype = {
{
let code = e.keyCode || e.which;
if (code >= e.DOM_VK_LEFT && code <= e.DOM_VK_DOWN) {
if (!e.altKey && !e.ctrlKey && !e.metaKey && !e.shiftKey) {
e.preventDefault();
e.stopPropagation();
}
if (e.altKey || e.ctrlKey || e.metaKey || e.shiftKey) {
this.arcball.cancelKeyEvents();
} else {
this.arcball.keyDown(code);
} else {
this.arcball.cancelKeyEvents();
}
},
@ -1012,15 +1010,16 @@ TiltVisualizer.Controller.prototype = {
{
let code = e.keyCode || e.which;
if (code >= e.DOM_VK_LEFT && code <= e.DOM_VK_DOWN) {
e.preventDefault();
e.stopPropagation();
}
if (code === e.DOM_VK_ESCAPE) {
this.presenter.tiltUI.destroy(this.presenter.tiltUI.currentWindowId);
return;
}
if (!e.altKey && !e.ctrlKey && !e.metaKey && !e.shiftKey) {
e.preventDefault();
e.stopPropagation();
this.arcball.keyUp(code);
}
},
/**

Просмотреть файл

@ -54,6 +54,7 @@ _BROWSER_TEST_FILES = \
browser_tilt_05_destruction-esc.js \
browser_tilt_05_destruction-url.js \
browser_tilt_05_destruction.js \
browser_tilt_arcball-reset-typeahead.js \
browser_tilt_arcball-reset.js \
browser_tilt_arcball.js \
browser_tilt_controller.js \

Просмотреть файл

@ -0,0 +1,107 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
/*global ok, is, info, isApproxVec, waitForExplicitFinish, executeSoon, finish */
/*global isTiltEnabled, isWebGLSupported, createTab, createTilt */
/*global Services, EventUtils, InspectorUI, TiltVisualizer, TILT_DESTROYED */
"use strict";
function test() {
if (!isTiltEnabled()) {
info("Skipping part of the arcball test because Tilt isn't enabled.");
return;
}
if (!isWebGLSupported()) {
info("Skipping part of the arcball test because WebGL isn't supported.");
return;
}
waitForExplicitFinish();
Services.prefs.setBoolPref("accessibility.typeaheadfind", true);
createTab(function() {
createTilt({
onTiltOpen: function(instance)
{
performTest(instance.presenter.canvas,
instance.controller.arcball, function() {
info("Killing arcball reset test.");
Services.prefs.setBoolPref("accessibility.typeaheadfind", false);
Services.obs.addObserver(cleanup, TILT_DESTROYED, false);
InspectorUI.closeInspectorUI();
});
}
});
});
}
function performTest(canvas, arcball, callback) {
is(document.activeElement, canvas,
"The visualizer canvas should be focused when performing this test.");
info("Starting arcball reset test.");
// start translating and rotating sometime at random
executeSoon(function() {
info("Synthesizing key down events.");
EventUtils.synthesizeKey("VK_W", { type: "keydown" });
EventUtils.synthesizeKey("VK_LEFT", { type: "keydown" });
// wait for some arcball translations and rotations to happen
executeSoon(function() {
info("Synthesizing key up events.");
EventUtils.synthesizeKey("VK_W", { type: "keyup" });
EventUtils.synthesizeKey("VK_LEFT", { type: "keyup" });
// ok, transformations finished, we can now try to reset the model view
executeSoon(function() {
info("Synthesizing arcball reset key press.");
arcball.onResetFinish = function() {
ok(isApproxVec(arcball._lastRot, [0, 0, 0, 1]),
"The arcball _lastRot field wasn't reset correctly.");
ok(isApproxVec(arcball._deltaRot, [0, 0, 0, 1]),
"The arcball _deltaRot field wasn't reset correctly.");
ok(isApproxVec(arcball._currentRot, [0, 0, 0, 1]),
"The arcball _currentRot field wasn't reset correctly.");
ok(isApproxVec(arcball._lastTrans, [0, 0, 0]),
"The arcball _lastTrans field wasn't reset correctly.");
ok(isApproxVec(arcball._deltaTrans, [0, 0, 0]),
"The arcball _deltaTrans field wasn't reset correctly.");
ok(isApproxVec(arcball._currentTrans, [0, 0, 0]),
"The arcball _currentTrans field wasn't reset correctly.");
ok(isApproxVec(arcball._additionalRot, [0, 0, 0]),
"The arcball _additionalRot field wasn't reset correctly.");
ok(isApproxVec(arcball._additionalTrans, [0, 0, 0]),
"The arcball _additionalTrans field wasn't reset correctly.");
ok(isApproxVec([arcball._zoomAmount], [0]),
"The arcball _zoomAmount field wasn't reset correctly.");
info("Finishing arcball reset test.");
callback();
};
EventUtils.synthesizeKey("VK_R", { type: "keydown" });
});
});
});
}
function cleanup() { /*global gBrowser */
info("Cleaning up arcball reset test.");
Services.obs.removeObserver(cleanup, TILT_DESTROYED);
gBrowser.removeCurrentTab();
finish();
}

Просмотреть файл

@ -3,7 +3,7 @@
/*global ok, is, info, waitForExplicitFinish, finish, executeSoon, gBrowser */
/*global isEqualVec, isTiltEnabled, isWebGLSupported, createTab, createTilt */
/*global EventUtils, vec3, mat4, quat4 */
/*global Services, EventUtils, vec3, mat4, quat4 */
"use strict";
function test() {
@ -46,6 +46,9 @@ function test() {
function testEventCancel(cancellingEvent) {
is(document.activeElement, canvas,
"The visualizer canvas should be focused when performing this test.");
EventUtils.synthesizeKey("VK_A", { type: "keydown" });
EventUtils.synthesizeKey("VK_LEFT", { type: "keydown" });
instance.controller.update();
@ -79,6 +82,9 @@ function test() {
"After focus lost, the transforms inertia eventually stops.");
}
info("Setting typeaheadfind to true.");
Services.prefs.setBoolPref("accessibility.typeaheadfind", true);
testEventCancel(function() {
EventUtils.synthesizeKey("T", { type: "keydown", altKey: 1 });
});
@ -91,6 +97,25 @@ function test() {
testEventCancel(function() {
EventUtils.synthesizeKey("T", { type: "keydown", shiftKey: 1 });
});
info("Setting typeaheadfind to false.");
Services.prefs.setBoolPref("accessibility.typeaheadfind", false);
testEventCancel(function() {
EventUtils.synthesizeKey("T", { type: "keydown", altKey: 1 });
});
testEventCancel(function() {
EventUtils.synthesizeKey("I", { type: "keydown", ctrlKey: 1 });
});
testEventCancel(function() {
EventUtils.synthesizeKey("L", { type: "keydown", metaKey: 1 });
});
testEventCancel(function() {
EventUtils.synthesizeKey("T", { type: "keydown", shiftKey: 1 });
});
info("Testing if loosing focus halts any stacked arcball animations.");
testEventCancel(function() {
gBrowser.selectedBrowser.contentWindow.focus();
});