Fix AXBoundsForRange in OS X accessibility
When returning a rect for AXBoundsForRange, we always incorporated one more character. Along with this one more character being often either a newline or the first character of new softline, visual bounds often got wrongly and unnecessarily multiline when in fact only single line was correct. Also noticeable when moving character by character (VO-Shift-arrow left/right) - now only one character is being shown (as opposed to two before). Still due to VoiceOver bug, for bounds of width less than 8 points, it will draw bounds width with of 8 points (reported as <rdar://problem/19370707>). But still this is an improvement for cases with bounds of width more or equal to 8 points. [ChangeLog][QtGui][Accessibility][OS X] Visual bounds returned by QTextEdit were singificantly improved, this enables VoiceOver to draw properly positioned VoiceOver cursor. Change-Id: Idc50310f8016fbcc01b061d27b655c72922a4807 Reviewed-by: Frederik Gladhorn <frederik.gladhorn@theqtcompany.com>bb10
parent
db5c011da1
commit
f7f58b8b69
|
|
@ -402,8 +402,17 @@ static void convertLineOffset(QAccessibleTextInterface *text, int &line, int &of
|
|||
if ([attribute isEqualToString: NSAccessibilityBoundsForRangeParameterizedAttribute]) {
|
||||
NSRange range = [parameter rangeValue];
|
||||
QRect firstRect = iface->textInterface()->characterRect(range.location);
|
||||
QRect lastRect = iface->textInterface()->characterRect(range.location + range.length);
|
||||
QRect rect = firstRect.united(lastRect); // This is off quite often, but at least a rough approximation
|
||||
QRect rect;
|
||||
if (range.length > 0) {
|
||||
NSUInteger position = range.location + range.length - 1;
|
||||
if (position > range.location && iface->textInterface()->text(position, position + 1) == QStringLiteral("\n"))
|
||||
--position;
|
||||
QRect lastRect = iface->textInterface()->characterRect(position);
|
||||
rect = firstRect.united(lastRect);
|
||||
} else {
|
||||
rect = firstRect;
|
||||
rect.setWidth(1);
|
||||
}
|
||||
return [NSValue valueWithRect: NSMakeRect((CGFloat) rect.x(),(CGFloat) qt_mac_flipYCoordinate(rect.y() + rect.height()), rect.width(), rect.height())];
|
||||
}
|
||||
if ([attribute isEqualToString: NSAccessibilityAttributedStringForRangeParameterizedAttribute]) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue