a11y: Report empty string as such
While the text data returned by the get_contents
function from the GtkAccessibleTextInterface
does not
have to be NUL-terminated,
gtk_accessible_text_get_contents
returns the
text contents as NUL-terminated UTF-8 data.
An empty string (returned as empty, i.e. size = 0,
but not NULL GBytes* data by get_contents
) is valid, and
therefore also needs to be NUL-terminated, so do this.
Without this, e.g. querying the text of an empty paragraph in the Gtk 4 variant of LibreOffice with the newly added GtkAccessibleInterface implementation [1] gives an incorrect result.
Previous sample use in Accerciser's IPython console:
In [24]: acc.queryText().getText(0, -1)
Out[24]: '[Invalid UTF-8]'
With this change in place, it now returns an empty string as expected:
In [25]: acc.queryText().getText(0, -1)
Out[25]: ''
[1] https://git.libreoffice.org/core/commit/e268efd612d12ae9a459d6b9d0cb23220f025163