Bug 1160775 - Fix reader mode detection to force 1 flush so we don't think the entire page is invisible. r=margaret, a=lizzard
authorGijs Kruitbosch <gijskruitbosch@gmail.com>
Wed, 06 May 2015 17:40:20 +0100
changeset 267479 b38b8126e4d1749706afe0bf89dd074d3efd075b
parent 267478 13e298c9841e5d8fdf01f2ef1084b8ba2674ea5c
child 267480 6a1a9d282be2b0eb6d4ff254d9c347883a2e5b2d
push id830
push userraliiev@mozilla.com
push dateFri, 19 Jun 2015 19:24:37 +0000
treeherdermozilla-release@932614382a68 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmargaret, lizzard
bugs1160775
milestone39.0
Bug 1160775 - Fix reader mode detection to force 1 flush so we don't think the entire page is invisible. r=margaret, a=lizzard
toolkit/components/reader/ReaderMode.jsm
--- a/toolkit/components/reader/ReaderMode.jsm
+++ b/toolkit/components/reader/ReaderMode.jsm
@@ -127,22 +127,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);
   },
 
   /**