Bug 755771 - Part 1: Remove HistoryEntry class. r=mfinkle

This commit is contained in:
Brian Nicholson 2012-05-16 23:07:55 -07:00
parent ce9dbc11a0
commit 8dc19d2d7b
2 changed files with 16 additions and 44 deletions

View File

@ -54,7 +54,6 @@ import org.mozilla.gecko.gfx.RectUtils;
import org.mozilla.gecko.gfx.SurfaceTextureLayer;
import org.mozilla.gecko.gfx.ViewportMetrics;
import org.mozilla.gecko.gfx.ImmutableViewportMetrics;
import org.mozilla.gecko.Tab.HistoryEntry;
import java.io.*;
import java.util.*;

View File

@ -76,8 +76,8 @@ public final class Tab {
private String mFaviconUrl;
private JSONObject mIdentityData;
private Drawable mThumbnail;
private List<HistoryEntry> mHistory;
private int mHistoryIndex;
private int mHistorySize;
private int mParentId;
private boolean mExternal;
private boolean mBookmark;
@ -98,16 +98,6 @@ public final class Tab {
public static final int STATE_SUCCESS = 2;
public static final int STATE_ERROR = 3;
public static final class HistoryEntry {
public String mUri; // must never be null
public String mTitle; // must never be null
public HistoryEntry(String uri, String title) {
mUri = uri;
mTitle = title;
}
}
public Tab(int id, String url, boolean external, int parentId, String title) {
mId = id;
mUrl = url;
@ -118,8 +108,8 @@ public final class Tab {
mFaviconUrl = null;
mIdentityData = null;
mThumbnail = null;
mHistory = new ArrayList<HistoryEntry>();
mHistoryIndex = -1;
mHistorySize = 0;
mBookmark = false;
mDoorHangers = new HashMap<String, DoorHanger>();
mFaviconLoadId = 0;
@ -251,7 +241,7 @@ public final class Tab {
mUrl = url;
Log.i(LOGTAG, "Updated url: " + url + " for tab with id: " + mId);
updateBookmark();
updateHistoryEntry(mUrl, mTitle);
updateHistory(mUrl, mTitle);
}
}
@ -275,22 +265,15 @@ public final class Tab {
mTitle = (title == null ? "" : title);
Log.i(LOGTAG, "Updated title: " + mTitle + " for tab with id: " + mId);
updateHistoryEntry(mUrl, mTitle);
updateHistory(mUrl, mTitle);
}
private void updateHistoryEntry(final String uri, final String title) {
final HistoryEntry he = getLastHistoryEntry();
if (he != null) {
he.mUri = uri;
he.mTitle = title;
GeckoAppShell.getHandler().post(new Runnable() {
public void run() {
GlobalHistory.getInstance().update(uri, title);
}
});
} else {
Log.e(LOGTAG, "Requested title update on empty history stack");
}
private void updateHistory(final String uri, final String title) {
GeckoAppShell.getHandler().post(new Runnable() {
public void run() {
GlobalHistory.getInstance().update(uri, title);
}
});
}
public void setState(int state) {
@ -317,12 +300,6 @@ public final class Tab {
return mFaviconLoadId;
}
public HistoryEntry getLastHistoryEntry() {
if (mHistory.isEmpty())
return null;
return mHistory.get(mHistoryIndex);
}
public void updateFavicon(Drawable favicon) {
mFavicon = favicon;
Log.i(LOGTAG, "Updated favicon for tab with id: " + mId);
@ -399,11 +376,11 @@ public final class Tab {
}
public boolean canDoForward() {
return (mHistoryIndex + 1 < mHistory.size());
return (mHistoryIndex + 1 < mHistorySize);
}
public boolean doForward() {
if (mHistoryIndex + 1 >= mHistory.size()) {
if (mHistoryIndex + 1 >= mHistorySize) {
return false;
}
GeckoEvent e = GeckoEvent.createBroadcastEvent("Session:Forward", "");
@ -452,11 +429,7 @@ public final class Tab {
if (event.equals("New")) {
final String uri = message.getString("uri");
mHistoryIndex++;
while (mHistory.size() > mHistoryIndex) {
mHistory.remove(mHistoryIndex);
}
HistoryEntry he = new HistoryEntry(uri, "");
mHistory.add(he);
mHistorySize = mHistoryIndex + 1;
GeckoAppShell.getHandler().post(new Runnable() {
public void run() {
GlobalHistory.getInstance().add(uri);
@ -469,20 +442,20 @@ public final class Tab {
}
mHistoryIndex--;
} else if (event.equals("Forward")) {
if (mHistoryIndex + 1 >= mHistory.size()) {
if (mHistoryIndex + 1 >= mHistorySize) {
Log.e(LOGTAG, "Received unexpected forward notification");
return;
}
mHistoryIndex++;
} else if (event.equals("Goto")) {
int index = message.getInt("index");
if (index < 0 || index >= mHistory.size()) {
if (index < 0 || index >= mHistorySize) {
Log.e(LOGTAG, "Received unexpected history-goto notification");
return;
}
mHistoryIndex = index;
} else if (event.equals("Purge")) {
mHistory.clear();
mHistorySize = 0;
mHistoryIndex = -1;
}
}