Skip to content

Commit 0a0b19e

Browse files
committed
1 parent cd77c14 commit 0a0b19e

File tree

1 file changed

+20
-5
lines changed

1 file changed

+20
-5
lines changed

litehtml/el_image.cpp

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,18 +33,33 @@ void litehtml::el_image::parse_styles(bool is_reparse)
3333
if(!m_css_height.val())
3434
{
3535
m_css_height.fromString(get_attr(L"height", L"auto"), L"auto");
36-
if(m_css_height.is_predefined())
37-
{
38-
m_css_height.set_value((float) sz.height, css_units_px);
39-
}
4036
}
4137
if(!m_css_width.val())
4238
{
4339
m_css_width.fromString(get_attr(L"width", L"auto"), L"auto");
44-
if(m_css_width.is_predefined())
40+
}
41+
if(m_css_height.is_predefined() && m_css_width.is_predefined())
42+
{
43+
m_css_height.set_value((float) sz.height, css_units_px);
44+
m_css_width.set_value((float) sz.width, css_units_px);
45+
} else if(!m_css_height.is_predefined() && m_css_width.is_predefined())
46+
{
47+
if(sz.height)
48+
{
49+
m_css_width.set_value((float) m_css_height.val() * (float)sz.width / (float)sz.height, css_units_px);
50+
} else
4551
{
4652
m_css_width.set_value((float) sz.width, css_units_px);
4753
}
54+
} else if(m_css_height.is_predefined() && !m_css_width.is_predefined())
55+
{
56+
if(sz.width)
57+
{
58+
m_css_height.set_value((float) m_css_width.val() * (float) sz.height / (float)sz.width, css_units_px);
59+
} else
60+
{
61+
m_css_height.set_value((float) sz.height, css_units_px);
62+
}
4863
}
4964
}
5065

0 commit comments

Comments
 (0)