Bug 1490524 - Make some nsISHistory attributes infallible. r=nika

This also requires making nsISHistory `builtinclass`.

--HG--
extra : rebase_source : a1f2c7a60782dcd741b350f6cd3979d888008a97
This commit is contained in:
Nicholas Nethercote 2018-09-11 16:08:37 +10:00
Родитель 86422376e7
Коммит a0583f1a89
4 изменённых файлов: 10 добавлений и 14 удалений

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

@ -8647,8 +8647,7 @@ nsDocShell::CreateContentViewer(const nsACString& aContentType,
// Be sure to have a correct mLSHE, it may have been cleared by
// EndPageLoad. See bug 302115.
if (mSessionHistory && !mLSHE) {
int32_t idx;
mSessionHistory->LegacySHistory()->GetRequestedIndex(&idx);
int32_t idx = mSessionHistory->LegacySHistory()->GetRequestedIndex();
if (idx == -1) {
idx = mSessionHistory->Index();
}
@ -11567,8 +11566,7 @@ nsDocShell::OnNewURI(nsIURI* aURI, nsIChannel* aChannel,
} else if (mSessionHistory && mLSHE && mURIResultedInDocument) {
// Even if we don't add anything to SHistory, ensure the current index
// points to the same SHEntry as our mLSHE.
int32_t index = 0;
mSessionHistory->LegacySHistory()->GetRequestedIndex(&index);
int32_t index = mSessionHistory->LegacySHistory()->GetRequestedIndex();
if (index == -1) {
index = mSessionHistory->Index();
}
@ -12238,8 +12236,7 @@ nsDocShell::AddToSessionHistory(nsIURI* aURI, nsIChannel* aChannel,
// Replace current entry in session history; If the requested index is
// valid, it indicates the loading was triggered by a history load, and
// we should replace the entry at requested index instead.
int32_t index = 0;
mSessionHistory->LegacySHistory()->GetRequestedIndex(&index);
int32_t index = mSessionHistory->LegacySHistory()->GetRequestedIndex();
if (index == -1) {
index = mSessionHistory->Index();
}

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

@ -32,9 +32,7 @@ ChildSHistory::~ChildSHistory()
int32_t
ChildSHistory::Count()
{
int32_t count;
mHistory->GetCount(&count);
return count;
return mHistory->GetCount();
}
int32_t

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

@ -28,7 +28,7 @@ interface nsIURI;
* This interface is accessible from javascript.
*/
[scriptable, uuid(7b807041-e60a-4384-935f-af3061d8b815)]
[builtinclass, scriptable, uuid(7b807041-e60a-4384-935f-af3061d8b815)]
interface nsISHistory: nsISupports
{
/**
@ -45,10 +45,11 @@ interface nsISHistory: nsISupports
* the number of toplevel documents currently available
* in session history.
*/
readonly attribute long count;
[infallible] readonly attribute long count;
/**
* The index of the current document in session history.
* The index of the current document in session history. Not infallible
* because setting can fail if the assigned value is out of range.
*/
attribute long index;
@ -58,7 +59,7 @@ interface nsISHistory: nsISupports
* didn't finished yet. When document finishes the loading
* value -1 is returned.
*/
readonly attribute long requestedIndex;
[infallible] readonly attribute long requestedIndex;
/**
* Get the history entry at a given index. Returns non-null on success.

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

@ -653,7 +653,7 @@ nsSHistory::AddEntry(nsISHEntry* aSHEntry, bool aPersist)
NS_IMETHODIMP
nsSHistory::GetCount(int32_t* aResult)
{
NS_ENSURE_ARG_POINTER(aResult);
MOZ_ASSERT(aResult, "null out param?");
*aResult = Length();
return NS_OK;
}