comparison pidgin/gtkwebview.c @ 32809:5617be6a8413

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.
author Elliott Sales de Andrade <qulogic@pidgin.im>
date Thu, 31 May 2012 03:42:49 +0000
parents b8cbd52e26b1
children
comparison
equal deleted inserted replaced
32808:b8cbd52e26b1 32809:5617be6a8413
549 */ 549 */
550 void 550 void
551 gtk_webview_append_html(GtkWebView *webview, const char *html) 551 gtk_webview_append_html(GtkWebView *webview, const char *html)
552 { 552 {
553 GtkWebViewPriv *priv = GTK_WEBVIEW_GET_PRIVATE(webview); 553 GtkWebViewPriv *priv = GTK_WEBVIEW_GET_PRIVATE(webview);
554 char *escaped = gtk_webview_quote_js_string(html); 554 WebKitDOMDocument *doc;
555 char *script = g_strdup_printf("document.write(%s)", escaped); 555 WebKitDOMHTMLElement *body;
556 webkit_web_view_execute_script(WEBKIT_WEB_VIEW(webview), script); 556 doc = webkit_web_view_get_dom_document(WEBKIT_WEB_VIEW(webview));
557 body = webkit_dom_document_get_body(doc);
558 webkit_dom_html_element_insert_adjacent_html(body, "beforeend", html, NULL);
557 priv->empty = FALSE; 559 priv->empty = FALSE;
558 g_free(script);
559 g_free(escaped);
560 } 560 }
561 561
562 void 562 void
563 gtk_webview_set_vadjustment(GtkWebView *webview, GtkAdjustment *vadj) 563 gtk_webview_set_vadjustment(GtkWebView *webview, GtkAdjustment *vadj)
564 { 564 {