Fix QAccessibleTextWidget::characterRect for complex lines

Current implementation of QAccessibleTextWidget::characterRect returned rect
with correct vertical position only when the font point size did not vary
inside the line. This commit makes it work for lines where point size changes
by taking text ascent and descent into account.

Change-Id: I9684b4872566ddfa86dc7a2e9c803a1be0138000
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@theqtcompany.com>
This commit is contained in:
Boris Dušek 2015-02-08 23:34:07 +01:00
parent 1cdb117001
commit e19a43be90

View File

@ -672,7 +672,7 @@ QRect QAccessibleTextWidget::characterRect(int offset) const
if (!ch.isEmpty()) {
int w = fm.width(ch);
int h = fm.height();
r = QRect(layoutPosition.x() + x, layoutPosition.y() + line.y(),
r = QRect(layoutPosition.x() + x, layoutPosition.y() + line.y() + line.ascent() + fm.descent() - h,
w, h);
r.moveTo(viewport()->mapToGlobal(r.topLeft()));
}