Re: [evolution-patches] *New* Patch for GTKHTML / A11Y fixes #312189
- From: Mengjie Yu <Meng-Jie Yu Sun COM>
- To: Kaushal Kumar <kakumar novell com>
- Cc: evolution-patch <evolution-patches lists ximian com>
- Subject: Re: [evolution-patches] *New* Patch for GTKHTML / A11Y fixes #312189
- Date: Thu, 04 Aug 2005 16:38:45 +0800
Dear ksh,
Thanks a lot for your review.
This is the updated patch for this bug, I have changed it according to
your proposal.
> > (attrib_set,
> > + ATK_TEXT_ATTR_BG_COLOR,
> > + value);
> > + }
> > +
>
> I think we need to free value here, else it would get leaked.
>
However, I think we should not free value here, because value will be
assigned to the value field of an AtkAttribute structure by
gail_misc_add_attribute and should be free by user later.
Yours,
Mengjie
On Wed, 2005-08-03 at 19:28 +0530, Kaushal Kumar wrote:
> Hi Mengjie,
>
> Now, that we have get_run_attributes implemented, we can remove the
> earlier declaration (commented out) of the same in text.c. Could you
> also remove those for get_offset_at_point and get_character_extents
> since they too are implemented already.
>
> > +static AtkAttributeSet * html_a11y_text_get_run_attributes (AtkText
> > *text, gint offset, gint *start_offset, gint *end_offset);
> >
> could we please follow the column limit of 80 (by wrapping down the
> parameter list). if possible, could you modify in the other places in
> the patch too.
>
> > + attrib_set = html_a11y_text_add_attribute
>
> Since html_a11y_text_add_attribute is same as gail_misc_add_attribute,
> could we not use gail_misc_add_attribute directly. It is already
> available since text.h includes gail-util.h which has gailmisc.h.
> This way we would be independent of the changes that are made to the
> standard gail api.
>
> > (attrib_set,
> > + ATK_TEXT_ATTR_BG_COLOR,
> > + value);
> > + }
> > +
>
> I think we need to free value here, else it would get leaked.
>
> > + pango_attr_iterator_destroy (iter);
> > + return attrib_set;
> > +
> > +}
> >
> >
> Rest looks fine.
> Thanks for your work.
>
> Cheers,
> Kaushal
> _______________________________________________
> evolution-patches mailing list
> evolution-patches lists ximian com
> http://lists.ximian.com/mailman/listinfo/evolution-patches
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/gtkhtml/a11y/ChangeLog,v
retrieving revision 1.25
diff -u -p -r1.25 ChangeLog
--- ChangeLog 6 Jul 2005 10:35:00 -0000 1.25
+++ ChangeLog 4 Aug 2005 08:24:23 -0000
@@ -1,3 +1,12 @@
+2005-08-04 Mengjie Yu <meng-jie yu sun com>
+
+ * text.c: (atk_text_interface_init),
+ (html_a11y_text_get_run_attributes):
+ Implement get_run_attributes function to inform atktools the attributes of the text.
+
+ Fixes #312189
+
+
2005-07-06 Mengjie Yu <meng-jie yu sun com>
* object.c: (gtk_html_a11y_insert_object_cb),
Index: text.c
===================================================================
RCS file: /cvs/gnome/gtkhtml/a11y/text.c,v
retrieving revision 1.16
diff -u -p -r1.16 text.c
--- text.c 6 Jul 2005 10:35:00 -0000 1.16
+++ text.c 4 Aug 2005 08:24:24 -0000
@@ -28,7 +28,7 @@
#include <atk/atkhyperlink.h>
#include <glib/gi18n-lib.h>
#include <glib/gmacros.h>
-
+#include <pango/pango.h>
#include "gtkhtml.h"
#include "htmlengine.h"
#include "htmlengine-edit.h"
@@ -107,6 +107,11 @@ static void html_a11y_text_paste_text (A
static AtkStateSet* html_a11y_text_ref_state_set (AtkObject *accessible);
+static AtkAttributeSet* html_a11y_text_get_run_attributes (AtkText *text,
+ gint offset,
+ gint *start_offset,
+ gint *end_offset);
+
static AtkObjectClass *parent_class = NULL;
static gint
@@ -238,6 +243,7 @@ atk_text_interface_init (AtkTextIface *i
iface->set_caret_offset = html_a11y_text_set_caret_offset;
iface->get_character_extents = html_a11y_text_get_character_extents;
iface->get_offset_at_point = html_a11y_text_get_offset_at_point;
+ iface->get_run_attributes = html_a11y_text_get_run_attributes;
}
static void
@@ -710,24 +716,171 @@ html_a11y_text_set_selection (AtkText *t
}
+/* Most of the code of the following function is copied from */
+/* libgail-util/gailmisc.c gail_misc_layout_get_run_attributes */
+
+static AtkAttributeSet *
+html_a11y_text_get_run_attributes (AtkText *text,
+ gint offset,
+ gint *start_offset,
+ gint *end_offset)
+{
+ PangoAttrIterator *iter;
+ PangoAttrList *attr;
+ PangoAttrString *pango_string;
+ PangoAttrInt *pango_int;
+ PangoAttrColor *pango_color;
+ PangoAttrLanguage *pango_lang;
+ PangoAttrFloat *pango_float;
+ gint index, start_index, end_index;
+ gboolean is_next = TRUE;
+ gchar *value = NULL;
+ glong len;
+ gchar *textstring;
+ AtkAttributeSet *attrib_set = NULL;
+ HTMLText *t = HTML_TEXT (HTML_A11Y_HTML (text));
+
+ g_return_val_if_fail (t, NULL);
+
+ textstring = t->text;
+ attr = t->attr_list;
+
+ g_return_val_if_fail (attr && textstring, NULL);
+
+ len = g_utf8_strlen (textstring, -1);
+ iter = pango_attr_list_get_iterator (attr);
+
+ /* Get invariant range offsets */
+ /* If offset out of range, set offset in range */
+ if (offset > len)
+ offset = len;
+ else if (offset < 0)
+ offset = 0;
+
+ index = g_utf8_offset_to_pointer (textstring, offset) - textstring;
+ pango_attr_iterator_range (iter, &start_index, &end_index);
+
+ while (is_next) {
+ if (index >= start_index && index < end_index) {
+ *start_offset = g_utf8_pointer_to_offset (textstring, textstring + start_index);
+ if (end_index == G_MAXINT)
+ /* Last iterator */
+ end_index = len;
+
+ *end_offset = g_utf8_pointer_to_offset (textstring, textstring + end_index);
+ break;
+ }
+ is_next = pango_attr_iterator_next (iter);
+ pango_attr_iterator_range (iter, &start_index, &end_index);
+ }
+
+ /* Get attributes */
+ if ((pango_string = (PangoAttrString*) pango_attr_iterator_get (iter,
+ PANGO_ATTR_FAMILY)) != NULL) {
+ value = g_strdup_printf("%s", pango_string->value);
+ attrib_set = gail_misc_add_attribute (attrib_set,
+ ATK_TEXT_ATTR_FAMILY_NAME,
+ value);
+ }
+ if ((pango_int = (PangoAttrInt*) pango_attr_iterator_get (iter,
+ PANGO_ATTR_STYLE)) != NULL) {
+ attrib_set = gail_misc_add_attribute (attrib_set,
+ ATK_TEXT_ATTR_STYLE,
+ g_strdup (atk_text_attribute_get_value (ATK_TEXT_ATTR_STYLE,
+ pango_int->value)));
+ }
+
+ if ((pango_int = (PangoAttrInt*) pango_attr_iterator_get (iter,
+ PANGO_ATTR_WEIGHT)) != NULL) {
+ value = g_strdup_printf("%i", pango_int->value);
+ attrib_set = gail_misc_add_attribute (attrib_set,
+ ATK_TEXT_ATTR_WEIGHT,
+ value);
+ }
+ if ((pango_int = (PangoAttrInt*) pango_attr_iterator_get (iter,
+ PANGO_ATTR_VARIANT)) != NULL) {
+ attrib_set = gail_misc_add_attribute (attrib_set,
+ ATK_TEXT_ATTR_VARIANT,
+ g_strdup (atk_text_attribute_get_value (ATK_TEXT_ATTR_VARIANT,
+ pango_int->value)));
+ }
+ if ((pango_int = (PangoAttrInt*) pango_attr_iterator_get (iter,
+ PANGO_ATTR_STRETCH)) != NULL) {
+ attrib_set = gail_misc_add_attribute (attrib_set,
+ ATK_TEXT_ATTR_STRETCH,
+ g_strdup (atk_text_attribute_get_value (ATK_TEXT_ATTR_STRETCH,
+ pango_int->value)));
+ }
+ if ((pango_int = (PangoAttrInt*) pango_attr_iterator_get (iter,
+ PANGO_ATTR_SIZE)) != NULL) {
+ value = g_strdup_printf("%i", pango_int->value / PANGO_SCALE);
+ attrib_set = gail_misc_add_attribute (attrib_set,
+ ATK_TEXT_ATTR_SIZE,
+ value);
+ }
+ if ((pango_int = (PangoAttrInt*) pango_attr_iterator_get (iter,
+ PANGO_ATTR_UNDERLINE)) != NULL) {
+ attrib_set = gail_misc_add_attribute (attrib_set,
+ ATK_TEXT_ATTR_UNDERLINE,
+ g_strdup (atk_text_attribute_get_value (ATK_TEXT_ATTR_UNDERLINE,
+ pango_int->value)));
+ }
+ if ((pango_int = (PangoAttrInt*) pango_attr_iterator_get (iter,
+ PANGO_ATTR_STRIKETHROUGH)) != NULL) {
+ attrib_set = gail_misc_add_attribute (attrib_set,
+ ATK_TEXT_ATTR_STRIKETHROUGH,
+ g_strdup (atk_text_attribute_get_value (ATK_TEXT_ATTR_STRIKETHROUGH,
+ pango_int->value)));
+ }
+ if ((pango_int = (PangoAttrInt*) pango_attr_iterator_get (iter,
+ PANGO_ATTR_RISE)) != NULL) {
+ value = g_strdup_printf("%i", pango_int->value);
+ attrib_set = gail_misc_add_attribute (attrib_set,
+ ATK_TEXT_ATTR_RISE,
+ value);
+ }
+ if ((pango_lang = (PangoAttrLanguage*) pango_attr_iterator_get (iter,
+ PANGO_ATTR_LANGUAGE)) != NULL) {
+ value = g_strdup( pango_language_to_string( pango_lang->value));
+ attrib_set = gail_misc_add_attribute (attrib_set,
+ ATK_TEXT_ATTR_LANGUAGE,
+ value);
+ }
+ if ((pango_float = (PangoAttrFloat*) pango_attr_iterator_get (iter,
+ PANGO_ATTR_SCALE)) != NULL) {
+ value = g_strdup_printf("%g", pango_float->value);
+ attrib_set = gail_misc_add_attribute (attrib_set,
+ ATK_TEXT_ATTR_SCALE,
+ value);
+ }
+ if ((pango_color = (PangoAttrColor*) pango_attr_iterator_get (iter,
+ PANGO_ATTR_FOREGROUND)) != NULL) {
+ value = g_strdup_printf ("%u,%u,%u",
+ pango_color->color.red,
+ pango_color->color.green,
+ pango_color->color.blue);
+ attrib_set = gail_misc_add_attribute (attrib_set,
+ ATK_TEXT_ATTR_FG_COLOR,
+ value);
+ }
+ if ((pango_color = (PangoAttrColor*) pango_attr_iterator_get (iter,
+ PANGO_ATTR_BACKGROUND)) != NULL) {
+ value = g_strdup_printf ("%u,%u,%u",
+ pango_color->color.red,
+ pango_color->color.green,
+ pango_color->color.blue);
+ attrib_set = gail_misc_add_attribute (attrib_set,
+ ATK_TEXT_ATTR_BG_COLOR,
+ value);
+ }
+
+ pango_attr_iterator_destroy (iter);
+ return attrib_set;
+
+}
+
/*
- AtkAttributeSet* (* get_run_attributes) (AtkText *text,
- gint offset,
- gint *start_offset,
- gint *end_offset);
AtkAttributeSet* (* get_default_attributes) (AtkText *text);
- void (* get_character_extents) (AtkText *text,
- gint offset,
- gint *x,
- gint *y,
- gint *width,
- gint *height,
- AtkCoordType coords);
- gint (* get_offset_at_point) (AtkText *text,
- gint x,
- gint y,
- AtkCoordType coords);
-
*/
static gint
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]