Clean up fs_images

This commit is contained in:
Kovid Goyal 2019-10-20 10:46:44 +05:30
parent 579049affd
commit ac2d44e4dc
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -3,6 +3,16 @@
from __python__ import bound_methods, hash_literals from __python__ import bound_methods, hash_literals
def is_svg_fs_markup(names, svg):
if svg is not None:
if names.length is 2 or names.length is 3:
if names[-1] is 'image' and names[-2] is 'svg':
if names.length is 2 or names[0] is 'div':
if svg.width is '100%' and svg.height is '100%':
return True
return False
def fix_fullscreen_svg_images(): def fix_fullscreen_svg_images():
# Full screen images using SVG no longer render correctly # Full screen images using SVG no longer render correctly
# webengine. This is because it sets the width to the # webengine. This is because it sets the width to the
@ -27,7 +37,7 @@ def fix_fullscreen_svg_images():
names.push(name) names.push(name)
if name is 'svg': if name is 'svg':
svg = node svg = node
if names == ['div', 'svg', 'image'] or names == ['svg', 'image']:
if svg.getAttribute('width') is '100%' and svg.getAttribute('height') is '100%': if is_svg_fs_markup(names, svg):
svg.setAttribute('width', '100vw') svg.setAttribute('width', '100vw')
svg.setAttribute('height', '100vh') svg.setAttribute('height', '100vh')