Bug 1302736 - Add rudimentary touch-scrolling support to the XUL tree widget. r?jaws
MozReview-Commit-ID: BKLk4CAjSY8
--- a/toolkit/content/widgets/tree.xml
+++ b/toolkit/content/widgets/tree.xml
@@ -125,16 +125,18 @@
<property name="_selectDelay"
onset="this.setAttribute('_selectDelay', val);"
onget="return this.getAttribute('_selectDelay') || 50;"/>
<field name="_columnsDirty">true</field>
<field name="_lastKeyTime">0</field>
<field name="_incrementalString">""</field>
+ <field name="_touchY">-1</field>
+
<method name="_ensureColumnOrder">
<body><![CDATA[
if (!this._columnsDirty)
return;
if (this.columns) {
// update the ordinal position of each column to assure that it is
// an odd number and 2 positions above its next sibling
@@ -679,16 +681,46 @@
}
}
return this.changeOpenState(this.currentIndex);
]]></body>
</method>
</implementation>
<handlers>
+ <handler event="touchstart">
+ <![CDATA[
+ if (event.touches.length > 1) {
+ // Multiple touch points detected, abort.
+ this._touchY = -1;
+ } else {
+ this._touchY = event.touches[0].screenY;
+ }
+ ]]>
+ </handler>
+ <handler event="touchmove">
+ <![CDATA[
+ if (event.touches.length == 1 &&
+ this._touchY != -1) {
+ var deltaY = this._touchY - event.touches[0].screenY;
+ var lines = Math.trunc(deltaY / this.treeBoxObject.rowHeight);
+ if (Math.abs(lines) > 0) {
+ this.treeBoxObject.scrollByLines(lines);
+ deltaY -= lines * this.treeBoxObject.rowHeight;
+ this._touchY = event.touches[0].screenY + deltaY;
+ }
+ event.preventDefault();
+ }
+ ]]>
+ </handler>
+ <handler event="touchend">
+ <![CDATA[
+ this._touchY = -1;
+ ]]>
+ </handler>
<handler event="MozMousePixelScroll" preventdefault="true"/>
<handler event="DOMMouseScroll" preventdefault="true">
<![CDATA[
if (this._editingColumn)
return;
if (event.axis == event.HORIZONTAL_AXIS)
return;