From 18b1dc35e90a6a3946e9e88c8cfa1ced3a00b1fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Boris=20Du=C5=A1ek?= Date: Mon, 5 Nov 2018 10:22:12 +0100 Subject: [PATCH] macOS a11y: Implement AXInsertionPointLineNumber with AXLineForIndex MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Follow DRY and do not repeat implementation of basically the same thing, especially now that the implementation is no longer completely trivial. AXLineForIndex can be considered a primitive attribute, and AXInsertionPointLineNumber a derived attribute, hence this opportunity to not repeat oneself. Change-Id: I64b596d8351e681f4438b91400a767407612c118 Reviewed-by: Frederik Gladhorn Reviewed-by: Tor Arne Vestbø --- .../platforms/cocoa/qcocoaaccessibilityelement.mm | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm b/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm index b826e821fc8..1a3c7793c0f 100644 --- a/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm +++ b/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm @@ -362,13 +362,8 @@ static void convertLineOffset(QAccessibleTextInterface *text, int *line, int *of } else if ([attribute isEqualToString:NSAccessibilityInsertionPointLineNumberAttribute]) { if (QAccessibleTextInterface *text = iface->textInterface()) { - int line = 0; // true for all single line edits - if (iface->state().multiLine) { - line = -1; - int position = text->cursorPosition(); - convertLineOffset(text, &line, &position); - } - return @(line); + int position = text->cursorPosition(); + return [self accessibilityAttributeValue:NSAccessibilityLineForIndexParameterizedAttribute forParameter:@(position)]; } return nil; } else if ([attribute isEqualToString:NSAccessibilityMinValueAttribute]) {