Bug 501566: It takes too long to highlight a selected link, r=froystig, r=mfinkle

This commit is contained in:
Benjamin Stover 2009-09-01 23:39:39 -04:00
parent 9bc60d8bd9
commit fd46364538
3 changed files with 60 additions and 35 deletions

View File

@ -488,6 +488,9 @@ MouseModule.prototype = {
this._owner.grab(this);
if (this._clicker)
this._clicker.mouseDown(evInfo.event.clientX, evInfo.event.clientY);
if (targetScrollInterface) {
this._doDragStart(evInfo.event);
}
@ -525,6 +528,9 @@ MouseModule.prototype = {
this._recordEvent(evInfo);
if (this._clicker)
this._clicker.mouseUp(evInfo.event.clientX, evInfo.event.clientY);
this._doClick(this._movedOutOfRadius);
this._owner.ungrab(this);

View File

@ -63,7 +63,18 @@ let Util = {
dumpLn: function dumpLn() {
for (var i = 0; i < arguments.length; i++) { dump(arguments[i] + ' '); }
dump("\n");
},
/** Executes aFunc after other events have been processed. */
executeSoon: function executeSoon(aFunc) {
let tm = Cc["@mozilla.org/thread-manager;1"].getService(Ci.nsIThreadManager);
tm.mainThread.dispatch({
run: function() {
aFunc();
}
}, Ci.nsIThread.DISPATCH_NORMAL);
}
};

View File

@ -344,7 +344,7 @@ var Browser = {
let bv = this._browserView = new BrowserView(container, Browser.getVisibleRect);
/* handles dispatching clicks on tiles into clicks in content or zooms */
container.customClicker = this._createContentCustomClicker(bv);
container.customClicker = new ContentCustomClicker(bv);
/* vertically scrolling box that contains tiles and the urlbar */
let contentScrollbox = this.contentScrollbox = document.getElementById("tile-container-container");
@ -851,40 +851,6 @@ var Browser = {
}
},
_createContentCustomClicker: function _createContentCustomClicker(browserView) {
// XXX we probably shouldn't generate this dynamically like this, but
// actually make it a prototype somewhere and instantiate it and such...
function dispatchContentClick(browser, x, y) {
let cwu = BrowserView.Util.getBrowserDOMWindowUtils(browser);
let scrollX = { value: 0 };
let scrollY = { value: 0 };
cwu.getScrollXY(false, scrollX, scrollY);
cwu.sendMouseEvent("mousedown", x - scrollX.value, y - scrollY.value, 0, 1, 0, true);
cwu.getScrollXY(false, scrollX, scrollY);
cwu.sendMouseEvent("mouseup", x - scrollX.value, y - scrollY.value, 0, 1, 0, true);
}
return {
singleClick: function singleClick(cX, cY) {
let browser = browserView.getBrowser();
if (browser) {
let [x, y] = Browser.transformClientToBrowser(cX, cY);
dispatchContentClick(browser, x, y);
}
},
doubleClick: function doubleClick(cX1, cY1, cX2, cY2) {
if (!Browser.zoomToPoint(cX2, cY2))
Browser.zoomFromPoint(cX2, cY2);
},
toString: function toString() {
return "[ContentCustomClicker] { }";
}
};
},
/**
* Compute the sidebar percentage visibility.
*
@ -1570,6 +1536,48 @@ const BrowserSearch = {
}
}
/** Watches for mouse events in chrome and sends them to content. */
function ContentCustomClicker(browserView) {
this._browserView = browserView;
}
ContentCustomClicker.prototype = {
/** Dispatch a mouse event with chrome client coordinates. */
_dispatchMouseEvent: function _dispatchMouseEvent(name, cX, cY) {
let browser = this._browserView.getBrowser();
let [x, y] = Browser.transformClientToBrowser(cX, cY);
let cwu = BrowserView.Util.getBrowserDOMWindowUtils(browser);
let scrollX = {}, scrollY = {};
if (browser) {
cwu.getScrollXY(false, scrollX, scrollY);
cwu.sendMouseEvent(name, x - scrollX.value, y - scrollY.value, 0, 1, 0, true);
}
},
mouseDown: function mouseDown(cX, cY) {
this._dispatchMouseEvent("mousedown", cX, cY);
// Re-render content after mousedown event has possibly selected something.
Util.executeSoon(this._browserView.renderNow);
},
mouseUp: function mouseUp(cX, cY) {
},
singleClick: function singleClick(cX, cY) {
// Send mouseup only once we know it is just one click.
this._dispatchMouseEvent("mouseup", cX, cY);
},
doubleClick: function doubleClick(cX1, cY1, cX2, cY2) {
if (!Browser.zoomToPoint(cX2, cY2))
Browser.zoomFromPoint(cX2, cY2);
},
toString: function toString() {
return "[ContentCustomClicker] { }";
}
};
/**
* Utility class to handle manipulations of the identity indicators in the UI
*/