a11y: expose the text with password-char
Text exposed by the AtkText methods should be the text displayed to the user (like the internal method clutter_text_get_display_text). So it should use the password-char if it is being used. This is also a security concern.
This commit is contained in:
parent
78a3590fd6
commit
ccea1644ba
@ -316,9 +316,9 @@ cally_text_real_initialize(AtkObject *obj,
|
|||||||
_check_activate_action (cally_text, clutter_text);
|
_check_activate_action (cally_text, clutter_text);
|
||||||
|
|
||||||
if (clutter_text_get_password_char (clutter_text) != 0)
|
if (clutter_text_get_password_char (clutter_text) != 0)
|
||||||
obj->role = ATK_ROLE_PASSWORD_TEXT;
|
atk_object_set_role (obj, ATK_ROLE_PASSWORD_TEXT);
|
||||||
else
|
else
|
||||||
obj->role = ATK_ROLE_TEXT;
|
atk_object_set_role (obj, ATK_ROLE_TEXT);
|
||||||
}
|
}
|
||||||
|
|
||||||
static AtkStateSet*
|
static AtkStateSet*
|
||||||
@ -1077,13 +1077,28 @@ cally_text_get_text (AtkText *text,
|
|||||||
gint end_offset)
|
gint end_offset)
|
||||||
{
|
{
|
||||||
ClutterActor *actor = NULL;
|
ClutterActor *actor = NULL;
|
||||||
|
PangoLayout *layout = NULL;
|
||||||
|
const gchar *string = NULL;
|
||||||
|
gint character_count = 0;
|
||||||
|
|
||||||
actor = CALLY_GET_CLUTTER_ACTOR (text);
|
actor = CALLY_GET_CLUTTER_ACTOR (text);
|
||||||
if (actor == NULL) /* Object is defunct */
|
if (actor == NULL) /* Object is defunct */
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
return clutter_text_get_chars (CLUTTER_TEXT (actor),
|
/* we use the pango layout instead of clutter_text_get_chars because
|
||||||
start_offset, end_offset);
|
it take into account password-char */
|
||||||
|
|
||||||
|
layout = clutter_text_get_layout (CLUTTER_TEXT (actor));
|
||||||
|
string = pango_layout_get_text (layout);
|
||||||
|
character_count = pango_layout_get_character_count (layout);
|
||||||
|
|
||||||
|
if (end_offset == -1 || end_offset > character_count)
|
||||||
|
end_offset = character_count;
|
||||||
|
|
||||||
|
if (string[0] == 0)
|
||||||
|
return g_strdup("");
|
||||||
|
else
|
||||||
|
return g_utf8_substring (string, start_offset, end_offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gunichar
|
static gunichar
|
||||||
@ -1091,15 +1106,21 @@ cally_text_get_character_at_offset (AtkText *text,
|
|||||||
gint offset)
|
gint offset)
|
||||||
{
|
{
|
||||||
ClutterActor *actor = NULL;
|
ClutterActor *actor = NULL;
|
||||||
gchar *string = NULL;
|
const gchar *string = NULL;
|
||||||
gchar *index = NULL;
|
gchar *index = NULL;
|
||||||
gunichar unichar;
|
gunichar unichar;
|
||||||
|
PangoLayout *layout = NULL;
|
||||||
|
|
||||||
actor = CALLY_GET_CLUTTER_ACTOR (text);
|
actor = CALLY_GET_CLUTTER_ACTOR (text);
|
||||||
if (actor == NULL) /* State is defunct */
|
if (actor == NULL) /* State is defunct */
|
||||||
return '\0';
|
return '\0';
|
||||||
|
|
||||||
string = clutter_text_get_chars (CLUTTER_TEXT (actor), 0, -1);
|
/* we use the pango layout instead of clutter_text_get_chars because
|
||||||
|
it take into account password-char */
|
||||||
|
|
||||||
|
layout = clutter_text_get_layout (CLUTTER_TEXT (actor));
|
||||||
|
string = pango_layout_get_text (layout);
|
||||||
|
|
||||||
if (offset >= g_utf8_strlen (string, -1))
|
if (offset >= g_utf8_strlen (string, -1))
|
||||||
{
|
{
|
||||||
unichar = '\0';
|
unichar = '\0';
|
||||||
@ -1111,8 +1132,6 @@ cally_text_get_character_at_offset (AtkText *text,
|
|||||||
unichar = g_utf8_get_char (index);
|
unichar = g_utf8_get_char (index);
|
||||||
}
|
}
|
||||||
|
|
||||||
g_free(string);
|
|
||||||
|
|
||||||
return unichar;
|
return unichar;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user