Bug 1160775 - fix reader mode detection to force 1 flush so we don't think the entire page is invisible, r=margaret a=lmandel
authorGijs Kruitbosch <gijskruitbosch@gmail.com>
Wed, 06 May 2015 17:40:20 +0100
changeset 260498 93b96d846d47
parent 260497 195e873a8ab1
child 260499 964442785c00
push id801
push userkwierso@gmail.com
push date2015-05-14 20:31 +0000
treeherdermozilla-release@5741ccc7bb74 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmargaret, lmandel
bugs1160775
milestone38.0.1
Bug 1160775 - fix reader mode detection to force 1 flush so we don't think the entire page is invisible, r=margaret a=lmandel
toolkit/components/reader/ReaderMode.jsm
--- a/toolkit/components/reader/ReaderMode.jsm
+++ b/toolkit/components/reader/ReaderMode.jsm
@@ -123,22 +123,30 @@ this.ReaderMode = {
     if (!this._shouldCheckUri(uri)) {
       return false;
     }
 
     let utils = this.getUtilsForWin(doc.defaultView);
     // We pass in a helper function to determine if a node is visible, because
     // it uses gecko APIs that the engine-agnostic readability code can't rely
     // upon.
-    // NOTE: This is currently disabled, see bug 1158228.
-    return new Readability(uri, doc).isProbablyReaderable(/*this.isNodeVisible.bind(this, utils)*/);
+    // NB: we need to do a flush the first time we call this, so we keep track of
+    // this using a property:
+    this._needFlushForVisibilityCheck = true;
+    return new Readability(uri, doc).isProbablyReaderable(this.isNodeVisible.bind(this, utils));
   },
 
   isNodeVisible: function(utils, node) {
-    let bounds = utils.getBoundsWithoutFlushing(node);
+    let bounds;
+    if (this._needFlushForVisibilityCheck) {
+      bounds = node.getBoundingClientRect();
+      this._needFlushForVisibilityCheck = false;
+    } else {
+      bounds = utils.getBoundsWithoutFlushing(node);
+    }
     return bounds.height > 0 && bounds.width > 0;
   },
 
   getUtilsForWin: function(win) {
     return win.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowUtils);
   },
 
   /**