Bug 920801 - Port chat/ changes from Instantbird to comm-central - 6 - Bio 2147 - Bubbles' last message sometimes doesn't auto-scroll, r=fqueze.
authoraleth <aleth@instantbird.org>
Tue, 24 Sep 2013 20:31:35 -0400
changeset 17241 4ee1299a54bd181bd93bf158dcd8c1e5a6c546be
parent 17240 b07d3f67e9406f03ac4946c520e509ff9589f4d1
child 17242 1d7c27dcd3c08ce1115200b9a1da6a26d87068f0
push id1103
push usermbanner@mozilla.com
push dateTue, 18 Mar 2014 07:44:06 +0000
treeherdercomm-beta@50c6279a0af0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfqueze
bugs920801
Bug 920801 - Port chat/ changes from Instantbird to comm-central - 6 - Bio 2147 - Bubbles' last message sometimes doesn't auto-scroll, r=fqueze.
chat/content/convbrowser.xml
--- 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