Handle the case of document stylesheets with null cssrules (caused by cross-origin security policies)

This commit is contained in:
Kovid Goyal 2016-12-24 11:05:44 +05:30
parent a35f1b7d26
commit 344864a807
3 changed files with 20 additions and 19 deletions

Binary file not shown.

View File

@ -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']

View File

@ -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