[evolution-patches] [gtkhtml] fix to avoid empty flows (without text objects) in table cells




Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/gtkhtml/src/ChangeLog,v
retrieving revision 1.2103
diff -u -p -r1.2103 ChangeLog
--- ChangeLog	10 Mar 2005 12:24:04 -0000	1.2103
+++ ChangeLog	10 Mar 2005 17:40:45 -0000
@@ -1,3 +1,15 @@
+2005-03-10  Radek Doulik  <rodo novell com>
+
+	* htmlobject.c (html_object_real_cursor_right): test for RTL
+	rather than LTR so that DERIVED defaults to LTR
+	(html_object_real_cursor_left): ditto
+
+	* test-suite.c (test_table_cell_parsing): added test to check
+	correct cell parsing
+
+	* htmlengine.c (block_end_cell): call close_flow to avoid empty
+	clueflows
+
 2005-03-10  Mengjie Yu  <meng-jie yu sun com>
 
 	* gtkhtml.c: (gtk_html_set_color):we should pass the insertion_color.
Index: htmlclue.c
===================================================================
RCS file: /cvs/gnome/gtkhtml/src/htmlclue.c,v
retrieving revision 1.107
diff -u -p -r1.107 htmlclue.c
--- htmlclue.c	3 Feb 2005 17:18:43 -0000	1.107
+++ htmlclue.c	10 Mar 2005 17:40:45 -0000
@@ -920,7 +920,6 @@ html_clue_remove_text_slaves (HTMLClue *
 	}
 }
 
-
 gboolean
 html_clue_is_empty (HTMLClue *clue)
 {
Index: htmlengine.c
===================================================================
RCS file: /cvs/gnome/gtkhtml/src/htmlengine.c,v
retrieving revision 1.629
diff -u -p -r1.629 htmlengine.c
--- htmlengine.c	28 Feb 2005 15:36:25 -0000	1.629
+++ htmlengine.c	10 Mar 2005 17:40:53 -0000
@@ -1260,6 +1260,7 @@ block_end_cell (HTMLEngine *e, HTMLObjec
 {
 	if (html_clue_is_empty (HTML_CLUE (clue)))
 		new_flow (e, clue, create_empty_text (e), HTML_CLEAR_NONE, HTML_DIRECTION_DERIVED);
+	close_flow (e, clue);
 	pop_clue (e);
 }
 
Index: htmlobject.c
===================================================================
RCS file: /cvs/gnome/gtkhtml/src/htmlobject.c,v
retrieving revision 1.188
diff -u -p -r1.188 htmlobject.c
--- htmlobject.c	9 Mar 2005 15:58:23 -0000	1.188
+++ htmlobject.c	10 Mar 2005 17:40:56 -0000
@@ -653,7 +653,7 @@ html_object_real_cursor_right (HTMLObjec
 	if (html_object_is_container (self))
 		return FALSE;
 
-	if (dir == HTML_DIRECTION_LTR) {
+	if (dir != HTML_DIRECTION_RTL) {
 		gint len;
 
 		len = html_object_get_length (self);
@@ -688,7 +688,7 @@ html_object_real_cursor_left (HTMLObject
 	if (html_object_is_container (self))
 		return FALSE;
 
-	if (dir == HTML_DIRECTION_LTR) {
+	if (dir != HTML_DIRECTION_RTL) {
 		HTMLObject *prev;
 		if (cursor->offset > 1 || (cursor->offset > 0 && (! (prev = html_object_prev_not_slave (self))
 								  || HTML_IS_CLUEALIGNED (prev) || !html_object_accepts_cursor (prev)))) {
Index: test-suite.c
===================================================================
RCS file: /cvs/gnome/gtkhtml/src/test-suite.c,v
retrieving revision 1.11
diff -u -p -r1.11 test-suite.c
--- test-suite.c	9 Mar 2005 15:54:59 -0000	1.11
+++ test-suite.c	10 Mar 2005 17:40:58 -0000
@@ -39,6 +39,7 @@ static int test_delete_nested_cluevs_and
 static int test_insert_nested_cluevs (GtkHTML *html);
 static int test_indentation_plain_text (GtkHTML *html);
 static int test_indentation_plain_text_rtl (GtkHTML *html);
+static int test_table_cell_parsing (GtkHTML *html);
 
 static Test tests[] = {
 	{ "cursor movement", NULL },
@@ -57,6 +58,7 @@ static Test tests[] = {
 	{ "insert nested cluev's", test_insert_nested_cluevs },
 	{ "indentation in plain text", test_indentation_plain_text },
 	{ "indentation in plain text (RTL)", test_indentation_plain_text_rtl },
+	{ "table cell parsing", test_table_cell_parsing },
 	{ NULL, NULL }
 };
 
@@ -540,6 +542,56 @@ test_capitalize_upcase_lowcase_word (Gtk
 	printf ("test_capitalize_upcase_lowcase_word: lower OK\n");
 
 	printf ("test_capitalize_upcase_lowcase_word: passed\n");
+
+	return TRUE;
+}
+
+static int
+test_table_cell_parsing (GtkHTML *html)
+{
+	load_editable (html, "<table><tr><td></td></tr></table>");
+
+	html_cursor_jump_to_position (html->engine->cursor, html->engine, 1);
+
+	if (html->engine->cursor->offset != 0
+	    || html->engine->cursor->position != 1)
+		return FALSE;
+
+	/* test that there's flow with text created in the cell and that it's only one flow */
+	if (!HTML_IS_TEXT (html->engine->cursor->object) || !html->engine->cursor->object->parent ||
+	    !HTML_IS_CLUEFLOW (html->engine->cursor->object->parent) || html->engine->cursor->object->parent->next ||
+	    !html->engine->cursor->object->parent->parent || !HTML_IS_TABLE_CELL (html->engine->cursor->object->parent->parent))
+		return FALSE;
+
+	load_editable (html, "<table><tr><td><br></td></tr></table>");
+
+	html_cursor_jump_to_position (html->engine->cursor, html->engine, 1);
+
+	if (html->engine->cursor->offset != 0
+	    || html->engine->cursor->position != 1)
+		return FALSE;
+
+	/* test that there are two flows created in the cell and that they are both containing text */
+	if (!HTML_IS_TEXT (html->engine->cursor->object) || !html->engine->cursor->object->parent ||
+	    !HTML_IS_CLUEFLOW (html->engine->cursor->object->parent) || !html->engine->cursor->object->parent->next ||
+	    !html->engine->cursor->object->parent->parent || !HTML_IS_TABLE_CELL (html->engine->cursor->object->parent->parent) ||
+	    !HTML_IS_CLUEFLOW (html->engine->cursor->object->parent->next) || !HTML_CLUE (html->engine->cursor->object->parent->next)->head ||
+	    !HTML_IS_TEXT (HTML_CLUE (html->engine->cursor->object->parent->next)->head))
+		return FALSE;
+
+	load_editable (html, "<table><tr><td>abc</td></tr></table>");
+
+	html_cursor_jump_to_position (html->engine->cursor, html->engine, 1);
+
+	if (html->engine->cursor->offset != 0
+	    || html->engine->cursor->position != 1)
+		return FALSE;
+
+	/* test that there's flow with text created in the cell and that it's only one flow */
+	if (!HTML_IS_TEXT (html->engine->cursor->object) || !html->engine->cursor->object->parent ||
+	    !HTML_IS_CLUEFLOW (html->engine->cursor->object->parent) || html->engine->cursor->object->parent->next ||
+	    !html->engine->cursor->object->parent->parent || !HTML_IS_TABLE_CELL (html->engine->cursor->object->parent->parent))
+		return FALSE;
 
 	return TRUE;
 }


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