adium 2753:97a8a57fcef4: We don't neet to create a new root node...
commits at adium.im
commits at adium.im
Tue Oct 20 17:02:35 UTC 2009
details: http://hg.adium.im/adium/rev/97a8a57fcef4
revision: 2753:97a8a57fcef4
author: Stephen Holt <sholt at adium.im>
date: Tue Oct 20 12:56:03 2009 -0400
We don't neet to create a new root node here.
Subject: adium 2754:b4cc4b3566d3: Add replaceLast support to already coalesced message streams.
details: http://hg.adium.im/adium/rev/b4cc4b3566d3
revision: 2754:b4cc4b3566d3
author: Stephen Holt <sholt at adium.im>
date: Tue Oct 20 12:58:13 2009 -0400
Add replaceLast support to already coalesced message streams.
I don't know how often this will be called, but it prevents us from cancelling a coalesced stream if some rapid status changes come in, or similar.
diffs (80 lines):
diff -r a365b03465cb -r b4cc4b3566d3 Plugins/WebKit Message View/Template.html
--- a/Plugins/WebKit Message View/Template.html Tue Oct 20 11:23:25 2009 -0400
+++ b/Plugins/WebKit Message View/Template.html Tue Oct 20 12:58:13 2009 -0400
@@ -32,6 +32,7 @@
if(insert)
insert.parentNode.removeChild(insert);
+ // wrap the elements into a documentFragment for fast insertion
var documentFragment = document.createDocumentFragment();
while(self.fragment.hasChildNodes()) {
documentFragment.appendChild(self.fragment.firstChild);
@@ -40,7 +41,7 @@
document.getElementById("Chat").appendChild(documentFragment);
alignChat(self.shouldScroll);
- self.fragment = document.createElement("div");
+ // reset state to empty/non-coalescing
self.shouldScroll = false;
self.isCoalescing = false;
self.coalesceRounds = 0;
@@ -100,6 +101,17 @@
self.shouldScroll = shouldScroll;
self.coalesce();
}
+
+ this.replaceLast = function (html, shouldScroll) {
+ var node = createHTMLNode(html);
+ var insert = self.fragment.querySelector("#insert");
+ if(insert)
+ insert.parentNode.removeChild(insert);
+ var lastMessage = self.fragment.lastChild;
+ lastMessage.parentNode.replaceChild(node, lastMessage);
+ if(shouldScroll)
+ self.shouldScroll = shouldScroll;
+ }
}
var coalescedHTML;
@@ -142,25 +154,25 @@
}
function replaceLastMessage(html){
- //cancel any coallescing
- coalescedHTML.cancel();
-
shouldScroll = nearBottom();
+ if(coalescedHTML.isCoalescing){
+ coalescedHTML.replaceLast(html, shouldScroll);
+ } else {
+ //Retrieve the current insertion point, then remove it
+ //This requires that there have been an insertion point... is there a better way to retrieve the last element? -evands
+ var insert = document.getElementById("insert");
+ if(insert){
+ var parentNode = insert.parentNode;
+ parentNode.removeChild(insert);
+ var lastMessage = document.getElementById("Chat").lastChild;
+ document.getElementById("Chat").removeChild(lastMessage);
+ }
- //Retrieve the current insertion point, then remove it
- //This requires that there have been an insertion point... is there a better way to retrieve the last element? -evands
- var insert = document.getElementById("insert");
- if(insert){
- var parentNode = insert.parentNode;
- parentNode.removeChild(insert);
- var lastMessage = document.getElementById("Chat").lastChild;
- document.getElementById("Chat").removeChild(lastMessage);
+ //Now append the message itself
+ appendHTML(html);
+
+ alignChat(shouldScroll);
}
-
- //Now append the message itself
- appendHTML(html);
-
- alignChat(shouldScroll);
}
//Auto-scroll to bottom. Use nearBottom to determine if a scrollToBottom is desired.
More information about the commits
mailing list