mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-01-09 05:14:24 +00:00
Bug 655004, cancel mouse scroll event and key events for grid datepicker and trees, prevents scroll events from bubbling up in tests, r=neil
This commit is contained in:
parent
2a9ee7ba0c
commit
2973a0228b
@ -15,7 +15,10 @@
|
||||
onpopuphidden="testtag_finish()">
|
||||
<datepicker id="datepicker"/>
|
||||
<datepicker id="datepicker-popup" type="popup"/>
|
||||
<datepicker id="datepicker-grid" type="grid"/>
|
||||
<hbox onDOMMouseScroll="mouseScrolled = event.getPreventDefault();"
|
||||
onkeypress="pageDownScrolled = event.getPreventDefault();">
|
||||
<datepicker id="datepicker-grid" type="grid"/>
|
||||
</hbox>
|
||||
</hbox>
|
||||
|
||||
<!-- Test-only key bindings, but must not conflict with the application. -->
|
||||
@ -36,6 +39,9 @@
|
||||
<script>
|
||||
<![CDATA[
|
||||
|
||||
var mouseScrolled = false;
|
||||
var pageDownScrolled = false;
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
function testtag_datepickers()
|
||||
@ -50,6 +56,16 @@ function testtag_datepickers()
|
||||
function testtag_finish()
|
||||
{
|
||||
ok(!document.getElementById("datepicker-popup").open, "datepicker popup open false again");
|
||||
|
||||
var dpgrid = document.getElementById("datepicker-grid");
|
||||
dpgrid.focus();
|
||||
synthesizeMouseScroll(dpgrid, 5, 5, { delta: 10 });
|
||||
is(mouseScrolled, true, "mouse scrolled default prevented");
|
||||
is(dpgrid.displayedMonth, 2, "mouse scroll changed month");
|
||||
|
||||
synthesizeKey("VK_PAGE_DOWN", { });
|
||||
is(pageDownScrolled, true, "page down scrolled default prevented");
|
||||
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
|
@ -334,11 +334,18 @@ function testtag_tree_TreeSelection_UI(tree, testid, multiple)
|
||||
selection.currentIndex = 0;
|
||||
tree.focus();
|
||||
|
||||
var keyPressDefaultPrevented = 0;
|
||||
function keyPressListener(event) {
|
||||
keyPressDefaultPrevented++;
|
||||
}
|
||||
|
||||
// check that cursor up and down keys navigate up and down
|
||||
// select event fires after a delay so don't expect it. The reason it fires after a delay
|
||||
// is so that cursor navigation allows quicking skimming over a set of items without
|
||||
// actually firing events in-between, improving performance. The select event will only
|
||||
// be fired on the row where the cursor stops.
|
||||
window.addEventListener("keypress", keyPressListener, false);
|
||||
|
||||
synthesizeKeyExpectEvent("VK_DOWN", {}, tree, "!select", "key down");
|
||||
testtag_tree_TreeSelection_State(tree, testid + "key down", 1, [1], 0);
|
||||
|
||||
@ -599,6 +606,9 @@ function testtag_tree_TreeSelection_UI(tree, testid, multiple)
|
||||
|
||||
// restore the scroll position to the start of the page
|
||||
synthesizeKey("VK_HOME", {});
|
||||
|
||||
window.removeEventListener("keypress", keyPressListener, false);
|
||||
is(keyPressDefaultPrevented, multiple ? 63 : 40, "key press default prevented");
|
||||
}
|
||||
|
||||
function testtag_tree_UI_editing(tree, testid, rowInfo)
|
||||
@ -1181,13 +1191,23 @@ function testtag_tree_mousescroll(aTree)
|
||||
is(aTree.treeBoxObject.getFirstVisibleRow(), aStart, "mouse-scroll horizontal starting " + aStart + " delta " + aDelta
|
||||
+ " eventType " + aKind.eventType + " hasPixels " + aKind.hasPixels);
|
||||
}
|
||||
|
||||
|
||||
var defaultPrevented = 0;
|
||||
|
||||
function mouseScrollListener(event) {
|
||||
defaultPrevented++;
|
||||
}
|
||||
window.addEventListener("DOMMouseScroll", mouseScrollListener, false);
|
||||
|
||||
kinds.forEach(function(aKind) {
|
||||
helper(2, -1, aKind);
|
||||
helper(2, 1, aKind);
|
||||
helper(2, -2, aKind);
|
||||
helper(2, 2, aKind);
|
||||
});
|
||||
|
||||
window.removeEventListener("DOMMouseScroll", mouseScrollListener, false);
|
||||
is(defaultPrevented, 16, "mouse scroll event default prevented");
|
||||
}
|
||||
|
||||
function synthesizeColumnDrag(aTree, aMouseDownColumnNumber, aMouseUpColumnNumber, aAfter)
|
||||
|
@ -1217,7 +1217,8 @@
|
||||
}
|
||||
]]>
|
||||
</handler>
|
||||
<handler event="DOMMouseScroll">
|
||||
<handler event="MozMousePixelScroll" preventdefault="true"/>
|
||||
<handler event="DOMMouseScroll" preventdefault="true">
|
||||
<![CDATA[
|
||||
this._increaseOrDecreaseMonth(event.detail < 0 ? -1 : 1);
|
||||
]]>
|
||||
@ -1230,9 +1231,9 @@
|
||||
action="this._increaseOrDecreaseDateFromEvent(event, -7);"/>
|
||||
<handler event="keypress" keycode="VK_DOWN"
|
||||
action="this._increaseOrDecreaseDateFromEvent(event, 7);"/>
|
||||
<handler event="keypress" keycode="VK_PAGE_UP"
|
||||
<handler event="keypress" keycode="VK_PAGE_UP" preventdefault="true"
|
||||
action="this._increaseOrDecreaseMonth(-1);"/>
|
||||
<handler event="keypress" keycode="VK_PAGE_DOWN"
|
||||
<handler event="keypress" keycode="VK_PAGE_DOWN" preventdefault="true"
|
||||
action="this._increaseOrDecreaseMonth(1);"/>
|
||||
</handlers>
|
||||
</binding>
|
||||
|
@ -685,7 +685,8 @@
|
||||
</implementation>
|
||||
|
||||
<handlers>
|
||||
<handler event="DOMMouseScroll">
|
||||
<handler event="MozMousePixelScroll" preventdefault="true"/>
|
||||
<handler event="DOMMouseScroll" preventdefault="true">
|
||||
<![CDATA[
|
||||
if (this._editingColumn)
|
||||
return;
|
||||
@ -701,7 +702,7 @@
|
||||
this.treeBoxObject.scrollByLines(rows);
|
||||
]]>
|
||||
</handler>
|
||||
<handler event="MozSwipeGesture">
|
||||
<handler event="MozSwipeGesture" preventdefault="true">
|
||||
<![CDATA[
|
||||
// Figure out which row to show
|
||||
let targetRow = 0;
|
||||
@ -754,7 +755,8 @@
|
||||
return;
|
||||
var row = this.currentIndex;
|
||||
var column = this.view.selection.currentColumn;
|
||||
this.startEditing(row, column);
|
||||
if (this.startEditing(row, column))
|
||||
event.preventDefault();
|
||||
]]>
|
||||
</handler>
|
||||
#endif // XP_MACOSX
|
||||
@ -789,8 +791,10 @@
|
||||
}
|
||||
|
||||
if (checkContainers) {
|
||||
if (this.changeOpenState(this.currentIndex, false))
|
||||
if (this.changeOpenState(this.currentIndex, false)) {
|
||||
event.preventDefault();
|
||||
return;
|
||||
}
|
||||
else {
|
||||
var parentIndex = this.view.getParentIndex(this.currentIndex);
|
||||
if (parentIndex >= 0) {
|
||||
@ -799,6 +803,7 @@
|
||||
}
|
||||
this.view.selection.select(parentIndex);
|
||||
this.treeBoxObject.ensureRowIsVisible(parentIndex);
|
||||
event.preventDefault();
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -809,6 +814,7 @@
|
||||
if (col) {
|
||||
this.view.selection.currentColumn = col;
|
||||
this.treeBoxObject.ensureCellIsVisible(row, col);
|
||||
event.preventDefault();
|
||||
}
|
||||
}
|
||||
]]>
|
||||
@ -833,8 +839,10 @@
|
||||
}
|
||||
|
||||
if (checkContainers) {
|
||||
if (this.changeOpenState(row, true))
|
||||
if (this.changeOpenState(row, true)) {
|
||||
event.preventDefault();
|
||||
return;
|
||||
}
|
||||
else {
|
||||
var c = row + 1;
|
||||
var view = this.view;
|
||||
@ -851,6 +859,7 @@
|
||||
}
|
||||
this.view.selection.timedSelect(c, this._selectDelay);
|
||||
this.treeBoxObject.ensureRowIsVisible(c);
|
||||
event.preventDefault();
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -861,33 +870,34 @@
|
||||
if (col) {
|
||||
this.view.selection.currentColumn = col;
|
||||
this.treeBoxObject.ensureCellIsVisible(row, col);
|
||||
event.preventDefault();
|
||||
}
|
||||
}
|
||||
]]>
|
||||
</handler>
|
||||
<handler event="keypress" keycode="VK_UP"
|
||||
<handler event="keypress" keycode="VK_UP" preventdefault="true"
|
||||
modifiers="accel any" action="_moveByOffset(-1, 0, event);"/>
|
||||
<handler event="keypress" keycode="VK_DOWN"
|
||||
<handler event="keypress" keycode="VK_DOWN" preventdefault="true"
|
||||
modifiers="accel any" action="_moveByOffset(1, this.view.rowCount - 1, event);"/>
|
||||
<handler event="keypress" keycode="VK_UP"
|
||||
<handler event="keypress" keycode="VK_UP" preventdefault="true"
|
||||
modifiers="accel any, shift" action="_moveByOffsetShift(-1, 0, event);"/>
|
||||
<handler event="keypress" keycode="VK_DOWN"
|
||||
<handler event="keypress" keycode="VK_DOWN" preventdefault="true"
|
||||
modifiers="accel any, shift" action="_moveByOffsetShift(1, this.view.rowCount - 1, event);"/>
|
||||
<handler event="keypress" keycode="VK_PAGE_UP"
|
||||
<handler event="keypress" keycode="VK_PAGE_UP" preventdefault="true"
|
||||
modifiers="accel any" action="_moveByPage(-1, 0, event);"/>
|
||||
<handler event="keypress" keycode="VK_PAGE_DOWN"
|
||||
<handler event="keypress" keycode="VK_PAGE_DOWN" preventdefault="true"
|
||||
modifiers="accel any" action="_moveByPage(1, this.view.rowCount - 1, event);"/>
|
||||
<handler event="keypress" keycode="VK_PAGE_UP"
|
||||
<handler event="keypress" keycode="VK_PAGE_UP" preventdefault="true"
|
||||
modifiers="accel any, shift" action="_moveByPageShift(-1, 0, event);"/>
|
||||
<handler event="keypress" keycode="VK_PAGE_DOWN"
|
||||
<handler event="keypress" keycode="VK_PAGE_DOWN" preventdefault="true"
|
||||
modifiers="accel any, shift" action="_moveByPageShift(1, this.view.rowCount - 1, event);"/>
|
||||
<handler event="keypress" keycode="VK_HOME"
|
||||
<handler event="keypress" keycode="VK_HOME" preventdefault="true"
|
||||
modifiers="accel any" action="_moveToEdge(0, event);"/>
|
||||
<handler event="keypress" keycode="VK_END"
|
||||
<handler event="keypress" keycode="VK_END" preventdefault="true"
|
||||
modifiers="accel any" action="_moveToEdge(this.view.rowCount - 1, event);"/>
|
||||
<handler event="keypress" keycode="VK_HOME"
|
||||
<handler event="keypress" keycode="VK_HOME" preventdefault="true"
|
||||
modifiers="accel any, shift" action="_moveToEdgeShift(0, event);"/>
|
||||
<handler event="keypress" keycode="VK_END"
|
||||
<handler event="keypress" keycode="VK_END" preventdefault="true"
|
||||
modifiers="accel any, shift" action="_moveToEdgeShift(this.view.rowCount - 1, event);"/>
|
||||
<handler event="keypress">
|
||||
<![CDATA[
|
||||
@ -899,6 +909,7 @@
|
||||
if (!this.view.selection.isSelected(c) ||
|
||||
(!this.view.selection.single && this._isAccelPressed(event))) {
|
||||
this.view.selection.toggleSelect(c);
|
||||
event.preventDefault();
|
||||
}
|
||||
}
|
||||
else if (!this.disableKeyNavigation && event.charCode > 0 &&
|
||||
@ -909,7 +920,8 @@
|
||||
this.view.selection.timedSelect(l, this._selectDelay);
|
||||
this.treeBoxObject.ensureRowIsVisible(l);
|
||||
}
|
||||
}
|
||||
event.preventDefault();
|
||||
}
|
||||
]]>
|
||||
</handler>
|
||||
</handlers>
|
||||
|
Loading…
Reference in New Issue
Block a user