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: I4ee43701a30ce9bff1db2f2d0422227496c3df4c
Reviewed-by: Jan Arve Sæther <jan-arve.saether@theqtcompany.com>
This commit is contained in:
Boris Dušek 2015-03-17 23:03:03 +01:00
parent 551f39bac5
commit 310b5e73f0

View File

@ -672,7 +672,7 @@ QRect QAccessibleTextWidget::characterRect(int offset) const
if (!ch.isEmpty()) { if (!ch.isEmpty()) {
int w = fm.width(ch); int w = fm.width(ch);
int h = fm.height(); 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); w, h);
r.moveTo(viewport()->mapToGlobal(r.topLeft())); r.moveTo(viewport()->mapToGlobal(r.topLeft()));
} }