mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 741228 - Add a small element cache to reduce time spent finding clickable elements. r=wesj
This commit is contained in:
parent
747bb56695
commit
45e654432d
@ -2715,8 +2715,11 @@ const ElementTouchHelper = {
|
||||
true, /* ignore root scroll frame*/
|
||||
false); /* don't flush layout */
|
||||
|
||||
// if this element is clickable we return quickly
|
||||
if (this.isElementClickable(target))
|
||||
// if this element is clickable we return quickly. also, if it isn't,
|
||||
// use a cache to speed up future calls to isElementClickable in the
|
||||
// loop below.
|
||||
let unclickableCache = new Array();
|
||||
if (this.isElementClickable(target, unclickableCache))
|
||||
return target;
|
||||
|
||||
let target = null;
|
||||
@ -2728,7 +2731,7 @@ const ElementTouchHelper = {
|
||||
let threshold = Number.POSITIVE_INFINITY;
|
||||
for (let i = 0; i < nodes.length; i++) {
|
||||
let current = nodes[i];
|
||||
if (!current.mozMatchesSelector || !this.isElementClickable(current))
|
||||
if (!current.mozMatchesSelector || !this.isElementClickable(current, unclickableCache))
|
||||
continue;
|
||||
|
||||
let rect = current.getBoundingClientRect();
|
||||
@ -2747,13 +2750,17 @@ const ElementTouchHelper = {
|
||||
return target;
|
||||
},
|
||||
|
||||
isElementClickable: function isElementClickable(aElement) {
|
||||
isElementClickable: function isElementClickable(aElement, aUnclickableCache) {
|
||||
const selector = "a,:link,:visited,[role=button],button,input,select,textarea,label";
|
||||
for (let elem = aElement; elem; elem = elem.parentNode) {
|
||||
if (aUnclickableCache && aUnclickableCache.indexOf(elem) != -1)
|
||||
continue;
|
||||
if (this._hasMouseListener(elem))
|
||||
return true;
|
||||
if (elem.mozMatchesSelector && elem.mozMatchesSelector(selector))
|
||||
return true;
|
||||
if (aUnclickableCache)
|
||||
aUnclickableCache.push(elem);
|
||||
}
|
||||
return false;
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user