From 655372f10f987e1c7ece3e5060512d846db7f98e Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 23 Feb 2017 22:42:03 +0530 Subject: [PATCH] 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) --- resources/compiled_coffeescript.zip | Bin 101577 -> 101797 bytes src/calibre/ebooks/oeb/display/paged.coffee | 10 ++++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/resources/compiled_coffeescript.zip b/resources/compiled_coffeescript.zip index 1934079e84f89f91a700f254c6f799c965df69db..fefc756553fddc5447b6615e4aa434f9a3480fb2 100644 GIT binary patch delta 456 zcmX>(lWpm2whiz0@`-N^_xcr|;Zc&uz)+Gm{j4^l$6MrvY; zf|?qtfL>u~YEflyYEEi$Nq&)rdTwe-Vsu_&ZmO*k%uc0Pbxms|^FcOeXdyWY)p`Ym z;>^7CoYeT@33QT|h3gxew#?3U5Z)=`3B00vygAj123Us+FeS zX$K0mbTK-E!%auYN)30_hT2KGb&FD8>pqtSL#NwDNzlLl2>>ftl>5sY@#ip7O1_lt8W|+>{$tXJgPbVYCX4!phQkys4IK#Nv z;!XztPn{WEYZbs|r zRy~Y9(`9-YgQwr_VRW1x(9Os(`TkVy>Hk5JK%R(3im9PdqGhV3WnyAds(F%`MY54) pQktn*qIs%`rJ=E 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