From 241fb296d56df1a5b11c8cdb77fe1fd2b34c1f4e Mon Sep 17 00:00:00 2001 From: "sfraser%netscape.com" Date: Fri, 31 Mar 2000 01:57:28 +0000 Subject: [PATCH] Work in progress for frameset detection, bug 14599. r=cmanske git-svn-id: svn://10.0.0.236/trunk@64664 18797224-902f-48f8-a5cc-f745e15eee43 --- .../editor/base/nsEditorParserObserver.cpp | 22 +++++++++++++----- mozilla/editor/base/nsEditorParserObserver.h | 23 ++++++++----------- .../composer/src/nsEditorParserObserver.cpp | 22 +++++++++++++----- .../composer/src/nsEditorParserObserver.h | 23 ++++++++----------- 4 files changed, 52 insertions(+), 38 deletions(-) diff --git a/mozilla/editor/base/nsEditorParserObserver.cpp b/mozilla/editor/base/nsEditorParserObserver.cpp index 7c2061508d6..09abdc2b271 100644 --- a/mozilla/editor/base/nsEditorParserObserver.cpp +++ b/mozilla/editor/base/nsEditorParserObserver.cpp @@ -48,12 +48,11 @@ nsEditorParserObserver::~nsEditorParserObserver() NS_IMETHODIMP_(const char*) nsEditorParserObserver::GetTagNameAt(PRUint32 aTagIndex) { - if (aTagIndex < gParserObserver_TagCount) - { - return gParserObserver_Tags[aTagIndex]; - } else { + nsCString* theString = mWatchTags[aTagIndex]; + if (theString) + return theString->GetBuffer(); + else return nsnull; - } } NS_IMETHODIMP nsEditorParserObserver::Notify( @@ -121,4 +120,15 @@ NS_IMETHODIMP nsEditorParserObserver::GetBadTagFound(PRBool *aFound) NS_ENSURE_ARG_POINTER(aFound); *aFound = mBadTagFound; return NS_OK; -} \ No newline at end of file +} + + +NS_IMETHODIMP nsEditorParserObserver::RegisterTagToWatch(const char* tagName) +{ + nsCString theTagString(tagName); + mWatchTags.AppendCString(theTagString); + return NS_OK; +} + + + diff --git a/mozilla/editor/base/nsEditorParserObserver.h b/mozilla/editor/base/nsEditorParserObserver.h index 1b03a556b97..a3f7696677b 100644 --- a/mozilla/editor/base/nsEditorParserObserver.h +++ b/mozilla/editor/base/nsEditorParserObserver.h @@ -24,14 +24,9 @@ #include "nsIElementObserver.h" #include "nsIObserver.h" #include "nsIObserverService.h" + #include "nsWeakReference.h" - -static const PRInt32 gParserObserver_TagCount=1; -static const char * gParserObserver_Tags[1] = {"FRAMESET"}; - - -// this needs to support the weak reference API, so that the parser -// does not need to hold a reference +#include "nsVoidArray.h" class nsEditorParserObserver : public nsSupportsWeakReference, public nsIElementObserver, @@ -49,29 +44,31 @@ public: NS_IMETHOD Notify(PRUint32 aDocumentID, eHTMLTags aTag, PRUint32 numOfAttributes, const PRUnichar* nameArray[], const PRUnichar* valueArray[]); NS_IMETHOD Notify(PRUint32 aDocumentID, const PRUnichar* aTag, PRUint32 numOfAttributes, - const PRUnichar* nameArray[], const PRUnichar* valueArray[]); + const PRUnichar* nameArray[], const PRUnichar* valueArray[]); /* methods for nsIObserver */ NS_DECL_NSIOBSERVER - /* begin observing */ + /* begin and end observing */ NS_IMETHOD Start(); - - /** end observing */ NS_IMETHOD End(); - /** query, did we find a bad tag? */ + /* query, did we find a bad tag? */ NS_IMETHOD GetBadTagFound(PRBool *aFound); + /* register a tag to watch for */ + NS_IMETHOD RegisterTagToWatch(const char* tagName); + protected: virtual void Notify(); - protected: PRBool mBadTagFound; + nsCStringArray mWatchTags; + }; diff --git a/mozilla/editor/composer/src/nsEditorParserObserver.cpp b/mozilla/editor/composer/src/nsEditorParserObserver.cpp index 7c2061508d6..09abdc2b271 100644 --- a/mozilla/editor/composer/src/nsEditorParserObserver.cpp +++ b/mozilla/editor/composer/src/nsEditorParserObserver.cpp @@ -48,12 +48,11 @@ nsEditorParserObserver::~nsEditorParserObserver() NS_IMETHODIMP_(const char*) nsEditorParserObserver::GetTagNameAt(PRUint32 aTagIndex) { - if (aTagIndex < gParserObserver_TagCount) - { - return gParserObserver_Tags[aTagIndex]; - } else { + nsCString* theString = mWatchTags[aTagIndex]; + if (theString) + return theString->GetBuffer(); + else return nsnull; - } } NS_IMETHODIMP nsEditorParserObserver::Notify( @@ -121,4 +120,15 @@ NS_IMETHODIMP nsEditorParserObserver::GetBadTagFound(PRBool *aFound) NS_ENSURE_ARG_POINTER(aFound); *aFound = mBadTagFound; return NS_OK; -} \ No newline at end of file +} + + +NS_IMETHODIMP nsEditorParserObserver::RegisterTagToWatch(const char* tagName) +{ + nsCString theTagString(tagName); + mWatchTags.AppendCString(theTagString); + return NS_OK; +} + + + diff --git a/mozilla/editor/composer/src/nsEditorParserObserver.h b/mozilla/editor/composer/src/nsEditorParserObserver.h index 1b03a556b97..a3f7696677b 100644 --- a/mozilla/editor/composer/src/nsEditorParserObserver.h +++ b/mozilla/editor/composer/src/nsEditorParserObserver.h @@ -24,14 +24,9 @@ #include "nsIElementObserver.h" #include "nsIObserver.h" #include "nsIObserverService.h" + #include "nsWeakReference.h" - -static const PRInt32 gParserObserver_TagCount=1; -static const char * gParserObserver_Tags[1] = {"FRAMESET"}; - - -// this needs to support the weak reference API, so that the parser -// does not need to hold a reference +#include "nsVoidArray.h" class nsEditorParserObserver : public nsSupportsWeakReference, public nsIElementObserver, @@ -49,29 +44,31 @@ public: NS_IMETHOD Notify(PRUint32 aDocumentID, eHTMLTags aTag, PRUint32 numOfAttributes, const PRUnichar* nameArray[], const PRUnichar* valueArray[]); NS_IMETHOD Notify(PRUint32 aDocumentID, const PRUnichar* aTag, PRUint32 numOfAttributes, - const PRUnichar* nameArray[], const PRUnichar* valueArray[]); + const PRUnichar* nameArray[], const PRUnichar* valueArray[]); /* methods for nsIObserver */ NS_DECL_NSIOBSERVER - /* begin observing */ + /* begin and end observing */ NS_IMETHOD Start(); - - /** end observing */ NS_IMETHOD End(); - /** query, did we find a bad tag? */ + /* query, did we find a bad tag? */ NS_IMETHOD GetBadTagFound(PRBool *aFound); + /* register a tag to watch for */ + NS_IMETHOD RegisterTagToWatch(const char* tagName); + protected: virtual void Notify(); - protected: PRBool mBadTagFound; + nsCStringArray mWatchTags; + };