mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-07 18:24:30 -04:00
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:
parent
a3ae1ad46e
commit
ff3af3ac15
@ -618,19 +618,20 @@ def current_cfi():
|
|||||||
if yb <= top or ya >= bottom:
|
if yb <= top or ya >= bottom:
|
||||||
break
|
break
|
||||||
yidx += 1
|
yidx += 1
|
||||||
xidx = 0
|
|
||||||
ys = v'[ya]' if ya is yb else v'[yb, ya]'
|
ys = v'[ya]' if ya is yb else v'[yb, ya]'
|
||||||
for cury in ys:
|
for cury in ys:
|
||||||
xb, xa = midx - xidx * deltax, midx + xidx * deltax
|
xidx = 0
|
||||||
if xa <= left or xb >= right:
|
while True:
|
||||||
break
|
xb, xa = midx - xidx * deltax, midx + xidx * deltax
|
||||||
xidx += 1
|
if xb <= left or xa >= right:
|
||||||
xs = v'[xa]' if xa is xb else v'[xb, xa]'
|
break
|
||||||
for curx in xs:
|
xidx += 1
|
||||||
cfi = cfi_at_point(curx, cury)
|
xs = v'[xa]' if xa is xb else v'[xb, xa]'
|
||||||
if cfi:
|
for curx in xs:
|
||||||
# print('Viewport cfi:', cfi)
|
cfi = cfi_at_point(curx, cury)
|
||||||
return cfi
|
if cfi:
|
||||||
|
# print('Viewport cfi:', cfi)
|
||||||
|
return cfi
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
ans = cfi_at_current() or None
|
ans = cfi_at_current() or None
|
||||||
|
Loading…
x
Reference in New Issue
Block a user