10720 fix - we now do meta tag refreshes

This commit is contained in:
valeski%netscape.com 1999-08-03 21:48:40 +00:00
Родитель f1ffca414c
Коммит 0830bda705
8 изменённых файлов: 225 добавлений и 45 удалений

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

@ -65,7 +65,9 @@
#include "nsStyleConsts.h"
#include "nsINameSpaceManager.h"
#include "nsIDOMHTMLMapElement.h"
#ifdef NECKO
#include "nsIRefreshURI.h"
#endif //NECKO
#include "nsVoidArray.h"
#include "nsIScriptContextOwner.h"
#include "nsHTMLIIDs.h"
@ -2879,7 +2881,26 @@ HTMLContentSink::ProcessMETATag(const nsIParserNode& aNode)
it->GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::content, result);
if (result.Length() > 0) {
#ifdef NECKO
NS_WARNING("need to fix how necko adds mime headers (in HTMLContentSink::ProcessMETATag)");
// XXX necko isn't going to process headers coming in from the parser
//NS_WARNING("need to fix how necko adds mime headers (in HTMLContentSink::ProcessMETATag)");
// parse out the content
nsIRefreshURI *reefer = nsnull;
rv = mWebShell->QueryInterface(nsCOMTypeInfo<nsIRefreshURI>::GetIID(), (void**)&reefer);
if (NS_FAILED(rv)) return rv;
const PRUnichar *uriStr = nsnull;
rv = mWebShell->GetURL(&uriStr);
if (NS_FAILED(rv)) return rv;
nsIURI *uri = nsnull;
rv = NS_NewURI(&uri, uriStr, nsnull);
if (NS_FAILED(rv)) return rv;
PRInt32 error;
PRInt32 millis = result.ToInteger(&error) * 1000;
rv = reefer->RefreshURI(uri, millis, PR_FALSE);
if (NS_FAILED(rv)) return rv;
#else
if (nsnull != httpUrl) {
char* value = result.ToNewCString(), *csHeader;

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

@ -29,6 +29,7 @@
#include "nsNeckoUtil.h"
#include "nsIProtocolHandler.h"
#include "nsIDNSService.h"
#include "nsIRefreshURI.h"
#else
#include "nsINetSupport.h"
#include "nsIRefreshUrl.h"
@ -143,6 +144,7 @@ class nsWebShell : public nsIWebShell,
public nsIDocumentLoaderObserver,
#ifdef NECKO
public nsIPrompt,
public nsIRefreshURI,
#else
public nsIRefreshUrl,
public nsINetSupport,
@ -354,11 +356,17 @@ public:
#endif
// NS_IMETHOD OnConnectionsComplete();
// nsIRefreshURL interface methods...
NS_IMETHOD RefreshURL(nsIURI* aURL, PRInt32 millis, PRBool repeat);
NS_IMETHOD RefreshURL(const char* aURL, PRInt32 millis, PRBool repeat);
NS_IMETHOD CancelRefreshURLTimers(void);
NS_IMETHOD RefreshURL(const char* aURL, PRInt32 millis, PRBool repeat);
// nsIRefreshURL interface methods...
#ifndef NECKO
NS_IMETHOD RefreshURL(nsIURI* aURL, PRInt32 aMillis, PRBool aRepeat);
NS_IMETHOD CancelRefreshURLTimers(void);
#else
NS_IMETHOD RefreshURI(nsIURI* aURI, PRInt32 aMillis, PRBool aRepeat);
NS_IMETHOD CancelRefreshURITimers(void);
#endif // NECKO
#if 0
// nsIStreamObserver
@ -545,7 +553,10 @@ static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
#ifndef NECKO
static NS_DEFINE_IID(kINetSupportIID, NS_INETSUPPORT_IID);
static NS_DEFINE_IID(kRefreshURLIID, NS_IREFRESHURL_IID);
#else
static NS_DEFINE_IID(kRefreshURIIID, NS_IREFRESHURI_IID);
#endif
static NS_DEFINE_IID(kIWebShellIID, NS_IWEB_SHELL_IID);
static NS_DEFINE_IID(kIWebShellServicesIID, NS_IWEB_SHELL_SERVICES_IID);
static NS_DEFINE_IID(kIWidgetIID, NS_IWIDGET_IID);
@ -664,7 +675,11 @@ nsWebShell::~nsWebShell()
NS_RELEASE(mDocLoader);
}
// Cancel any timers that were set for this loader.
#ifndef NECKO
CancelRefreshURLTimers();
#else
CancelRefreshURITimers();
#endif // NECKO
++mRefCnt; // following releases can cause this destructor to be called
// recursively if the refcount is allowed to remain 0
@ -813,26 +828,30 @@ nsWebShell::QueryInterface(REFNSIID aIID, void** aInstancePtr)
NS_ADDREF_THIS();
return NS_OK;
}
#ifndef NECKO
if (aIID.Equals(kRefreshURLIID)) {
*aInstancePtr = (void*)(nsIRefreshUrl*)this;
NS_ADDREF_THIS();
return NS_OK;
}
#endif
#ifdef NECKO
if (aIID.Equals(nsIPrompt::GetIID())) {
*aInstancePtr = (void*) ((nsIPrompt*)this);
NS_ADDREF_THIS();
return NS_OK;
}
if (aIID.Equals(kRefreshURIIID)) {
*aInstancePtr = (void*) ((nsIRefreshURI*)this);
NS_ADDREF_THIS();
return NS_OK;
}
#else
if (aIID.Equals(kINetSupportIID)) {
*aInstancePtr = (void*) ((nsINetSupport*)this);
NS_ADDREF_THIS();
return NS_OK;
}
#endif
if (aIID.Equals(kRefreshURLIID)) {
*aInstancePtr = (void*)((nsIRefreshUrl*)this);
NS_ADDREF_THIS();
return NS_OK;
}
#endif // NECKO
if (aIID.Equals(kIClipboardCommandsIID)) {
*aInstancePtr = (void*) ((nsIClipboardCommands*)this);
NS_ADDREF_THIS();
@ -1976,6 +1995,10 @@ nsWebShell::LoadURL(const PRUnichar *aURLSpec,
urlStr.Trim(" ", PR_TRUE, PR_TRUE);
convertFileToURL(urlStr, urlSpec);
#ifdef NECKO
CancelRefreshURITimers();
#endif // NECKO
//#ifdef NECKO
// nsCOMPtr<nsIURI> url;
// rv = NS_NewURI(getter_AddRefs(url), urlSpec);
@ -2131,7 +2154,11 @@ NS_IMETHODIMP nsWebShell::Stop(void)
}
// Cancel any timers that were set for this loader.
#ifndef NECKO
CancelRefreshURLTimers();
#else
CancelRefreshURITimers();
#endif // NECKO
if (mDocLoader) {
// Stop any documents that are currently being loaded...
@ -2179,7 +2206,11 @@ nsWebShell::StopAfterURLAvailable()
}
// Cancel any timers that were set for this loader.
#ifndef NECKO
CancelRefreshURLTimers();
#else
CancelRefreshURITimers();
#endif // NECKO
// Recurse down the webshell hierarchy.
PRInt32 i, n = mChildren.Count();
@ -3223,12 +3254,16 @@ void refreshData::Notify(nsITimer *aTimer)
NS_IMETHODIMP
nsWebShell::RefreshURL(nsIURI* aURL, PRInt32 millis, PRBool repeat)
#ifndef NECKO
nsWebShell::RefreshURL(nsIURI* aURI, PRInt32 millis, PRBool repeat)
#else
nsWebShell::RefreshURI(nsIURI* aURI, PRInt32 millis, PRBool repeat)
#endif // NECKO
{
nsresult rv = NS_OK;
if (nsnull == aURL) {
NS_PRECONDITION((aURL != nsnull), "Null pointer");
if (nsnull == aURI) {
NS_PRECONDITION((aURI != nsnull), "Null pointer");
rv = NS_ERROR_NULL_POINTER;
goto done;
}
@ -3238,7 +3273,7 @@ nsWebShell::RefreshURL(nsIURI* aURL, PRInt32 millis, PRBool repeat)
#else
const char* spec;
#endif
aURL->GetSpec(&spec);
aURI->GetSpec(&spec);
rv = RefreshURL(spec, millis, repeat);
#ifdef NECKO
nsCRT::free(spec);
@ -3248,14 +3283,14 @@ done:
}
NS_IMETHODIMP
nsWebShell::RefreshURL(const char* aURL, PRInt32 millis, PRBool repeat)
nsWebShell::RefreshURL(const char* aURI, PRInt32 millis, PRBool repeat)
{
nsresult rv = NS_OK;
nsITimer *timer=nsnull;
refreshData *data;
if (nsnull == aURL) {
NS_PRECONDITION((aURL != nsnull), "Null pointer");
if (nsnull == aURI) {
NS_PRECONDITION((aURI != nsnull), "Null pointer");
rv = NS_ERROR_NULL_POINTER;
goto done;
}
@ -3272,7 +3307,7 @@ nsWebShell::RefreshURL(const char* aURL, PRInt32 millis, PRBool repeat)
data->mShell = this;
NS_ADDREF(data->mShell);
data->mUrlSpec = aURL;
data->mUrlSpec = aURI;
data->mDelay = millis;
data->mRepeat = repeat;
@ -3292,7 +3327,11 @@ done:
}
NS_IMETHODIMP
#ifdef NECKO
nsWebShell::CancelRefreshURITimers(void)
#else
nsWebShell::CancelRefreshURLTimers(void)
#endif // NECKO
{
PRInt32 i;
nsITimer* timer;

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

@ -65,7 +65,9 @@
#include "nsStyleConsts.h"
#include "nsINameSpaceManager.h"
#include "nsIDOMHTMLMapElement.h"
#ifdef NECKO
#include "nsIRefreshURI.h"
#endif //NECKO
#include "nsVoidArray.h"
#include "nsIScriptContextOwner.h"
#include "nsHTMLIIDs.h"
@ -2879,7 +2881,26 @@ HTMLContentSink::ProcessMETATag(const nsIParserNode& aNode)
it->GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::content, result);
if (result.Length() > 0) {
#ifdef NECKO
NS_WARNING("need to fix how necko adds mime headers (in HTMLContentSink::ProcessMETATag)");
// XXX necko isn't going to process headers coming in from the parser
//NS_WARNING("need to fix how necko adds mime headers (in HTMLContentSink::ProcessMETATag)");
// parse out the content
nsIRefreshURI *reefer = nsnull;
rv = mWebShell->QueryInterface(nsCOMTypeInfo<nsIRefreshURI>::GetIID(), (void**)&reefer);
if (NS_FAILED(rv)) return rv;
const PRUnichar *uriStr = nsnull;
rv = mWebShell->GetURL(&uriStr);
if (NS_FAILED(rv)) return rv;
nsIURI *uri = nsnull;
rv = NS_NewURI(&uri, uriStr, nsnull);
if (NS_FAILED(rv)) return rv;
PRInt32 error;
PRInt32 millis = result.ToInteger(&error) * 1000;
rv = reefer->RefreshURI(uri, millis, PR_FALSE);
if (NS_FAILED(rv)) return rv;
#else
if (nsnull != httpUrl) {
char* value = result.ToNewCString(), *csHeader;

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

@ -15,3 +15,4 @@ nsIWebShellServices.h
nsIClipboardCommands.h
nsIUrlDispatcher.h
nsweb.h
nsIRefreshURI.h

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

@ -38,6 +38,9 @@ EXPORTS = \
nsweb.h \
nsIDocStreamLoaderFactory.h \
nsIUrlDispatcher.h \
ifdef NECKO
nsIRefreshURI.h \
endif
$(NULL)
EXPORTS := $(addprefix $(srcdir)/, $(EXPORTS))

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

@ -31,10 +31,13 @@ EXPORTS = \
nsILinkHandler.h \
nsIThrobber.h \
nsIWebShell.h \
nsIWebShellServices.h \
nsIWebShellServices.h \
nsIClipboardCommands.h \
nsIUrlDispatcher.h \
nsweb.h \
!ifdef NECKO
nsIRefreshURI.h \
!endif
$(NULL)
include <$(DEPTH)\config\rules.mak>

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

@ -0,0 +1,53 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#ifndef nsIRefreshUri_h___
#define nsIRefreshUri_h___
#include "nscore.h"
#include "nsISupports.h"
#include "nsIURI.h"
#include "nspr.h"
/* 69EFC430-2EFE-11d2-9E5D-006008BF092E */
#define NS_IREFRESHURI_IID \
{ 0x69efc430, 0x2efe, 0x11d2, \
{ 0x9e, 0x5d, 0x0, 0x60, 0x8, 0xbf, 0x9, 0x2e } }
struct nsIRefreshURI : public nsISupports
{
public:
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IREFRESHURI_IID)
/**
* Reloads a uri after waiting millis milliseconds.
*
* @param uri The uri to refresh.
* @param millis The number of milliseconds to wait.
* @param repeat Do you want the uri to be repeatedly refreshed every millis milliseconds.
*/
NS_IMETHOD RefreshURI(nsIURI *aURI, PRInt32 aMillis, PRBool aRepeat) = 0;
/**
* Cancels all timer loads.
*/
NS_IMETHOD CancelRefreshURITimers(void) = 0;
};
#endif /* nsIRefreshUri_h___ */

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

@ -29,6 +29,7 @@
#include "nsNeckoUtil.h"
#include "nsIProtocolHandler.h"
#include "nsIDNSService.h"
#include "nsIRefreshURI.h"
#else
#include "nsINetSupport.h"
#include "nsIRefreshUrl.h"
@ -143,6 +144,7 @@ class nsWebShell : public nsIWebShell,
public nsIDocumentLoaderObserver,
#ifdef NECKO
public nsIPrompt,
public nsIRefreshURI,
#else
public nsIRefreshUrl,
public nsINetSupport,
@ -354,11 +356,17 @@ public:
#endif
// NS_IMETHOD OnConnectionsComplete();
// nsIRefreshURL interface methods...
NS_IMETHOD RefreshURL(nsIURI* aURL, PRInt32 millis, PRBool repeat);
NS_IMETHOD RefreshURL(const char* aURL, PRInt32 millis, PRBool repeat);
NS_IMETHOD CancelRefreshURLTimers(void);
NS_IMETHOD RefreshURL(const char* aURL, PRInt32 millis, PRBool repeat);
// nsIRefreshURL interface methods...
#ifndef NECKO
NS_IMETHOD RefreshURL(nsIURI* aURL, PRInt32 aMillis, PRBool aRepeat);
NS_IMETHOD CancelRefreshURLTimers(void);
#else
NS_IMETHOD RefreshURI(nsIURI* aURI, PRInt32 aMillis, PRBool aRepeat);
NS_IMETHOD CancelRefreshURITimers(void);
#endif // NECKO
#if 0
// nsIStreamObserver
@ -545,7 +553,10 @@ static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
#ifndef NECKO
static NS_DEFINE_IID(kINetSupportIID, NS_INETSUPPORT_IID);
static NS_DEFINE_IID(kRefreshURLIID, NS_IREFRESHURL_IID);
#else
static NS_DEFINE_IID(kRefreshURIIID, NS_IREFRESHURI_IID);
#endif
static NS_DEFINE_IID(kIWebShellIID, NS_IWEB_SHELL_IID);
static NS_DEFINE_IID(kIWebShellServicesIID, NS_IWEB_SHELL_SERVICES_IID);
static NS_DEFINE_IID(kIWidgetIID, NS_IWIDGET_IID);
@ -664,7 +675,11 @@ nsWebShell::~nsWebShell()
NS_RELEASE(mDocLoader);
}
// Cancel any timers that were set for this loader.
#ifndef NECKO
CancelRefreshURLTimers();
#else
CancelRefreshURITimers();
#endif // NECKO
++mRefCnt; // following releases can cause this destructor to be called
// recursively if the refcount is allowed to remain 0
@ -813,26 +828,30 @@ nsWebShell::QueryInterface(REFNSIID aIID, void** aInstancePtr)
NS_ADDREF_THIS();
return NS_OK;
}
#ifndef NECKO
if (aIID.Equals(kRefreshURLIID)) {
*aInstancePtr = (void*)(nsIRefreshUrl*)this;
NS_ADDREF_THIS();
return NS_OK;
}
#endif
#ifdef NECKO
if (aIID.Equals(nsIPrompt::GetIID())) {
*aInstancePtr = (void*) ((nsIPrompt*)this);
NS_ADDREF_THIS();
return NS_OK;
}
if (aIID.Equals(kRefreshURIIID)) {
*aInstancePtr = (void*) ((nsIRefreshURI*)this);
NS_ADDREF_THIS();
return NS_OK;
}
#else
if (aIID.Equals(kINetSupportIID)) {
*aInstancePtr = (void*) ((nsINetSupport*)this);
NS_ADDREF_THIS();
return NS_OK;
}
#endif
if (aIID.Equals(kRefreshURLIID)) {
*aInstancePtr = (void*)((nsIRefreshUrl*)this);
NS_ADDREF_THIS();
return NS_OK;
}
#endif // NECKO
if (aIID.Equals(kIClipboardCommandsIID)) {
*aInstancePtr = (void*) ((nsIClipboardCommands*)this);
NS_ADDREF_THIS();
@ -1976,6 +1995,10 @@ nsWebShell::LoadURL(const PRUnichar *aURLSpec,
urlStr.Trim(" ", PR_TRUE, PR_TRUE);
convertFileToURL(urlStr, urlSpec);
#ifdef NECKO
CancelRefreshURITimers();
#endif // NECKO
//#ifdef NECKO
// nsCOMPtr<nsIURI> url;
// rv = NS_NewURI(getter_AddRefs(url), urlSpec);
@ -2131,7 +2154,11 @@ NS_IMETHODIMP nsWebShell::Stop(void)
}
// Cancel any timers that were set for this loader.
#ifndef NECKO
CancelRefreshURLTimers();
#else
CancelRefreshURITimers();
#endif // NECKO
if (mDocLoader) {
// Stop any documents that are currently being loaded...
@ -2179,7 +2206,11 @@ nsWebShell::StopAfterURLAvailable()
}
// Cancel any timers that were set for this loader.
#ifndef NECKO
CancelRefreshURLTimers();
#else
CancelRefreshURITimers();
#endif // NECKO
// Recurse down the webshell hierarchy.
PRInt32 i, n = mChildren.Count();
@ -3223,12 +3254,16 @@ void refreshData::Notify(nsITimer *aTimer)
NS_IMETHODIMP
nsWebShell::RefreshURL(nsIURI* aURL, PRInt32 millis, PRBool repeat)
#ifndef NECKO
nsWebShell::RefreshURL(nsIURI* aURI, PRInt32 millis, PRBool repeat)
#else
nsWebShell::RefreshURI(nsIURI* aURI, PRInt32 millis, PRBool repeat)
#endif // NECKO
{
nsresult rv = NS_OK;
if (nsnull == aURL) {
NS_PRECONDITION((aURL != nsnull), "Null pointer");
if (nsnull == aURI) {
NS_PRECONDITION((aURI != nsnull), "Null pointer");
rv = NS_ERROR_NULL_POINTER;
goto done;
}
@ -3238,7 +3273,7 @@ nsWebShell::RefreshURL(nsIURI* aURL, PRInt32 millis, PRBool repeat)
#else
const char* spec;
#endif
aURL->GetSpec(&spec);
aURI->GetSpec(&spec);
rv = RefreshURL(spec, millis, repeat);
#ifdef NECKO
nsCRT::free(spec);
@ -3248,14 +3283,14 @@ done:
}
NS_IMETHODIMP
nsWebShell::RefreshURL(const char* aURL, PRInt32 millis, PRBool repeat)
nsWebShell::RefreshURL(const char* aURI, PRInt32 millis, PRBool repeat)
{
nsresult rv = NS_OK;
nsITimer *timer=nsnull;
refreshData *data;
if (nsnull == aURL) {
NS_PRECONDITION((aURL != nsnull), "Null pointer");
if (nsnull == aURI) {
NS_PRECONDITION((aURI != nsnull), "Null pointer");
rv = NS_ERROR_NULL_POINTER;
goto done;
}
@ -3272,7 +3307,7 @@ nsWebShell::RefreshURL(const char* aURL, PRInt32 millis, PRBool repeat)
data->mShell = this;
NS_ADDREF(data->mShell);
data->mUrlSpec = aURL;
data->mUrlSpec = aURI;
data->mDelay = millis;
data->mRepeat = repeat;
@ -3292,7 +3327,11 @@ done:
}
NS_IMETHODIMP
#ifdef NECKO
nsWebShell::CancelRefreshURITimers(void)
#else
nsWebShell::CancelRefreshURLTimers(void)
#endif // NECKO
{
PRInt32 i;
nsITimer* timer;