Bug 1153384 - improve isProbablyReaderable detection, r=margaret

--HG--
extra : rebase_source : 37154ce2a688269bcbd96b2181da22af922980c2
This commit is contained in:
Gijs Kruitbosch 2015-04-27 15:58:24 +01:00
Родитель 6d6e989ad3
Коммит 91b96d53ca
1 изменённых файлов: 15 добавлений и 1 удалений

Просмотреть файл

@ -20,6 +20,7 @@ XPCOMUtils.defineLazyModuleGetter(this, "Task", "resource://gre/modules/Task.jsm
XPCOMUtils.defineLazyGetter(this, "Readability", function() {
let scope = {};
scope.dump = this.dump;
Services.scriptloader.loadSubScript("resource://gre/modules/reader/Readability.js", scope);
return scope["Readability"];
});
@ -116,7 +117,20 @@ this.ReaderMode = {
return false;
}
return new Readability(uri, doc).isProbablyReaderable();
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.
return new Readability(uri, doc).isProbablyReaderable(this.isNodeVisible.bind(this, utils));
},
isNodeVisible: function(utils, node) {
let bounds = utils.getBoundsWithoutFlushing(node);
return bounds.height > 0 && bounds.width > 0;
},
getUtilsForWin: function(win) {
return win.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowUtils);
},
/**