soc.2009.webkitmessageview: 8d49ba25: more cleanup.

tdrhq at soc.pidgin.im tdrhq at soc.pidgin.im
Tue Aug 25 12:03:27 EDT 2009


-----------------------------------------------------------------
Revision: 8d49ba25c8d4a30f8c0f94a971727f4036041db6
Ancestor: c4a9d3c1001b23a9ac68c0a22a1a8355b984a946
Author: tdrhq at soc.pidgin.im
Date: 2009-08-07T18:44:27
Branch: im.pidgin.soc.2009.webkitmessageview
URL: http://d.pidgin.im/viewmtn/revision/info/8d49ba25c8d4a30f8c0f94a971727f4036041db6

Modified files:
        pidgin/gtkwebview.c

ChangeLog: 

more cleanup.

-------------- next part --------------
============================================================
--- pidgin/gtkwebview.c	3d307ddc4f2a769f229ab70f0ee7f43c3c1933a5
+++ pidgin/gtkwebview.c	12ad35bdbbf95e1efd522a048d1b14a474365fab
@@ -109,7 +109,7 @@ replace_img_id_with_src (GtkWebView *vie
 		if (!cur)
 			cur = strstr (img, ">");
 
-		if (!cur) { /*oops, invalid html */
+		if (!cur) { /* invalid html? */
 			g_string_printf (buffer, "%s", html);
 			break;
 		}
@@ -119,8 +119,12 @@ replace_img_id_with_src (GtkWebView *vie
 			break;
 		}
 
-		/* now I _kinda_ know that it has an id=, and does not have a src= */
-		/* todo: take care of src= and id= appearing in strings? */
+		/*
+		 * if this is valid HTML, then I can be sure that it
+		 * has an id= and does not have an src=, since
+		 * '=' cannot appear in parameters.
+		 */
+
 		id = strstr (img, "id=") + 3; 
 
 		/* *id can't be \0, since a ">" appears after this */
@@ -134,6 +138,7 @@ replace_img_id_with_src (GtkWebView *vie
 
 		g_string_append_printf (buffer, " src='file://%s' ", get_image_filename_from_id (view, nid));
 	}
+
 	return g_string_free (buffer, FALSE);
 }
 
@@ -153,9 +158,9 @@ webview_link_clicked (WebKitWebView *vie
 
 static gboolean
 webview_link_clicked (WebKitWebView *view,
-                     WebKitWebFrame *frame,
-                     WebKitNetworkRequest *request,
-                     WebKitWebNavigationAction *navigation_action,
+		      WebKitWebFrame *frame,
+		      WebKitNetworkRequest *request,
+		      WebKitWebNavigationAction *navigation_action,
 		      WebKitWebPolicyDecision *policy_decision)
 {
 	const gchar *uri;
@@ -209,7 +214,6 @@ gtk_webview_load_html_string_with_imgsto
 	g_free (html_imged);
 }
 
-/* taken from sean's webkit plugin */
 char *gtk_webview_quote_js_string(const char *text)
 {
         GString *str = g_string_new("\"");
@@ -275,7 +279,7 @@ GType gtk_webview_get_type ()
 GType gtk_webview_get_type ()
 {
 	static GType mview_type = 0;
-	if (!mview_type) {
+	if (G_UNLIKELY (mview_type == 0)) {
 		static const GTypeInfo mview_info = {
 			sizeof (GtkWebViewClass),
 			NULL,


More information about the Commits mailing list