Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/gtkhtml/a11y/ChangeLog,v
retrieving revision 1.24
diff -u -p -r1.24 ChangeLog
--- ChangeLog	17 May 2005 14:47:56 -0000	1.24
+++ ChangeLog	21 Jun 2005 09:12:09 -0000
@@ -1,3 +1,16 @@
+2005-06-21  Mengjie Yu  <meng-jie.yu@sun.com>
+
+	* object.c: (gtk_html_a11y_insert_object_cb),
+	(gtk_html_a11y_delete_object_cb):
+	We should pass the correct offset of the text instead of the absolute position
+	of the whole document to the callback funtion.
+
+	* text.c: (html_a11y_text_get_text_at_offset):
+ 	We should assign the correct start_offset and end_offset and return the text content
+	if start_slave or end_slave doesn't exist.
+
+	Fixes #306238
+
 2005-05-13  Changwoo Ryu  <cwryu@debian.org>
 
 	* Makefile.am (INCLUDES): use I18N_LIB_CFLAGS.
Index: object.c
===================================================================
RCS file: /cvs/gnome/gtkhtml/a11y/object.c,v
retrieving revision 1.12
diff -u -p -r1.12 object.c
--- object.c	17 May 2005 14:47:56 -0000	1.12
+++ object.c	21 Jun 2005 09:12:09 -0000
@@ -351,6 +351,10 @@ gtk_html_a11y_insert_object_cb (GtkWidge
 {
 	AtkObject * a11y, *obj;
 
+
+	HTMLCursor *cursor = GTK_HTML (widget)->engine->cursor;
+
+
         obj = gtk_widget_get_accessible (widget);
 	a11y = gtk_html_a11y_get_focus_object (widget);
 	g_return_if_fail (a11y != NULL);
@@ -362,7 +366,7 @@ gtk_html_a11y_insert_object_cb (GtkWidge
 	}
 
 	if (G_IS_HTML_A11Y_TEXT(a11y)) {
-		g_signal_emit_by_name (a11y, "text_changed::insert", pos, len);
+		g_signal_emit_by_name (a11y, "text_changed::insert", cursor->offset - len, len);
 
 	} 
 }
@@ -371,6 +375,7 @@ static void
 gtk_html_a11y_delete_object_cb (GtkWidget * widget, int pos, int len) 
 {
 	AtkObject * a11y, *obj;
+	HTMLCursor *cursor = GTK_HTML (widget)->engine->cursor;
 
         obj = gtk_widget_get_accessible (widget);
 	a11y = gtk_html_a11y_get_focus_object (widget);
@@ -383,7 +388,7 @@ gtk_html_a11y_delete_object_cb (GtkWidge
 	}
 
 	if (G_IS_HTML_A11Y_TEXT(a11y)) {
-		g_signal_emit_by_name (a11y, "text_changed::delete", pos, len);
+		g_signal_emit_by_name (a11y, "text_changed::delete", cursor->offset, len);
 	}
 }
 
Index: text.c
===================================================================
RCS file: /cvs/gnome/gtkhtml/a11y/text.c,v
retrieving revision 1.15
diff -u -p -r1.15 text.c
--- text.c	17 May 2005 14:47:56 -0000	1.15
+++ text.c	21 Jun 2005 09:12:10 -0000
@@ -532,29 +532,39 @@ html_a11y_text_get_text_at_offset (AtkTe
 	switch (boundary_type) {
 	case ATK_TEXT_BOUNDARY_LINE_START:
 		start_slave = html_text_get_slave_at_offset (to, NULL, offset);
-		g_return_val_if_fail (start_slave, NULL);
-		end_slave = (HTMLTextSlave *) HTML_OBJECT (start_slave)->next;
 
-		if (end_slave && HTML_IS_TEXT_SLAVE (end_slave)) {
-			*end_offset = end_slave->posStart;
+		if (start_slave == NULL) {
+			*start_offset = 0;
+			*end_offset = to->text_len;
 		} else {
-			*end_offset = start_slave->posStart + start_slave->posLen;
+			end_slave = (HTMLTextSlave *) HTML_OBJECT (start_slave)->next;
+
+			if (end_slave && HTML_IS_TEXT_SLAVE (end_slave)) {
+				*end_offset = end_slave->posStart;
+			} else {
+				*end_offset = start_slave->posStart + start_slave->posLen;
+			}
+			*start_offset = start_slave->posStart;
 		}
-		*start_offset = start_slave->posStart;
 
 		return html_a11y_text_get_text (text, *start_offset, *end_offset);
 
 	case ATK_TEXT_BOUNDARY_LINE_END:
 		end_slave = html_text_get_slave_at_offset (to, NULL, offset);
-		g_return_val_if_fail (end_slave, NULL);
-		start_slave = (HTMLTextSlave *) HTML_OBJECT (end_slave)->prev;
 
-		if (start_slave && HTML_IS_TEXT_SLAVE (start_slave)) {
-			*start_offset = start_slave->posStart + start_slave->posLen;
+		if (end_slave == NULL) {
+			*start_offset = 0;
+			*end_offset = to->text_len;
 		} else {
-			*start_offset = end_slave->posStart;
+			start_slave = (HTMLTextSlave *) HTML_OBJECT (end_slave)->prev;
+
+			if (start_slave && HTML_IS_TEXT_SLAVE (start_slave)) {
+				*start_offset = start_slave->posStart + start_slave->posLen;
+			} else {
+				*start_offset = end_slave->posStart;
+			}
+			*end_offset = end_slave->posStart + end_slave->posLen;
 		}
-		*end_offset = end_slave->posStart + end_slave->posLen;
 
 		return html_a11y_text_get_text (text, *start_offset, *end_offset);
 
