Reduce amount of isPointInRange calls for repeated ranges

This commit is contained in:
toasted-nutbread 2019-08-31 22:38:01 -04:00
parent 171e3f1097
commit ee59b3ab8b

View File

@ -269,16 +269,20 @@ function caretRangeFromPointExt(x, y, elements) {
const modifications = [];
try {
let i = 0;
let startContinerPre = null;
while (true) {
const range = caretRangeFromPoint(x, y);
if (range === null) {
return null;
}
const inRange = isPointInRange(x, y, range);
if (inRange) {
const startContainer = range.startContainer;
if (startContinerPre !== startContainer) {
if (isPointInRange(x, y, range)) {
return range;
}
startContinerPre = startContainer;
}
i = disableTransparentElement(elements, i, modifications);
if (i < 0) {