Bug 597283 - Limit pan animation using MozBeforePaint [r=mfinkle]

This commit is contained in:
Benjamin Stover 2010-09-17 11:28:35 -07:00
parent 7b195b8cab
commit 30b4cbf55e

View File

@ -349,7 +349,7 @@ function MouseModule(owner, browserViewContainer) {
MouseModule.prototype = {
handleEvent: function handleEvent(aEvent) {
if (aEvent.button !== 0 && aEvent.type != "contextmenu")
if (aEvent.button !== 0 && aEvent.type != "contextmenu" && aEvent.type != "MozBeforePaint")
return;
switch (aEvent.type) {
@ -372,6 +372,10 @@ MouseModule.prototype = {
if (this._dragData.dragging)
this._doDragStop(0, 0, true);
break;
case "MozBeforePaint":
this._waitingForPaint = false;
removeEventListener("MozBeforePaint", this, false);
break;
}
},
@ -525,7 +529,7 @@ MouseModule.prototype = {
_onMouseMove: function _onMouseMove(aEvent) {
let dragData = this._dragData;
if (dragData.dragging) {
if (dragData.dragging && !this._waitingForPaint) {
let oldIsPan = dragData.isPan();
dragData.setDragPosition(aEvent.screenX, aEvent.screenY);
aEvent.stopPropagation();
@ -609,7 +613,13 @@ MouseModule.prototype = {
*/
_dragBy: function _dragBy(dX, dY) {
let dragData = this._dragData;
return this._dragger.dragMove(dX, dY, this._targetScrollInterface);
let dragged = this._dragger.dragMove(dX, dY, this._targetScrollInterface);
if (dragged && !this._waitingForPaint) {
this._waitingForPaint = true;
mozRequestAnimationFrame();
addEventListener("MozBeforePaint", this, false);
}
return dragged;
},
/** Callback for kinetic scroller. */