Bug 920801 - Port chat/ changes from Instantbird to comm-central - 6 - Bio 2147 - Bubbles' last message sometimes doesn't auto-scroll, r=fqueze.
--- a/chat/content/convbrowser.xml
+++ b/chat/content/convbrowser.xml
@@ -274,16 +274,24 @@
let body = this.contentDocument.querySelector("body");
this._autoScrollEnabled =
body.scrollHeight <= body.scrollTop + body.clientHeight + 10;
return this._autoScrollEnabled;
]]>
</body>
</method>
+ <method name="autoScrollEnabled">
+ <body>
+ <![CDATA[
+ return this._autoScrollEnabled || this._updateAutoScrollEnabled();
+ ]]>
+ </body>
+ </method>
+
<method name="_scrollToElement">
<parameter name="aElt"/>
<body>
<![CDATA[
aElt.scrollIntoView(true);
this._scrollingIntoView = true;
]]>
</body>
@@ -513,17 +521,17 @@
}
else {
let html = getHTMLForMessage(aMsg, this.theme, next, aContext);
newElt = insertHTMLForMessage(aMsg, html, doc, next);
}
if (!aNoAutoScroll) {
newElt.getBoundingClientRect(); // avoid ireflow bugs
- if (this._autoScrollEnabled || this._updateAutoScrollEnabled())
+ if (this.autoScrollEnabled())
this._scrollToElement(newElt);
}
this._lastElement = newElt;
this._lastMessage = aMsg;
if (!aContext && !this._firstNonContextElt && !aMsg.system)
this._firstNonContextElt = newElt;
this._lastMessageIsContext = aContext;
]]>
@@ -852,18 +860,20 @@
if (!this._loadState) {
try {
initHTMLDocument(this._conv, this.theme, this.contentDocument);
} catch(e) {
Components.utils.reportError(e);
}
this._loadState = 1;
- // Expose scrollToElement to the message styles.
+ // Expose scrollToElement and autoScrollEnabled to the
+ // message styles.
this.contentWindow.scrollToElement = this._scrollToElement.bind(this);
+ this.contentWindow.autoScrollEnabled = this.autoScrollEnabled.bind(this);
return;
}
this.removeProgressListener(this);
this.initMagicCopy();
// We need to reset these variables here to avoid a race
// condition if we are starting to display a new conversation