Skip to content

Commit aa59f60

Browse files
committed
Use checkVisibility for optimization
1 parent c6a51a0 commit aa59f60

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

webextensions/content_scripts/range.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,15 @@ function isNodeVisible(node) {
299299
if (nodeVisibilityCache.has(node))
300300
return nodeVisibilityCache.get(node);
301301

302+
if (typeof node.checkVisibility == 'function') {
303+
const visible = node.checkVisibility({
304+
checkOpacity: true,
305+
checkVisibilityCSS: true
306+
});
307+
nodeVisibilityCache.set(node, visible);
308+
return visible;
309+
}
310+
302311
// We should return earlier if the node is certainly invisible,
303312
// because getClientRects and elementsFromPointElements are slow.
304313
if (node.offsetWidth == 0 || node.offsetHeight == 0) {

0 commit comments

Comments
 (0)