зеркало из https://github.com/mozilla/pjs.git
the RefreshURI code now talks in terms of nsIURI instead of strings. Removed unused member variable mScrollPref. Cleaned refreshData up to follow xpcom rules better and to deal with nsIURI instead of strings. It also now talks in terms of docshells instead of webshells.
This commit is contained in:
Родитель
698dde3fae
Коммит
6a06f69242
|
@ -300,8 +300,6 @@ public:
|
||||||
const PRUnichar* aTargetSpec);
|
const PRUnichar* aTargetSpec);
|
||||||
NS_IMETHOD GetLinkState(const PRUnichar* aURLSpec, nsLinkState& aState);
|
NS_IMETHOD GetLinkState(const PRUnichar* aURLSpec, nsLinkState& aState);
|
||||||
|
|
||||||
NS_IMETHOD RefreshURL(const char* aURL, PRInt32 millis, PRBool repeat);
|
|
||||||
|
|
||||||
// nsIRefreshURL interface methods...
|
// nsIRefreshURL interface methods...
|
||||||
NS_IMETHOD RefreshURI(nsIURI* aURI, PRInt32 aMillis, PRBool aRepeat);
|
NS_IMETHOD RefreshURI(nsIURI* aURI, PRInt32 aMillis, PRBool aRepeat);
|
||||||
NS_IMETHOD CancelRefreshURITimers(void);
|
NS_IMETHOD CancelRefreshURITimers(void);
|
||||||
|
@ -344,8 +342,6 @@ public:
|
||||||
|
|
||||||
void ShowHistory();
|
void ShowHistory();
|
||||||
|
|
||||||
static void RefreshURLCallback(nsITimer* aTimer, void* aClosure);
|
|
||||||
|
|
||||||
static nsEventStatus PR_CALLBACK HandleEvent(nsGUIEvent *aEvent);
|
static nsEventStatus PR_CALLBACK HandleEvent(nsGUIEvent *aEvent);
|
||||||
|
|
||||||
nsresult CreatePluginHost(PRBool aAllowPlugins);
|
nsresult CreatePluginHost(PRBool aAllowPlugins);
|
||||||
|
@ -389,8 +385,6 @@ protected:
|
||||||
PRPackedBool mIsInSHist;
|
PRPackedBool mIsInSHist;
|
||||||
PRPackedBool mFailedToLoadHistoryService;
|
PRPackedBool mFailedToLoadHistoryService;
|
||||||
|
|
||||||
nsScrollPreference mScrollPref;
|
|
||||||
|
|
||||||
nsVoidArray mRefreshments;
|
nsVoidArray mRefreshments;
|
||||||
|
|
||||||
eCharsetReloadState mCharsetReloadState;
|
eCharsetReloadState mCharsetReloadState;
|
||||||
|
@ -551,7 +545,6 @@ nsWebShell::nsWebShell() : nsDocShell()
|
||||||
|
|
||||||
NS_INIT_REFCNT();
|
NS_INIT_REFCNT();
|
||||||
mHistoryIndex = -1;
|
mHistoryIndex = -1;
|
||||||
mScrollPref = nsScrollPreference_kAuto;
|
|
||||||
mThreadEventQueue = nsnull;
|
mThreadEventQueue = nsnull;
|
||||||
InitFrameData();
|
InitFrameData();
|
||||||
mItemType = typeContent;
|
mItemType = typeContent;
|
||||||
|
@ -2702,8 +2695,8 @@ public:
|
||||||
// nsITimerCallback interface
|
// nsITimerCallback interface
|
||||||
NS_IMETHOD_(void) Notify(nsITimer *timer);
|
NS_IMETHOD_(void) Notify(nsITimer *timer);
|
||||||
|
|
||||||
nsIWebShell* mShell;
|
nsCOMPtr<nsIDocShell> mDocShell;
|
||||||
nsString mUrlSpec;
|
nsCOMPtr<nsIURI> mURI;
|
||||||
PRBool mRepeat;
|
PRBool mRepeat;
|
||||||
PRInt32 mDelay;
|
PRInt32 mDelay;
|
||||||
|
|
||||||
|
@ -2714,13 +2707,10 @@ protected:
|
||||||
refreshData::refreshData()
|
refreshData::refreshData()
|
||||||
{
|
{
|
||||||
NS_INIT_REFCNT();
|
NS_INIT_REFCNT();
|
||||||
|
|
||||||
mShell = nsnull;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
refreshData::~refreshData()
|
refreshData::~refreshData()
|
||||||
{
|
{
|
||||||
NS_IF_RELEASE(mShell);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -2728,10 +2718,10 @@ NS_IMPL_ISUPPORTS(refreshData, kITimerCallbackIID);
|
||||||
|
|
||||||
NS_IMETHODIMP_(void) refreshData::Notify(nsITimer *aTimer)
|
NS_IMETHODIMP_(void) refreshData::Notify(nsITimer *aTimer)
|
||||||
{
|
{
|
||||||
NS_PRECONDITION((nsnull != mShell), "Null pointer...");
|
NS_ASSERTION(mDocShell, "DocShell is somehow null");
|
||||||
if (nsnull != mShell) {
|
|
||||||
mShell->LoadURL(mUrlSpec.GetUnicode(), nsnull, PR_TRUE, nsIChannel::LOAD_NORMAL);
|
if(mDocShell)
|
||||||
}
|
mDocShell->LoadURI(mURI, nsnull);
|
||||||
/*
|
/*
|
||||||
* LoadURL(...) will cancel all refresh timers... This causes the Timer and
|
* LoadURL(...) will cancel all refresh timers... This causes the Timer and
|
||||||
* its refreshData instance to be released...
|
* its refreshData instance to be released...
|
||||||
|
@ -2739,68 +2729,31 @@ NS_IMETHODIMP_(void) refreshData::Notify(nsITimer *aTimer)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP nsWebShell::RefreshURI(nsIURI* aURI, PRInt32 aDelay, PRBool aRepeat)
|
||||||
nsWebShell::RefreshURI(nsIURI* aURI, PRInt32 millis, PRBool repeat)
|
|
||||||
{
|
{
|
||||||
|
NS_ENSURE_ARG(aURI);
|
||||||
|
|
||||||
nsresult rv = NS_OK;
|
refreshData* data = new refreshData();
|
||||||
if (nsnull == aURI) {
|
NS_ENSURE_TRUE(data, NS_ERROR_OUT_OF_MEMORY);
|
||||||
NS_PRECONDITION((aURI != nsnull), "Null pointer");
|
|
||||||
rv = NS_ERROR_NULL_POINTER;
|
|
||||||
goto done;
|
|
||||||
}
|
|
||||||
|
|
||||||
char* spec;
|
nsCOMPtr<nsISupports> dataRef = data; // Get the ref count to 1
|
||||||
aURI->GetSpec(&spec);
|
|
||||||
rv = RefreshURL(spec, millis, repeat);
|
|
||||||
nsCRT::free(spec);
|
|
||||||
|
|
||||||
done:
|
data->mDocShell = this;
|
||||||
return rv;
|
data->mURI = aURI;
|
||||||
}
|
data->mDelay = aDelay;
|
||||||
|
data->mRepeat = aRepeat;
|
||||||
|
|
||||||
NS_IMETHODIMP
|
nsITimer* timer = nsnull;
|
||||||
nsWebShell::RefreshURL(const char* aURI, PRInt32 millis, PRBool repeat)
|
|
||||||
{
|
|
||||||
nsresult rv = NS_OK;
|
|
||||||
nsITimer *timer=nsnull;
|
|
||||||
refreshData *data;
|
|
||||||
|
|
||||||
if (nsnull == aURI) {
|
NS_NewTimer(&timer);
|
||||||
NS_PRECONDITION((aURI != nsnull), "Null pointer");
|
NS_ENSURE_TRUE(timer, NS_ERROR_FAILURE);
|
||||||
rv = NS_ERROR_NULL_POINTER;
|
|
||||||
goto done;
|
|
||||||
}
|
|
||||||
|
|
||||||
NS_NEWXPCOM(data, refreshData);
|
NS_LOCK_INSTANCE(); // XXX What is this for?
|
||||||
if (nsnull == data) {
|
mRefreshments.AppendElement(timer);
|
||||||
rv = NS_ERROR_OUT_OF_MEMORY;
|
timer->Init(data, aDelay);
|
||||||
goto done;
|
NS_UNLOCK_INSTANCE();
|
||||||
}
|
|
||||||
|
|
||||||
// Set the reference count to one...
|
return NS_OK;
|
||||||
NS_ADDREF(data);
|
|
||||||
|
|
||||||
data->mShell = this;
|
|
||||||
NS_ADDREF(data->mShell);
|
|
||||||
|
|
||||||
data->mUrlSpec = aURI;
|
|
||||||
data->mDelay = millis;
|
|
||||||
data->mRepeat = repeat;
|
|
||||||
|
|
||||||
/* Create the timer. */
|
|
||||||
if (NS_OK == NS_NewTimer(&timer)) {
|
|
||||||
/* Add the timer to our array. */
|
|
||||||
NS_LOCK_INSTANCE();
|
|
||||||
mRefreshments.AppendElement(timer);
|
|
||||||
timer->Init(data, millis);
|
|
||||||
NS_UNLOCK_INSTANCE();
|
|
||||||
}
|
|
||||||
|
|
||||||
NS_RELEASE(data);
|
|
||||||
|
|
||||||
done:
|
|
||||||
return rv;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
|
|
|
@ -300,8 +300,6 @@ public:
|
||||||
const PRUnichar* aTargetSpec);
|
const PRUnichar* aTargetSpec);
|
||||||
NS_IMETHOD GetLinkState(const PRUnichar* aURLSpec, nsLinkState& aState);
|
NS_IMETHOD GetLinkState(const PRUnichar* aURLSpec, nsLinkState& aState);
|
||||||
|
|
||||||
NS_IMETHOD RefreshURL(const char* aURL, PRInt32 millis, PRBool repeat);
|
|
||||||
|
|
||||||
// nsIRefreshURL interface methods...
|
// nsIRefreshURL interface methods...
|
||||||
NS_IMETHOD RefreshURI(nsIURI* aURI, PRInt32 aMillis, PRBool aRepeat);
|
NS_IMETHOD RefreshURI(nsIURI* aURI, PRInt32 aMillis, PRBool aRepeat);
|
||||||
NS_IMETHOD CancelRefreshURITimers(void);
|
NS_IMETHOD CancelRefreshURITimers(void);
|
||||||
|
@ -344,8 +342,6 @@ public:
|
||||||
|
|
||||||
void ShowHistory();
|
void ShowHistory();
|
||||||
|
|
||||||
static void RefreshURLCallback(nsITimer* aTimer, void* aClosure);
|
|
||||||
|
|
||||||
static nsEventStatus PR_CALLBACK HandleEvent(nsGUIEvent *aEvent);
|
static nsEventStatus PR_CALLBACK HandleEvent(nsGUIEvent *aEvent);
|
||||||
|
|
||||||
nsresult CreatePluginHost(PRBool aAllowPlugins);
|
nsresult CreatePluginHost(PRBool aAllowPlugins);
|
||||||
|
@ -389,8 +385,6 @@ protected:
|
||||||
PRPackedBool mIsInSHist;
|
PRPackedBool mIsInSHist;
|
||||||
PRPackedBool mFailedToLoadHistoryService;
|
PRPackedBool mFailedToLoadHistoryService;
|
||||||
|
|
||||||
nsScrollPreference mScrollPref;
|
|
||||||
|
|
||||||
nsVoidArray mRefreshments;
|
nsVoidArray mRefreshments;
|
||||||
|
|
||||||
eCharsetReloadState mCharsetReloadState;
|
eCharsetReloadState mCharsetReloadState;
|
||||||
|
@ -551,7 +545,6 @@ nsWebShell::nsWebShell() : nsDocShell()
|
||||||
|
|
||||||
NS_INIT_REFCNT();
|
NS_INIT_REFCNT();
|
||||||
mHistoryIndex = -1;
|
mHistoryIndex = -1;
|
||||||
mScrollPref = nsScrollPreference_kAuto;
|
|
||||||
mThreadEventQueue = nsnull;
|
mThreadEventQueue = nsnull;
|
||||||
InitFrameData();
|
InitFrameData();
|
||||||
mItemType = typeContent;
|
mItemType = typeContent;
|
||||||
|
@ -2702,8 +2695,8 @@ public:
|
||||||
// nsITimerCallback interface
|
// nsITimerCallback interface
|
||||||
NS_IMETHOD_(void) Notify(nsITimer *timer);
|
NS_IMETHOD_(void) Notify(nsITimer *timer);
|
||||||
|
|
||||||
nsIWebShell* mShell;
|
nsCOMPtr<nsIDocShell> mDocShell;
|
||||||
nsString mUrlSpec;
|
nsCOMPtr<nsIURI> mURI;
|
||||||
PRBool mRepeat;
|
PRBool mRepeat;
|
||||||
PRInt32 mDelay;
|
PRInt32 mDelay;
|
||||||
|
|
||||||
|
@ -2714,13 +2707,10 @@ protected:
|
||||||
refreshData::refreshData()
|
refreshData::refreshData()
|
||||||
{
|
{
|
||||||
NS_INIT_REFCNT();
|
NS_INIT_REFCNT();
|
||||||
|
|
||||||
mShell = nsnull;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
refreshData::~refreshData()
|
refreshData::~refreshData()
|
||||||
{
|
{
|
||||||
NS_IF_RELEASE(mShell);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -2728,10 +2718,10 @@ NS_IMPL_ISUPPORTS(refreshData, kITimerCallbackIID);
|
||||||
|
|
||||||
NS_IMETHODIMP_(void) refreshData::Notify(nsITimer *aTimer)
|
NS_IMETHODIMP_(void) refreshData::Notify(nsITimer *aTimer)
|
||||||
{
|
{
|
||||||
NS_PRECONDITION((nsnull != mShell), "Null pointer...");
|
NS_ASSERTION(mDocShell, "DocShell is somehow null");
|
||||||
if (nsnull != mShell) {
|
|
||||||
mShell->LoadURL(mUrlSpec.GetUnicode(), nsnull, PR_TRUE, nsIChannel::LOAD_NORMAL);
|
if(mDocShell)
|
||||||
}
|
mDocShell->LoadURI(mURI, nsnull);
|
||||||
/*
|
/*
|
||||||
* LoadURL(...) will cancel all refresh timers... This causes the Timer and
|
* LoadURL(...) will cancel all refresh timers... This causes the Timer and
|
||||||
* its refreshData instance to be released...
|
* its refreshData instance to be released...
|
||||||
|
@ -2739,68 +2729,31 @@ NS_IMETHODIMP_(void) refreshData::Notify(nsITimer *aTimer)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP nsWebShell::RefreshURI(nsIURI* aURI, PRInt32 aDelay, PRBool aRepeat)
|
||||||
nsWebShell::RefreshURI(nsIURI* aURI, PRInt32 millis, PRBool repeat)
|
|
||||||
{
|
{
|
||||||
|
NS_ENSURE_ARG(aURI);
|
||||||
|
|
||||||
nsresult rv = NS_OK;
|
refreshData* data = new refreshData();
|
||||||
if (nsnull == aURI) {
|
NS_ENSURE_TRUE(data, NS_ERROR_OUT_OF_MEMORY);
|
||||||
NS_PRECONDITION((aURI != nsnull), "Null pointer");
|
|
||||||
rv = NS_ERROR_NULL_POINTER;
|
|
||||||
goto done;
|
|
||||||
}
|
|
||||||
|
|
||||||
char* spec;
|
nsCOMPtr<nsISupports> dataRef = data; // Get the ref count to 1
|
||||||
aURI->GetSpec(&spec);
|
|
||||||
rv = RefreshURL(spec, millis, repeat);
|
|
||||||
nsCRT::free(spec);
|
|
||||||
|
|
||||||
done:
|
data->mDocShell = this;
|
||||||
return rv;
|
data->mURI = aURI;
|
||||||
}
|
data->mDelay = aDelay;
|
||||||
|
data->mRepeat = aRepeat;
|
||||||
|
|
||||||
NS_IMETHODIMP
|
nsITimer* timer = nsnull;
|
||||||
nsWebShell::RefreshURL(const char* aURI, PRInt32 millis, PRBool repeat)
|
|
||||||
{
|
|
||||||
nsresult rv = NS_OK;
|
|
||||||
nsITimer *timer=nsnull;
|
|
||||||
refreshData *data;
|
|
||||||
|
|
||||||
if (nsnull == aURI) {
|
NS_NewTimer(&timer);
|
||||||
NS_PRECONDITION((aURI != nsnull), "Null pointer");
|
NS_ENSURE_TRUE(timer, NS_ERROR_FAILURE);
|
||||||
rv = NS_ERROR_NULL_POINTER;
|
|
||||||
goto done;
|
|
||||||
}
|
|
||||||
|
|
||||||
NS_NEWXPCOM(data, refreshData);
|
NS_LOCK_INSTANCE(); // XXX What is this for?
|
||||||
if (nsnull == data) {
|
mRefreshments.AppendElement(timer);
|
||||||
rv = NS_ERROR_OUT_OF_MEMORY;
|
timer->Init(data, aDelay);
|
||||||
goto done;
|
NS_UNLOCK_INSTANCE();
|
||||||
}
|
|
||||||
|
|
||||||
// Set the reference count to one...
|
return NS_OK;
|
||||||
NS_ADDREF(data);
|
|
||||||
|
|
||||||
data->mShell = this;
|
|
||||||
NS_ADDREF(data->mShell);
|
|
||||||
|
|
||||||
data->mUrlSpec = aURI;
|
|
||||||
data->mDelay = millis;
|
|
||||||
data->mRepeat = repeat;
|
|
||||||
|
|
||||||
/* Create the timer. */
|
|
||||||
if (NS_OK == NS_NewTimer(&timer)) {
|
|
||||||
/* Add the timer to our array. */
|
|
||||||
NS_LOCK_INSTANCE();
|
|
||||||
mRefreshments.AppendElement(timer);
|
|
||||||
timer->Init(data, millis);
|
|
||||||
NS_UNLOCK_INSTANCE();
|
|
||||||
}
|
|
||||||
|
|
||||||
NS_RELEASE(data);
|
|
||||||
|
|
||||||
done:
|
|
||||||
return rv;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
|
|
Загрузка…
Ссылка в новой задаче