Bug 782739 Handle new mousewheel prefs in browser_fullZoom.js r=smaug+dao

This commit is contained in:
Masayuki Nakano 2012-08-16 00:51:13 +09:00
parent 37ce4e65cd
commit 87f15e6b61
3 changed files with 25 additions and 22 deletions

View File

@ -88,23 +88,26 @@ var FullZoom = {
_handleMouseScrolled: function FullZoom__handleMouseScrolled(event) {
// Construct the "mousewheel action" pref key corresponding to this event.
// Based on nsEventStateManager::GetBasePrefKeyForMouseWheel.
var pref = "mousewheel";
if (event.axis == event.HORIZONTAL_AXIS)
pref += ".horizscroll";
// Based on nsEventStateManager::WheelPrefs::GetBasePrefName().
var pref = "mousewheel.";
if (event.shiftKey)
pref += ".withshiftkey";
else if (event.ctrlKey)
pref += ".withcontrolkey";
else if (event.altKey)
pref += ".withaltkey";
else if (event.metaKey)
pref += ".withmetakey";
else
pref += ".withnokey";
var pressedModifierCount = event.shiftKey + event.ctrlKey + event.altKey +
event.metaKey + event.getModifierState("OS");
if (pressedModifierCount != 1) {
pref += "default.";
} else if (event.shiftKey) {
pref += "with_shift.";
} else if (event.ctrlKey) {
pref += "with_control.";
} else if (event.altKey) {
pref += "with_alt.";
} else if (event.metaKey) {
pref += "with_meta.";
} else {
pref += "with_win.";
}
pref += ".action";
pref += "action";
// Don't do anything if this isn't a "zoom" scroll event.
var isZoomEvent = false;

View File

@ -34,7 +34,7 @@ function hitEventLoop(aFunc, aTimes)
function runTests()
{
SpecialPowers.setIntPref("mousewheel.with_control.action", 3);
SpecialPowers.setFullZoom(window, 1.0);
synthesizeKey("0", { accelKey: true });
var video = document.getElementById("v");
hitEventLoop(function () {
@ -47,7 +47,7 @@ function runTests()
isnot(SpecialPowers.getFullZoom(window), 1.0,
"failed to zoom by ctrl+wheel");
SpecialPowers.setFullZoom(window, 1.0);
synthesizeKey("0", { accelKey: true });
SpecialPowers.clearUserPref("mousewheel.with_control.action");
hitEventLoop(window.opener.finish, 20);

View File

@ -782,7 +782,7 @@ function doTestZoom(aSettings, aCallback)
}
}
SpecialPowers.setFullZoom(window, 1.0);
synthesizeKey("0", { accelKey: true });
hitEventLoop(doNextTest, 20);
}, 20);
}
@ -794,7 +794,7 @@ function doTestZoomedScroll()
function testZoomedPixelScroll()
{
// Reset zoom and store the scroll amount into the data.
SpecialPowers.setFullZoom(window, 1.0);
synthesizeKey("0", { accelKey: true });
gScrollableElement.scrollTop = 1000;
gScrollableElement.scrollLeft = 1000;
// Ensure not to be in reflow.
@ -843,7 +843,7 @@ function doTestZoomedScroll()
gScrollableElement.scrollTop + ", scrolledY=" + scrolledY);
window.removeEventListener("MozMousePixelScroll", handler, true);
SpecialPowers.setFullZoom(window, 1.0);
synthesizeKey("0", { accelKey: true });
testZoomedLineScroll();
}, 20);
}, 20);
@ -854,7 +854,7 @@ function doTestZoomedScroll()
function testZoomedLineScroll()
{
// Reset zoom and store the scroll amount into the data.
SpecialPowers.setFullZoom(window, 1.0);
synthesizeKey("0", { accelKey: true });
gScrollableElement.scrollTop = 1000;
gScrollableElement.scrollLeft = 1000;
// Ensure not to be in reflow.
@ -915,7 +915,7 @@ function doTestZoomedScroll()
window.removeEventListener("MozMousePixelScroll", handler, true);
SpecialPowers.setFullZoom(window, 1.0);
synthesizeKey("0", { accelKey: true });
}, 20);
}, 20);
}, 20);