Commit 4340e977 authored by Joanmarie Diggs's avatar Joanmarie Diggs Committed by Benjamin Otte

a11y: Refactor textcellaccessible code

Compute the new text and its length in advance. This way those
computations will not confuse us when they happen in the middle of the
actual action.

https://bugzilla.gnome.org/show_bug.cgi?id=746706
parent abf3d78b
......@@ -137,7 +137,7 @@ gtk_text_cell_accessible_update_cache (GtkCellAccessible *cell)
GtkTextCellAccessible *text_cell = GTK_TEXT_CELL_ACCESSIBLE (cell);
AtkObject *obj = ATK_OBJECT (cell);
gboolean rv = FALSE;
gint temp_length;
gint temp_length, text_length;
gchar *text;
GtkCellRenderer *renderer;
......@@ -149,6 +149,10 @@ gtk_text_cell_accessible_update_cache (GtkCellAccessible *cell)
g_object_get (renderer, "text", &text, NULL);
g_object_unref (renderer);
if (text == NULL)
text = g_strdup ("");
text_length = g_utf8_strlen (text, -1);
if (text_cell->priv->cell_text)
{
if (text == NULL || g_strcmp0 (text_cell->priv->cell_text, text) != 0)
......@@ -169,16 +173,8 @@ gtk_text_cell_accessible_update_cache (GtkCellAccessible *cell)
if (rv)
{
if (text == NULL)
{
text_cell->priv->cell_text = g_strdup ("");
text_cell->priv->cell_length = 0;
}
else
{
text_cell->priv->cell_text = g_strdup (text);
text_cell->priv->cell_length = g_utf8_strlen (text, -1);
}
text_cell->priv->cell_text = g_strdup (text);
text_cell->priv->cell_length = text_length;
}
g_free (text);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment