mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
E-book viewer: Use heuristics to try to detect comics encoded as fixed layout EPUBs to ensure they are displayed as intended. Fixes #1667357 [Private bug](https://bugs.launchpad.net/calibre/+bug/1667357)
This commit is contained in:
parent
775b69d74f
commit
655372f10f
Binary file not shown.
@ -142,6 +142,14 @@ class PagedDisplay
|
||||
# Check if the current document is a full screen layout like
|
||||
# cover, if so we treat it specially.
|
||||
single_screen = (document.body.scrollHeight < window.innerHeight + 75)
|
||||
has_svg = document.getElementsByTagName('svg').length > 0
|
||||
only_img = document.getElementsByTagName('img').length == 1 and document.getElementsByTagName('div').length < 3 and document.getElementsByTagName('p').length < 2
|
||||
if only_img
|
||||
has_viewport = document.head and document.head.querySelector('meta[name="viewport"]')
|
||||
if has_viewport
|
||||
# Has a viewport and only an img, is probably a comic, see for
|
||||
# example: https://bugs.launchpad.net/bugs/1667357
|
||||
single_screen = true
|
||||
this.handle_rtl_body(body_style)
|
||||
first_layout = true
|
||||
if not single_screen and this.cols_per_screen > 1
|
||||
@ -248,8 +256,6 @@ class PagedDisplay
|
||||
# width 100% are wider than body and lead to a blank page after the
|
||||
# current page (when cols_per_screen == 1). Similarly img elements
|
||||
# with height=100% overflow the first column
|
||||
has_svg = document.getElementsByTagName('svg').length > 0
|
||||
only_img = document.getElementsByTagName('img').length == 1 and document.getElementsByTagName('div').length < 3 and document.getElementsByTagName('p').length < 2
|
||||
# We only set full_screen_layout if scrollWidth is in (body_width,
|
||||
# 2*body_width) as if it is <= body_width scrolling will work
|
||||
# anyway and if it is >= 2*body_width it can't be a full screen
|
||||
|
Loading…
x
Reference in New Issue
Block a user