Methods Summary |
---|
synchronized void | addHistoryItem(WebHistoryItem item)Add a new history item to the list. This will remove all items after the
current item and append the new item to the end of the list. Called from
the WebCore thread only. Synchronized because the UI thread may be
reading the array or the current index.
// Update the current position because we are going to add the new item
// in that slot.
++mCurrentIndex;
// If the current position is not at the end, remove all history items
// after the current item.
final int size = mArray.size();
final int newPos = mCurrentIndex;
if (newPos != size) {
for (int i = size - 1; i >= newPos; i--) {
final WebHistoryItem h = mArray.remove(i);
}
}
// Add the item to the list.
mArray.add(item);
|
protected synchronized android.webkit.WebBackForwardList | clone()Clone the entire object to be used in the UI thread by clients of
WebView. This creates a copy that should never be modified by any of the
webkit package classes.
WebBackForwardList l = new WebBackForwardList();
if (mClearPending) {
// If a clear is pending, return a copy with only the current item.
l.addHistoryItem(getCurrentItem());
return l;
}
l.mCurrentIndex = mCurrentIndex;
int size = getSize();
l.mArray = new ArrayList<WebHistoryItem>(size);
for (int i = 0; i < size; i++) {
// Add a copy of each WebHistoryItem
l.mArray.add(mArray.get(i).clone());
}
return l;
|
synchronized void | close(int nativeFrame)Clear the back/forward list. Called from the WebCore thread.
// Clear the array first because nativeClose will call addHistoryItem
// with the current item.
mArray.clear();
mCurrentIndex = -1;
nativeClose(nativeFrame);
// Reset the clear flag
mClearPending = false;
|
synchronized boolean | getClearPending()Return the status of the clear flag. This is used on the UI side to
determine if the list is valid for checking things like canGoBack.
return mClearPending;
|
public synchronized int | getCurrentIndex()Get the index of the current history item. This index can be used to
directly index into the array list.
return mCurrentIndex;
|
public synchronized WebHistoryItem | getCurrentItem()Return the current history item. This method returns null if the list is
empty.
return getItemAtIndex(mCurrentIndex);
|
public synchronized WebHistoryItem | getItemAtIndex(int index)Get the history item at the given index. The index range is from 0...n
where 0 is the first item and n is the last item.
if (index < 0 || index >= getSize()) {
return null;
}
return mArray.get(index);
|
public synchronized int | getSize()Get the total size of the back/forward list.
return mArray.size();
|
private static native void | nativeClose(int nativeFrame)
|
private synchronized void | removeHistoryItem(int index)
// XXX: This is a special case. Since the callback is only triggered
// when removing the first item, we can assert that the index is 0.
// This lets us change the current index without having to query the
// native BackForwardList.
if (Config.DEBUG && (index != 0)) {
throw new AssertionError();
}
final WebHistoryItem h = mArray.remove(index);
// XXX: If we ever add another callback for removing history items at
// any index, this will no longer be valid.
mCurrentIndex--;
|
static native synchronized void | restoreIndex(int nativeFrame, int index)Restore the history index.
|
synchronized void | setClearPending()Mark the back/forward list as having a pending clear. This is used on the
UI side to mark the list as being invalid during the clearHistory method.
mClearPending = true;
|
synchronized void | setCurrentIndex(int newIndex)Set the new history index.
mCurrentIndex = newIndex;
|