diff --git a/gtkhtml/gtkhtml-embedded.c b/gtkhtml/gtkhtml-embedded.c
index 9681a08..fb8f3e8 100644
--- a/gtkhtml/gtkhtml-embedded.c
+++ b/gtkhtml/gtkhtml-embedded.c
@@ -120,7 +120,7 @@ static void gtk_html_embedded_remove (GtkContainer *container, GtkWidget *child)
 }
 
 typedef void (*draw_print_signal)(GObject *, gpointer, gpointer);
-typedef void (*draw_gdk_signal)(GObject *, gpointer, gpointer, gint, gint, gpointer);
+typedef void (*draw_gdk_signal)(GObject *, gpointer, gint, gint, gpointer);
 
 static void
 draw_gdk_signal_marshaller (GClosure     *closure,
@@ -150,20 +150,19 @@ draw_gdk_signal_marshaller (GClosure     *closure,
 
 	ff (data1,
 	    g_value_get_pointer (param_values + 1),
-	    g_value_get_pointer (param_values + 2),
+	    g_value_get_int (param_values + 2),
 	    g_value_get_int (param_values + 3),
-	    g_value_get_int (param_values + 4),
 	    data2);
 }
 
 static void
 gtk_html_embedded_class_init (GtkHTMLEmbeddedClass *class)
 {
-	GObjectClass *gobject_class;
+	GObjectClass *object_class;
 	GtkWidgetClass *widget_class;
 	GtkContainerClass *container_class;
 
-	gobject_class = G_OBJECT_CLASS (class);
+	object_class = G_OBJECT_CLASS (class);
 	widget_class = GTK_WIDGET_CLASS (class);
 	container_class = GTK_CONTAINER_CLASS (class);
 
@@ -171,7 +170,7 @@ gtk_html_embedded_class_init (GtkHTMLEmbeddedClass *class)
 
 	signals[CHANGED] =
 		g_signal_new ("changed",
-			      G_TYPE_FROM_CLASS (gobject_class),
+			      G_TYPE_FROM_CLASS (object_class),
 			      G_SIGNAL_RUN_FIRST,
 			      G_STRUCT_OFFSET (GtkHTMLEmbeddedClass, changed),
 			      NULL, NULL,
@@ -179,7 +178,7 @@ gtk_html_embedded_class_init (GtkHTMLEmbeddedClass *class)
 			      G_TYPE_NONE, 0);
 	signals[DRAW_GDK] =
 		g_signal_new ("draw_gdk",
-			      G_TYPE_FROM_CLASS (gobject_class),
+			      G_TYPE_FROM_CLASS (object_class),
 			      G_SIGNAL_RUN_FIRST,
 			      G_STRUCT_OFFSET (GtkHTMLEmbeddedClass, draw_gdk),
 			      NULL, NULL,
@@ -189,7 +188,7 @@ gtk_html_embedded_class_init (GtkHTMLEmbeddedClass *class)
 
 	signals[DRAW_PRINT] =
 		g_signal_new ("draw_print",
-			      G_TYPE_FROM_CLASS (gobject_class),
+			      G_TYPE_FROM_CLASS (object_class),
 			      G_SIGNAL_RUN_FIRST,
 			      G_STRUCT_OFFSET (GtkHTMLEmbeddedClass, draw_print),
 			      NULL, NULL,
@@ -197,7 +196,7 @@ gtk_html_embedded_class_init (GtkHTMLEmbeddedClass *class)
 			      G_TYPE_NONE, 1,
 			      G_TYPE_POINTER);
 
-	gobject_class->finalize = gtk_html_embedded_finalize;
+	object_class->finalize = gtk_html_embedded_finalize;
 
 	widget_class->size_request = gtk_html_embedded_size_request;
 	widget_class->size_allocate = gtk_html_embedded_size_allocate;
@@ -219,7 +218,7 @@ gtk_html_embedded_size_request (GtkWidget *widget, GtkRequisition *requisition)
 	child = gtk_bin_get_child (GTK_BIN (widget));
 
 	if (child) {
-		gtk_widget_size_request (child, requisition);
+		gtk_widget_get_preferred_size (child, requisition, NULL);
 	} else {
 		GtkRequisition self_requisition;
 
diff --git a/gtkhtml/gtkhtml-embedded.h b/gtkhtml/gtkhtml-embedded.h
index 564e9e9..a7e64ff 100644
--- a/gtkhtml/gtkhtml-embedded.h
+++ b/gtkhtml/gtkhtml-embedded.h
@@ -54,7 +54,7 @@ struct _GtkHTMLEmbeddedClass {
         GtkBinClass parent_class;
 
         void (*changed)(GtkHTMLEmbedded *);
-        void (*draw_gdk)(GtkHTMLEmbedded *, GdkPixmap *, GdkGC *,
+        void (*draw_gdk)(GtkHTMLEmbedded *, cairo_t *,
                          gint, gint);
         void (*draw_print)(GtkHTMLEmbedded *, GtkPrintContext *);
 };
diff --git a/gtkhtml/gtkhtml.c b/gtkhtml/gtkhtml.c
index a0fd654..ea3e498 100644
--- a/gtkhtml/gtkhtml.c
+++ b/gtkhtml/gtkhtml.c
@@ -759,73 +759,6 @@ remove_scroll_timeout (GtkHTML *html)
 }
 
 
-/* GObject methods.  */
-
-static void
-dispose (GObject *object)
-{
-	GtkHTML *html;
-
-	html = GTK_HTML (object);
-
-	g_free (html->pointer_url);
-	html->pointer_url = NULL;
-
-	if (html->hand_cursor) {
-		gdk_cursor_unref (html->hand_cursor);
-		html->hand_cursor = NULL;
-	}
-
-	if (html->ibeam_cursor) {
-		gdk_cursor_unref (html->ibeam_cursor);
-		html->ibeam_cursor = NULL;
-	}
-
-	connect_adjustments (html, NULL, NULL);
-
-	if (html->priv) {
-		if (html->priv->idle_handler_id != 0) {
-			g_source_remove (html->priv->idle_handler_id);
-			html->priv->idle_handler_id = 0;
-		}
-
-		if (html->priv->scroll_timeout_id != 0) {
-			g_source_remove (html->priv->scroll_timeout_id);
-			html->priv->scroll_timeout_id = 0;
-		}
-
-		if (html->priv->notify_monospace_font_id) {
-			gconf_client_notify_remove (
-				gconf_client_get_default (),
-				html->priv->notify_monospace_font_id);
-			html->priv->notify_monospace_font_id = 0;
-		}
-
-		if (html->priv->resize_cursor) {
-			gdk_cursor_unref (html->priv->resize_cursor);
-			html->priv->resize_cursor = NULL;
-		}
-
-		if (html->priv->im_context) {
-			g_object_unref (html->priv->im_context);
-			html->priv->im_context = NULL;
-		}
-
-		g_free (html->priv->base_url);
-		g_free (html->priv->caret_first_focus_anchor);
-		g_free (html->priv);
-		html->priv = NULL;
-	}
-
-	if (html->engine) {
-		g_object_unref (G_OBJECT (html->engine));
-		html->engine = NULL;
-	}
-
-	if (G_OBJECT_CLASS (parent_class)->dispose != NULL)
-		(* G_OBJECT_CLASS (parent_class)->dispose) (object);
-}
-
 GtkHTML *
 gtk_html_get_top_html (GtkHTML *html)
 {
@@ -995,6 +928,72 @@ set_caret_mode (HTMLEngine *engine, gboolean caret_mode)
 }
 
 /* GtkWidget methods.  */
+
+static void
+destroy (GtkWidget *widget)
+{
+	GtkHTML *html;
+
+	html = GTK_HTML (widget);
+
+	g_free (html->pointer_url);
+	html->pointer_url = NULL;
+
+	if (html->hand_cursor) {
+		gdk_cursor_unref (html->hand_cursor);
+		html->hand_cursor = NULL;
+	}
+
+	if (html->ibeam_cursor) {
+		gdk_cursor_unref (html->ibeam_cursor);
+		html->ibeam_cursor = NULL;
+	}
+
+	connect_adjustments (html, NULL, NULL);
+
+	if (html->priv) {
+		if (html->priv->idle_handler_id != 0) {
+			g_source_remove (html->priv->idle_handler_id);
+			html->priv->idle_handler_id = 0;
+		}
+
+		if (html->priv->scroll_timeout_id != 0) {
+			g_source_remove (html->priv->scroll_timeout_id);
+			html->priv->scroll_timeout_id = 0;
+		}
+
+		if (html->priv->notify_monospace_font_id) {
+			gconf_client_notify_remove (
+				gconf_client_get_default (),
+				html->priv->notify_monospace_font_id);
+			html->priv->notify_monospace_font_id = 0;
+		}
+
+		if (html->priv->resize_cursor) {
+			gdk_cursor_unref (html->priv->resize_cursor);
+			html->priv->resize_cursor = NULL;
+		}
+
+		if (html->priv->im_context) {
+			g_object_unref (html->priv->im_context);
+			html->priv->im_context = NULL;
+		}
+
+		g_free (html->priv->base_url);
+		g_free (html->priv->caret_first_focus_anchor);
+		g_free (html->priv);
+		html->priv = NULL;
+	}
+
+	if (html->engine) {
+		g_object_unref (G_OBJECT (html->engine));
+		html->engine = NULL;
+	}
+
+	if (GTK_WIDGET_CLASS (parent_class)->destroy != NULL)
+		(* GTK_WIDGET_CLASS (parent_class)->destroy) (widget);
+}
+
 static void
 style_set (GtkWidget *widget, GtkStyle  *previous_style)
 {
@@ -1192,7 +1191,7 @@ realize (GtkWidget *widget)
 
 	/* This sets the backing pixmap to None, so that scrolling does not
            erase the newly exposed area, thus making the thing smoother.  */
-	gdk_window_set_back_pixmap (bin_window, NULL, FALSE);
+	gdk_window_set_background_pattern (bin_window, NULL);
 
 	/* If someone was silly enough to stick us in something that doesn't
 	 * have adjustments, go ahead and create them now since we expect them
@@ -1231,15 +1230,15 @@ unrealize (GtkWidget *widget)
 }
 
 static gboolean
-expose (GtkWidget *widget, GdkEventExpose *event)
+draw (GtkWidget *widget, cairo_t *cr)
 {
-	/* printf ("expose x: %d y: %d\n", GTK_HTML (widget)->engine->x_offset, GTK_HTML (widget)->engine->y_offset); */
+	/* printf ("draw x: %d y: %d\n", GTK_HTML (widget)->engine->x_offset, GTK_HTML (widget)->engine->y_offset); */
 
-	html_engine_expose (GTK_HTML (widget)->engine, event);
+	html_engine_expose (GTK_HTML (widget)->engine, cr);
 
-	if (GTK_WIDGET_CLASS (parent_class)->expose_event)
-		(* GTK_WIDGET_CLASS (parent_class)->expose_event) (widget, event);
-	/* printf ("expose END\n"); */
+	if (GTK_WIDGET_CLASS (parent_class)->draw)
+		(* GTK_WIDGET_CLASS (parent_class)->draw) (widget, cr);
+	/* printf ("draw END\n"); */
 
 	return FALSE;
 }
@@ -2878,7 +2877,7 @@ gtk_html_direction_changed (GtkWidget *widget, GtkTextDirection previous_dir)
 static void
 gtk_html_class_init (GtkHTMLClass *klass)
 {
-	GObjectClass      *gobject_class;
+	GObjectClass      *object_class;
 	GtkHTMLClass      *html_class;
 	GtkWidgetClass    *widget_class;
 	GtkLayoutClass    *layout_class;
@@ -2887,7 +2886,7 @@ gtk_html_class_init (GtkHTMLClass *klass)
 	GConfClient *client;
 
 	html_class = (GtkHTMLClass *) klass;
-	gobject_class = (GObjectClass *) klass;
+	object_class = (GObjectClass *) klass;
 	widget_class = (GtkWidgetClass *) klass;
 	layout_class = (GtkLayoutClass *) klass;
 	container_class = (GtkContainerClass *) klass;
@@ -2896,7 +2895,7 @@ gtk_html_class_init (GtkHTMLClass *klass)
 
 	signals[TITLE_CHANGED] =
 		g_signal_new ("title_changed",
-			      G_TYPE_FROM_CLASS (gobject_class),
+			      G_TYPE_FROM_CLASS (object_class),
 			      G_SIGNAL_RUN_FIRST,
 			      G_STRUCT_OFFSET (GtkHTMLClass, title_changed),
 			      NULL, NULL,
@@ -2905,7 +2904,7 @@ gtk_html_class_init (GtkHTMLClass *klass)
 			      G_TYPE_STRING);
 	signals[URL_REQUESTED] =
 		g_signal_new ("url_requested",
-			      G_TYPE_FROM_CLASS (gobject_class),
+			      G_TYPE_FROM_CLASS (object_class),
 			      G_SIGNAL_RUN_LAST,
 			      G_STRUCT_OFFSET (GtkHTMLClass, url_requested),
 			      NULL, NULL,
@@ -2915,7 +2914,7 @@ gtk_html_class_init (GtkHTMLClass *klass)
 			      G_TYPE_POINTER);
 	signals[LOAD_DONE] =
 		g_signal_new ("load_done",
-			      G_TYPE_FROM_CLASS (gobject_class),
+			      G_TYPE_FROM_CLASS (object_class),
 			      G_SIGNAL_RUN_FIRST,
 			      G_STRUCT_OFFSET (GtkHTMLClass, load_done),
 			      NULL, NULL,
@@ -2923,7 +2922,7 @@ gtk_html_class_init (GtkHTMLClass *klass)
 			      G_TYPE_NONE, 0);
 	signals[LINK_CLICKED] =
 		g_signal_new ("link_clicked",
-			      G_TYPE_FROM_CLASS (gobject_class),
+			      G_TYPE_FROM_CLASS (object_class),
 			      G_SIGNAL_RUN_FIRST,
 			      G_STRUCT_OFFSET (GtkHTMLClass, link_clicked),
 			      NULL, NULL,
@@ -2932,7 +2931,7 @@ gtk_html_class_init (GtkHTMLClass *klass)
 			      G_TYPE_STRING);
 	signals[SET_BASE] =
 		g_signal_new ("set_base",
-			      G_TYPE_FROM_CLASS (gobject_class),
+			      G_TYPE_FROM_CLASS (object_class),
 			      G_SIGNAL_RUN_FIRST,
 			      G_STRUCT_OFFSET (GtkHTMLClass, set_base),
 			      NULL, NULL,
@@ -2941,7 +2940,7 @@ gtk_html_class_init (GtkHTMLClass *klass)
 			      G_TYPE_STRING);
 	signals[SET_BASE_TARGET] =
 		g_signal_new ("set_base_target",
-			      G_TYPE_FROM_CLASS (gobject_class),
+			      G_TYPE_FROM_CLASS (object_class),
 			      G_SIGNAL_RUN_FIRST,
 			      G_STRUCT_OFFSET (GtkHTMLClass, set_base_target),
 			      NULL, NULL,
@@ -2951,7 +2950,7 @@ gtk_html_class_init (GtkHTMLClass *klass)
 
 	signals[ON_URL] =
 		g_signal_new ("on_url",
-			      G_TYPE_FROM_CLASS (gobject_class),
+			      G_TYPE_FROM_CLASS (object_class),
 			      G_SIGNAL_RUN_FIRST,
 			      G_STRUCT_OFFSET (GtkHTMLClass, on_url),
 			      NULL, NULL,
@@ -2961,7 +2960,7 @@ gtk_html_class_init (GtkHTMLClass *klass)
 
 	signals[REDIRECT] =
 		g_signal_new ("redirect",
-			      G_TYPE_FROM_CLASS (gobject_class),
+			      G_TYPE_FROM_CLASS (object_class),
 			      G_SIGNAL_RUN_FIRST,
 			      G_STRUCT_OFFSET (GtkHTMLClass, redirect),
 			      NULL, NULL,
@@ -2972,7 +2971,7 @@ gtk_html_class_init (GtkHTMLClass *klass)
 
 	signals[SUBMIT] =
 		g_signal_new ("submit",
-			      G_TYPE_FROM_CLASS (gobject_class),
+			      G_TYPE_FROM_CLASS (object_class),
 			      G_SIGNAL_RUN_FIRST,
 			      G_STRUCT_OFFSET (GtkHTMLClass, submit),
 			      NULL, NULL,
@@ -2984,7 +2983,7 @@ gtk_html_class_init (GtkHTMLClass *klass)
 
 	signals[OBJECT_REQUESTED] =
 		g_signal_new ("object_requested",
-			      G_TYPE_FROM_CLASS (gobject_class),
+			      G_TYPE_FROM_CLASS (object_class),
 			      G_SIGNAL_RUN_LAST,
 			      G_STRUCT_OFFSET (GtkHTMLClass, object_requested),
 			      NULL, NULL,
@@ -2994,7 +2993,7 @@ gtk_html_class_init (GtkHTMLClass *klass)
 
 	signals[CURRENT_PARAGRAPH_STYLE_CHANGED] =
 		g_signal_new ("current_paragraph_style_changed",
-			      G_TYPE_FROM_CLASS (gobject_class),
+			      G_TYPE_FROM_CLASS (object_class),
 			      G_SIGNAL_RUN_FIRST,
 			      G_STRUCT_OFFSET (GtkHTMLClass, current_paragraph_style_changed),
 			      NULL, NULL,
@@ -3004,7 +3003,7 @@ gtk_html_class_init (GtkHTMLClass *klass)
 
 	signals[CURRENT_PARAGRAPH_INDENTATION_CHANGED] =
 		g_signal_new ("current_paragraph_indentation_changed",
-			      G_TYPE_FROM_CLASS (gobject_class),
+			      G_TYPE_FROM_CLASS (object_class),
 			      G_SIGNAL_RUN_FIRST,
 			      G_STRUCT_OFFSET (GtkHTMLClass, current_paragraph_indentation_changed),
 			      NULL, NULL,
@@ -3014,7 +3013,7 @@ gtk_html_class_init (GtkHTMLClass *klass)
 
 	signals[CURRENT_PARAGRAPH_ALIGNMENT_CHANGED] =
 		g_signal_new ("current_paragraph_alignment_changed",
-			      G_TYPE_FROM_CLASS (gobject_class),
+			      G_TYPE_FROM_CLASS (object_class),
 			      G_SIGNAL_RUN_FIRST,
 			      G_STRUCT_OFFSET (GtkHTMLClass, current_paragraph_alignment_changed),
 			      NULL, NULL,
@@ -3024,7 +3023,7 @@ gtk_html_class_init (GtkHTMLClass *klass)
 
 	signals[INSERTION_FONT_STYLE_CHANGED] =
 		g_signal_new ("insertion_font_style_changed",
-			      G_TYPE_FROM_CLASS (gobject_class),
+			      G_TYPE_FROM_CLASS (object_class),
 			      G_SIGNAL_RUN_FIRST,
 			      G_STRUCT_OFFSET (GtkHTMLClass, insertion_font_style_changed),
 			      NULL, NULL,
@@ -3034,7 +3033,7 @@ gtk_html_class_init (GtkHTMLClass *klass)
 
 	signals[INSERTION_COLOR_CHANGED] =
 		g_signal_new ("insertion_color_changed",
-			      G_TYPE_FROM_CLASS (gobject_class),
+			      G_TYPE_FROM_CLASS (object_class),
 			      G_SIGNAL_RUN_FIRST,
 			      G_STRUCT_OFFSET (GtkHTMLClass, insertion_color_changed),
 			      NULL, NULL,
@@ -3044,7 +3043,7 @@ gtk_html_class_init (GtkHTMLClass *klass)
 
 	signals[SIZE_CHANGED] =
 		g_signal_new ("size_changed",
-			      G_TYPE_FROM_CLASS (gobject_class),
+			      G_TYPE_FROM_CLASS (object_class),
 			      G_SIGNAL_RUN_FIRST,
 			      G_STRUCT_OFFSET (GtkHTMLClass, size_changed),
 			      NULL, NULL,
@@ -3052,7 +3051,7 @@ gtk_html_class_init (GtkHTMLClass *klass)
 			      G_TYPE_NONE, 0);
 	signals[IFRAME_CREATED] =
 		g_signal_new ("iframe_created",
-			      G_TYPE_FROM_CLASS (gobject_class),
+			      G_TYPE_FROM_CLASS (object_class),
 			      G_SIGNAL_RUN_FIRST,
 			      G_STRUCT_OFFSET (GtkHTMLClass, iframe_created),
 			      NULL, NULL,
@@ -3062,7 +3061,7 @@ gtk_html_class_init (GtkHTMLClass *klass)
 
 	signals[SCROLL] =
 		g_signal_new ("scroll",
-			      G_TYPE_FROM_CLASS (gobject_class),
+			      G_TYPE_FROM_CLASS (object_class),
 			      G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
 			      G_STRUCT_OFFSET (GtkHTMLClass, scroll),
 			      NULL, NULL,
@@ -3073,7 +3072,7 @@ gtk_html_class_init (GtkHTMLClass *klass)
 
 	signals[CURSOR_MOVE] =
 		g_signal_new ("cursor_move",
-			      G_TYPE_FROM_CLASS (gobject_class),
+			      G_TYPE_FROM_CLASS (object_class),
 			      G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
 			      G_STRUCT_OFFSET (GtkHTMLClass, cursor_move),
 			      NULL, NULL,
@@ -3082,7 +3081,7 @@ gtk_html_class_init (GtkHTMLClass *klass)
 
 	signals[COMMAND] =
 		g_signal_new ("command",
-			      G_TYPE_FROM_CLASS (gobject_class),
+			      G_TYPE_FROM_CLASS (object_class),
 			      G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
 			      G_STRUCT_OFFSET (GtkHTMLClass, command),
 			      NULL, NULL,
@@ -3091,7 +3090,7 @@ gtk_html_class_init (GtkHTMLClass *klass)
 
 	signals[CURSOR_CHANGED] =
 		g_signal_new ("cursor_changed",
-			      G_TYPE_FROM_CLASS (gobject_class),
+			      G_TYPE_FROM_CLASS (object_class),
 			      G_SIGNAL_RUN_FIRST,
 			      G_STRUCT_OFFSET (GtkHTMLClass, cursor_changed),
 			      NULL, NULL,
@@ -3100,7 +3099,7 @@ gtk_html_class_init (GtkHTMLClass *klass)
 
 	signals[OBJECT_INSERTED] =
 		g_signal_new ("object_inserted",
-			      G_TYPE_FROM_CLASS (gobject_class),
+			      G_TYPE_FROM_CLASS (object_class),
 			      G_SIGNAL_RUN_FIRST,
 			      G_STRUCT_OFFSET (GtkHTMLClass, object_inserted),
 			      NULL, NULL,
@@ -3110,41 +3109,40 @@ gtk_html_class_init (GtkHTMLClass *klass)
 
 	signals[OBJECT_DELETE] =
 		g_signal_new ("object_delete",
-			      G_TYPE_FROM_CLASS (gobject_class),
+			      G_TYPE_FROM_CLASS (object_class),
 			      G_SIGNAL_RUN_FIRST,
 			      G_STRUCT_OFFSET (GtkHTMLClass, object_delete),
 			      NULL, NULL,
 			      html_g_cclosure_marshal_VOID__INT_INT,
 			      G_TYPE_NONE, 2,
 			      G_TYPE_INT, G_TYPE_INT);
-	gobject_class->dispose = dispose;
 
 #ifdef USE_PROPS
-	gobject_class->get_property = gtk_html_get_property;
-	gobject_class->set_property = gtk_html_set_property;
+	object_class->get_property = gtk_html_get_property;
+	object_class->set_property = gtk_html_set_property;
 
-	g_object_class_install_property (gobject_class,
+	g_object_class_install_property (object_class,
 					 PROP_EDITABLE,
 					 g_param_spec_boolean ("editable",
 							       "Editable",
 							       "Whether the html can be edited",
 							       FALSE,
 							       G_PARAM_READABLE | G_PARAM_WRITABLE));
-	g_object_class_install_property (gobject_class,
+	g_object_class_install_property (object_class,
 					 PROP_TITLE,
 					 g_param_spec_string ("title",
 							      "Document Title",
 							      "The title of the current document",
 							      NULL,
 							      G_PARAM_WRITABLE | G_PARAM_READABLE));
-	g_object_class_install_property (gobject_class,
+	g_object_class_install_property (object_class,
 					 PROP_DOCUMENT_BASE,
 					 g_param_spec_string ("document_base",
 							      "Document Base",
 							      "The base URL for relative references",
 							      NULL,
 							      G_PARAM_WRITABLE | G_PARAM_READABLE));
-	g_object_class_install_property (gobject_class,
+	g_object_class_install_property (object_class,
 					 PROP_TARGET_BASE,
 					 g_param_spec_string ("target_base",
 							      "Target Base",
@@ -3192,12 +3190,13 @@ gtk_html_class_init (GtkHTMLClass *klass)
 								     GDK_TYPE_COLOR,
 								     G_PARAM_READABLE));
 
+	widget_class->destroy = destroy;
 	widget_class->realize = realize;
 	widget_class->unrealize = unrealize;
 	widget_class->style_set = style_set;
 	widget_class->key_press_event = key_press_event;
 	widget_class->key_release_event = key_release_event;
-	widget_class->expose_event  = expose;
+	widget_class->draw = draw;
 	widget_class->size_request = gtk_html_size_request;
 	widget_class->size_allocate = size_allocate;
 	widget_class->motion_notify_event = motion_notify_event;
diff --git a/gtkhtml/htmldrawqueue.c b/gtkhtml/htmldrawqueue.c
index ccf3079..f954d7d 100644
--- a/gtkhtml/htmldrawqueue.c
+++ b/gtkhtml/htmldrawqueue.c
@@ -256,7 +256,7 @@ html_draw_queue_flush (HTMLDrawQueue *queue)
 
 	/* check to make sure we have something to draw on */
 
-	vis = queue->engine->window ? gdk_drawable_get_visual (queue->engine->window): NULL;
+	vis = queue->engine->window ? gdk_window_get_visual (queue->engine->window): NULL;
 
 	/* Draw clear areas.  */
 
diff --git a/gtkhtml/htmlembedded.c b/gtkhtml/htmlembedded.c
index f9b9642..fdae86d 100644
--- a/gtkhtml/htmlembedded.c
+++ b/gtkhtml/htmlembedded.c
@@ -154,7 +154,7 @@ calc_min_width (HTMLObject *self,
 		return 0;
 
 	requisition.width = requisition.height = 0;
-	gtk_widget_size_request (widget, &requisition);
+	gtk_widget_get_preferred_size (widget, &requisition, NULL);
 	pixel_size = html_painter_get_pixel_size (painter);
 
 	min_width = requisition.width * pixel_size;
@@ -181,7 +181,7 @@ html_embedded_real_calc_size (HTMLObject *self, HTMLPainter *painter, GList **ch
 	old_ascent = self->ascent;
 
 	requisition.width = requisition.height = 0;
-	gtk_widget_size_request (widget, &requisition);
+	gtk_widget_get_preferred_size (widget, &requisition, NULL);
 
 	if (GTK_IS_HTML_EMBEDDED (widget))
 		self->descent = GTK_HTML_EMBEDDED (widget)->descent * pixel_size;
diff --git a/gtkhtml/htmlengine-edit-cursor.c b/gtkhtml/htmlengine-edit-cursor.c
index 5b8f1a5..fdc2d58 100644
--- a/gtkhtml/htmlengine-edit-cursor.c
+++ b/gtkhtml/htmlengine-edit-cursor.c
@@ -115,28 +115,46 @@ clip_cursor (HTMLEngine *engine, gint x, gint y, gint width, gint height, gint *
 }
 
 static void
+_cairo_draw_rectangle (cairo_t *cr,
+                       gboolean filled,
+                       gint x,
+                       gint y,
+                       gint width,
+                       gint height)
+{
+  if (filled)
+    {
+      cairo_rectangle (cr, x, y, width, height);
+      cairo_fill (cr);
+    }
+  else
+    {
+      cairo_rectangle (cr, x + 0.5, y + 0.5, width, height);
+      cairo_stroke (cr);
+    }
+}
+
+static void
 draw_cursor_rectangle (HTMLEngine *e, gint x1, gint y1, gint x2, gint y2,
 		       GdkColor *on_color, GdkColor *off_color,
 		       gint offset)
 {
-	GdkGC *gc;
+	cairo_t *cr;
 	GdkColor color;
-	gint8 dashes[2] = { 1, 3 };
+	const double dashes[2] = { 1, 3 };
+	int ndash  = sizeof (dashes) / sizeof (dashes[0]);
 
 	if (x1 > x2 || y1 > y2 || !e->window)
 		return;
 
-	gc = gdk_gc_new (e->window);
+	/* FIXME: what is the off color for? */
+	cr = gdk_cairo_create (e->window);
 	color = *on_color;
-	gdk_rgb_find_color (gdk_drawable_get_colormap (e->window), &color);
-	gdk_gc_set_foreground (gc, &color);
-	color = *off_color;
-	gdk_rgb_find_color (gdk_drawable_get_colormap (e->window), &color);
-	gdk_gc_set_background (gc, &color);
-	gdk_gc_set_line_attributes (gc, 1, GDK_LINE_DOUBLE_DASH, GDK_CAP_ROUND, GDK_JOIN_ROUND);
-	gdk_gc_set_dashes (gc, offset, dashes, 2);
-	gdk_draw_rectangle (e->window, gc, 0, x1, y1, x2 - x1, y2 - y1);
-	g_object_unref (gc);
+	gdk_cairo_set_source_color (cr, &color);
+	cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND);
+	cairo_set_dash (cr, dashes, ndash, offset);
+	_cairo_draw_rectangle (cr, FALSE, x1, y1, x2 - x1, y2 - y1);
+	cairo_destroy (cr);
 }
 
 static gint cursor_enabled = TRUE;
@@ -282,6 +300,24 @@ html_engine_draw_table_cursor (HTMLEngine *e)
 		}
 }
 
+static void
+_cairo_draw_line (cairo_t  *cr,
+                  gint      x1,
+                  gint      y1,
+                  gint      x2,
+                  gint      y2)
+{
+  cairo_save (cr);
+
+  cairo_set_line_cap (cr, CAIRO_LINE_CAP_SQUARE);
+
+  cairo_move_to (cr, x1 + 0.5, y1 + 0.5);
+  cairo_line_to (cr, x2 + 0.5, y2 + 0.5);
+  cairo_stroke (cr);
+
+  cairo_restore (cr);
+}
+
 void
 html_engine_draw_cursor_in_area (HTMLEngine *engine,
 				 gint x, gint y,
@@ -341,7 +377,12 @@ html_engine_draw_cursor_in_area (HTMLEngine *engine,
 	gtk_im_context_set_cursor_location (GTK_HTML (engine->widget)->priv->im_context, &pos);
 
 	if (clip_cursor (engine, x, y, width, height, &x1, &y1, &x2, &y2)) {
-		gdk_draw_line (engine->window, engine->invert_gc, x1, y1, x2, y2);
+		cairo_t *cr;
+		cr = gdk_cairo_create (engine->window);
+		cairo_set_source_rgb (cr, 1, 1, 1);
+		cairo_set_operator (cr, CAIRO_OPERATOR_DIFFERENCE);
+		_cairo_draw_line (cr, x1, y1, x2, y2);
+		cairo_destroy (cr);
 	}
 }
 
diff --git a/gtkhtml/htmlengine.c b/gtkhtml/htmlengine.c
index 5f5feba..eaf02e3 100644
--- a/gtkhtml/htmlengine.c
+++ b/gtkhtml/htmlengine.c
@@ -4094,11 +4094,6 @@ html_engine_finalize (GObject *object)
 	}
 	html_engine_clipboard_clear (engine);
 
-	if (engine->invert_gc != NULL) {
-		g_object_unref (engine->invert_gc);
-		engine->invert_gc = NULL;
-	}
-
 	if (engine->cursor) {
 		html_cursor_destroy (engine->cursor);
 		engine->cursor = NULL;
@@ -4393,7 +4388,6 @@ html_engine_init (HTMLEngine *engine)
 	engine->pending_expose = NULL;
 
 	engine->window = NULL;
-	engine->invert_gc = NULL;
 
 	/* settings, colors and painter init */
 
@@ -4497,8 +4491,6 @@ void
 html_engine_realize (HTMLEngine *e,
 		     GdkWindow *window)
 {
-	GdkGCValues gc_values;
-
 	g_return_if_fail (e != NULL);
 	g_return_if_fail (window != NULL);
 	g_return_if_fail (e->window == NULL);
@@ -4509,9 +4501,6 @@ html_engine_realize (HTMLEngine *e,
 		html_gdk_painter_realize (
 			HTML_GDK_PAINTER (e->painter), window);
 
-	gc_values.function = GDK_INVERT;
-	e->invert_gc = gdk_gc_new_with_values (e->window, &gc_values, GDK_GC_FUNCTION);
-
 	if (e->need_update)
 		html_engine_schedule_update (e);
 }
@@ -5140,12 +5129,15 @@ html_engine_draw_real (HTMLEngine *e, gint x, gint y, gint width, gint height, g
 }
 
 void
-html_engine_expose (HTMLEngine *e, GdkEventExpose *event)
+html_engine_expose (HTMLEngine *e, cairo_t *cr)
 {
+	GdkRectangle rect;
+
+	gdk_cairo_get_clip_rectangle (cr, &rect);
 	if (html_engine_frozen (e))
-		html_engine_add_expose (e, event->area.x, event->area.y, event->area.width, event->area.height, TRUE);
+		html_engine_add_expose (e, rect.x, rect.y, rect.width, rect.height, TRUE);
 	else
-		html_engine_draw_real (e, event->area.x, event->area.y, event->area.width, event->area.height, TRUE);
+		html_engine_draw_real (e, rect.x, rect.y, rect.width, rect.height, TRUE);
 }
 
 void
diff --git a/gtkhtml/htmlengine.h b/gtkhtml/htmlengine.h
index a3ff3ac..9464be6 100644
--- a/gtkhtml/htmlengine.h
+++ b/gtkhtml/htmlengine.h
@@ -60,7 +60,6 @@ struct _HTMLEngine {
 	HTMLUndo *undo;
 
 	GdkWindow *window;
-	GdkGC *invert_gc;
 
 	gboolean editable;
 	gboolean caret_mode;
@@ -337,7 +336,7 @@ void  html_engine_draw                 (HTMLEngine *e,
 					gint        width,
 					gint        height);
 void  html_engine_expose               (HTMLEngine *e,
-					GdkEventExpose *event);
+					cairo_t    *cr);
 void  html_engine_draw_background      (HTMLEngine *e,
 					gint        x,
 					gint        y,
diff --git a/gtkhtml/htmlgdkpainter.c b/gtkhtml/htmlgdkpainter.c
index 2567862..ad4c635 100644
--- a/gtkhtml/htmlgdkpainter.c
+++ b/gtkhtml/htmlgdkpainter.c
@@ -24,6 +24,7 @@
 
 #include <string.h>
 #include <stdlib.h>
+#include <math.h>
 
 #include <glib/gi18n-lib.h>
 
@@ -51,14 +52,14 @@ finalize (GObject *object)
 
 	painter = HTML_GDK_PAINTER (object);
 
-	if (painter->gc != NULL) {
-		g_object_unref (painter->gc);
-		painter->gc = NULL;
+	if (painter->cr != NULL) {
+		cairo_destroy (painter->cr);
+		painter->cr = NULL;
 	}
 
-	if (painter->pixmap != NULL) {
-		g_object_unref (painter->pixmap);
-		painter->pixmap = NULL;
+	if (painter->surface != NULL) {
+		cairo_surface_destroy (painter->surface);
+		painter->surface = NULL;
 	}
 
 	if (G_OBJECT_CLASS (parent_class)->finalize) {
@@ -70,14 +71,6 @@ static void
 alloc_color (HTMLPainter *painter,
 	     GdkColor *color)
 {
-	HTMLGdkPainter *gdk_painter;
-	GdkColormap *colormap;
-
-	gdk_painter = HTML_GDK_PAINTER (painter);
-	g_return_if_fail (gdk_painter->window != NULL);
-
-	colormap = gdk_drawable_get_colormap (gdk_painter->window);
-	gdk_rgb_find_color (colormap, color);
 }
 
 static void
@@ -86,6 +79,80 @@ free_color (HTMLPainter *painter,
 {
 }
 
+static void
+_cairo_draw_line (cairo_t  *cr,
+                  gint      x1,
+                  gint      y1,
+                  gint      x2,
+                  gint      y2)
+{
+  cairo_save (cr);
+
+  cairo_set_line_cap (cr, CAIRO_LINE_CAP_SQUARE);
+
+  cairo_move_to (cr, x1 + 0.5, y1 + 0.5);
+  cairo_line_to (cr, x2 + 0.5, y2 + 0.5);
+  cairo_stroke (cr);
+
+  cairo_restore (cr);
+}
+
+static void
+_cairo_draw_rectangle (cairo_t *cr,
+                       gboolean filled,
+                       gint x,
+                       gint y,
+                       gint width,
+                       gint height)
+{
+  if (filled)
+    {
+      cairo_rectangle (cr, x, y, width, height);
+      cairo_fill (cr);
+    }
+  else
+    {
+      cairo_rectangle (cr, x + 0.5, y + 0.5, width, height);
+      cairo_stroke (cr);
+    }
+}
+
+static void
+_cairo_draw_ellipse (cairo_t *cr,
+		     gboolean filled,
+		     gint x,
+		     gint y,
+		     gint width,
+		     gint height)
+{
+	cairo_save (cr);
+
+	cairo_translate (cr, x + width / 2.0, y + height / 2.0);
+	cairo_scale (cr, width / 2.0, height / 2.0);
+	cairo_arc (cr, 0.0, 0.0, 1.0, 0.0, 2 * M_PI);
+
+	if (filled) {
+		cairo_fill (cr);
+	} else {
+		cairo_stroke (cr);
+	}
+
+	cairo_restore (cr);
+}
+
+static void
+_cairo_draw_glyphs (cairo_t          *cr,
+		    PangoFont        *font,
+		    int               x,
+		    int               y,
+		    PangoGlyphString *glyphs)
+{
+	cairo_save (cr);
+	cairo_move_to (cr, (double)x / PANGO_SCALE, (double)y / PANGO_SCALE);
+	pango_cairo_show_glyph_string (cr, font, glyphs);
+	cairo_restore (cr);
+}
+
 
 static void
 begin (HTMLPainter *painter, gint x1, gint y1, gint x2, gint y2)
@@ -97,62 +164,71 @@ begin (HTMLPainter *painter, gint x1, gint y1, gint x2, gint y2)
 	gdk_painter = HTML_GDK_PAINTER (painter);
 	g_return_if_fail (gdk_painter->window != NULL);
 
-	set_clip_rectangle (painter, 0, 0, 0, 0);
+	/* FIXME: Ideally it should be NULL before coming here. */
+	if (gdk_painter->cr)
+		cairo_destroy (gdk_painter->cr);
+	if (gdk_painter->surface)
+		cairo_surface_destroy (gdk_painter->surface);
 
 	if (gdk_painter->double_buffer) {
 		const gint width = x2 - x1 + 1;
 		const gint height = y2 - y1 + 1;
 
-		/* FIXME: Ideally it should be NULL before coming here. */
-		if (gdk_painter->pixmap && gdk_painter->pixmap != gdk_painter->window)
-			g_object_unref (gdk_painter->pixmap);
-
-		gdk_painter->pixmap = gdk_pixmap_new (gdk_painter->window, width, height, -1);
+		gdk_painter->surface = gdk_window_create_similar_surface (gdk_painter->window,
+									  CAIRO_CONTENT_COLOR,
+									  MAX (width, 1),
+									  MAX (height, 1));
 		gdk_painter->x1 = x1;
 		gdk_painter->y1 = y1;
 		gdk_painter->x2 = x2;
 		gdk_painter->y2 = y2;
 
 		if (gdk_painter->set_background) {
-			gdk_gc_set_background (gdk_painter->gc, &gdk_painter->background);
 			gdk_painter->set_background = FALSE;
 		}
 
-		gdk_gc_set_foreground (gdk_painter->gc, &gdk_painter->background);
-		gdk_draw_rectangle (gdk_painter->pixmap, gdk_painter->gc,
-				    TRUE, 0, 0, width, height);
+		gdk_painter->cr = cairo_create (gdk_painter->surface);
+		gdk_cairo_set_source_color (gdk_painter->cr, &gdk_painter->background);
+		_cairo_draw_rectangle (gdk_painter->cr,
+				       TRUE, 0, 0, width, height);
 	} else {
-		gdk_painter->pixmap = gdk_painter->window;
+		gdk_painter->cr = gdk_cairo_create (gdk_painter->window);
+		gdk_painter->surface = NULL;
 		gdk_painter->x1 = 0;
 		gdk_painter->y1 = 0;
 		gdk_painter->x2 = 0;
 		gdk_painter->y2 = 0;
 	}
-
-	g_return_if_fail (gdk_drawable_get_colormap (gdk_painter->pixmap) != NULL);
 }
 
 static void
 end (HTMLPainter *painter)
 {
 	HTMLGdkPainter *gdk_painter;
+	cairo_t *cr;
 
 	/* printf ("painter end\n"); */
 
 	gdk_painter = HTML_GDK_PAINTER (painter);
 
+	cairo_destroy (gdk_painter->cr);
+	gdk_painter->cr = NULL;
+
 	if (!gdk_painter->double_buffer)
 		return;
 
-	gdk_draw_drawable (gdk_painter->window, gdk_painter->gc,
-			   gdk_painter->pixmap,
-			   0, 0,
-			   gdk_painter->x1, gdk_painter->y1,
-			   gdk_painter->x2 - gdk_painter->x1,
-			   gdk_painter->y2 - gdk_painter->y1);
-
-	g_object_unref (gdk_painter->pixmap);
-	gdk_painter->pixmap = NULL;
+	cr = gdk_cairo_create (gdk_painter->window);
+	cairo_set_source_surface (cr, gdk_painter->surface, 0, 0);
+	cairo_rectangle (cr,
+			 gdk_painter->x1,
+			 gdk_painter->y1,
+			 gdk_painter->x2 - gdk_painter->x1,
+			 gdk_painter->y2 - gdk_painter->y1);
+	cairo_fill (cr);
+	cairo_destroy (cr);
+
+	cairo_surface_destroy (gdk_painter->surface);
+	gdk_painter->surface = NULL;
 }
 
 static void
@@ -163,15 +239,16 @@ clear (HTMLPainter *painter)
 	gdk_painter = HTML_GDK_PAINTER (painter);
 
 	if (!gdk_painter->double_buffer) {
-		gdk_window_clear (gdk_painter->window);
+		gdk_cairo_set_source_color (gdk_painter->cr, &gdk_painter->background);
+		cairo_paint (gdk_painter->cr);
 	} else {
-		if (gdk_painter->pixmap != NULL)
-			gdk_window_clear (gdk_painter->pixmap);
-		else
+		if (gdk_painter->surface != NULL) {
+			gdk_cairo_set_source_color (gdk_painter->cr, &gdk_painter->background);
+			cairo_paint (gdk_painter->cr);
+		} else {
 			gdk_painter->do_clear = TRUE;
+		}
 	}
-
-	g_return_if_fail (gdk_drawable_get_colormap (gdk_painter->pixmap) != NULL);
 }
 
 
@@ -186,7 +263,6 @@ set_clip_rectangle (HTMLPainter *painter,
 	gdk_painter = HTML_GDK_PAINTER (painter);
 
 	if (width == 0 || height == 0) {
-		gdk_gc_set_clip_rectangle (gdk_painter->gc, NULL);
 		return;
 	}
 
@@ -195,7 +271,8 @@ set_clip_rectangle (HTMLPainter *painter,
 	rect.width = CLAMP (width, 0, gdk_painter->x2 - gdk_painter->x1 - rect.x);
 	rect.height = CLAMP (height, 0, gdk_painter->y2 - gdk_painter->y1 - rect.y);
 
-	gdk_gc_set_clip_rectangle (gdk_painter->gc, &rect);
+	gdk_cairo_rectangle (gdk_painter->cr, &rect);
+	cairo_clip (gdk_painter->cr);
 }
 
 static void
@@ -214,7 +291,7 @@ set_pen (HTMLPainter *painter,
 	gdk_painter = HTML_GDK_PAINTER (painter);
 
 	/* GdkColor API not const-safe!  */
-	gdk_gc_set_foreground (gdk_painter->gc, (GdkColor *) color);
+	gdk_cairo_set_source_color (gdk_painter->cr, (GdkColor *) color);
 }
 
 static const GdkColor *
@@ -243,7 +320,7 @@ draw_line (HTMLPainter *painter,
 	x2 -= gdk_painter->x1;
 	y2 -= gdk_painter->y1;
 
-	gdk_draw_line (gdk_painter->pixmap, gdk_painter->gc, x1, y1, x2, y2);
+	_cairo_draw_line (gdk_painter->cr, x1, y1, x2, y2);
 }
 
 static void
@@ -255,10 +332,8 @@ draw_ellipse (HTMLPainter *painter,
 
 	gdk_painter = HTML_GDK_PAINTER (painter);
 
-	gdk_draw_arc (gdk_painter->pixmap, gdk_painter->gc, TRUE,
-		      x - gdk_painter->x1, y - gdk_painter->y1,
-		      width, height,
-		      0, 360 * 64);
+	_cairo_draw_ellipse (gdk_painter->cr, TRUE,
+			     x, y, width, height);
 }
 
 static void
@@ -270,9 +345,9 @@ draw_rect (HTMLPainter *painter,
 
 	gdk_painter = HTML_GDK_PAINTER (painter);
 
-	gdk_draw_rectangle (gdk_painter->pixmap, gdk_painter->gc, FALSE,
-			    x - gdk_painter->x1, y - gdk_painter->y1,
-			    width, height);
+	_cairo_draw_rectangle (gdk_painter->cr, FALSE,
+			       x - gdk_painter->x1, y - gdk_painter->y1,
+			       width, height);
 }
 
 static void
@@ -298,9 +373,6 @@ draw_border (HTMLPainter *painter,
 	LIGHT (green);
 	LIGHT (blue);
 
-	alloc_color (painter, &dark);
-	alloc_color (painter, &light);
-
 	gdk_painter = HTML_GDK_PAINTER (painter);
 
 	switch (style) {
@@ -324,21 +396,21 @@ draw_border (HTMLPainter *painter,
 
 	while (bordersize > 0) {
 		if (col2) {
-			gdk_gc_set_foreground (gdk_painter->gc, col2);
+			gdk_cairo_set_source_color (gdk_painter->cr, col2);
 		}
 
-		gdk_draw_line (gdk_painter->pixmap, gdk_painter->gc,
-			       x + width - 1, y, x + width - 1, y + height - 1);
-		gdk_draw_line (gdk_painter->pixmap, gdk_painter->gc,
-			       x + 1, y + height - 1, x + width - 1, y + height - 1);
+		_cairo_draw_line (gdk_painter->cr,
+				  x + width - 1, y, x + width - 1, y + height - 1);
+		_cairo_draw_line (gdk_painter->cr,
+				  x + 1, y + height - 1, x + width - 1, y + height - 1);
 		if (col1) {
-			gdk_gc_set_foreground (gdk_painter->gc, col1);
+			gdk_cairo_set_source_color (gdk_painter->cr, col1);
 		}
 
-		gdk_draw_line (gdk_painter->pixmap, gdk_painter->gc,
-			       x, y, x + width - 2, y);
-		gdk_draw_line (gdk_painter->pixmap, gdk_painter->gc,
-			       x, y, x, y + height - 1);
+		_cairo_draw_line (gdk_painter->cr,
+				  x, y, x + width - 2, y);
+		_cairo_draw_line (gdk_painter->cr,
+				  x, y, x, y + height - 1);
 		bordersize--;
 		x++;
 		y++;
@@ -362,7 +434,6 @@ draw_background (HTMLPainter *painter,
 	gint pw;
 	gint ph;
 	gint tile_width, tile_height;
-	gint w, h;
 	GdkRectangle expose, paint, clip;
 
 	gdk_painter = HTML_GDK_PAINTER (painter);
@@ -387,10 +458,10 @@ draw_background (HTMLPainter *painter,
 		return;
 
 	if (color && !pixbuf) {
-		gdk_gc_set_foreground (gdk_painter->gc, color);
-		gdk_draw_rectangle (gdk_painter->pixmap, gdk_painter->gc,
-				    TRUE, paint.x - clip.x, paint.y - clip.y,
-				    paint.width, paint.height);
+		gdk_cairo_set_source_color (gdk_painter->cr, color);
+		_cairo_draw_rectangle (gdk_painter->cr,
+				       TRUE, paint.x - clip.x, paint.y - clip.y,
+				       paint.width, paint.height);
 
 	}
 
@@ -412,15 +483,14 @@ draw_background (HTMLPainter *painter,
 			pixcol.green = p[1] * 0xff;
 			pixcol.blue = p[2] * 0xff;
 
-			html_painter_alloc_color (painter, &pixcol);
 			color = &pixcol;
 		}
 
 		if (color) {
-			gdk_gc_set_foreground (gdk_painter->gc, color);
-			gdk_draw_rectangle (gdk_painter->pixmap, gdk_painter->gc,
-					    TRUE, paint.x - clip.x, paint.y - clip.y,
-					    paint.width, paint.height);
+			gdk_cairo_set_source_color (gdk_painter->cr, color);
+			_cairo_draw_rectangle (gdk_painter->cr,
+					       TRUE, paint.x - clip.x, paint.y - clip.y,
+					       paint.width, paint.height);
 		}
 
 		return;
@@ -431,94 +501,42 @@ draw_background (HTMLPainter *painter,
 
 	/* do tiling */
 	if (tile_width > pw || tile_height > ph) {
-		GdkPixmap *pixmap = NULL;
-		gint cw, ch, cx, cy;
 		gint dw, dh;
-		GdkGC *gc;
 
 		dw = MIN (pw, tile_width);
 		dh = MIN (ph, tile_height);
 
-		gc = gdk_gc_new (gdk_painter->window);
-
-		if (color || !gdk_pixbuf_get_has_alpha (pixbuf)) {
-			pixmap = gdk_pixmap_new (gdk_painter->window, dw, dh, -1);
-
-			if (color) {
-				gdk_gc_set_foreground (gc, color);
-				gdk_draw_rectangle (pixmap, gc,
-						    TRUE, 0, 0,
-						    dw, dh);
-			}
+		if (color) {
+			gdk_cairo_set_source_color (gdk_painter->cr, color);
+			_cairo_draw_rectangle (gdk_painter->cr,
+					       TRUE, 0, 0,
+					       dw, dh);
+		}
 
-			gdk_draw_pixbuf (pixmap, NULL, pixbuf,
-					 0, 0,
-					 0, 0,
-					 dw, dh,
-					 GDK_RGB_DITHER_NORMAL,
-					 paint.x, paint.y);
-
-			gdk_gc_set_tile (gc, pixmap);
-			gdk_gc_set_fill (gc, GDK_TILED);
-			gdk_gc_set_ts_origin (gc,
-					      paint.x - (tile_x % pw) - clip.x,
-					      paint.y - (tile_y % ph) - clip.y);
-
-			gdk_draw_rectangle (gdk_painter->pixmap, gc, TRUE,
-					    paint.x - clip.x, paint.y - clip.y,
-					    paint.width, paint.height);
-
-			g_object_unref (pixmap);
-			g_object_unref (gc);
-		} else {
-			gint incr_x = 0;
-			gint incr_y = 0;
-
-			cy = paint.y;
-			ch = paint.height;
-			h = tile_y % ph;
-			while (ch > 0) {
-				incr_y = dh - h;
-
-				cx = paint.x;
-				cw = paint.width;
-				w = tile_x % pw;
-				while (cw > 0) {
-					incr_x = dw - w;
-
-					gdk_draw_pixbuf (gdk_painter->pixmap, NULL, pixbuf,
-							 w, h,
-							 cx - clip.x, cy - clip.y,
-							 (cw >= incr_x) ? incr_x : cw,
-							 (ch >= incr_y) ? incr_y : ch,
-							 GDK_RGB_DITHER_NORMAL,
-							 cx, cy);
-
-					cw -= incr_x;
-					cx += incr_x;
-					w = 0;
-				}
-				ch -= incr_y;
-				cy += incr_y;
-				h = 0;
-			}
+		gdk_cairo_set_source_pixbuf (gdk_painter->cr, pixbuf,
+					     paint.x - (tile_x % pw) - clip.x,
+					     paint.y - (tile_y % ph) - clip.y);
+		cairo_pattern_set_extend (cairo_get_source (gdk_painter->cr), CAIRO_EXTEND_REPEAT);
 
-			g_object_unref (gc);
-		}
+		cairo_rectangle (gdk_painter->cr, paint.x - clip.x, paint.y - clip.y,
+				 paint.width, paint.height);
+		cairo_fill (gdk_painter->cr);
 	} else {
 		if (color && gdk_pixbuf_get_has_alpha (pixbuf)) {
-			gdk_gc_set_foreground (gdk_painter->gc, color);
-			gdk_draw_rectangle (gdk_painter->pixmap, gdk_painter->gc, TRUE,
-					    paint.x - clip.x, paint.y - clip.y,
-					    paint.width, paint.height);
+			gdk_cairo_set_source_color (gdk_painter->cr, color);
+			_cairo_draw_rectangle (gdk_painter->cr,
+					       TRUE,
+					       paint.x - clip.x, paint.y - clip.y,
+					       paint.width, paint.height);
 		}
 
-		gdk_draw_pixbuf (gdk_painter->pixmap, NULL, pixbuf,
-				 tile_x % pw, tile_y % ph,
+		gdk_cairo_set_source_pixbuf (gdk_painter->cr,
+					     pixbuf,
+					     tile_x % pw, tile_y % ph);
+		cairo_rectangle (gdk_painter->cr,
 				 paint.x - clip.x, paint.y - clip.y,
-				 paint.width, paint.height,
-				 GDK_RGB_DITHER_NORMAL,
-				 paint.x, paint.y);
+				 paint.width, paint.height);
+		cairo_fill (gdk_painter->cr);
 	}
 }
 
@@ -561,15 +579,13 @@ draw_pixmap (HTMLPainter *painter,
 	    return;
 
 	if (scale_width == orig_width && scale_height == orig_height && color == NULL) {
-		gdk_draw_pixbuf (gdk_painter->pixmap, NULL, pixbuf,
-				 paint.x - image.x,
-				 paint.y - image.y,
-				 paint.x - clip.x,
-				 paint.y - clip.y,
-				 paint.width,
-				 paint.height,
-				 GDK_RGB_DITHER_NORMAL,
-				 paint.x, paint.y);
+		gdk_cairo_set_source_pixbuf (gdk_painter->cr, pixbuf,
+					     paint.x - image.x,
+					     paint.y - image.y);
+		cairo_rectangle (gdk_painter->cr,
+				 paint.x - clip.x, paint.y - clip.y,
+				 paint.width, paint.height);
+		cairo_fill (gdk_painter->cr);
 		return;
 	}
 
@@ -637,15 +653,12 @@ draw_pixmap (HTMLPainter *painter,
 		}
 	}
 
-	gdk_draw_pixbuf (gdk_painter->pixmap, NULL, tmp_pixbuf,
-			 0,
-			 0,
-			 paint.x - clip.x,
-			 paint.y - clip.y,
-			 paint.width,
-			 paint.height,
-			 GDK_RGB_DITHER_NORMAL,
-			 paint.x, paint.y);
+	gdk_cairo_set_source_pixbuf (gdk_painter->cr, tmp_pixbuf,
+				     0, 0);
+	cairo_rectangle (gdk_painter->cr,
+			 paint.x - clip.x, paint.y - clip.y,
+			 paint.width, paint.height);
+	cairo_fill (gdk_painter->cr);
 	g_object_unref (tmp_pixbuf);
 }
 
@@ -658,33 +671,31 @@ fill_rect (HTMLPainter *painter,
 
 	gdk_painter = HTML_GDK_PAINTER (painter);
 
-	gdk_draw_rectangle (gdk_painter->pixmap, gdk_painter->gc,
-			    TRUE, x - gdk_painter->x1, y - gdk_painter->y1,
-			    width, height);
+	_cairo_draw_rectangle (gdk_painter->cr,
+			       TRUE, x - gdk_painter->x1, y - gdk_painter->y1,
+			       width, height);
 }
 
 static gint
 draw_spell_error (HTMLPainter *painter, gint x, gint y, gint width)
 {
 	HTMLGdkPainter *gdk_painter;
-	GdkGCValues values;
-	gint8 dash_list[] = { 2, 2 };
+	const double dashes[] = { 2, 2 };
+	int ndash  = sizeof (dashes) / sizeof (dashes[0]);
 
 	gdk_painter = HTML_GDK_PAINTER (painter);
 
 	x -= gdk_painter->x1;
 	y -= gdk_painter->y1;
 
-	gdk_gc_get_values (gdk_painter->gc, &values);
-	gdk_gc_set_fill (gdk_painter->gc, GDK_OPAQUE_STIPPLED);
-	gdk_gc_set_line_attributes (gdk_painter->gc, 1, GDK_LINE_ON_OFF_DASH, values.cap_style, values.join_style);
-	gdk_gc_set_dashes (gdk_painter->gc, 2, dash_list, 2);
-	gdk_draw_line (gdk_painter->pixmap, gdk_painter->gc, x, y, x + width, y);
-	gdk_gc_set_dashes (gdk_painter->gc, 0, dash_list, 2);
-	gdk_draw_line (gdk_painter->pixmap, gdk_painter->gc, x, y + 1, x + width, y + 1);
-	gdk_gc_set_fill (gdk_painter->gc, values.fill);
-	gdk_gc_set_line_attributes (gdk_painter->gc, values.line_width,
-				    values.line_style, values.cap_style, values.join_style);
+	cairo_save (gdk_painter->cr);
+
+	cairo_set_dash (gdk_painter->cr, dashes, ndash, 2);
+	_cairo_draw_line (gdk_painter->cr, x, y, x + width, y);
+	cairo_set_dash (gdk_painter->cr, dashes, ndash, 0);
+	_cairo_draw_line (gdk_painter->cr, x, y + 1, x + width, y + 1);
+
+	cairo_restore (gdk_painter->cr);
 
 	return width;
 }
@@ -699,8 +710,7 @@ draw_embedded (HTMLPainter * p, HTMLEmbedded *o, gint x, gint y)
 	if (embedded_widget && GTK_IS_HTML_EMBEDDED (embedded_widget)) {
 		g_signal_emit_by_name (embedded_widget,
 				       "draw_gdk", 0,
-				       gdk_painter->pixmap,
-				       gdk_painter->gc,
+				       gdk_painter->cr,
 				       x, y);
 	}
 }
@@ -732,7 +742,7 @@ set_item_gc (HTMLPainter *p, HTMLPangoProperties *properties, GdkColor **fg_colo
 }
 
 static gint
-draw_lines (PangoGlyphString *str, gint x, gint y, GdkDrawable *drawable, GdkGC *gc, PangoItem *item, HTMLPangoProperties *properties)
+draw_lines (PangoGlyphString *str, gint x, gint y, cairo_t *cr, PangoItem *item, HTMLPangoProperties *properties)
 {
 	PangoRectangle log_rect;
 	gint width, dsc, asc;
@@ -744,10 +754,10 @@ draw_lines (PangoGlyphString *str, gint x, gint y, GdkDrawable *drawable, GdkGC
 	asc = PANGO_PIXELS (PANGO_ASCENT (log_rect));
 
 	if (properties->underline)
-		gdk_draw_line (drawable, gc, x, y + dsc - 2, x + PANGO_PIXELS (width), y + dsc - 2);
+		_cairo_draw_line (cr, x, y + dsc - 2, x + PANGO_PIXELS (width), y + dsc - 2);
 
 	if (properties->strikethrough)
-		gdk_draw_line (drawable, gc, x, y - asc + (asc + dsc)/2, x + PANGO_PIXELS (width), y - asc + (asc + dsc)/2);
+		_cairo_draw_line (cr, x, y - asc + (asc + dsc)/2, x + PANGO_PIXELS (width), y - asc + (asc + dsc)/2);
 
 	return width;
 }
@@ -760,7 +770,6 @@ draw_glyphs (HTMLPainter *painter, gint x, gint y, PangoItem *item, PangoGlyphSt
 	HTMLPangoProperties properties;
 	GdkColor *fg_text_color;
 	GdkColor *bg_text_color;
-	GdkGCValues orig_fg;
 	gint cw = 0;
 
 	gdk_painter = HTML_GDK_PAINTER (painter);
@@ -775,35 +784,38 @@ draw_glyphs (HTMLPainter *painter, gint x, gint y, PangoItem *item, PangoGlyphSt
 	if (bg_text_color || bg) {
 		PangoRectangle log_rect;
 
-		gdk_gc_get_values (gdk_painter->gc, &orig_fg);
+		cairo_save (gdk_painter->cr);
+
 		if (bg)
-			gdk_gc_set_rgb_fg_color (gdk_painter->gc, bg);
+			gdk_cairo_set_source_color (gdk_painter->cr, bg);
 		else
-			gdk_gc_set_rgb_fg_color (gdk_painter->gc, bg_text_color);
+			gdk_cairo_set_source_color (gdk_painter->cr, bg_text_color);
+
 		pango_glyph_string_extents (glyphs, item->analysis.font, NULL, &log_rect);
-		gdk_draw_rectangle (gdk_painter->pixmap, gdk_painter->gc, TRUE, x, y - PANGO_PIXELS (PANGO_ASCENT (log_rect)),
-				    PANGO_PIXELS (log_rect.width), PANGO_PIXELS (log_rect.height));
-		gdk_gc_set_foreground (gdk_painter->gc, &orig_fg.foreground);
+		_cairo_draw_rectangle (gdk_painter->cr, TRUE, x, y - PANGO_PIXELS (PANGO_ASCENT (log_rect)),
+				       PANGO_PIXELS (log_rect.width), PANGO_PIXELS (log_rect.height));
+		cairo_restore (gdk_painter->cr);
 	}
 
 	if (fg_text_color || fg) {
-		gdk_gc_get_values (gdk_painter->gc, &orig_fg);
+		cairo_save (gdk_painter->cr);
+
 		if (fg)
-			gdk_gc_set_rgb_fg_color (gdk_painter->gc, fg);
+			gdk_cairo_set_source_color (gdk_painter->cr, fg);
 		else
-			gdk_gc_set_rgb_fg_color (gdk_painter->gc, fg_text_color);
+			gdk_cairo_set_source_color (gdk_painter->cr, fg_text_color);
 	}
 
-	gdk_draw_glyphs (gdk_painter->pixmap, gdk_painter->gc,
-			 item->analysis.font, x, y, glyphs);
+	_cairo_draw_glyphs (gdk_painter->cr,
+			    item->analysis.font, x, y, glyphs);
 	if (properties.strikethrough || properties.underline)
-		cw = draw_lines (glyphs, x, y, gdk_painter->pixmap, gdk_painter->gc, item, &properties);
+		cw = draw_lines (glyphs, x, y, gdk_painter->cr, item, &properties);
 	else
 		for (i=0; i < glyphs->num_glyphs; i++)
 			cw += glyphs->glyphs[i].geometry.width;
 
 	if (fg_text_color || fg)
-		gdk_gc_set_foreground (gdk_painter->gc, &orig_fg.foreground);
+		cairo_restore (gdk_painter->cr);
 
 	if (fg_text_color)
 		g_free (fg_text_color);
@@ -826,10 +838,10 @@ draw_shade_line (HTMLPainter *painter,
 	x -= gdk_painter->x1;
 	y -= gdk_painter->y1;
 
-	gdk_gc_set_foreground (gdk_painter->gc, &gdk_painter->dark);
-	gdk_draw_line (gdk_painter->pixmap, gdk_painter->gc, x, y, x+width, y);
-	gdk_gc_set_foreground (gdk_painter->gc, &gdk_painter->light);
-	gdk_draw_line (gdk_painter->pixmap, gdk_painter->gc, x, y + 1, x + width, y + 1);
+	gdk_cairo_set_source_color (gdk_painter->cr, &gdk_painter->dark);
+	_cairo_draw_line (gdk_painter->cr, x, y, x+width, y);
+	gdk_cairo_set_source_color (gdk_painter->cr, &gdk_painter->light);
+	_cairo_draw_line (gdk_painter->cr, x, y + 1, x + width, y + 1);
 }
 
 static guint
@@ -872,10 +884,10 @@ html_gdk_painter_init (GObject *object)
 
 	gdk_painter->window = NULL;
 
-	gdk_painter->gc = NULL;
+	gdk_painter->cr = NULL;
 
 	gdk_painter->double_buffer = TRUE;
-	gdk_painter->pixmap = NULL;
+	gdk_painter->surface = NULL;
 	gdk_painter->x1 = gdk_painter->y1 = 0;
 	gdk_painter->x2 = gdk_painter->y2 = 0;
 	gdk_painter->set_background = FALSE;
@@ -977,23 +989,19 @@ html_gdk_painter_realize (HTMLGdkPainter *gdk_painter,
 	g_return_if_fail (gdk_painter != NULL);
 	g_return_if_fail (window != NULL);
 
-	gdk_painter->gc = gdk_gc_new (window);
 	gdk_painter->window = window;
 
 	gdk_painter->light.red = 0xffff;
 	gdk_painter->light.green = 0xffff;
 	gdk_painter->light.blue = 0xffff;
-	html_painter_alloc_color (HTML_PAINTER (gdk_painter), &gdk_painter->light);
 
 	gdk_painter->dark.red = 0x7fff;
 	gdk_painter->dark.green = 0x7fff;
 	gdk_painter->dark.blue = 0x7fff;
-	html_painter_alloc_color (HTML_PAINTER (gdk_painter), &gdk_painter->dark);
 
 	gdk_painter->black.red = 0x0000;
 	gdk_painter->black.green = 0x0000;
 	gdk_painter->black.blue = 0x0000;
-	html_painter_alloc_color (HTML_PAINTER (gdk_painter), &gdk_painter->black);
 }
 
 void
@@ -1003,9 +1011,6 @@ html_gdk_painter_unrealize (HTMLGdkPainter *painter)
 	g_return_if_fail (HTML_IS_GDK_PAINTER (painter));
 
 	if (html_gdk_painter_realized (painter)) {
-		g_object_unref (painter->gc);
-		painter->gc = NULL;
-
 		painter->window = NULL;
 	}
 }
diff --git a/gtkhtml/htmlgdkpainter.h b/gtkhtml/htmlgdkpainter.h
index 5fbaeda..d7c4212 100644
--- a/gtkhtml/htmlgdkpainter.h
+++ b/gtkhtml/htmlgdkpainter.h
@@ -38,13 +38,11 @@ struct _HTMLGdkPainter {
 
 	/* GdkWindow to draw on */
 	GdkWindow *window;
-
-	/* The current GC used.  */
-	GdkGC *gc;
+	cairo_t *cr;
 
 	/* For the double-buffering system.  */
 	gboolean double_buffer;
-	GdkPixmap *pixmap;
+	cairo_surface_t *surface;
 	gint x1, y1, x2, y2;
 	GdkColor background;
 	gboolean set_background;
diff --git a/gtkhtml/htmlimage.c b/gtkhtml/htmlimage.c
index dae1272..9677f0e 100644
--- a/gtkhtml/htmlimage.c
+++ b/gtkhtml/htmlimage.c
@@ -375,11 +375,31 @@ draw_plain (HTMLObject *o, HTMLPainter *p, gint x, gint y, gint width, gint heig
 }
 
 static void
+_cairo_draw_rectangle (cairo_t *cr,
+                       gboolean filled,
+                       gint x,
+                       gint y,
+                       gint width,
+                       gint height)
+{
+  if (filled)
+    {
+      cairo_rectangle (cr, x, y, width, height);
+      cairo_fill (cr);
+    }
+  else
+    {
+      cairo_rectangle (cr, x + 0.5, y + 0.5, width, height);
+      cairo_stroke (cr);
+    }
+}
+
+static void
 draw_focus  (HTMLImage *image, HTMLPainter *painter, GdkRectangle *box)
 {
 	HTMLGdkPainter *p;
-	GdkGCValues values;
-	gint8 dash_list[] = { 1, 1 };
+	const double dashes[] = { 1, 1 };
+	int ndash  = sizeof (dashes) / sizeof (dashes[0]);
 	HTMLEngine *e;
 
 	if (painter->widget && GTK_IS_HTML (painter->widget))
@@ -393,14 +413,15 @@ draw_focus  (HTMLImage *image, HTMLPainter *painter, GdkRectangle *box)
 	p = HTML_GDK_PAINTER (painter);
 	/* printf ("draw_image_focus\n"); */
 
-	gdk_gc_set_foreground (p->gc, &html_colorset_get_color_allocated (e->settings->color_set,
-									  painter, HTMLTextColor)->color);
-	gdk_gc_get_values (p->gc, &values);
+	cairo_save (p->cr);
+	gdk_cairo_set_source_color (p->cr,
+				    &html_colorset_get_color_allocated (e->settings->color_set,
+									painter, HTMLTextColor)->color);
+	cairo_set_line_cap (p->cr, CAIRO_LINE_CAP_ROUND);
+	cairo_set_dash (p->cr, dashes, ndash, 2);
+	_cairo_draw_rectangle (p->cr, FALSE, box->x - p->x1, box->y - p->y1, box->width - 1, box->height - 1);
 
-	gdk_gc_set_line_attributes (p->gc, 1, GDK_LINE_ON_OFF_DASH, values.cap_style, values.join_style);
-	gdk_gc_set_dashes (p->gc, 2, dash_list, 2);
-	gdk_draw_rectangle (p->pixmap, p->gc, 0, box->x - p->x1, box->y - p->y1, box->width - 1, box->height - 1);
-	gdk_gc_set_line_attributes (p->gc, 1, values.line_style, values.cap_style, values.join_style);
+	cairo_restore (p->cr);
 }
 
 static void
diff --git a/gtkhtml/htmlplainpainter.c b/gtkhtml/htmlplainpainter.c
index 718405c..c1d714d 100644
--- a/gtkhtml/htmlplainpainter.c
+++ b/gtkhtml/htmlplainpainter.c
@@ -44,6 +44,26 @@ draw_border (HTMLPainter *painter,
 }
 
 static void
+_cairo_draw_rectangle (cairo_t *cr,
+                       gboolean filled,
+                       gint x,
+                       gint y,
+                       gint width,
+                       gint height)
+{
+  if (filled)
+    {
+      cairo_rectangle (cr, x, y, width, height);
+      cairo_fill (cr);
+    }
+  else
+    {
+      cairo_rectangle (cr, x + 0.5, y + 0.5, width, height);
+      cairo_stroke (cr);
+    }
+}
+
+static void
 draw_background (HTMLPainter *painter,
 		 GdkColor *color,
 		 GdkPixbuf *pixbuf,
@@ -73,10 +93,10 @@ draw_background (HTMLPainter *painter,
 		return;
 
 	if (color) {
-		gdk_gc_set_foreground (gdk_painter->gc, color);
-		gdk_draw_rectangle (gdk_painter->pixmap, gdk_painter->gc,
-				    TRUE, paint.x - clip.x, paint.y - clip.y,
-				    paint.width, paint.height);
+		gdk_cairo_set_source_color (gdk_painter->cr, color);
+		_cairo_draw_rectangle (gdk_painter->cr,
+				       TRUE, paint.x - clip.x, paint.y - clip.y,
+				       paint.width, paint.height);
 
 	}
 
@@ -101,9 +121,9 @@ fill_rect (HTMLPainter *painter,
 
 	gdk_painter = HTML_GDK_PAINTER (painter);
 
-	gdk_draw_rectangle (gdk_painter->pixmap, gdk_painter->gc,
-			    TRUE, x - gdk_painter->x1, y - gdk_painter->y1,
-			    width, height);
+	_cairo_draw_rectangle (gdk_painter->cr,
+			       TRUE, x - gdk_painter->x1, y - gdk_painter->y1,
+			       width, height);
 }
 
 static void
diff --git a/gtkhtml/htmlselect.c b/gtkhtml/htmlselect.c
index 0f3eeea..d8043e1 100644
--- a/gtkhtml/htmlselect.c
+++ b/gtkhtml/htmlselect.c
@@ -237,7 +237,7 @@ html_select_init (HTMLSelect *select,
 
 		gtk_list_store_append (store, &iter);
 		gtk_list_store_set (store, &iter, 0, "height", -1);
-		gtk_widget_size_request (select->view, &req);
+		gtk_widget_get_preferred_size (select->view, &req, NULL);
 		gtk_widget_set_size_request (
 			select->view, 120, req.height * size);
 		gtk_list_store_remove (store, &iter);
@@ -342,11 +342,11 @@ html_select_set_text (HTMLSelect *select, const gchar *text)
 		gint width;
 
 		scrollbar = gtk_scrolled_window_get_vscrollbar (GTK_SCROLLED_WINDOW (w));
-		gtk_widget_size_request (select->view, &req);
+		gtk_widget_get_preferred_size (select->view, &req, NULL);
 		width = req.width;
 
 		if (n_children > select->size && scrollbar != NULL) {
-			gtk_widget_size_request (scrollbar, &req);
+			gtk_widget_get_preferred_size (scrollbar, &req, NULL);
 			width += req.width + 8;
 		}
 
diff --git a/gtkhtml/htmltextslave.c b/gtkhtml/htmltextslave.c
index 395efe1..5389dd3 100644
--- a/gtkhtml/htmltextslave.c
+++ b/gtkhtml/htmltextslave.c
@@ -851,11 +851,31 @@ draw_text (HTMLTextSlave *self,
 }
 
 static void
+_cairo_draw_rectangle (cairo_t *cr,
+                       gboolean filled,
+                       gint x,
+                       gint y,
+                       gint width,
+                       gint height)
+{
+  if (filled)
+    {
+      cairo_rectangle (cr, x, y, width, height);
+      cairo_fill (cr);
+    }
+  else
+    {
+      cairo_rectangle (cr, x + 0.5, y + 0.5, width, height);
+      cairo_stroke (cr);
+    }
+}
+
+static void
 draw_focus_rectangle  (HTMLTextSlave *slave, HTMLPainter *painter, GdkRectangle *box)
 {
 	HTMLGdkPainter *p;
-	GdkGCValues values;
-	gint8 dash_list[] = { 1, 1 };
+	const double dashes[] = { 1, 1 };
+	int ndash  = sizeof (dashes) / sizeof (dashes[0]);
 	HTMLEngine *e;
 
 	if (painter->widget && GTK_IS_HTML (painter->widget))
@@ -869,14 +889,15 @@ draw_focus_rectangle  (HTMLTextSlave *slave, HTMLPainter *painter, GdkRectangle
 	p = HTML_GDK_PAINTER (painter);
 	/* printf ("draw_text_focus\n"); */
 
-	gdk_gc_set_foreground (p->gc, &html_colorset_get_color_allocated (e->settings->color_set,
-									  painter, HTMLTextColor)->color);
-	gdk_gc_get_values (p->gc, &values);
+	cairo_save (p->cr);
+	gdk_cairo_set_source_color (p->cr,
+				    &html_colorset_get_color_allocated (e->settings->color_set,
+									painter, HTMLTextColor)->color);
+	cairo_set_line_cap (p->cr, CAIRO_LINE_CAP_ROUND);
+	cairo_set_dash (p->cr, dashes, ndash, 2);
+	_cairo_draw_rectangle (p->cr, FALSE, box->x - p->x1, box->y - p->y1, box->width - 1, box->height - 1);
 
-	gdk_gc_set_line_attributes (p->gc, 1, GDK_LINE_ON_OFF_DASH, values.cap_style, values.join_style);
-	gdk_gc_set_dashes (p->gc, 2, dash_list, 2);
-	gdk_draw_rectangle (p->pixmap, p->gc, 0, box->x - p->x1, box->y - p->y1, box->width - 1, box->height - 1);
-	gdk_gc_set_line_attributes (p->gc, 1, values.line_style, values.cap_style, values.join_style);
+	cairo_restore (p->cr);
 }
 
 static void
