summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm
diff options
context:
space:
mode:
authorBoris Dušek <me@dusek.me>2014-12-29 00:37:05 +0100
committerBoris Dušek <me@dusek.me>2015-02-13 06:59:17 +0000
commitf7f58b8b69eb4bc412ccc5e2c603732c67c029f9 (patch)
tree4be538065923c2839f5f7589200feb2d3652d166 /src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm
parentdb5c011da1f3d8b233af17d104b6fecfc0d7d716 (diff)
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>
Diffstat (limited to 'src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm')
-rw-r--r--src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm b/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm
index 8a6c27605b..1cb51a37bc 100644
--- a/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm
+++ b/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm
@@ -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]) {