a11y atspi: Report correct char code point when it's > 65535
QString uses UTF-16 encoding and thus "unicode characters with code values above 65535 are stored using surrogate pairs, i.e., two consecutive QChars.". [1] When the character inside of text is retrieved using the GetCharacterAtOffset method of the AT-SPI Text interface, use QStringIterator to retrieve the character's actual codepoint instead of returning an invalid/incorrect one. [1] https://doc.qt.io/qt-6/qstring.html Fixes: QTBUG-113438 Change-Id: I07108481716329fd23a92c88892eaedd3f9defc6 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> (cherry picked from commit c7b925757f9b55924b788a2f08d777baa0e63250) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
fadc5f7274
commit
1cdc197664
@ -16,6 +16,7 @@
|
||||
#if QT_CONFIG(accessibility)
|
||||
#include "socket_interface.h"
|
||||
#include "qspi_constant_mappings_p.h"
|
||||
#include <QtCore/private/qstringiterator_p.h>
|
||||
#include <QtGui/private/qaccessiblebridgeutils_p.h>
|
||||
|
||||
#include "qspiapplicationadaptor_p.h"
|
||||
@ -1980,8 +1981,13 @@ bool AtSpiAdaptor::textInterface(QAccessibleInterface *interface, const QString
|
||||
int offset = message.arguments().at(0).toInt();
|
||||
int start;
|
||||
int end;
|
||||
QString result = interface->textInterface()->textAtOffset(offset, QAccessible::CharBoundary, &start, &end);
|
||||
sendReply(connection, message, (int) *(qPrintable (result)));
|
||||
const QString charString = interface->textInterface()
|
||||
->textAtOffset(offset, QAccessible::CharBoundary, &start, &end);
|
||||
int codePoint = 0;
|
||||
QStringIterator stringIt(charString);
|
||||
if (stringIt.hasNext())
|
||||
codePoint = static_cast<int>(stringIt.peekNext());
|
||||
sendReply(connection, message, codePoint);
|
||||
} else if (function == "GetCharacterExtents"_L1) {
|
||||
int offset = message.arguments().at(0).toInt();
|
||||
int coordType = message.arguments().at(1).toUInt();
|
||||
|
Loading…
x
Reference in New Issue
Block a user