From ceddb6ce58289d37c476e016cdee6e79de4bca5b Mon Sep 17 00:00:00 2001 From: "waterson%netscape.com" Date: Wed, 15 Dec 1999 23:18:34 +0000 Subject: [PATCH] Bug 21610. Add support to distinguish key binding overlay from normal overlay documents. git-svn-id: svn://10.0.0.236/trunk@56060 18797224-902f-48f8-a5cc-f745e15eee43 --- .../xul/document/public/nsIXULDocument.h | 6 ++++ .../xul/document/src/nsXULDocument.cpp | 33 ++++++++++++------- .../content/xul/document/src/nsXULDocument.h | 2 ++ mozilla/rdf/content/public/nsIXULDocument.h | 6 ++++ mozilla/rdf/content/src/nsXULDocument.cpp | 33 ++++++++++++------- mozilla/rdf/content/src/nsXULDocument.h | 2 ++ mozilla/rdf/content/src/nsXULKeyListener.cpp | 13 +++++--- 7 files changed, 69 insertions(+), 26 deletions(-) diff --git a/mozilla/content/xul/document/public/nsIXULDocument.h b/mozilla/content/xul/document/public/nsIXULDocument.h index 973a66db811..8a1fa084941 100644 --- a/mozilla/content/xul/document/public/nsIXULDocument.h +++ b/mozilla/content/xul/document/public/nsIXULDocument.h @@ -127,6 +127,12 @@ public: * Load inline and attribute style sheets */ NS_IMETHOD PrepareStyleSheets(nsIURI* aURI) = 0; + + /** + * Indicate that this doc will be used only to load a key binding + * document. + */ + NS_IMETHOD SetIsKeybindingDocument(PRBool aIsKeyBindingDoc) = 0; }; // factory functions diff --git a/mozilla/content/xul/document/src/nsXULDocument.cpp b/mozilla/content/xul/document/src/nsXULDocument.cpp index 9206a2ee514..1bf30a97457 100644 --- a/mozilla/content/xul/document/src/nsXULDocument.cpp +++ b/mozilla/content/xul/document/src/nsXULDocument.cpp @@ -309,6 +309,7 @@ nsXULDocument::nsXULDocument(void) mNextSrcLoadWaiter(nsnull), mCharSetID("UTF-8"), mDisplaySelection(PR_FALSE), + mIsKeyBindingDoc(PR_FALSE), mIsPopup(PR_FALSE), mResolutionPhase(nsForwardReference::eStart), mNextContentID(NS_CONTENT_ID_COUNTER_BASE), @@ -602,6 +603,13 @@ nsXULDocument::PrepareStyleSheets(nsIURI* anURL) return NS_OK; } +NS_IMETHODIMP +nsXULDocument::SetIsKeybindingDocument(PRBool aIsKeyBindingDoc) +{ + mIsKeyBindingDoc = aIsKeyBindingDoc; + return NS_OK; +} + NS_IMETHODIMP nsXULDocument::SetDocumentURL(nsIURI* anURL) { @@ -3175,18 +3183,20 @@ nsXULDocument::Init() getter_AddRefs(mNameSpaceManager)); if (NS_FAILED(rv)) return rv; - // Create our focus tracker and hook it up. - rv = nsXULCommandDispatcher::Create(getter_AddRefs(mCommandDispatcher)); - NS_ASSERTION(NS_SUCCEEDED(rv), "unable to create a focus tracker"); - if (NS_FAILED(rv)) return rv; + if (!mIsKeyBindingDoc) { + // Create our focus tracker and hook it up. + rv = nsXULCommandDispatcher::Create(getter_AddRefs(mCommandDispatcher)); + NS_ASSERTION(NS_SUCCEEDED(rv), "unable to create a focus tracker"); + if (NS_FAILED(rv)) return rv; - nsCOMPtr CommandDispatcher = - do_QueryInterface(mCommandDispatcher); + nsCOMPtr CommandDispatcher = + do_QueryInterface(mCommandDispatcher); - if (CommandDispatcher) { - // Take the focus tracker and add it as an event listener for focus and blur events. - AddEventListener("focus", CommandDispatcher, PR_TRUE); - AddEventListener("blur", CommandDispatcher, PR_TRUE); + if (CommandDispatcher) { + // Take the focus tracker and add it as an event listener for focus and blur events. + AddEventListener("focus", CommandDispatcher, PR_TRUE); + AddEventListener("blur", CommandDispatcher, PR_TRUE); + } } // Get the local store. Yeah, I know. I wish GetService() used a @@ -4934,7 +4944,8 @@ nsXULDocument::CreateElement(nsXULPrototypeElement* aPrototype, nsIContent** aRe // We also need to pay special attention to the keyset tag to set up a listener if ((aPrototype->mNameSpaceID == kNameSpaceID_XUL) && - (aPrototype->mTag.get() == kKeysetAtom)) { + (aPrototype->mTag.get() == kKeysetAtom) && + ! mIsKeyBindingDoc) { // Create our nsXULKeyListener and hook it up. nsCOMPtr keyListener; rv = nsComponentManager::CreateInstance(kXULKeyListenerCID, diff --git a/mozilla/content/xul/document/src/nsXULDocument.h b/mozilla/content/xul/document/src/nsXULDocument.h index 1da445193e4..093765a173e 100644 --- a/mozilla/content/xul/document/src/nsXULDocument.h +++ b/mozilla/content/xul/document/src/nsXULDocument.h @@ -289,6 +289,7 @@ public: NS_IMETHOD SetCurrentPrototype(nsIXULPrototypeDocument* aDocument); NS_IMETHOD SetDocumentURL(nsIURI* anURL); NS_IMETHOD PrepareStyleSheets(nsIURI* anURL); + NS_IMETHOD SetIsKeybindingDocument(PRBool aIsKeyBindingDoc); // nsIStreamLoadableDocument interface NS_IMETHOD LoadFromStream(nsIInputStream& xulStream, @@ -507,6 +508,7 @@ protected: nsVoidArray mStyleSheets; nsCOMPtr mSelection; // [OWNER] PRBool mDisplaySelection; + PRBool mIsKeyBindingDoc; nsVoidArray mPresShells; nsCOMPtr mListenerManager; // [OWNER] nsCOMPtr mNameSpaceManager; // [OWNER] diff --git a/mozilla/rdf/content/public/nsIXULDocument.h b/mozilla/rdf/content/public/nsIXULDocument.h index 973a66db811..8a1fa084941 100644 --- a/mozilla/rdf/content/public/nsIXULDocument.h +++ b/mozilla/rdf/content/public/nsIXULDocument.h @@ -127,6 +127,12 @@ public: * Load inline and attribute style sheets */ NS_IMETHOD PrepareStyleSheets(nsIURI* aURI) = 0; + + /** + * Indicate that this doc will be used only to load a key binding + * document. + */ + NS_IMETHOD SetIsKeybindingDocument(PRBool aIsKeyBindingDoc) = 0; }; // factory functions diff --git a/mozilla/rdf/content/src/nsXULDocument.cpp b/mozilla/rdf/content/src/nsXULDocument.cpp index 9206a2ee514..1bf30a97457 100644 --- a/mozilla/rdf/content/src/nsXULDocument.cpp +++ b/mozilla/rdf/content/src/nsXULDocument.cpp @@ -309,6 +309,7 @@ nsXULDocument::nsXULDocument(void) mNextSrcLoadWaiter(nsnull), mCharSetID("UTF-8"), mDisplaySelection(PR_FALSE), + mIsKeyBindingDoc(PR_FALSE), mIsPopup(PR_FALSE), mResolutionPhase(nsForwardReference::eStart), mNextContentID(NS_CONTENT_ID_COUNTER_BASE), @@ -602,6 +603,13 @@ nsXULDocument::PrepareStyleSheets(nsIURI* anURL) return NS_OK; } +NS_IMETHODIMP +nsXULDocument::SetIsKeybindingDocument(PRBool aIsKeyBindingDoc) +{ + mIsKeyBindingDoc = aIsKeyBindingDoc; + return NS_OK; +} + NS_IMETHODIMP nsXULDocument::SetDocumentURL(nsIURI* anURL) { @@ -3175,18 +3183,20 @@ nsXULDocument::Init() getter_AddRefs(mNameSpaceManager)); if (NS_FAILED(rv)) return rv; - // Create our focus tracker and hook it up. - rv = nsXULCommandDispatcher::Create(getter_AddRefs(mCommandDispatcher)); - NS_ASSERTION(NS_SUCCEEDED(rv), "unable to create a focus tracker"); - if (NS_FAILED(rv)) return rv; + if (!mIsKeyBindingDoc) { + // Create our focus tracker and hook it up. + rv = nsXULCommandDispatcher::Create(getter_AddRefs(mCommandDispatcher)); + NS_ASSERTION(NS_SUCCEEDED(rv), "unable to create a focus tracker"); + if (NS_FAILED(rv)) return rv; - nsCOMPtr CommandDispatcher = - do_QueryInterface(mCommandDispatcher); + nsCOMPtr CommandDispatcher = + do_QueryInterface(mCommandDispatcher); - if (CommandDispatcher) { - // Take the focus tracker and add it as an event listener for focus and blur events. - AddEventListener("focus", CommandDispatcher, PR_TRUE); - AddEventListener("blur", CommandDispatcher, PR_TRUE); + if (CommandDispatcher) { + // Take the focus tracker and add it as an event listener for focus and blur events. + AddEventListener("focus", CommandDispatcher, PR_TRUE); + AddEventListener("blur", CommandDispatcher, PR_TRUE); + } } // Get the local store. Yeah, I know. I wish GetService() used a @@ -4934,7 +4944,8 @@ nsXULDocument::CreateElement(nsXULPrototypeElement* aPrototype, nsIContent** aRe // We also need to pay special attention to the keyset tag to set up a listener if ((aPrototype->mNameSpaceID == kNameSpaceID_XUL) && - (aPrototype->mTag.get() == kKeysetAtom)) { + (aPrototype->mTag.get() == kKeysetAtom) && + ! mIsKeyBindingDoc) { // Create our nsXULKeyListener and hook it up. nsCOMPtr keyListener; rv = nsComponentManager::CreateInstance(kXULKeyListenerCID, diff --git a/mozilla/rdf/content/src/nsXULDocument.h b/mozilla/rdf/content/src/nsXULDocument.h index 1da445193e4..093765a173e 100644 --- a/mozilla/rdf/content/src/nsXULDocument.h +++ b/mozilla/rdf/content/src/nsXULDocument.h @@ -289,6 +289,7 @@ public: NS_IMETHOD SetCurrentPrototype(nsIXULPrototypeDocument* aDocument); NS_IMETHOD SetDocumentURL(nsIURI* anURL); NS_IMETHOD PrepareStyleSheets(nsIURI* anURL); + NS_IMETHOD SetIsKeybindingDocument(PRBool aIsKeyBindingDoc); // nsIStreamLoadableDocument interface NS_IMETHOD LoadFromStream(nsIInputStream& xulStream, @@ -507,6 +508,7 @@ protected: nsVoidArray mStyleSheets; nsCOMPtr mSelection; // [OWNER] PRBool mDisplaySelection; + PRBool mIsKeyBindingDoc; nsVoidArray mPresShells; nsCOMPtr mListenerManager; // [OWNER] nsCOMPtr mNameSpaceManager; // [OWNER] diff --git a/mozilla/rdf/content/src/nsXULKeyListener.cpp b/mozilla/rdf/content/src/nsXULKeyListener.cpp index 16aba851d10..2b8da5c8b88 100644 --- a/mozilla/rdf/content/src/nsXULKeyListener.cpp +++ b/mozilla/rdf/content/src/nsXULKeyListener.cpp @@ -6,8 +6,7 @@ * the License at http://www.mozilla.org/NPL/ * * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WA - RRANTY OF ANY KIND, either express or + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or * implied. See the License for the specific language governing * rights and limitations under the License. * @@ -1085,7 +1084,7 @@ NS_IMETHODIMP nsXULKeyListenerImpl::GetKeyBindingDocument(nsCAutoString& aURLStr // We've got a file. Check our key binding file cache. nsIURIKey key(uri); - document = NS_STATIC_CAST(nsIDOMXULDocument*, mKeyBindingTable->Get(&key)); + document = dont_AddRef(NS_STATIC_CAST(nsIDOMXULDocument*, mKeyBindingTable->Get(&key))); if (!document) { LoadKeyBindingDocument(uri, getter_AddRefs(document)); @@ -1112,6 +1111,13 @@ NS_IMETHODIMP nsXULKeyListenerImpl::LoadKeyBindingDocument(nsIURI* aURI, nsIDOMX nsIDOMXULDocument::GetIID(), getter_AddRefs(doc)); + if (NS_FAILED(rv)) return rv; + + nsCOMPtr xulDoc = do_QueryInterface(doc, &rv); + if (NS_FAILED(rv)) return rv; + + xulDoc->SetIsKeybindingDocument(PR_TRUE); + // Now we have to synchronously load the key binding file. // Create a XUL content sink, a parser, and kick off a load for // the overlay. @@ -1132,7 +1138,6 @@ NS_IMETHODIMP nsXULKeyListenerImpl::LoadKeyBindingDocument(nsIURI* aURI, nsIDOMX proto->SetDocumentPrincipal(principal); // Set master and current prototype - nsCOMPtr xulDoc = do_QueryInterface(doc); xulDoc->SetMasterPrototype(proto); xulDoc->SetCurrentPrototype(proto);