diff --git a/resources/compiled_coffeescript.zip b/resources/compiled_coffeescript.zip index b93b2a8de9..0581528412 100644 Binary files a/resources/compiled_coffeescript.zip and b/resources/compiled_coffeescript.zip differ diff --git a/src/calibre/ebooks/oeb/display/paged.coffee b/src/calibre/ebooks/oeb/display/paged.coffee index 2985179706..07d4ae33e8 100644 --- a/src/calibre/ebooks/oeb/display/paged.coffee +++ b/src/calibre/ebooks/oeb/display/paged.coffee @@ -85,15 +85,16 @@ class PagedDisplay tmp.style.position = 'absolute' document.body.appendChild(tmp) for sheet in document.styleSheets - for rule in sheet.rules - if rule.type == CSSRule.PAGE_RULE - for prop in ['left', 'top', 'bottom', 'right'] - val = rule.style.getPropertyValue('margin-'+prop) - if val - tmp.style.height = val - pxval = parseInt(window.getComputedStyle(tmp).height) - if not isNaN(pxval) - this.document_margins[prop] = pxval + if sheet.rules + for rule in sheet.rules + if rule.type == CSSRule.PAGE_RULE + for prop in ['left', 'top', 'bottom', 'right'] + val = rule.style.getPropertyValue('margin-'+prop) + if val + tmp.style.height = val + pxval = parseInt(window.getComputedStyle(tmp).height) + if not isNaN(pxval) + this.document_margins[prop] = pxval document.body.removeChild(tmp) if this.document_margins.left is null val = parseInt(window.getComputedStyle(document.body).marginLeft) @@ -232,14 +233,15 @@ class PagedDisplay # Convert page-breaks to column-breaks for sheet in document.styleSheets - for rule in sheet.rules - if rule.type == CSSRule.STYLE_RULE - for prop in ['page-break-before', 'page-break-after', 'page-break-inside'] - val = rule.style.getPropertyValue(prop) - if val - cprop = '-webkit-column-' + prop.substr(5) - priority = rule.style.getPropertyPriority(prop) - rule.style.setProperty(cprop, val, priority) + if sheet.rules + for rule in sheet.rules + if rule.type == CSSRule.STYLE_RULE + for prop in ['page-break-before', 'page-break-after', 'page-break-inside'] + val = rule.style.getPropertyValue(prop) + if val + cprop = '-webkit-column-' + prop.substr(5) + priority = rule.style.getPropertyPriority(prop) + rule.style.setProperty(cprop, val, priority) if first_layout # Because of a bug in webkit column mode, svg elements defined with diff --git a/src/calibre/ebooks/oeb/polish/preview.coffee b/src/calibre/ebooks/oeb/polish/preview.coffee index 7e0652cbc5..9abca8beb4 100644 --- a/src/calibre/ebooks/oeb/polish/preview.coffee +++ b/src/calibre/ebooks/oeb/polish/preview.coffee @@ -214,7 +214,7 @@ get_matched_css = (node, is_ancestor, all_properties) -> node_style = window.getComputedStyle(node) for sheet, sheet_index in document.styleSheets - if sheet.disabled + if sheet.disabled or not sheet.cssRules continue process_rules(node, sheet.cssRules, [], sheet, sheet_index, matching_selectors, all_properties, node_style, is_ancestor, ans) @@ -354,4 +354,3 @@ class PreviewIntegration window.calibre_preview_integration = new PreviewIntegration() window.onload = window.calibre_preview_integration.onload -