Let the browser engine tell us if the selection is hidden or not

This commit is contained in:
Kovid Goyal 2023-06-19 10:33:50 +05:30
parent 779598eec0
commit cb41907196
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -2,8 +2,6 @@
# License: GPL v3 Copyright: 2020, Kovid Goyal <kovid at kovidgoyal.net> # License: GPL v3 Copyright: 2020, Kovid Goyal <kovid at kovidgoyal.net>
from __python__ import bound_methods, hash_literals from __python__ import bound_methods, hash_literals
from range_utils import select_first_node_from_range, is_node_visible
def build_text_map(): def build_text_map():
node_list = v'[]' node_list = v'[]'
flat_text = '' flat_text = ''
@ -141,12 +139,7 @@ def select_find_result(match):
sel.setBaseAndExtent(match.start_node, match.start_offset, match.end_node, match.end_offset) sel.setBaseAndExtent(match.start_node, match.start_offset, match.end_node, match.end_offset)
except: # if offset is outside node except: # if offset is outside node
return False return False
if not sel.rangeCount: return bool(sel.rangeCount and sel.toString())
return False
for i in range(sel.rangeCount):
if select_first_node_from_range(sel.getRangeAt(i), is_node_visible):
return True
return False
def select_search_result(sr): def select_search_result(sr):