mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-02 01:48:05 +00:00
Bug 782421 - Use parsed result for reader articles. r=lucasr
This commit is contained in:
parent
5c83107603
commit
d3fbc2c3f4
@ -439,7 +439,8 @@ public final class Tab {
|
||||
if (!mReaderEnabled)
|
||||
return;
|
||||
|
||||
GeckoApp.mAppContext.loadUrl("about:reader?url=" + Uri.encode(getURL()) +
|
||||
GeckoApp.mAppContext.loadUrl("about:reader?tabId=" + mId +
|
||||
"&url=" + Uri.encode(getURL()) +
|
||||
"&readingList=" + (mReadingListItem ? 1 : 0));
|
||||
}
|
||||
|
||||
|
@ -90,15 +90,13 @@ let AboutReader = {
|
||||
this._updateToggleButton();
|
||||
|
||||
let url = queryArgs.url;
|
||||
if (url) {
|
||||
let tabId = queryArgs.tabId;
|
||||
if (tabId) {
|
||||
dump("Loading from tab with ID: " + tabId + ", URL: " + url);
|
||||
this._loadFromTab(tabId, url);
|
||||
} else {
|
||||
dump("Fetching page with URL: " + url);
|
||||
this._loadFromURL(url);
|
||||
} else {
|
||||
var tabId = queryArgs.tabId;
|
||||
if (tabId) {
|
||||
dump("Loading from tab with ID: " + tabId);
|
||||
this._loadFromTab(tabId);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@ -319,10 +317,10 @@ let AboutReader = {
|
||||
}.bind(this));
|
||||
},
|
||||
|
||||
_loadFromTab: function Reader_loadFromTab(tabId) {
|
||||
_loadFromTab: function Reader_loadFromTab(tabId, url) {
|
||||
this._showProgress();
|
||||
|
||||
gChromeWin.Reader.parseDocumentFromTab(tabId, function(article) {
|
||||
gChromeWin.Reader.getArticleForTab(tabId, url, function(article) {
|
||||
if (article)
|
||||
this._showContent(article);
|
||||
else
|
||||
|
@ -2101,6 +2101,7 @@ function Tab(aURL, aParams) {
|
||||
this.clickToPlayPluginsActivated = false;
|
||||
this.desktopMode = false;
|
||||
this.originalURI = null;
|
||||
this.savedArticle = null;
|
||||
|
||||
this.create(aURL, aParams);
|
||||
}
|
||||
@ -2840,8 +2841,16 @@ Tab.prototype = {
|
||||
// Do nothing if there's no article or the page in this tab has
|
||||
// changed
|
||||
let tabURL = this.browser.currentURI.specIgnoringRef;
|
||||
if (article == null || (article.url != tabURL))
|
||||
if (article == null || (article.url != tabURL)) {
|
||||
// Don't clear the article for about:reader pages since we want to
|
||||
// use the article from the previous page
|
||||
if (!/^about:reader/i.test(tabURL))
|
||||
this.savedArticle = null;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
this.savedArticle = article;
|
||||
|
||||
sendMessageToJava({
|
||||
gecko: {
|
||||
@ -6348,7 +6357,8 @@ let Reader = {
|
||||
switch(aTopic) {
|
||||
case "Reader:Add": {
|
||||
let tab = BrowserApp.getTabForId(aData);
|
||||
let url = tab.browser.contentWindow.location.href;
|
||||
let currentURI = tab.browser.currentURI;
|
||||
let url = currentURI.spec;
|
||||
|
||||
let sendResult = function(success, title) {
|
||||
this.log("Reader:Add success=" + success + ", url=" + url + ", title=" + title);
|
||||
@ -6363,7 +6373,7 @@ let Reader = {
|
||||
});
|
||||
}.bind(this);
|
||||
|
||||
this.parseDocumentFromTab(aData, function(article) {
|
||||
this.getArticleForTab(aData, currentURI.specIgnoringRef, function (article) {
|
||||
if (!article) {
|
||||
sendResult(false, "");
|
||||
return;
|
||||
@ -6423,6 +6433,18 @@ let Reader = {
|
||||
}
|
||||
},
|
||||
|
||||
getArticleForTab: function Reader_getArticleForTab(tabId, url, callback) {
|
||||
let tab = BrowserApp.getTabForId(tabId);
|
||||
let article = tab.savedArticle;
|
||||
|
||||
if (article && article.url == url) {
|
||||
this.log("Saved article found in tab");
|
||||
callback(article);
|
||||
} else {
|
||||
this.parseDocumentFromURL(url, callback);
|
||||
}
|
||||
},
|
||||
|
||||
parseDocumentFromTab: function(tabId, callback) {
|
||||
try {
|
||||
this.log("parseDocumentFromTab: " + tabId);
|
||||
|
Loading…
Reference in New Issue
Block a user