diff --git a/docshell/base/nsDocShell.cpp b/docshell/base/nsDocShell.cpp index dd54d88d6e91..5577d3a5a104 100644 --- a/docshell/base/nsDocShell.cpp +++ b/docshell/base/nsDocShell.cpp @@ -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(); } diff --git a/docshell/shistory/ChildSHistory.cpp b/docshell/shistory/ChildSHistory.cpp index c0321e6199ac..0c6b40cb1133 100644 --- a/docshell/shistory/ChildSHistory.cpp +++ b/docshell/shistory/ChildSHistory.cpp @@ -32,9 +32,7 @@ ChildSHistory::~ChildSHistory() int32_t ChildSHistory::Count() { - int32_t count; - mHistory->GetCount(&count); - return count; + return mHistory->GetCount(); } int32_t diff --git a/docshell/shistory/nsISHistory.idl b/docshell/shistory/nsISHistory.idl index 7daef0a86b43..1159ac2d3419 100644 --- a/docshell/shistory/nsISHistory.idl +++ b/docshell/shistory/nsISHistory.idl @@ -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. diff --git a/docshell/shistory/nsSHistory.cpp b/docshell/shistory/nsSHistory.cpp index 944eb896fe74..2239d8908d25 100644 --- a/docshell/shistory/nsSHistory.cpp +++ b/docshell/shistory/nsSHistory.cpp @@ -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; }