[evolution-patches] [gtkhtml] cursor movement around images (and other non text objects) fix
- From: Radek Doulík <rodo novell com>
- To: Patches <evolution-patches ximian com>
- Cc: Rodrigo Moya <rodrigo novell com>, Rodney Dawes <dobey novell com>
- Subject: [evolution-patches] [gtkhtml] cursor movement around images (and other non text objects) fix
- Date: Mon, 14 Mar 2005 13:01:39 +0100
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/gtkhtml/src/ChangeLog,v
retrieving revision 1.2105
diff -u -p -r1.2105 ChangeLog
--- ChangeLog 11 Mar 2005 15:24:29 -0000 1.2105
+++ ChangeLog 14 Mar 2005 09:50:56 -0000
@@ -1,3 +1,16 @@
+2005-03-14 Radek Doulik <rodo novell com>
+
+ * test-suite.c (test_cursor_around_image): added new test for
+ cursor movement around images
+ put widget into scrolled window for convenience
+
+ * htmltextslave.c (html_text_slave_cursor_left_one): move to
+ boundary only if there's no prev object
+ (html_text_slave_cursor_right_one): remove unneeded braces
+
+ * htmlcursor.c (move_right): move offset one step forward when
+ moving between neighbor objects
+
2005-03-10 Radek Doulik <rodo novell com>
* test-suite.c (test_delete_around_table): added new test for
Index: htmlcursor.c
===================================================================
RCS file: /cvs/gnome/gtkhtml/src/htmlcursor.c,v
retrieving revision 1.72
diff -u -p -r1.72 htmlcursor.c
--- htmlcursor.c 9 Mar 2005 15:58:23 -0000 1.72
+++ htmlcursor.c 14 Mar 2005 09:50:58 -0000
@@ -996,10 +996,22 @@ move_right (HTMLCursor *cursor, HTMLEngi
retval = TRUE;
if (!html_object_cursor_right (cursor->object, e->painter, cursor)) {
if (cursor->object->parent) {
+ gboolean rv;
+ HTMLObject *orig = cursor->object;
+
if (html_object_get_direction (cursor->object->parent) == HTML_DIRECTION_RTL)
- return move_to_prev_object (cursor, e);
+ rv = move_to_prev_object (cursor, e);
else
- return move_to_next_object (cursor, e);
+ rv = move_to_next_object (cursor, e);
+
+ if (rv && !html_object_is_container (cursor->object) && cursor->object->parent == orig->parent) {
+ if (html_object_get_direction (cursor->object) == HTML_DIRECTION_RTL)
+ cursor->offset --;
+ else
+ cursor->offset ++;
+ }
+
+ return rv;
}
}
return retval;
Index: htmltextslave.c
===================================================================
RCS file: /cvs/gnome/gtkhtml/src/htmltextslave.c,v
retrieving revision 1.189
diff -u -p -r1.189 htmltextslave.c
--- htmltextslave.c 9 Mar 2005 15:58:23 -0000 1.189
+++ htmltextslave.c 14 Mar 2005 09:50:59 -0000
@@ -1274,7 +1274,7 @@ html_text_slave_cursor_right_one (HTMLTe
}
} else {
/* RTL */
- if (index > gi->glyph_item.item->offset && (index <= gi->glyph_item.item->offset + gi->glyph_item.item->length)) {
+ if (index > gi->glyph_item.item->offset && index <= gi->glyph_item.item->offset + gi->glyph_item.item->length) {
cursor->offset --;
cursor->position --;
@@ -1319,6 +1319,7 @@ html_text_slave_cursor_left_one (HTMLTex
{
HTMLTextSlaveGlyphItem *prev, *next;
int index;
+ HTMLObject *prev_obj = HTML_OBJECT (slave->owner)->prev;
HTMLTextSlaveGlyphItem *gi = html_text_slave_get_glyph_item_at_offset (slave, painter, cursor->offset - slave->posStart, &prev, &next, NULL, &index);
/* printf ("gi: %p item num chars: %d\n", gi, gi ? gi->glyph_item.item->num_chars : -1); */
@@ -1328,7 +1329,7 @@ html_text_slave_cursor_left_one (HTMLTex
if (gi->glyph_item.item->analysis.level % 2 == 0) {
/* LTR */
- if (index - gi->glyph_item.item->offset > 1 || (!prev && index - gi->glyph_item.item->offset > 0)) {
+ if (index - gi->glyph_item.item->offset > 1 || (!prev && !prev_obj && index - gi->glyph_item.item->offset > 0)) {
cursor->offset --;
cursor->position --;
Index: test-suite.c
===================================================================
RCS file: /cvs/gnome/gtkhtml/src/test-suite.c,v
retrieving revision 1.13
diff -u -p -r1.13 test-suite.c
--- test-suite.c 11 Mar 2005 15:24:30 -0000 1.13
+++ test-suite.c 14 Mar 2005 09:51:02 -0000
@@ -2,6 +2,7 @@
#include <stdio.h>
#include <glib/gstring.h>
#include <gtk/gtkmain.h>
+#include <gtk/gtkscrolledwindow.h>
#include <gtk/gtkwindow.h>
#include "gtkhtml.h"
#include "htmlclue.h"
@@ -31,6 +32,7 @@ static int test_cursor_left_right_on_lin
static int test_cursor_left_right_on_lines_boundaries_rtl (GtkHTML *html);
static int test_cursor_left_right_on_lines_boundaries_wo_white (GtkHTML *html);
static int test_cursor_around_containers (GtkHTML *html);
+static int test_cursor_around_image (GtkHTML *html);
static int test_quotes_in_div_block (GtkHTML *html);
static int test_quotes_in_table (GtkHTML *html);
@@ -51,6 +53,7 @@ static Test tests[] = {
{ "begin/end of line", test_cursor_beol },
{ "begin/end of line (RTL)", test_cursor_beol_rtl },
{ "around containers", test_cursor_around_containers },
+ { "around image", test_cursor_around_image },
{ "various fixed bugs", NULL },
{ "outer quotes inside div block", test_quotes_in_div_block },
{ "outer quotes inside table", test_quotes_in_table },
@@ -206,6 +209,37 @@ static int test_cursor_around_containers
return TRUE;
}
+static int test_cursor_around_image (GtkHTML *html)
+{
+ load_editable (html, "<pre>abc <img src=none> abc");
+
+ if (!html_cursor_right (html->engine->cursor, html->engine)
+ || !html_cursor_right (html->engine->cursor, html->engine)
+ || !html_cursor_right (html->engine->cursor, html->engine)
+ || !html_cursor_right (html->engine->cursor, html->engine)
+ || !html_cursor_right (html->engine->cursor, html->engine)
+ || html->engine->cursor->offset != 1
+ || html->engine->cursor->position != 5
+ || !html_cursor_right (html->engine->cursor, html->engine)
+ || html->engine->cursor->offset != 1
+ || html->engine->cursor->position != 6
+ || !html_cursor_left (html->engine->cursor, html->engine)
+ || !html_cursor_left (html->engine->cursor, html->engine)
+ || html->engine->cursor->offset != 4
+ || html->engine->cursor->position != 4) {
+ fprintf (stderr, "\npos: %d off: %d\n", html->engine->cursor->position, html->engine->cursor->offset);
+ return FALSE;
+ }
+
+ while (html_cursor_left (html->engine->cursor, html->engine))
+ ;
+
+ if (html->engine->cursor->position != 0 || html->engine->cursor->offset != 0)
+ return FALSE;
+
+ return TRUE;
+}
+
static int test_cursor_left_right_on_items_boundaries (GtkHTML *html)
{
load_editable (html, "ab<b>cde</b>ef");
@@ -626,7 +660,7 @@ test_table_cell_parsing (GtkHTML *html)
int main (int argc, char *argv[])
{
- GtkWidget *win, *html_widget;
+ GtkWidget *win, *sw, *html_widget;
GtkHTML *html;
int i = 0, n_all, n_successful;
@@ -637,9 +671,13 @@ int main (int argc, char *argv[])
gtk_html_load_empty (html);
gtk_html_set_editable (html, TRUE);
win = gtk_window_new (GTK_WINDOW_TOPLEVEL);
- gtk_container_add (GTK_CONTAINER (win), html_widget);
+ sw = gtk_scrolled_window_new (NULL, NULL);
+ gtk_widget_set_size_request (win, 600, 400);
+ gtk_container_add (GTK_CONTAINER (sw), html_widget);
+ gtk_container_add (GTK_CONTAINER (win), sw);
- /* gtk_widget_show_all (win); */
+/* gtk_widget_show_all (win); */
+/* gtk_widget_show_now (win); */
n_all = n_successful = 0;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]