Bug 1147487 - Don't bother sending reader mode updates when isArticle is false. r=margaret, a=sledru
authorGijs Kruitbosch <gijskruitbosch@gmail.com>
Tue, 07 Apr 2015 17:07:29 +0100
changeset 258526 125ec6c54576
parent 258525 e66ad17db13f
child 258527 7e31d76c4d7b
push id4690
push userryanvm@gmail.com
push date2015-04-20 16:04 +0000
treeherdermozilla-beta@eb5e2063637b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmargaret, sledru
bugs1147487
milestone38.0
Bug 1147487 - Don't bother sending reader mode updates when isArticle is false. r=margaret, a=sledru
browser/base/content/content.js
--- a/browser/base/content/content.js
+++ b/browser/base/content/content.js
@@ -541,21 +541,26 @@ let AboutReaderListener = {
         break;
       case "DOMContentLoaded":
         this.updateReaderButton();
         break;
 
     }
   },
   updateReaderButton: function() {
-    if (!ReaderMode.isEnabledForParseOnLoad || this.isAboutReader) {
+    if (!ReaderMode.isEnabledForParseOnLoad || this.isAboutReader ||
+        !(content.document instanceof content.HTMLDocument) ||
+        content.document.mozSyntheticDocument) {
       return;
     }
-    let isArticle = ReaderMode.isProbablyReaderable(content.document);
-    sendAsyncMessage("Reader:UpdateReaderButton", { isArticle: isArticle });
+    // Only send updates when there are articles; there's no point updating with
+    // |false| all the time.
+    if (ReaderMode.isProbablyReaderable(content.document)) {
+      sendAsyncMessage("Reader:UpdateReaderButton", { isArticle: true });
+    }
   },
 };
 AboutReaderListener.init();
 
 // An event listener for custom "WebChannelMessageToChrome" events on pages
 addEventListener("WebChannelMessageToChrome", function (e) {
   // if target is window then we want the document principal, otherwise fallback to target itself.
   let principal = e.target.nodePrincipal ? e.target.nodePrincipal : e.target.document.nodePrincipal;