Bug 770371 - Add a margin to the tappable area for copying selected text [r=margaret]

This commit is contained in:
Matt Brubeck 2012-07-03 10:39:22 -07:00
Родитель 44034475aa
Коммит 9942c1c338
1 изменённых файлов: 20 добавлений и 12 удалений

Просмотреть файл

@ -1746,8 +1746,11 @@ var SelectionHandler = {
win = win.parent;
}
return (aX - offset.x > this.cache.rect.left && aX - offset.x < this.cache.rect.right) &&
(aY - offset.y > this.cache.rect.top && aY - offset.y < this.cache.rect.bottom);
let radius = ElementTouchHelper.getTouchRadius();
return (aX - offset.x > this.cache.rect.left - radius.left &&
aX - offset.x < this.cache.rect.right + radius.right &&
aY - offset.y > this.cache.rect.top - radius.top &&
aY - offset.y < this.cache.rect.bottom + radius.bottom);
},
// Returns true if the selection has been reversed. Takes optional aIsStartHandle
@ -3623,6 +3626,19 @@ const ElementTouchHelper = {
return elem;
},
/* Returns the touch radius in content px. */
getTouchRadius: function getTouchRadius() {
let dpiRatio = ViewportHandler.displayDPI / kReferenceDpi;
let zoom = BrowserApp.selectedTab._zoom;
return {
top: this.radius.top * dpiRatio / zoom,
right: this.radius.right * dpiRatio / zoom,
bottom: this.radius.bottom * dpiRatio / zoom,
left: this.radius.left * dpiRatio / zoom
};
},
/* Returns the touch radius in reference pixels. */
get radius() {
let prefs = Services.prefs;
delete this.radius;
@ -3640,11 +3656,6 @@ const ElementTouchHelper = {
/* Retrieve the closest element to a point by looking at borders position */
getClosest: function getClosest(aWindowUtils, aX, aY) {
if (!this.dpiRatio)
this.dpiRatio = aWindowUtils.displayDPI / kReferenceDpi;
let dpiRatio = this.dpiRatio;
let target = aWindowUtils.elementFromPoint(aX, aY,
true, /* ignore root scroll frame*/
false); /* don't flush layout */
@ -3657,11 +3668,8 @@ const ElementTouchHelper = {
return target;
target = null;
let zoom = BrowserApp.selectedTab._zoom;
let nodes = aWindowUtils.nodesFromRect(aX, aY, this.radius.top * dpiRatio / zoom,
this.radius.right * dpiRatio / zoom,
this.radius.bottom * dpiRatio / zoom,
this.radius.left * dpiRatio / zoom, true, false);
let radius = this.getTouchRadius();
let nodes = aWindowUtils.nodesFromRect(aX, aY, radius.top, radius.right, radius.bottom, radius.left, true, false);
let threshold = Number.POSITIVE_INFINITY;
for (let i = 0; i < nodes.length; i++) {