From c5a2652c9bb3e9877fd8f22776be6aa45867b056 Mon Sep 17 00:00:00 2001 From: Samuel Degueldre Date: Fri, 30 Oct 2020 09:15:13 +0000 Subject: [PATCH] [FIX] web_editor: fix gap between transformed shape and next section Previously, when flipping some shapes vertically on chrome, and vertically or horizontally on firefox, there was a gap of 1px or less at some screen widths. This is caused by the way these browsers render backgrounds on transformed elements. It seems like firefox will round the size of the element to render the background image on it if the element is transformed, while chrome will always render the background at the correct size (or render it at a larger size and clip it to the correct size after the fact), but will round the coordinates of the symmetry point, causing only the vertical flip to have this issue, and only if the background image would not extend beyond the bounds of the element (on firefox, even shapes that would extend beyond the bounds of the element would showcase a gap, eg origins 1) This commit fixes that by applying the transform to the SVG rather than to the element, by use of the shapes controller. task-2369560 closes odoo/odoo#61609 X-original-commit: 42b3ad10e0b32b7fc72f801e2c67d6baf938c566 Signed-off-by: Quentin Smetz (qsm) --- addons/web_editor/controllers/main.py | 17 ++++--- addons/web_editor/static/shapes/Airy/03.svg | 2 +- .../web_editor/static/shapes/Origins/05.svg | 2 +- .../web_editor/static/shapes/Origins/06.svg | 2 +- .../web_editor/static/shapes/Origins/11.svg | 2 +- .../web_editor/static/shapes/Origins/13.svg | 2 +- .../web_editor/static/shapes/Origins/14.svg | 2 +- addons/web_editor/static/shapes/Wavy/01.svg | 2 +- addons/web_editor/static/shapes/Wavy/05.svg | 2 +- addons/web_editor/static/shapes/Zigs/03.svg | 2 +- .../static/src/js/editor/snippets.options.js | 45 ++++++++++++++----- 11 files changed, 55 insertions(+), 25 deletions(-) diff --git a/addons/web_editor/controllers/main.py b/addons/web_editor/controllers/main.py index 87db5e7b377..e85a678f54e 100644 --- a/addons/web_editor/controllers/main.py +++ b/addons/web_editor/controllers/main.py @@ -531,13 +531,20 @@ class Web_Editor(http.Controller): svg = file.read() user_colors = [] - for key, color in kwargs.items(): - match = re.match('^c([1-5])$', key) - if match: + for key, value in kwargs.items(): + colorMatch = re.match('^c([1-5])$', key) + if colorMatch: # Check that color is hex or rgb(a) to prevent arbitrary injection - if not re.match(r'(?i)^#[0-9A-F]{6,8}$|^rgba?\(\d{1,3},\d{1,3},\d{1,3}(?:,[0-9.]{1,4})?\)$', color.replace(' ', '')): + if not re.match(r'(?i)^#[0-9A-F]{6,8}$|^rgba?\(\d{1,3},\d{1,3},\d{1,3}(?:,[0-9.]{1,4})?\)$', value.replace(' ', '')): raise werkzeug.exceptions.BadRequest() - user_colors.append([tools.html_escape(color), match.group(1)]) + user_colors.append([tools.html_escape(value), colorMatch.group(1)]) + elif key == 'flip': + if value == 'x': + svg = svg.replace(' + viewBox="0 0 1400 244.7" xml:space="preserve">