[evolution-patches] [gtkhtml] fix for empty second text slave



Attached patch fixes cursor navigation in case there's second or former empty text slave. That can lead to broken cursor position, which can cause reversed input order.
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/gtkhtml/src/ChangeLog,v
retrieving revision 1.2099
diff -u -p -r1.2099 ChangeLog
--- ChangeLog	28 Feb 2005 15:36:25 -0000	1.2099
+++ ChangeLog	7 Mar 2005 19:46:38 -0000
@@ -1,3 +1,8 @@
+2005-03-07  Radek Doulik  <rodo novell com>
+
+	* htmltext.c (html_text_cursor_next_slave): make sure we handle
+	the case where there is second or later empty slave
+
 2005-02-28  Radek Doulik  <rodo novell com>
 
 	* htmltext.c (html_text_direction_pango_to_html): new helper
Index: htmltext.c
===================================================================
--- htmltext.c	2005-03-07 21:01:41 +01:00
+++ htmltext.c.nortl	2005-03-07 21:02:11 +01:00
@@ -2450,14 +2450,17 @@
 static gboolean
 html_text_cursor_prev_slave (HTMLObject *slave, HTMLPainter *painter, HTMLCursor *cursor)
 {
-	HTMLObject *prev = HTML_OBJECT (slave)->prev;
 	int offset = cursor->offset;
 
-	if (prev && HTML_IS_TEXT_SLAVE (prev)) {
-		if (html_text_slave_cursor_tail (HTML_TEXT_SLAVE (prev), cursor, painter)) {
-			cursor->position += cursor->offset - offset;
-			return TRUE;
+	while (slave->prev && HTML_IS_TEXT_SLAVE (slave->prev)) {
+		if (HTML_TEXT_SLAVE (slave->prev)->posLen) {
+			if (html_text_slave_cursor_tail (HTML_TEXT_SLAVE (slave->prev), cursor, painter)) {
+				cursor->position += cursor->offset - offset;
+				return TRUE;
+			} else
+				break;
 		}
+		slave = slave->prev;
 	}
 
 	return FALSE;
@@ -2466,14 +2469,17 @@
 static gboolean
 html_text_cursor_next_slave (HTMLObject *slave, HTMLPainter *painter, HTMLCursor *cursor)
 {
-	HTMLObject *next = slave->next;
 	int offset = cursor->offset;
 
-	if (next && HTML_IS_TEXT_SLAVE (next)) {
-		if (html_text_slave_cursor_head (HTML_TEXT_SLAVE (next), cursor, painter)) {
-			cursor->position += cursor->offset - offset;
-			return TRUE;
+	while (slave->next && HTML_IS_TEXT_SLAVE (slave->next)) {
+		if (HTML_TEXT_SLAVE (slave->next)->posLen) {
+			if (html_text_slave_cursor_head (HTML_TEXT_SLAVE (slave->next), cursor, painter)) {
+				cursor->position += cursor->offset - offset;
+				return TRUE;
+			} else
+				break;
 		}
+		slave = slave->next;
 	}
 
 	return FALSE;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]