| 46 | } |
| 47 | |
| 48 | int litehtml::el_image::render( int x, int y, int max_width, bool second_pass ) |
| 49 | { |
| 50 | int parent_width = max_width; |
| 51 | |
| 52 | calc_outlines(parent_width); |
| 53 | |
| 54 | m_pos.move_to(x, y); |
| 55 | |
| 56 | document::ptr doc = get_document(); |
| 57 | |
| 58 | litehtml::size sz; |
| 59 | doc->container()->get_image_size(m_src.c_str(), 0, sz); |
| 60 | |
| 61 | m_pos.width = sz.width; |
| 62 | m_pos.height = sz.height; |
| 63 | |
| 64 | if(m_css_height.is_predefined() && m_css_width.is_predefined()) |
| 65 | { |
| 66 | m_pos.height = sz.height; |
| 67 | m_pos.width = sz.width; |
| 68 | |
| 69 | // check for max-width |
| 70 | if(!m_css_max_width.is_predefined()) |
| 71 | { |
| 72 | int max_width = doc->cvt_units(m_css_max_width, m_font_size, parent_width); |
| 73 | if(m_pos.width > max_width) |
| 74 | { |
| 75 | m_pos.width = max_width; |
| 76 | } |
| 77 | if(sz.width) |
| 78 | { |
| 79 | m_pos.height = (int) ((float) m_pos.width * (float) sz.height / (float)sz.width); |
| 80 | } else |
| 81 | { |
| 82 | m_pos.height = sz.height; |
| 83 | } |
| 84 | } |
| 85 | |
| 86 | // check for max-height |
| 87 | if(!m_css_max_height.is_predefined()) |
| 88 | { |
| 89 | int max_height = calc_max_height(sz.height); |
| 90 | if(m_pos.height > max_height) |
| 91 | { |
| 92 | m_pos.height = max_height; |
| 93 | } |
| 94 | if(sz.height) |
| 95 | { |
| 96 | m_pos.width = (int) (m_pos.height * (float)sz.width / (float)sz.height); |
| 97 | } else |
| 98 | { |
| 99 | m_pos.width = sz.width; |
| 100 | } |
| 101 | } |
| 102 | } else if(!m_css_height.is_predefined() && m_css_width.is_predefined()) |
| 103 | { |
| 104 | if (!get_predefined_height(m_pos.height)) |
| 105 | { |
nothing calls this directly
no test coverage detected