E-book viewer: Make CFI calculation more robust especially on pages with very little content. Fixes #2037454 [E-book viewer: "Back" button doesn't work under some conditions](https://bugs.launchpad.net/calibre/+bug/2037454)

We were only testing two x values per y value. Instead test all 48.
This commit is contained in:
Kovid Goyal 2023-09-27 19:54:56 +05:30
parent a3ae1ad46e
commit ff3af3ac15
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -618,11 +618,12 @@ def current_cfi():
if yb <= top or ya >= bottom:
break
yidx += 1
xidx = 0
ys = v'[ya]' if ya is yb else v'[yb, ya]'
for cury in ys:
xidx = 0
while True:
xb, xa = midx - xidx * deltax, midx + xidx * deltax
if xa <= left or xb >= right:
if xb <= left or xa >= right:
break
xidx += 1
xs = v'[xa]' if xa is xb else v'[xb, xa]'