mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Conversion pipeline: Respect max-width and max-height when calculating the effective size of an element
This commit is contained in:
parent
6143392ee9
commit
113ff417d6
@ -253,7 +253,10 @@ class Stylizer(object):
|
|||||||
upd = {}
|
upd = {}
|
||||||
for prop in ('width', 'height'):
|
for prop in ('width', 'height'):
|
||||||
val = elem.get(prop, '').strip()
|
val = elem.get(prop, '').strip()
|
||||||
|
try:
|
||||||
del elem.attrib[prop]
|
del elem.attrib[prop]
|
||||||
|
except:
|
||||||
|
pass
|
||||||
if val:
|
if val:
|
||||||
if num_pat.match(val) is not None:
|
if num_pat.match(val) is not None:
|
||||||
val += 'px'
|
val += 'px'
|
||||||
@ -584,6 +587,13 @@ class Style(object):
|
|||||||
if isinstance(result, (unicode, str, bytes)):
|
if isinstance(result, (unicode, str, bytes)):
|
||||||
result = self._profile.width
|
result = self._profile.width
|
||||||
self._width = result
|
self._width = result
|
||||||
|
if 'max-width' in self._style:
|
||||||
|
result = self._unit_convert(self._style['max-width'], base=base)
|
||||||
|
if isinstance(result, (unicode, str, bytes)):
|
||||||
|
result = self._width
|
||||||
|
if result < self._width:
|
||||||
|
self._width = result
|
||||||
|
|
||||||
return self._width
|
return self._width
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@ -607,6 +617,13 @@ class Style(object):
|
|||||||
if isinstance(result, (unicode, str, bytes)):
|
if isinstance(result, (unicode, str, bytes)):
|
||||||
result = self._profile.height
|
result = self._profile.height
|
||||||
self._height = result
|
self._height = result
|
||||||
|
if 'max-height' in self._style:
|
||||||
|
result = self._unit_convert(self._style['max-height'], base=base)
|
||||||
|
if isinstance(result, (unicode, str, bytes)):
|
||||||
|
result = self._height
|
||||||
|
if result < self._height:
|
||||||
|
self._height = result
|
||||||
|
|
||||||
return self._height
|
return self._height
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
Loading…
x
Reference in New Issue
Block a user