From e94f9fd04a3cf8707793668dbf90f8a9da537dd8 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 8 Nov 2019 16:34:42 +0530 Subject: [PATCH] Viewer: Do not wait for loading of tags that are not stylesheets. Fixes #1851814 [Link tag with url results in slow loading](https://bugs.launchpad.net/calibre/+bug/1851814) --- src/pyj/read_book/resources.pyj | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/pyj/read_book/resources.pyj b/src/pyj/read_book/resources.pyj index fea033e91c..305c288324 100644 --- a/src/pyj/read_book/resources.pyj +++ b/src/pyj/read_book/resources.pyj @@ -190,6 +190,16 @@ def apply_attributes(src, elem, ns_map): continue elem.setAttribute(name, a[1]) + +def is_loadable_link(attributes): + for a in attributes: + if a[0].toLowerCase() is 'rel' and a[1]: + for x in a[1].split(' '): + if x.toLowerCase() is 'stylesheet': + return True + return False + + def process_stack(stack, tag_map, ns_map, load_required, onload): while stack.length: node, parent = stack.pop() @@ -216,7 +226,7 @@ def process_stack(stack, tag_map, ns_map, load_required, onload): if src.a: for a in src.a: if a[0] is attr: - loadable = True + loadable = is_loadable_link(src.a) if src.n is 'link' else True break if loadable: load_required.add(tag_id)