Rewrite debug window pausing in JS.

Sat, 04 May 2013 22:37:40 -0400

author
Elliott Sales de Andrade <qulogic@pidgin.im>
date
Sat, 04 May 2013 22:37:40 -0400
changeset 33920
6a4eaacdd207
parent 33919
9f3f19ab8342
child 33921
d1e2fdbc3d56

Rewrite debug window pausing in JS.

pidgin/gtkdebug.c file | annotate | diff | comparison | revisions
--- a/pidgin/gtkdebug.c	Sat May 04 22:32:43 2013 -0400
+++ b/pidgin/gtkdebug.c	Sat May 04 22:37:40 2013 -0400
@@ -94,6 +94,16 @@
 	"function clear() {" \
 		"document.body.innerHTML = '';" \
 	"}" \
+	"function pauseOutput() {" \
+		"document.body.insertAdjacentHTML('beforeEnd', '<div id=pause></div>');" \
+	"}" \
+	"function resumeOutput() {" \
+		"var pause = document.getElementById('pause');" \
+		"if (pause) {" \
+			"var parent = pause.parentNode;" \
+			"parent.removeChild(pause);" \
+		"}" \
+	"}" \
 	"</script></head><body class=l0></body></html>"
 
 static DebugWindow *debug_win = NULL;
@@ -177,20 +187,10 @@
 {
 	win->paused = gtk_toggle_tool_button_get_active(GTK_TOGGLE_TOOL_BUTTON(w));
 
-	if (win->paused) {
-		gtk_webview_append_html(GTK_WEBVIEW(win->text), "<div id=pause></div>");
-	} else {
-		WebKitDOMDocument *dom;
-		WebKitDOMElement *pause;
-
-		dom = webkit_web_view_get_dom_document(WEBKIT_WEB_VIEW(win->text));
-		pause = webkit_dom_document_get_element_by_id(dom, "pause");
-		if (pause) {
-			WebKitDOMNode *parent;
-			parent = webkit_dom_node_get_parent_node(WEBKIT_DOM_NODE(pause));
-			webkit_dom_node_remove_child(parent, WEBKIT_DOM_NODE(pause), NULL);
-		}
-	}
+	if (win->paused)
+		gtk_webview_safe_execute_script(GTK_WEBVIEW(win->text), "pauseOutput();");
+	else
+		gtk_webview_safe_execute_script(GTK_WEBVIEW(win->text), "resumeOutput();");
 }
 
 /******************************************************************************

mercurial