| 175 | } |
| 176 | |
| 177 | static Selection::Element selectionDetails(const litehtml::element::ptr &element, |
| 178 | const QString &text, |
| 179 | const QPoint &pos) |
| 180 | { |
| 181 | // shortcut, which _might_ not really be correct |
| 182 | if (element->get_children_count() > 0) |
| 183 | return {element, -1, -1}; // everything selected |
| 184 | const QFont &font = toQFont(element->get_font()); |
| 185 | const QFontMetrics fm(font); |
| 186 | int previous = 0; |
| 187 | for (int i = 0; i < text.size(); ++i) { |
| 188 | const int width = fm.size(0, text.left(i + 1)).width(); |
| 189 | if ((width + previous) / 2 >= pos.x()) |
| 190 | return {element, i, previous}; |
| 191 | previous = width; |
| 192 | } |
| 193 | return {element, int(text.size()), previous}; |
| 194 | } |
| 195 | |
| 196 | static Selection::Element deepest_child_at_point(const litehtml::document::ptr &document, |
| 197 | const QPoint &pos, |
no test coverage detected