From a6e66131ce5b676ccc888ec5b1011d0946dc3907 Mon Sep 17 00:00:00 2001 From: Nicolas Lempereur Date: Mon, 12 Feb 2018 12:46:00 +0100 Subject: [FIX] web_editor: error on cross domain stylesheet On latest chromium (as of version 64), accessing rules of a stylesheet is forbidden for cross-domain. This commit catch and ignores the error when that happened. chromium commit: https://chromium.googlesource.com/chromium/src/+/a4ebe08c91 opw-813480 opw-815860 closes #23009 --- addons/web_editor/static/src/js/transcoder.js | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) (limited to 'addons/web_editor/static/src/js/transcoder.js') diff --git a/addons/web_editor/static/src/js/transcoder.js b/addons/web_editor/static/src/js/transcoder.js index b0831832dd6..5772db9bccc 100644 --- a/addons/web_editor/static/src/js/transcoder.js +++ b/addons/web_editor/static/src/js/transcoder.js @@ -13,17 +13,12 @@ var getMatchedCSSRules = function (a) { var sheets = document.styleSheets; for(var i = sheets.length-1; i >= 0 ; i--) { var rules; - if (sheets[i].hasOwnProperty('rules')) { - rules = sheets[i].rules; - } else { - //try...catch because Firefox not able to enumerate document.styleSheets[].cssRules[] for cross-domain stylesheets. - try { - rules = sheets[i].cssRules; - } catch(e) { - console.warn("Can't read the css rules of: " + sheets[i].href, e); - continue; - } - rules = sheets[i].cssRules; + // try...catch because browser may not able to enumerate rules for cross-domain sheets + try { + rules = sheets[i].rules || sheets[i].cssRules; + } catch (e) { + console.warn("Can't read the css rules of: " + sheets[i].href, e); + continue; } if (rules) { for(var r = rules.length-1; r >= 0; r--) { -- cgit v1.2.3 From 32bdadad1314360b1c5d4734435f481d2545bbf1 Mon Sep 17 00:00:00 2001 From: qsm-odoo Date: Tue, 13 Feb 2018 12:04:51 +0100 Subject: [FIX] web_editor, mass_mailing: better transcode alignment inheritance Browsers' default alignement of is 'inherit'. Some mail clients do not set this value properly though and even if it is explicitely set, they do not compute the final value well. As a fix, this commit forces the 'inherit' value on and computes the real alignment for 'inherit' values when transcoding. opw-813688 --- addons/web_editor/static/src/js/transcoder.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'addons/web_editor/static/src/js/transcoder.js') diff --git a/addons/web_editor/static/src/js/transcoder.js b/addons/web_editor/static/src/js/transcoder.js index 265ca5ab3f0..b402c14a39f 100644 --- a/addons/web_editor/static/src/js/transcoder.js +++ b/addons/web_editor/static/src/js/transcoder.js @@ -131,6 +131,20 @@ var getMatchedCSSRules = function (a) { delete style['text-decoration-style']; } + // text-align inheritance does not seem to get past elements on some + // mail clients + if (style['text-align'] === 'inherit') { + var $el = $(a).parent(); + do { + var align = $el.css('text-align'); + if (_.indexOf(['left', 'right', 'center', 'justify'], align) >= 0) { + style['text-align'] = align; + break; + } + $el = $el.parent(); + } while (!$el.is('html')); + } + return style; }; -- cgit v1.2.3