mirror of
https://github.com/koreader/koreader.git
synced 2026-12-03 10:36:11 +00:00
ReaderLink:isXpointerCoherent(): fix check in some edge cases
This commit is contained in:
1 parent
a72790090c
commit
8ae5f9f79e
2 files changed
+6
-4
No files matched your search
@@ -612,14 +612,16 @@ function ReaderLink:isXpointerCoherent(a_xpointer)
|
||||
-- Get screen coordinates of xpointer
|
||||
local screen_y, screen_x = self.document:getScreenPositionFromXPointer(a_xpointer)
|
||||
-- Get again link and a_xpointer from this position
|
||||
local re_link_xpointer, re_a_xpointer = self.document:getLinkFromPosition({x = screen_x, y = screen_y}) -- luacheck: no unused
|
||||
-- Providing forTextSelection=true may give more chances of success here
|
||||
-- (eg. with negative text indent and the link rect being outside of its paragraph rect).
|
||||
local re_link_xpointer, re_a_xpointer = self.document:getLinkFromPosition({x = screen_x, y = screen_y}, true) -- luacheck: no unused
|
||||
-- We should get the same a_xpointer. If not, crengine has messed up
|
||||
-- and we should not trust this xpointer to get back to this link.
|
||||
if re_a_xpointer ~= a_xpointer then
|
||||
-- Try it again with screen_x+1 (in the rare cases where screen_x
|
||||
-- fails, screen_x+1 usually works - probably something in crengine,
|
||||
-- but easier to workaround here that way)
|
||||
re_link_xpointer, re_a_xpointer = self.document:getLinkFromPosition({x = screen_x+1, y = screen_y}) -- luacheck: no unused
|
||||
re_link_xpointer, re_a_xpointer = self.document:getLinkFromPosition({x = screen_x+1, y = screen_y}, true) -- luacheck: no unused
|
||||
if re_a_xpointer ~= a_xpointer then
|
||||
logger.info("noncoherent a_xpointer:", a_xpointer)
|
||||
return false
|
||||
|
||||
Reference in new issue
Block a user