зеркало из https://github.com/mozilla/pjs.git
Bug 699786 - Cancel pending favicon loads when location changes (r=blassey)
This commit is contained in:
Родитель
80f9b81eed
Коммит
09f6db2b68
|
@ -550,8 +550,23 @@ abstract public class GeckoApp
|
||||||
GeckoAppShell.sendEventToGecko(event);
|
GeckoAppShell.sendEventToGecko(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void maybeCancelFaviconLoad(Tab tab) {
|
||||||
|
long faviconLoadId = tab.getFaviconLoadId();
|
||||||
|
|
||||||
|
if (faviconLoadId == Favicons.NOT_LOADING)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Cancel pending favicon load task
|
||||||
|
mFavicons.cancelFaviconLoad(faviconLoadId);
|
||||||
|
|
||||||
|
// Reset favicon load state
|
||||||
|
tab.setFaviconLoadId(Favicons.NOT_LOADING);
|
||||||
|
}
|
||||||
|
|
||||||
private void loadFavicon(final Tab tab) {
|
private void loadFavicon(final Tab tab) {
|
||||||
mFavicons.loadFavicon(tab.getURL(), tab.getFaviconURL(),
|
maybeCancelFaviconLoad(tab);
|
||||||
|
|
||||||
|
long id = mFavicons.loadFavicon(tab.getURL(), tab.getFaviconURL(),
|
||||||
new Favicons.OnFaviconLoadedListener() {
|
new Favicons.OnFaviconLoadedListener() {
|
||||||
|
|
||||||
public void onFaviconLoaded(String pageUrl, Drawable favicon) {
|
public void onFaviconLoaded(String pageUrl, Drawable favicon) {
|
||||||
|
@ -570,6 +585,7 @@ abstract public class GeckoApp
|
||||||
Log.i(LOGTAG, "Favicon is for current URL = " + pageUrl);
|
Log.i(LOGTAG, "Favicon is for current URL = " + pageUrl);
|
||||||
|
|
||||||
tab.updateFavicon(favicon);
|
tab.updateFavicon(favicon);
|
||||||
|
tab.setFaviconLoadId(Favicons.NOT_LOADING);
|
||||||
|
|
||||||
if (Tabs.getInstance().isSelectedTab(tab))
|
if (Tabs.getInstance().isSelectedTab(tab))
|
||||||
mBrowserToolbar.setFavicon(tab.getFavicon());
|
mBrowserToolbar.setFavicon(tab.getFavicon());
|
||||||
|
@ -577,6 +593,8 @@ abstract public class GeckoApp
|
||||||
onTabsChanged(tab);
|
onTabsChanged(tab);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
tab.setFaviconLoadId(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
void handleLocationChange(final int tabId, final String uri) {
|
void handleLocationChange(final int tabId, final String uri) {
|
||||||
|
@ -602,6 +620,8 @@ abstract public class GeckoApp
|
||||||
tab.updateSecurityMode("unknown");
|
tab.updateSecurityMode("unknown");
|
||||||
tab.removeTransientDoorHangers();
|
tab.removeTransientDoorHangers();
|
||||||
|
|
||||||
|
maybeCancelFaviconLoad(tab);
|
||||||
|
|
||||||
mMainHandler.post(new Runnable() {
|
mMainHandler.post(new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
if (Tabs.getInstance().isSelectedTab(tab)) {
|
if (Tabs.getInstance().isSelectedTab(tab)) {
|
||||||
|
|
|
@ -71,6 +71,7 @@ public class Tab {
|
||||||
private boolean mLoading;
|
private boolean mLoading;
|
||||||
private boolean mBookmark;
|
private boolean mBookmark;
|
||||||
private HashMap<String, DoorHanger> mDoorHangers;
|
private HashMap<String, DoorHanger> mDoorHangers;
|
||||||
|
private long mFaviconLoadId;
|
||||||
|
|
||||||
static class HistoryEntry {
|
static class HistoryEntry {
|
||||||
public final String mUri;
|
public final String mUri;
|
||||||
|
@ -98,6 +99,7 @@ public class Tab {
|
||||||
mHistoryIndex = -1;
|
mHistoryIndex = -1;
|
||||||
mBookmark = false;
|
mBookmark = false;
|
||||||
mDoorHangers = new HashMap<String, DoorHanger>();
|
mDoorHangers = new HashMap<String, DoorHanger>();
|
||||||
|
mFaviconLoadId = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getId() {
|
public int getId() {
|
||||||
|
@ -178,6 +180,14 @@ public class Tab {
|
||||||
mBookmark = bookmark;
|
mBookmark = bookmark;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setFaviconLoadId(long faviconLoadId) {
|
||||||
|
mFaviconLoadId = faviconLoadId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getFaviconLoadId() {
|
||||||
|
return mFaviconLoadId;
|
||||||
|
}
|
||||||
|
|
||||||
public HistoryEntry getLastHistoryEntry() {
|
public HistoryEntry getLastHistoryEntry() {
|
||||||
if (mHistory.isEmpty())
|
if (mHistory.isEmpty())
|
||||||
return null;
|
return null;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче