Reduce amount of isPointInRange calls for repeated ranges
This commit is contained in:
parent
171e3f1097
commit
ee59b3ab8b
@ -269,15 +269,19 @@ function caretRangeFromPointExt(x, y, elements) {
|
|||||||
const modifications = [];
|
const modifications = [];
|
||||||
try {
|
try {
|
||||||
let i = 0;
|
let i = 0;
|
||||||
|
let startContinerPre = null;
|
||||||
while (true) {
|
while (true) {
|
||||||
const range = caretRangeFromPoint(x, y);
|
const range = caretRangeFromPoint(x, y);
|
||||||
if (range === null) {
|
if (range === null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
const inRange = isPointInRange(x, y, range);
|
const startContainer = range.startContainer;
|
||||||
if (inRange) {
|
if (startContinerPre !== startContainer) {
|
||||||
return range;
|
if (isPointInRange(x, y, range)) {
|
||||||
|
return range;
|
||||||
|
}
|
||||||
|
startContinerPre = startContainer;
|
||||||
}
|
}
|
||||||
|
|
||||||
i = disableTransparentElement(elements, i, modifications);
|
i = disableTransparentElement(elements, i, modifications);
|
||||||
|
Loading…
Reference in New Issue
Block a user