зеркало из https://github.com/mozilla/gecko-dev.git
Bug 163549 - Remove History.goURI(). Patch by mstoltz & jst. r=alecf/mstoltz. sr=heikki.
This commit is contained in:
Родитель
3d99d3f6a8
Коммит
ce91c3fdca
|
@ -50,7 +50,8 @@ interface nsIDOMHistory : nsISupports
|
|||
|
||||
void back();
|
||||
void forward();
|
||||
void goIndex(in long aDelta);
|
||||
void goUri(in DOMString aUriSubstring);
|
||||
|
||||
// go() gets special treatment in nsIDOMNSHistory
|
||||
[noscript] void go(in long aDelta);
|
||||
DOMString item(in unsigned long index);
|
||||
};
|
||||
|
|
|
@ -37,13 +37,14 @@
|
|||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsIDOMHistory.idl"
|
||||
#include "domstubs.idl"
|
||||
|
||||
[scriptable, uuid(5fb96f46-1dd2-11b2-a5dc-998ca8636ea9)]
|
||||
interface nsIDOMNSHistory : nsIDOMHistory
|
||||
interface nsIDOMNSHistory : nsISupports
|
||||
{
|
||||
/** go() can be called with either a string or a number argument
|
||||
* from JS
|
||||
/**
|
||||
* go() can be called with an integer argument or no arguments (a
|
||||
* nop) from JS
|
||||
*/
|
||||
void go(/* ... */);
|
||||
};
|
||||
|
|
|
@ -1329,6 +1329,7 @@ nsDOMClassInfo::Init()
|
|||
DOM_CLASSINFO_MAP_END
|
||||
|
||||
DOM_CLASSINFO_MAP_BEGIN(History, nsIDOMHistory)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMHistory)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMNSHistory)
|
||||
DOM_CLASSINFO_MAP_END
|
||||
|
||||
|
|
|
@ -67,7 +67,7 @@ HistoryImpl::~HistoryImpl()
|
|||
|
||||
// QueryInterface implementation for HistoryImpl
|
||||
NS_INTERFACE_MAP_BEGIN(HistoryImpl)
|
||||
NS_INTERFACE_MAP_ENTRY(nsISupports)
|
||||
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDOMHistory)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMHistory)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMNSHistory)
|
||||
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(History)
|
||||
|
@ -215,7 +215,7 @@ HistoryImpl::Forward()
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
HistoryImpl::GoIndex(PRInt32 aDelta)
|
||||
HistoryImpl::Go(PRInt32 aDelta)
|
||||
{
|
||||
nsCOMPtr<nsISHistory> session_history;
|
||||
|
||||
|
@ -233,64 +233,13 @@ HistoryImpl::GoIndex(PRInt32 aDelta)
|
|||
|
||||
PRInt32 index = curIndex + aDelta;
|
||||
if (index > -1 && index < len)
|
||||
webnav->GotoIndex(index);
|
||||
webnav->GotoIndex(index);
|
||||
// We always want to return a NS_OK, since returning errors
|
||||
// from GotoIndex() can lead to exceptions and a possible leak
|
||||
// of history length
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
HistoryImpl::GoUri(const nsAString& aUriSubstring)
|
||||
{
|
||||
nsCOMPtr<nsISHistory> session_history;
|
||||
|
||||
GetSessionHistoryFromDocShell(mDocShell, getter_AddRefs(session_history));
|
||||
NS_ENSURE_TRUE(session_history, NS_ERROR_FAILURE);
|
||||
|
||||
// QI SHistory to nsIWebNavigation
|
||||
nsCOMPtr<nsIWebNavigation> webnav(do_QueryInterface(session_history));
|
||||
NS_ENSURE_TRUE(webnav, NS_ERROR_FAILURE);
|
||||
|
||||
nsresult rv = NS_OK;
|
||||
PRInt32 i, count;
|
||||
|
||||
rv = session_history->GetCount(&count);
|
||||
|
||||
for (i = 0; (i < count) && NS_SUCCEEDED(rv); i++) {
|
||||
nsCOMPtr<nsIHistoryEntry> sh_entry;
|
||||
|
||||
rv = session_history->GetEntryAtIndex(i, PR_FALSE,
|
||||
getter_AddRefs(sh_entry));
|
||||
if (sh_entry) {
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
|
||||
rv = sh_entry->GetURI(getter_AddRefs(uri));
|
||||
|
||||
if (uri) {
|
||||
nsCAutoString urlCString;
|
||||
rv = uri->GetSpec(urlCString);
|
||||
|
||||
NS_ConvertUTF8toUCS2 url(urlCString);
|
||||
|
||||
nsReadingIterator<PRUnichar> start;
|
||||
nsReadingIterator<PRUnichar> end;
|
||||
|
||||
url.BeginReading(start);
|
||||
url.EndReading(end);
|
||||
|
||||
if (FindInReadable(aUriSubstring, start, end)) {
|
||||
rv = webnav->GotoIndex(i);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
HistoryImpl::Go()
|
||||
{
|
||||
|
@ -319,22 +268,15 @@ HistoryImpl::Go()
|
|||
ncc->GetArgvPtr(&argv);
|
||||
NS_ENSURE_TRUE(argv, NS_ERROR_UNEXPECTED);
|
||||
|
||||
JSContext *cx = nsnull;
|
||||
if (!JSVAL_IS_INT(argv[0])) {
|
||||
// Not an index, don't do anything.
|
||||
|
||||
rv = ncc->GetJSContext(&cx);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (JSVAL_IS_INT(argv[0])) {
|
||||
PRInt32 delta = JSVAL_TO_INT(argv[0]);
|
||||
|
||||
return GoIndex(delta);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
JSString* jsstr = JS_ValueToString(cx, argv[0]);
|
||||
|
||||
return GoUri(nsDependentString(NS_REINTERPRET_CAST(const PRUnichar *,
|
||||
::JS_GetStringChars(jsstr)),
|
||||
::JS_GetStringLength(jsstr)));
|
||||
PRInt32 delta = JSVAL_TO_INT(argv[0]);
|
||||
|
||||
return Go(delta);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
|
|
@ -38,6 +38,7 @@
|
|||
#ifndef nsHistory_h___
|
||||
#define nsHistory_h___
|
||||
|
||||
#include "nsIDOMHistory.h"
|
||||
#include "nsIDOMNSHistory.h"
|
||||
#include "nsISupports.h"
|
||||
#include "nscore.h"
|
||||
|
@ -47,7 +48,8 @@
|
|||
class nsIDocShell;
|
||||
|
||||
// Script "History" object
|
||||
class HistoryImpl : public nsIDOMNSHistory
|
||||
class HistoryImpl : public nsIDOMHistory,
|
||||
public nsIDOMNSHistory
|
||||
{
|
||||
public:
|
||||
HistoryImpl(nsIDocShell* aDocShell);
|
||||
|
|
Загрузка…
Ссылка в новой задаче