mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Handle the case of document stylesheets with null cssrules (caused by cross-origin security policies)
This commit is contained in:
parent
a35f1b7d26
commit
344864a807
Binary file not shown.
@ -85,6 +85,7 @@ class PagedDisplay
|
||||
tmp.style.position = 'absolute'
|
||||
document.body.appendChild(tmp)
|
||||
for sheet in document.styleSheets
|
||||
if sheet.rules
|
||||
for rule in sheet.rules
|
||||
if rule.type == CSSRule.PAGE_RULE
|
||||
for prop in ['left', 'top', 'bottom', 'right']
|
||||
@ -232,6 +233,7 @@ class PagedDisplay
|
||||
|
||||
# Convert page-breaks to column-breaks
|
||||
for sheet in document.styleSheets
|
||||
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']
|
||||
|
@ -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
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user