From 6be4a67322403b44a39650f0dd3e6daf7eafe5c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Boris=20Du=C5=A1ek?= Date: Sat, 3 Nov 2018 14:30:35 +0100 Subject: Align implementation of LineForIndex with InsertionPointLineNumber MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On macOS, the accessibility implementation of InsertionPointLineNumber currently reflects a fix for issue (QTBUG-49437). While it seems from testing this issue no longer requires such a fix, it still is a nice optimization for single-line edits. So we hereby bring the same optimization to LineForIndex parameterized attribute as well, and makes the code for both attributes consistent. Change-Id: I18b8cc249b6c65a25150f4e503999b04437e0306 Reviewed-by: Frederik Gladhorn Reviewed-by: Tor Arne Vestbø --- src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm b/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm index 63233a0390..b826e821fc 100644 --- a/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm +++ b/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm @@ -424,8 +424,11 @@ static void convertLineOffset(QAccessibleTextInterface *text, int *line, int *of int index = [parameter intValue]; if (index < 0 || index > iface->textInterface()->characterCount()) return nil; - int line = -1; - convertLineOffset(iface->textInterface(), &line, &index); + int line = 0; // true for all single line edits + if (iface->state().multiLine) { + line = -1; + convertLineOffset(iface->textInterface(), &line, &index); + } return @(line); } if ([attribute isEqualToString: NSAccessibilityRangeForLineParameterizedAttribute]) { -- cgit v1.2.3