Use insertAdjacentHtml instead of document.write. This seems a lot

Thu, 31 May 2012 03:42:49 +0000

author
Elliott Sales de Andrade <qulogic@pidgin.im>
date
Thu, 31 May 2012 03:42:49 +0000
changeset 32994
ce92490a3edb
parent 32993
d6da54acf528
child 32995
416f017698b1

Use insertAdjacentHtml instead of document.write. This seems a lot
better since it correctly applies styles and adds elements to the DOM,
which then show up in the inspector.

pidgin/gtkwebview.c file | annotate | diff | comparison | revisions
--- a/pidgin/gtkwebview.c	Thu May 31 00:36:55 2012 +0000
+++ b/pidgin/gtkwebview.c	Thu May 31 03:42:49 2012 +0000
@@ -551,12 +551,12 @@
 gtk_webview_append_html(GtkWebView *webview, const char *html)
 {
 	GtkWebViewPriv *priv = GTK_WEBVIEW_GET_PRIVATE(webview);
-	char *escaped = gtk_webview_quote_js_string(html);
-	char *script = g_strdup_printf("document.write(%s)", escaped);
-	webkit_web_view_execute_script(WEBKIT_WEB_VIEW(webview), script);
+	WebKitDOMDocument *doc;
+	WebKitDOMHTMLElement *body;
+	doc = webkit_web_view_get_dom_document(WEBKIT_WEB_VIEW(webview));
+	body = webkit_dom_document_get_body(doc);
+	webkit_dom_html_element_insert_adjacent_html(body, "beforeend", html, NULL);
 	priv->empty = FALSE;
-	g_free(script);
-	g_free(escaped);
 }
 
 void

mercurial