mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Viewer: Fix images not being rendered at certain sizes when they are the only content on the page in paged mode with single page per screen. Fixes #1857803 [Viewer doesn't show some images](https://bugs.launchpad.net/calibre/+bug/1857803)
This commit is contained in:
parent
034d561be7
commit
3932fb8b5a
@ -143,7 +143,8 @@ def layout(is_single_page, on_resize):
|
|||||||
# cover, if so we treat it specially.
|
# cover, if so we treat it specially.
|
||||||
single_screen = (document_height() < scroll_viewport.height() + 75)
|
single_screen = (document_height() < scroll_viewport.height() + 75)
|
||||||
first_layout = True
|
first_layout = True
|
||||||
has_svg = document.getElementsByTagName('svg').length > 0
|
svgs = document.getElementsByTagName('svg')
|
||||||
|
has_svg = svgs.length > 0
|
||||||
imgs = document.getElementsByTagName('img')
|
imgs = document.getElementsByTagName('img')
|
||||||
only_img = imgs.length is 1 and document.getElementsByTagName('div').length < 3 and document.getElementsByTagName('p').length < 2
|
only_img = imgs.length is 1 and document.getElementsByTagName('div').length < 3 and document.getElementsByTagName('p').length < 2
|
||||||
if only_img and window.getComputedStyle(imgs[0]).zIndex < 0:
|
if only_img and window.getComputedStyle(imgs[0]).zIndex < 0:
|
||||||
@ -206,9 +207,14 @@ def layout(is_single_page, on_resize):
|
|||||||
# width 100% are wider than body and lead to a blank page after the
|
# width 100% are wider than body and lead to a blank page after the
|
||||||
# current page (when cols_per_screen == 1). Similarly img elements
|
# current page (when cols_per_screen == 1). Similarly img elements
|
||||||
# with height=100% overflow the first column
|
# with height=100% overflow the first column
|
||||||
is_full_screen_layout = (only_img or has_svg) and single_screen and (scroll_viewport.paged_content_width() < 2*ww + 10)
|
is_full_screen_layout = is_single_page
|
||||||
if is_single_page:
|
if not is_full_screen_layout:
|
||||||
is_full_screen_layout = True
|
has_no_more_than_two_columns = (scroll_viewport.paged_content_width() < 2*ww + 10)
|
||||||
|
if has_no_more_than_two_columns and single_screen:
|
||||||
|
if only_img and imgs.length and imgs[0].getBoundingClientRect().left < ww:
|
||||||
|
is_full_screen_layout = True
|
||||||
|
if has_svg and svgs.length == 1 and svgs[0].getBoundingClientRect().left < ww:
|
||||||
|
is_full_screen_layout = True
|
||||||
|
|
||||||
# Some browser engine, WebKit at least, adjust column widths to please
|
# Some browser engine, WebKit at least, adjust column widths to please
|
||||||
# themselves, unless the container width is an exact multiple, so we check
|
# themselves, unless the container width is an exact multiple, so we check
|
||||||
|
Loading…
x
Reference in New Issue
Block a user