From aba17d157e4800a573e1d2a1399a25802460fede Mon Sep 17 00:00:00 2001 From: "hyatt%netscape.com" Date: Wed, 8 Dec 1999 04:56:56 +0000 Subject: [PATCH] Massive rewrite of the key binding system and the command dispatcher. Key bindings are now fully hierarchical. In addition, DOM windows, input fields and textareas can pull their key bindings from a separate XUL file. This allows configurable key bindings. Massive rewrite of the command dispatcher system. The command dispatcher now deals with DOM windows in addition to DOM elements. It now tracks both successfully and works in conjunction with the new focus/blur architecture. r=saari git-svn-id: svn://10.0.0.236/trunk@55718 18797224-902f-48f8-a5cc-f745e15eee43 --- .../xul/document/public/nsIXULDocument.h | 22 + .../document/src/nsXULCommandDispatcher.cpp | 223 ++-- .../xul/document/src/nsXULCommandDispatcher.h | 8 +- .../xul/document/src/nsXULDocument.cpp | 22 +- .../content/xul/document/src/nsXULDocument.h | 9 +- .../public/idl/xul/XULCommandDispatcher.idl | 3 +- .../public/xul/nsIDOMXULCommandDispatcher.h | 47 +- mozilla/dom/public/xul/nsIDOMXULDocument.h | 26 +- mozilla/dom/public/xul/nsIDOMXULElement.h | 26 +- mozilla/dom/public/xul/nsIDOMXULTreeElement.h | 26 +- .../dom/src/xul/nsJSXULCommandDispatcher.cpp | 103 +- mozilla/dom/src/xul/nsJSXULDocument.cpp | 32 +- mozilla/dom/src/xul/nsJSXULElement.cpp | 34 +- mozilla/dom/src/xul/nsJSXULTreeElement.cpp | 54 +- .../public/idl/XULCommandDispatcher.idl | 3 +- .../public/nsIDOMXULCommandDispatcher.h | 47 +- .../rdf/content/public/nsIDOMXULDocument.h | 26 +- .../content/public/nsIDOMXULEditorElement.h | 26 +- mozilla/rdf/content/public/nsIDOMXULElement.h | 26 +- .../rdf/content/public/nsIDOMXULTreeElement.h | 26 +- mozilla/rdf/content/public/nsIXULDocument.h | 22 + .../content/src/nsJSXULCommandDispatcher.cpp | 103 +- mozilla/rdf/content/src/nsJSXULDocument.cpp | 32 +- .../rdf/content/src/nsJSXULEditorElement.cpp | 26 +- mozilla/rdf/content/src/nsJSXULElement.cpp | 34 +- .../rdf/content/src/nsJSXULTreeElement.cpp | 54 +- .../content/src/nsXULCommandDispatcher.cpp | 223 ++-- .../rdf/content/src/nsXULCommandDispatcher.h | 8 +- mozilla/rdf/content/src/nsXULDocument.cpp | 22 +- mozilla/rdf/content/src/nsXULDocument.h | 9 +- mozilla/rdf/content/src/nsXULKeyListener.cpp | 1035 ++++++++++++----- 31 files changed, 1561 insertions(+), 796 deletions(-) diff --git a/mozilla/content/xul/document/public/nsIXULDocument.h b/mozilla/content/xul/document/public/nsIXULDocument.h index 953bf747bd3..973a66db811 100644 --- a/mozilla/content/xul/document/public/nsIXULDocument.h +++ b/mozilla/content/xul/document/public/nsIXULDocument.h @@ -46,6 +46,7 @@ class nsIRDFContentModelBuilder; class nsIRDFResource; class nsISupportsArray; class nsIXULPrototypeDocument; +class nsIURI; // {954F0811-81DC-11d2-B52A-000000000000} #define NS_IRDFDOCUMENT_IID \ @@ -56,6 +57,7 @@ class nsIXULPrototypeDocument; */ class nsIRDFDataSource; +class nsIXULPrototypeDocument; class nsIXULDocument : public nsIXMLDocument { @@ -105,6 +107,26 @@ public: * Resolve the all of the document's forward references. */ NS_IMETHOD ResolveForwardReferences() = 0; + + /** + * Set the master prototype. + */ + NS_IMETHOD SetMasterPrototype(nsIXULPrototypeDocument* aDocument) = 0; + + /** + * Set the current prototype + */ + NS_IMETHOD SetCurrentPrototype(nsIXULPrototypeDocument* aDocument) = 0; + + /** + * Set the doc's URL + */ + NS_IMETHOD SetDocumentURL(nsIURI* aURI) = 0; + + /** + * Load inline and attribute style sheets + */ + NS_IMETHOD PrepareStyleSheets(nsIURI* aURI) = 0; }; // factory functions diff --git a/mozilla/content/xul/document/src/nsXULCommandDispatcher.cpp b/mozilla/content/xul/document/src/nsXULCommandDispatcher.cpp index 4357d4fb2b4..cea17d4a278 100644 --- a/mozilla/content/xul/document/src/nsXULCommandDispatcher.cpp +++ b/mozilla/content/xul/document/src/nsXULCommandDispatcher.cpp @@ -29,6 +29,8 @@ #include "nsIContent.h" #include "nsIControllers.h" #include "nsIDOMDocument.h" +#include "nsIDOMXULDocument.h" +#include "nsIDOMHTMLDocument.h" #include "nsIDOMElement.h" #include "nsIDOMNSHTMLInputElement.h" #include "nsIDOMNSHTMLTextAreaElement.h" @@ -51,7 +53,7 @@ static PRLogModuleInfo* gLog; //////////////////////////////////////////////////////////////////////// nsXULCommandDispatcher::nsXULCommandDispatcher(void) - : mScriptObject(nsnull), mCurrentNode(nsnull), mUpdaters(nsnull) + : mScriptObject(nsnull), mUpdaters(nsnull) { NS_INIT_REFCNT(); @@ -63,11 +65,11 @@ nsXULCommandDispatcher::nsXULCommandDispatcher(void) nsXULCommandDispatcher::~nsXULCommandDispatcher(void) { - while (mUpdaters) { - Updater* doomed = mUpdaters; - mUpdaters = mUpdaters->mNext; - delete doomed; - } + while (mUpdaters) { + Updater* doomed = mUpdaters; + mUpdaters = mUpdaters->mNext; + delete doomed; + } } NS_IMPL_ADDREF(nsXULCommandDispatcher) @@ -120,24 +122,37 @@ nsXULCommandDispatcher::Create(nsIDOMXULCommandDispatcher** aResult) // nsIDOMXULTracker Interface NS_IMETHODIMP -nsXULCommandDispatcher::GetFocusedNode(nsIDOMNode** aNode) +nsXULCommandDispatcher::GetFocusedElement(nsIDOMElement** aElement) { - *aNode = mCurrentNode; - NS_IF_ADDREF(*aNode); + *aElement = mCurrentElement; + NS_IF_ADDREF(*aElement); return NS_OK; } NS_IMETHODIMP -nsXULCommandDispatcher::SetFocusedNode(nsIDOMNode* aNode) +nsXULCommandDispatcher::GetFocusedWindow(nsIDOMWindow** aWindow) { - // XXX On a blur, will need to fire an updatecommands (focus) on the - // parent window. - mCurrentNode = aNode; - if (mCurrentNode) + *aWindow = mCurrentWindow; + NS_IF_ADDREF(*aWindow); + return NS_OK; +} + +NS_IMETHODIMP +nsXULCommandDispatcher::SetFocusedElement(nsIDOMElement* aElement) +{ + mCurrentElement = aElement; + if (mCurrentElement) UpdateCommands(nsAutoString("focus")); return NS_OK; } +NS_IMETHODIMP +nsXULCommandDispatcher::SetFocusedWindow(nsIDOMWindow* aWindow) +{ + mCurrentWindow = aWindow; + return NS_OK; +} + NS_IMETHODIMP nsXULCommandDispatcher::AddCommandUpdater(nsIDOMElement* aElement, const nsString& aEvents, @@ -224,13 +239,12 @@ nsXULCommandDispatcher::UpdateCommands(const nsString& aEventName) nsresult rv; nsAutoString id; - nsCOMPtr element = do_QueryInterface(mCurrentNode); - if (element) { - rv = element->GetAttribute(nsAutoString("id"), id); + if (mCurrentElement) { + rv = mCurrentElement->GetAttribute(nsAutoString("id"), id); NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get element's id"); if (NS_FAILED(rv)) return rv; } - + for (Updater* updater = mUpdaters; updater != nsnull; updater = updater->mNext) { // Skip any nodes that don't match our 'events' or 'targets' // filters. @@ -286,20 +300,21 @@ nsXULCommandDispatcher::GetControllers(nsIControllers** aResult) { //XXX: we should fix this so there's a generic interface that describes controllers, // so this code would have no special knowledge of what object might have controllers. - if (mCurrentNode) { - nsCOMPtr xulElement = do_QueryInterface(mCurrentNode); + if (mCurrentElement) { + nsCOMPtr xulElement = do_QueryInterface(mCurrentElement); if (xulElement) return xulElement->GetControllers(aResult); - nsCOMPtr htmlTextArea = do_QueryInterface(mCurrentNode); + nsCOMPtr htmlTextArea = do_QueryInterface(mCurrentElement); if (htmlTextArea) return htmlTextArea->GetControllers(aResult); - nsCOMPtr htmlInputElement = do_QueryInterface(mCurrentNode); + nsCOMPtr htmlInputElement = do_QueryInterface(mCurrentElement); if (htmlInputElement) return htmlInputElement->GetControllers(aResult); - - nsCOMPtr domWindow = do_QueryInterface(mCurrentNode); + } + else if (mCurrentWindow) { + nsCOMPtr domWindow = do_QueryInterface(mCurrentWindow); if (domWindow) return domWindow->GetControllers(aResult); } @@ -318,10 +333,40 @@ nsXULCommandDispatcher::Focus(nsIDOMEvent* aEvent) nsCOMPtr t; aEvent->GetTarget(getter_AddRefs(t)); - // XXX: Bad fix - nsCOMPtr element = do_QueryInterface(t); - if(element) { - SetFocusedNode(t); +/* + printf("%d : Focus occurred on: ", this); + nsCOMPtr domDebugElement = do_QueryInterface(t); + if (domDebugElement) { + printf("A Focusable DOM Element"); + } + nsCOMPtr domDebugDocument = do_QueryInterface(t); + if (domDebugDocument) { + nsCOMPtr htmlDoc = do_QueryInterface(t); + if (htmlDoc) { + printf("Window with an HTML doc (happens twice)"); + } + else printf("Window with a XUL doc (happens twice)"); + } + printf("\n"); +*/ + + nsCOMPtr domElement = do_QueryInterface(t); + if (domElement && (domElement != mCurrentElement)) { + SetFocusedElement(domElement); + } + else { + // We're focusing a window. We only want to do an update commands + // if no element is focused. + nsCOMPtr domWindow; + nsCOMPtr domDoc = do_QueryInterface(t); + if (domDoc) { + GetParentWindowFromDocument(domDoc, getter_AddRefs(domWindow)); + if (domWindow && (domWindow != mCurrentWindow)) { + SetFocusedWindow(domWindow); + if (!mCurrentElement) + UpdateCommands(nsAutoString("focus")); + } + } } return NS_OK; @@ -332,8 +377,35 @@ nsXULCommandDispatcher::Blur(nsIDOMEvent* aEvent) { nsCOMPtr t; aEvent->GetTarget(getter_AddRefs(t)); - if( t == mCurrentNode ) { - SetFocusedNode(nsnull); + +/* + printf("%d : Blur occurred on: ", this); + nsCOMPtr domDebugElement = do_QueryInterface(t); + if (domDebugElement) { + printf("A Focusable DOM Element"); + } + nsCOMPtr domDebugDocument = do_QueryInterface(t); + if (domDebugDocument) { + nsCOMPtr htmlDoc = do_QueryInterface(t); + if (htmlDoc) { + printf("Window with an HTML doc (happens twice)"); + } + else printf("Window with a XUL doc (happens twice)"); + } + printf("\n"); +*/ + + nsCOMPtr domElement = do_QueryInterface(t); + if (domElement) { + SetFocusedElement(nsnull); + } + + nsCOMPtr domWindow; + nsCOMPtr domDoc = do_QueryInterface(t); + if (domDoc) { + GetParentWindowFromDocument(domDoc, getter_AddRefs(domWindow)); + if (domWindow) + SetFocusedWindow(nsnull); } return NS_OK; @@ -393,25 +465,19 @@ nsXULCommandDispatcher::Matches(const nsString& aList, const nsString& aElement) } -NS_IMETHODIMP -nsXULCommandDispatcher::GetParentWindowFromElement(nsIDOMElement* aElement, nsPIDOMWindow** aPWindow) +nsresult +nsXULCommandDispatcher::GetParentWindowFromDocument(nsIDOMDocument* aDocument, nsIDOMWindow** aWindow) { - nsCOMPtr document; - aElement->GetOwnerDocument(getter_AddRefs(document)); - if(!document) return NS_OK; - - nsCOMPtr objectOwner = do_QueryInterface(document); + nsCOMPtr objectOwner = do_QueryInterface(aDocument); if(!objectOwner) return NS_OK; nsCOMPtr globalObject; objectOwner->GetScriptGlobalObject(getter_AddRefs(globalObject)); if(!globalObject) return NS_OK; - nsCOMPtr privateDOMWindow = do_QueryInterface(globalObject); - if(!privateDOMWindow) return NS_OK; - - privateDOMWindow->GetPrivateParent(aPWindow); - + nsCOMPtr domWindow = do_QueryInterface(globalObject); + *aWindow = domWindow; + NS_IF_ADDREF(*aWindow); return NS_OK; } @@ -423,46 +489,47 @@ nsXULCommandDispatcher::GetControllerForCommand(const nsString& command, nsICont nsCOMPtr controllers; GetControllers(getter_AddRefs(controllers)); if(controllers) { - nsCOMPtr controller; - controllers->GetControllerForCommand(command.GetUnicode(), getter_AddRefs(controller)); - if(controller) { + nsCOMPtr controller; + controllers->GetControllerForCommand(command.GetUnicode(), getter_AddRefs(controller)); + if(controller) { + *_retval = controller; + NS_ADDREF(*_retval); + return NS_OK; + } + } + + nsCOMPtr currentWindow; + if (mCurrentElement) { + // Move up to the window. + nsCOMPtr domDoc; + mCurrentElement->GetOwnerDocument(getter_AddRefs(domDoc)); + nsCOMPtr domWindow; + GetParentWindowFromDocument(domDoc, getter_AddRefs(domWindow)); + currentWindow = do_QueryInterface(domWindow); + } + else if (mCurrentWindow) { + nsCOMPtr privateWin = do_QueryInterface(mCurrentWindow); + privateWin->GetPrivateParent(getter_AddRefs(currentWindow)); + } + else return NS_OK; + + while(currentWindow) { + nsCOMPtr domWindow = do_QueryInterface(currentWindow); + if(domWindow) { + nsCOMPtr controllers2; + domWindow->GetControllers(getter_AddRefs(controllers2)); + if(controllers2) { + nsCOMPtr controller; + controllers2->GetControllerForCommand(command.GetUnicode(), getter_AddRefs(controller)); + if(controller) { *_retval = controller; NS_ADDREF(*_retval); return NS_OK; + } } - } - - if(!mCurrentNode) return NS_OK; - - nsCOMPtr currentWindow; - - nsCOMPtr element = do_QueryInterface(mCurrentNode); - if(element) { - GetParentWindowFromElement(element, getter_AddRefs(currentWindow)); - } else { - nsCOMPtr window = do_QueryInterface(mCurrentNode); - if(!window) return NS_OK; - - window->GetPrivateParent(getter_AddRefs(currentWindow)); - } - - while(currentWindow) { - nsCOMPtr domWindow = do_QueryInterface(currentWindow); - if(domWindow) { - nsCOMPtr controllers2; - domWindow->GetControllers(getter_AddRefs(controllers2)); - if(controllers2) { - nsCOMPtr controller; - controllers2->GetControllerForCommand(command.GetUnicode(), getter_AddRefs(controller)); - if(controller) { - *_retval = controller; - NS_ADDREF(*_retval); - return NS_OK; - } - } - } - nsCOMPtr parentPWindow = currentWindow; - parentPWindow->GetPrivateParent(getter_AddRefs(currentWindow)); + } + nsCOMPtr parentPWindow = currentWindow; + parentPWindow->GetPrivateParent(getter_AddRefs(currentWindow)); } return NS_OK; diff --git a/mozilla/content/xul/document/src/nsXULCommandDispatcher.h b/mozilla/content/xul/document/src/nsXULCommandDispatcher.h index 39438250ecb..bc850314c9a 100644 --- a/mozilla/content/xul/document/src/nsXULCommandDispatcher.h +++ b/mozilla/content/xul/document/src/nsXULCommandDispatcher.h @@ -73,15 +73,17 @@ public: NS_IMETHOD GetScriptObject(nsIScriptContext *aContext, void** aScriptObject); NS_IMETHOD SetScriptObject(void *aScriptObject); -protected: - NS_IMETHOD GetParentWindowFromElement(nsIDOMElement* aElement, nsPIDOMWindow** aPWindow); +public: + static nsresult GetParentWindowFromDocument(nsIDOMDocument* aElement, nsIDOMWindow** aWindow); +protected: void* mScriptObject; // ???? // XXX THis was supposed to be WEAK, but c'mon, that's an accident // waiting to happen! If somebody deletes the node, then asks us // for the focus, we'll get killed! - nsCOMPtr mCurrentNode; // [OWNER] + nsCOMPtr mCurrentElement; // [OWNER] + nsCOMPtr mCurrentWindow; // [OWNER] class Updater { public: diff --git a/mozilla/content/xul/document/src/nsXULDocument.cpp b/mozilla/content/xul/document/src/nsXULDocument.cpp index fb9f140a826..a63878b170d 100644 --- a/mozilla/content/xul/document/src/nsXULDocument.cpp +++ b/mozilla/content/xul/document/src/nsXULDocument.cpp @@ -601,11 +601,11 @@ nsXULDocument::PrepareStyleSheets(nsIURI* anURL) return NS_OK; } -void -nsXULDocument::SetDocumentURLAndGroup(nsIURI* anURL) +NS_IMETHODIMP +nsXULDocument::SetDocumentURL(nsIURI* anURL) { mDocumentURL = dont_QueryInterface(anURL); - // XXX help + return NS_OK; } NS_IMETHODIMP @@ -2021,6 +2021,19 @@ nsXULDocument::ResolveForwardReferences() return NS_OK; } +NS_IMETHODIMP +nsXULDocument::SetMasterPrototype(nsIXULPrototypeDocument* aDocument) +{ + mMasterPrototype = aDocument; + return NS_OK; +} + +NS_IMETHODIMP +nsXULDocument::SetCurrentPrototype(nsIXULPrototypeDocument* aDocument) +{ + mCurrentPrototype = aDocument; + return NS_OK; +} //---------------------------------------------------------------------- // @@ -4360,8 +4373,7 @@ nsXULDocument::PrepareToWalk() if (NS_FAILED(rv)) return rv; nsCOMPtr group = do_QueryReferent(mDocumentLoadGroup); - NS_ASSERTION(group != nsnull, "no load group"); - + if (group) { rv = mPlaceholderChannel->SetLoadGroup(group); if (NS_FAILED(rv)) return rv; diff --git a/mozilla/content/xul/document/src/nsXULDocument.h b/mozilla/content/xul/document/src/nsXULDocument.h index 1bfb50ddca9..1da445193e4 100644 --- a/mozilla/content/xul/document/src/nsXULDocument.h +++ b/mozilla/content/xul/document/src/nsXULDocument.h @@ -285,7 +285,11 @@ public: NS_IMETHOD SetForm(nsIDOMHTMLFormElement* aForm); NS_IMETHOD AddForwardReference(nsForwardReference* aRef); NS_IMETHOD ResolveForwardReferences(); - + NS_IMETHOD SetMasterPrototype(nsIXULPrototypeDocument* aDocument); + NS_IMETHOD SetCurrentPrototype(nsIXULPrototypeDocument* aDocument); + NS_IMETHOD SetDocumentURL(nsIURI* anURL); + NS_IMETHOD PrepareStyleSheets(nsIURI* anURL); + // nsIStreamLoadableDocument interface NS_IMETHOD LoadFromStream(nsIInputStream& xulStream, nsISupports* aContainer, @@ -413,9 +417,6 @@ protected: nsresult ParseTagString(const nsString& aTagName, nsIAtom*& aName, PRInt32& aNameSpaceID); - NS_IMETHOD PrepareStyleSheets(nsIURI* anURL); - - void SetDocumentURLAndGroup(nsIURI* anURL); void SetIsPopup(PRBool isPopup) { mIsPopup = isPopup; }; nsresult CreateElement(PRInt32 aNameSpaceID, diff --git a/mozilla/dom/public/idl/xul/XULCommandDispatcher.idl b/mozilla/dom/public/idl/xul/XULCommandDispatcher.idl index cf74b8e76d9..d985b0b9d6d 100644 --- a/mozilla/dom/public/idl/xul/XULCommandDispatcher.idl +++ b/mozilla/dom/public/idl/xul/XULCommandDispatcher.idl @@ -3,7 +3,8 @@ interface XULCommandDispatcher { /* IID: { 0xf3c50361, 0x14fe, 0x11d3, \ { 0xbf, 0x87, 0x0, 0x10, 0x5a, 0x1b, 0x6, 0x27 } } */ - attribute Node focusedNode; + attribute Element focusedElement; + attribute Window focusedWindow; void addCommandUpdater(in Element updater, in DOMString events, in DOMString targets); void removeCommandUpdater(in Element updater); diff --git a/mozilla/dom/public/xul/nsIDOMXULCommandDispatcher.h b/mozilla/dom/public/xul/nsIDOMXULCommandDispatcher.h index 93864e44fb4..a188c55ad9e 100644 --- a/mozilla/dom/public/xul/nsIDOMXULCommandDispatcher.h +++ b/mozilla/dom/public/xul/nsIDOMXULCommandDispatcher.h @@ -1,19 +1,23 @@ /* -*- Mode: C++; tab-width: 2; 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/ + * The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License 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. + * Software distributed under the License is distributed on an "AS + * 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. * - * The Initial Developer of this code under the NPL is Netscape + * The Original Code is mozilla.org code. + * + * The Initial Developer of the Original Code is Netscape * Communications Corporation. Portions created by Netscape are - * Copyright (C) 1998 Netscape Communications Corporation. All Rights - * Reserved. + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): */ /* AUTO-GENERATED. DO NOT EDIT!!! */ @@ -26,7 +30,7 @@ class nsIController; class nsIDOMElement; -class nsIDOMNode; +class nsIDOMWindow; class nsIControllers; #define NS_IDOMXULCOMMANDDISPATCHER_IID \ @@ -37,8 +41,11 @@ class nsIDOMXULCommandDispatcher : public nsISupports { public: static const nsIID& GetIID() { static nsIID iid = NS_IDOMXULCOMMANDDISPATCHER_IID; return iid; } - NS_IMETHOD GetFocusedNode(nsIDOMNode** aFocusedNode)=0; - NS_IMETHOD SetFocusedNode(nsIDOMNode* aFocusedNode)=0; + NS_IMETHOD GetFocusedElement(nsIDOMElement** aFocusedElement)=0; + NS_IMETHOD SetFocusedElement(nsIDOMElement* aFocusedElement)=0; + + NS_IMETHOD GetFocusedWindow(nsIDOMWindow** aFocusedWindow)=0; + NS_IMETHOD SetFocusedWindow(nsIDOMWindow* aFocusedWindow)=0; NS_IMETHOD AddCommandUpdater(nsIDOMElement* aUpdater, const nsString& aEvents, const nsString& aTargets)=0; @@ -53,8 +60,10 @@ public: #define NS_DECL_IDOMXULCOMMANDDISPATCHER \ - NS_IMETHOD GetFocusedNode(nsIDOMNode** aFocusedNode); \ - NS_IMETHOD SetFocusedNode(nsIDOMNode* aFocusedNode); \ + NS_IMETHOD GetFocusedElement(nsIDOMElement** aFocusedElement); \ + NS_IMETHOD SetFocusedElement(nsIDOMElement* aFocusedElement); \ + NS_IMETHOD GetFocusedWindow(nsIDOMWindow** aFocusedWindow); \ + NS_IMETHOD SetFocusedWindow(nsIDOMWindow* aFocusedWindow); \ NS_IMETHOD AddCommandUpdater(nsIDOMElement* aUpdater, const nsString& aEvents, const nsString& aTargets); \ NS_IMETHOD RemoveCommandUpdater(nsIDOMElement* aUpdater); \ NS_IMETHOD UpdateCommands(const nsString& aEventName); \ @@ -64,8 +73,10 @@ public: #define NS_FORWARD_IDOMXULCOMMANDDISPATCHER(_to) \ - NS_IMETHOD GetFocusedNode(nsIDOMNode** aFocusedNode) { return _to GetFocusedNode(aFocusedNode); } \ - NS_IMETHOD SetFocusedNode(nsIDOMNode* aFocusedNode) { return _to SetFocusedNode(aFocusedNode); } \ + NS_IMETHOD GetFocusedElement(nsIDOMElement** aFocusedElement) { return _to GetFocusedElement(aFocusedElement); } \ + NS_IMETHOD SetFocusedElement(nsIDOMElement* aFocusedElement) { return _to SetFocusedElement(aFocusedElement); } \ + NS_IMETHOD GetFocusedWindow(nsIDOMWindow** aFocusedWindow) { return _to GetFocusedWindow(aFocusedWindow); } \ + NS_IMETHOD SetFocusedWindow(nsIDOMWindow* aFocusedWindow) { return _to SetFocusedWindow(aFocusedWindow); } \ NS_IMETHOD AddCommandUpdater(nsIDOMElement* aUpdater, const nsString& aEvents, const nsString& aTargets) { return _to AddCommandUpdater(aUpdater, aEvents, aTargets); } \ NS_IMETHOD RemoveCommandUpdater(nsIDOMElement* aUpdater) { return _to RemoveCommandUpdater(aUpdater); } \ NS_IMETHOD UpdateCommands(const nsString& aEventName) { return _to UpdateCommands(aEventName); } \ diff --git a/mozilla/dom/public/xul/nsIDOMXULDocument.h b/mozilla/dom/public/xul/nsIDOMXULDocument.h index 09d3ed86bb1..f88879301a7 100644 --- a/mozilla/dom/public/xul/nsIDOMXULDocument.h +++ b/mozilla/dom/public/xul/nsIDOMXULDocument.h @@ -1,19 +1,23 @@ /* -*- Mode: C++; tab-width: 2; 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/ + * The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License 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. + * Software distributed under the License is distributed on an "AS + * 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. * - * The Initial Developer of this code under the NPL is Netscape + * The Original Code is mozilla.org code. + * + * The Initial Developer of the Original Code is Netscape * Communications Corporation. Portions created by Netscape are - * Copyright (C) 1998 Netscape Communications Corporation. All Rights - * Reserved. + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): */ /* AUTO-GENERATED. DO NOT EDIT!!! */ diff --git a/mozilla/dom/public/xul/nsIDOMXULElement.h b/mozilla/dom/public/xul/nsIDOMXULElement.h index 987b4c9bde8..6cf47fee4f8 100644 --- a/mozilla/dom/public/xul/nsIDOMXULElement.h +++ b/mozilla/dom/public/xul/nsIDOMXULElement.h @@ -1,19 +1,23 @@ /* -*- Mode: C++; tab-width: 2; 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/ + * The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License 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. + * Software distributed under the License is distributed on an "AS + * 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. * - * The Initial Developer of this code under the NPL is Netscape + * The Original Code is mozilla.org code. + * + * The Initial Developer of the Original Code is Netscape * Communications Corporation. Portions created by Netscape are - * Copyright (C) 1998 Netscape Communications Corporation. All Rights - * Reserved. + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): */ /* AUTO-GENERATED. DO NOT EDIT!!! */ diff --git a/mozilla/dom/public/xul/nsIDOMXULTreeElement.h b/mozilla/dom/public/xul/nsIDOMXULTreeElement.h index 1c5f6eb63a9..6691e834ca9 100644 --- a/mozilla/dom/public/xul/nsIDOMXULTreeElement.h +++ b/mozilla/dom/public/xul/nsIDOMXULTreeElement.h @@ -1,19 +1,23 @@ /* -*- Mode: C++; tab-width: 2; 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/ + * The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License 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. + * Software distributed under the License is distributed on an "AS + * 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. * - * The Initial Developer of this code under the NPL is Netscape + * The Original Code is mozilla.org code. + * + * The Initial Developer of the Original Code is Netscape * Communications Corporation. Portions created by Netscape are - * Copyright (C) 1998 Netscape Communications Corporation. All Rights - * Reserved. + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): */ /* AUTO-GENERATED. DO NOT EDIT!!! */ diff --git a/mozilla/dom/src/xul/nsJSXULCommandDispatcher.cpp b/mozilla/dom/src/xul/nsJSXULCommandDispatcher.cpp index 1a736702bd0..aa8c24d4716 100644 --- a/mozilla/dom/src/xul/nsJSXULCommandDispatcher.cpp +++ b/mozilla/dom/src/xul/nsJSXULCommandDispatcher.cpp @@ -1,19 +1,23 @@ /* -*- Mode: C++; tab-width: 2; 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/ + * The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License 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. + * Software distributed under the License is distributed on an "AS + * 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. * - * The Initial Developer of this code under the NPL is Netscape + * The Original Code is mozilla.org code. + * + * The Initial Developer of the Original Code is Netscape * Communications Corporation. Portions created by Netscape are - * Copyright (C) 1998 Netscape Communications Corporation. All Rights - * Reserved. + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): */ /* AUTO-GENERATED. DO NOT EDIT!!! */ @@ -32,8 +36,8 @@ #include "nsString.h" #include "nsIController.h" #include "nsIDOMElement.h" -#include "nsIDOMNode.h" #include "nsIDOMXULCommandDispatcher.h" +#include "nsIDOMWindow.h" #include "nsIControllers.h" @@ -42,21 +46,22 @@ static NS_DEFINE_IID(kIJSScriptObjectIID, NS_IJSSCRIPTOBJECT_IID); static NS_DEFINE_IID(kIScriptGlobalObjectIID, NS_ISCRIPTGLOBALOBJECT_IID); static NS_DEFINE_IID(kIControllerIID, NS_ICONTROLLER_IID); static NS_DEFINE_IID(kIElementIID, NS_IDOMELEMENT_IID); -static NS_DEFINE_IID(kINodeIID, NS_IDOMNODE_IID); static NS_DEFINE_IID(kIXULCommandDispatcherIID, NS_IDOMXULCOMMANDDISPATCHER_IID); +static NS_DEFINE_IID(kIWindowIID, NS_IDOMWINDOW_IID); static NS_DEFINE_IID(kIControllersIID, NS_ICONTROLLERS_IID); NS_DEF_PTR(nsIController); NS_DEF_PTR(nsIDOMElement); -NS_DEF_PTR(nsIDOMNode); NS_DEF_PTR(nsIDOMXULCommandDispatcher); +NS_DEF_PTR(nsIDOMWindow); NS_DEF_PTR(nsIControllers); // // XULCommandDispatcher property ids // enum XULCommandDispatcher_slots { - XULCOMMANDDISPATCHER_FOCUSEDNODE = -1 + XULCOMMANDDISPATCHER_FOCUSEDELEMENT = -1, + XULCOMMANDDISPATCHER_FOCUSEDWINDOW = -2 }; /***********************************************************************/ @@ -80,16 +85,35 @@ GetXULCommandDispatcherProperty(JSContext *cx, JSObject *obj, jsval id, jsval *v return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_SECMAN_ERR); } switch(JSVAL_TO_INT(id)) { - case XULCOMMANDDISPATCHER_FOCUSEDNODE: + case XULCOMMANDDISPATCHER_FOCUSEDELEMENT: { PRBool ok = PR_FALSE; - secMan->CheckScriptAccess(scriptCX, obj, NS_DOM_PROP_XULCOMMANDDISPATCHER_FOCUSEDNODE, PR_FALSE, &ok); + secMan->CheckScriptAccess(scriptCX, obj, NS_DOM_PROP_XULCOMMANDDISPATCHER_FOCUSEDELEMENT, PR_FALSE, &ok); if (!ok) { return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_SECURITY_ERR); } - nsIDOMNode* prop; + nsIDOMElement* prop; nsresult result = NS_OK; - result = a->GetFocusedNode(&prop); + result = a->GetFocusedElement(&prop); + if (NS_SUCCEEDED(result)) { + // get the js object + nsJSUtils::nsConvertObjectToJSVal((nsISupports *)prop, cx, vp); + } + else { + return nsJSUtils::nsReportError(cx, result); + } + break; + } + case XULCOMMANDDISPATCHER_FOCUSEDWINDOW: + { + PRBool ok = PR_FALSE; + secMan->CheckScriptAccess(scriptCX, obj, NS_DOM_PROP_XULCOMMANDDISPATCHER_FOCUSEDWINDOW, PR_FALSE, &ok); + if (!ok) { + return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_SECURITY_ERR); + } + nsIDOMWindow* prop; + nsresult result = NS_OK; + result = a->GetFocusedWindow(&prop); if (NS_SUCCEEDED(result)) { // get the js object nsJSUtils::nsConvertObjectToJSVal((nsISupports *)prop, cx, vp); @@ -131,21 +155,39 @@ SetXULCommandDispatcherProperty(JSContext *cx, JSObject *obj, jsval id, jsval *v return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_SECMAN_ERR); } switch(JSVAL_TO_INT(id)) { - case XULCOMMANDDISPATCHER_FOCUSEDNODE: + case XULCOMMANDDISPATCHER_FOCUSEDELEMENT: { PRBool ok = PR_FALSE; - secMan->CheckScriptAccess(scriptCX, obj, NS_DOM_PROP_XULCOMMANDDISPATCHER_FOCUSEDNODE, PR_TRUE, &ok); + secMan->CheckScriptAccess(scriptCX, obj, NS_DOM_PROP_XULCOMMANDDISPATCHER_FOCUSEDELEMENT, PR_TRUE, &ok); if (!ok) { return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_SECURITY_ERR); } - nsIDOMNode* prop; + nsIDOMElement* prop; if (PR_FALSE == nsJSUtils::nsConvertJSValToObject((nsISupports **)&prop, - kINodeIID, "Node", + kIElementIID, "Element", cx, *vp)) { return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_NOT_OBJECT_ERR); } - a->SetFocusedNode(prop); + a->SetFocusedElement(prop); + NS_IF_RELEASE(prop); + break; + } + case XULCOMMANDDISPATCHER_FOCUSEDWINDOW: + { + PRBool ok = PR_FALSE; + secMan->CheckScriptAccess(scriptCX, obj, NS_DOM_PROP_XULCOMMANDDISPATCHER_FOCUSEDWINDOW, PR_TRUE, &ok); + if (!ok) { + return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_SECURITY_ERR); + } + nsIDOMWindow* prop; + if (PR_FALSE == nsJSUtils::nsConvertJSValToObject((nsISupports **)&prop, + kIWindowIID, "Window", + cx, *vp)) { + return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_NOT_OBJECT_ERR); + } + + a->SetFocusedWindow(prop); NS_IF_RELEASE(prop); break; } @@ -212,7 +254,7 @@ XULCommandDispatcherAddCommandUpdater(JSContext *cx, JSObject *obj, uintN argc, } { PRBool ok; - secMan->CheckScriptAccess(scriptCX, obj, NS_DOM_PROP_XULCOMMANDDISPATCHER_ADDCOMMANDUPDATER,PR_FALSE , &ok); + secMan->CheckScriptAccess(scriptCX, obj, NS_DOM_PROP_XULCOMMANDDISPATCHER_ADDCOMMANDUPDATER, PR_FALSE, &ok); if (!ok) { return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_SECURITY_ERR); } @@ -269,7 +311,7 @@ XULCommandDispatcherRemoveCommandUpdater(JSContext *cx, JSObject *obj, uintN arg } { PRBool ok; - secMan->CheckScriptAccess(scriptCX, obj, NS_DOM_PROP_XULCOMMANDDISPATCHER_REMOVECOMMANDUPDATER,PR_FALSE , &ok); + secMan->CheckScriptAccess(scriptCX, obj, NS_DOM_PROP_XULCOMMANDDISPATCHER_REMOVECOMMANDUPDATER, PR_FALSE, &ok); if (!ok) { return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_SECURITY_ERR); } @@ -324,7 +366,7 @@ XULCommandDispatcherUpdateCommands(JSContext *cx, JSObject *obj, uintN argc, jsv } { PRBool ok; - secMan->CheckScriptAccess(scriptCX, obj, NS_DOM_PROP_XULCOMMANDDISPATCHER_UPDATECOMMANDS,PR_FALSE , &ok); + secMan->CheckScriptAccess(scriptCX, obj, NS_DOM_PROP_XULCOMMANDDISPATCHER_UPDATECOMMANDS, PR_FALSE, &ok); if (!ok) { return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_SECURITY_ERR); } @@ -374,7 +416,7 @@ XULCommandDispatcherGetControllerForCommand(JSContext *cx, JSObject *obj, uintN } { PRBool ok; - secMan->CheckScriptAccess(scriptCX, obj, NS_DOM_PROP_XULCOMMANDDISPATCHER_GETCONTROLLERFORCOMMAND,PR_FALSE , &ok); + secMan->CheckScriptAccess(scriptCX, obj, NS_DOM_PROP_XULCOMMANDDISPATCHER_GETCONTROLLERFORCOMMAND, PR_FALSE, &ok); if (!ok) { return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_SECURITY_ERR); } @@ -424,7 +466,7 @@ XULCommandDispatcherGetControllers(JSContext *cx, JSObject *obj, uintN argc, jsv } { PRBool ok; - secMan->CheckScriptAccess(scriptCX, obj, NS_DOM_PROP_XULCOMMANDDISPATCHER_GETCONTROLLERS,PR_FALSE , &ok); + secMan->CheckScriptAccess(scriptCX, obj, NS_DOM_PROP_XULCOMMANDDISPATCHER_GETCONTROLLERS, PR_FALSE, &ok); if (!ok) { return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_SECURITY_ERR); } @@ -473,7 +515,8 @@ JSClass XULCommandDispatcherClass = { // static JSPropertySpec XULCommandDispatcherProperties[] = { - {"focusedNode", XULCOMMANDDISPATCHER_FOCUSEDNODE, JSPROP_ENUMERATE}, + {"focusedElement", XULCOMMANDDISPATCHER_FOCUSEDELEMENT, JSPROP_ENUMERATE}, + {"focusedWindow", XULCOMMANDDISPATCHER_FOCUSEDWINDOW, JSPROP_ENUMERATE}, {0} }; diff --git a/mozilla/dom/src/xul/nsJSXULDocument.cpp b/mozilla/dom/src/xul/nsJSXULDocument.cpp index 1a5fffc02a6..db84f7e3c22 100644 --- a/mozilla/dom/src/xul/nsJSXULDocument.cpp +++ b/mozilla/dom/src/xul/nsJSXULDocument.cpp @@ -1,19 +1,23 @@ /* -*- Mode: C++; tab-width: 2; 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/ + * The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License 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. + * Software distributed under the License is distributed on an "AS + * 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. * - * The Initial Developer of this code under the NPL is Netscape + * The Original Code is mozilla.org code. + * + * The Initial Developer of the Original Code is Netscape * Communications Corporation. Portions created by Netscape are - * Copyright (C) 1998 Netscape Communications Corporation. All Rights - * Reserved. + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): */ /* AUTO-GENERATED. DO NOT EDIT!!! */ @@ -269,7 +273,7 @@ XULDocumentGetElementById(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, } { PRBool ok; - secMan->CheckScriptAccess(scriptCX, obj, NS_DOM_PROP_XULDOCUMENT_GETELEMENTBYID,PR_FALSE , &ok); + secMan->CheckScriptAccess(scriptCX, obj, NS_DOM_PROP_XULDOCUMENT_GETELEMENTBYID, PR_FALSE, &ok); if (!ok) { return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_SECURITY_ERR); } @@ -320,7 +324,7 @@ XULDocumentGetElementsByAttribute(JSContext *cx, JSObject *obj, uintN argc, jsva } { PRBool ok; - secMan->CheckScriptAccess(scriptCX, obj, NS_DOM_PROP_XULDOCUMENT_GETELEMENTSBYATTRIBUTE,PR_FALSE , &ok); + secMan->CheckScriptAccess(scriptCX, obj, NS_DOM_PROP_XULDOCUMENT_GETELEMENTSBYATTRIBUTE, PR_FALSE, &ok); if (!ok) { return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_SECURITY_ERR); } @@ -371,7 +375,7 @@ XULDocumentPersist(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval } { PRBool ok; - secMan->CheckScriptAccess(scriptCX, obj, NS_DOM_PROP_XULDOCUMENT_PERSIST,PR_FALSE , &ok); + secMan->CheckScriptAccess(scriptCX, obj, NS_DOM_PROP_XULDOCUMENT_PERSIST, PR_FALSE, &ok); if (!ok) { return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_SECURITY_ERR); } diff --git a/mozilla/dom/src/xul/nsJSXULElement.cpp b/mozilla/dom/src/xul/nsJSXULElement.cpp index 720d863d2a9..51bd30107e6 100644 --- a/mozilla/dom/src/xul/nsJSXULElement.cpp +++ b/mozilla/dom/src/xul/nsJSXULElement.cpp @@ -1,19 +1,23 @@ /* -*- Mode: C++; tab-width: 2; 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/ + * The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License 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. + * Software distributed under the License is distributed on an "AS + * 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. * - * The Initial Developer of this code under the NPL is Netscape + * The Original Code is mozilla.org code. + * + * The Initial Developer of the Original Code is Netscape * Communications Corporation. Portions created by Netscape are - * Copyright (C) 1998 Netscape Communications Corporation. All Rights - * Reserved. + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): */ /* AUTO-GENERATED. DO NOT EDIT!!! */ @@ -342,7 +346,7 @@ XULElementAddBroadcastListener(JSContext *cx, JSObject *obj, uintN argc, jsval * } { PRBool ok; - secMan->CheckScriptAccess(scriptCX, obj, NS_DOM_PROP_XULELEMENT_ADDBROADCASTLISTENER,PR_FALSE , &ok); + secMan->CheckScriptAccess(scriptCX, obj, NS_DOM_PROP_XULELEMENT_ADDBROADCASTLISTENER, PR_FALSE, &ok); if (!ok) { return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_SECURITY_ERR); } @@ -399,7 +403,7 @@ XULElementRemoveBroadcastListener(JSContext *cx, JSObject *obj, uintN argc, jsva } { PRBool ok; - secMan->CheckScriptAccess(scriptCX, obj, NS_DOM_PROP_XULELEMENT_REMOVEBROADCASTLISTENER,PR_FALSE , &ok); + secMan->CheckScriptAccess(scriptCX, obj, NS_DOM_PROP_XULELEMENT_REMOVEBROADCASTLISTENER, PR_FALSE, &ok); if (!ok) { return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_SECURITY_ERR); } @@ -454,7 +458,7 @@ XULElementDoCommand(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval } { PRBool ok; - secMan->CheckScriptAccess(scriptCX, obj, NS_DOM_PROP_XULELEMENT_DOCOMMAND,PR_FALSE , &ok); + secMan->CheckScriptAccess(scriptCX, obj, NS_DOM_PROP_XULELEMENT_DOCOMMAND, PR_FALSE, &ok); if (!ok) { return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_SECURITY_ERR); } @@ -500,7 +504,7 @@ XULElementGetElementsByAttribute(JSContext *cx, JSObject *obj, uintN argc, jsval } { PRBool ok; - secMan->CheckScriptAccess(scriptCX, obj, NS_DOM_PROP_XULELEMENT_GETELEMENTSBYATTRIBUTE,PR_FALSE , &ok); + secMan->CheckScriptAccess(scriptCX, obj, NS_DOM_PROP_XULELEMENT_GETELEMENTSBYATTRIBUTE, PR_FALSE, &ok); if (!ok) { return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_SECURITY_ERR); } diff --git a/mozilla/dom/src/xul/nsJSXULTreeElement.cpp b/mozilla/dom/src/xul/nsJSXULTreeElement.cpp index d451997cd58..9a8a426a793 100644 --- a/mozilla/dom/src/xul/nsJSXULTreeElement.cpp +++ b/mozilla/dom/src/xul/nsJSXULTreeElement.cpp @@ -1,19 +1,23 @@ /* -*- Mode: C++; tab-width: 2; 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/ + * The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License 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. + * Software distributed under the License is distributed on an "AS + * 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. * - * The Initial Developer of this code under the NPL is Netscape + * The Original Code is mozilla.org code. + * + * The Initial Developer of the Original Code is Netscape * Communications Corporation. Portions created by Netscape are - * Copyright (C) 1998 Netscape Communications Corporation. All Rights - * Reserved. + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): */ /* AUTO-GENERATED. DO NOT EDIT!!! */ @@ -207,7 +211,7 @@ XULTreeElementSelectItem(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, } { PRBool ok; - secMan->CheckScriptAccess(scriptCX, obj, NS_DOM_PROP_XULTREEELEMENT_SELECTITEM,PR_FALSE , &ok); + secMan->CheckScriptAccess(scriptCX, obj, NS_DOM_PROP_XULTREEELEMENT_SELECTITEM, PR_FALSE, &ok); if (!ok) { return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_SECURITY_ERR); } @@ -262,7 +266,7 @@ XULTreeElementSelectCell(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, } { PRBool ok; - secMan->CheckScriptAccess(scriptCX, obj, NS_DOM_PROP_XULTREEELEMENT_SELECTCELL,PR_FALSE , &ok); + secMan->CheckScriptAccess(scriptCX, obj, NS_DOM_PROP_XULTREEELEMENT_SELECTCELL, PR_FALSE, &ok); if (!ok) { return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_SECURITY_ERR); } @@ -316,7 +320,7 @@ XULTreeElementClearItemSelection(JSContext *cx, JSObject *obj, uintN argc, jsval } { PRBool ok; - secMan->CheckScriptAccess(scriptCX, obj, NS_DOM_PROP_XULTREEELEMENT_CLEARITEMSELECTION,PR_FALSE , &ok); + secMan->CheckScriptAccess(scriptCX, obj, NS_DOM_PROP_XULTREEELEMENT_CLEARITEMSELECTION, PR_FALSE, &ok); if (!ok) { return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_SECURITY_ERR); } @@ -359,7 +363,7 @@ XULTreeElementClearCellSelection(JSContext *cx, JSObject *obj, uintN argc, jsval } { PRBool ok; - secMan->CheckScriptAccess(scriptCX, obj, NS_DOM_PROP_XULTREEELEMENT_CLEARCELLSELECTION,PR_FALSE , &ok); + secMan->CheckScriptAccess(scriptCX, obj, NS_DOM_PROP_XULTREEELEMENT_CLEARCELLSELECTION, PR_FALSE, &ok); if (!ok) { return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_SECURITY_ERR); } @@ -403,7 +407,7 @@ XULTreeElementAddItemToSelection(JSContext *cx, JSObject *obj, uintN argc, jsval } { PRBool ok; - secMan->CheckScriptAccess(scriptCX, obj, NS_DOM_PROP_XULTREEELEMENT_ADDITEMTOSELECTION,PR_FALSE , &ok); + secMan->CheckScriptAccess(scriptCX, obj, NS_DOM_PROP_XULTREEELEMENT_ADDITEMTOSELECTION, PR_FALSE, &ok); if (!ok) { return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_SECURITY_ERR); } @@ -458,7 +462,7 @@ XULTreeElementRemoveItemFromSelection(JSContext *cx, JSObject *obj, uintN argc, } { PRBool ok; - secMan->CheckScriptAccess(scriptCX, obj, NS_DOM_PROP_XULTREEELEMENT_REMOVEITEMFROMSELECTION,PR_FALSE , &ok); + secMan->CheckScriptAccess(scriptCX, obj, NS_DOM_PROP_XULTREEELEMENT_REMOVEITEMFROMSELECTION, PR_FALSE, &ok); if (!ok) { return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_SECURITY_ERR); } @@ -513,7 +517,7 @@ XULTreeElementAddCellToSelection(JSContext *cx, JSObject *obj, uintN argc, jsval } { PRBool ok; - secMan->CheckScriptAccess(scriptCX, obj, NS_DOM_PROP_XULTREEELEMENT_ADDCELLTOSELECTION,PR_FALSE , &ok); + secMan->CheckScriptAccess(scriptCX, obj, NS_DOM_PROP_XULTREEELEMENT_ADDCELLTOSELECTION, PR_FALSE, &ok); if (!ok) { return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_SECURITY_ERR); } @@ -568,7 +572,7 @@ XULTreeElementRemoveCellFromSelection(JSContext *cx, JSObject *obj, uintN argc, } { PRBool ok; - secMan->CheckScriptAccess(scriptCX, obj, NS_DOM_PROP_XULTREEELEMENT_REMOVECELLFROMSELECTION,PR_FALSE , &ok); + secMan->CheckScriptAccess(scriptCX, obj, NS_DOM_PROP_XULTREEELEMENT_REMOVECELLFROMSELECTION, PR_FALSE, &ok); if (!ok) { return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_SECURITY_ERR); } @@ -623,7 +627,7 @@ XULTreeElementToggleItemSelection(JSContext *cx, JSObject *obj, uintN argc, jsva } { PRBool ok; - secMan->CheckScriptAccess(scriptCX, obj, NS_DOM_PROP_XULTREEELEMENT_TOGGLEITEMSELECTION,PR_FALSE , &ok); + secMan->CheckScriptAccess(scriptCX, obj, NS_DOM_PROP_XULTREEELEMENT_TOGGLEITEMSELECTION, PR_FALSE, &ok); if (!ok) { return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_SECURITY_ERR); } @@ -678,7 +682,7 @@ XULTreeElementToggleCellSelection(JSContext *cx, JSObject *obj, uintN argc, jsva } { PRBool ok; - secMan->CheckScriptAccess(scriptCX, obj, NS_DOM_PROP_XULTREEELEMENT_TOGGLECELLSELECTION,PR_FALSE , &ok); + secMan->CheckScriptAccess(scriptCX, obj, NS_DOM_PROP_XULTREEELEMENT_TOGGLECELLSELECTION, PR_FALSE, &ok); if (!ok) { return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_SECURITY_ERR); } @@ -734,7 +738,7 @@ XULTreeElementSelectItemRange(JSContext *cx, JSObject *obj, uintN argc, jsval *a } { PRBool ok; - secMan->CheckScriptAccess(scriptCX, obj, NS_DOM_PROP_XULTREEELEMENT_SELECTITEMRANGE,PR_FALSE , &ok); + secMan->CheckScriptAccess(scriptCX, obj, NS_DOM_PROP_XULTREEELEMENT_SELECTITEMRANGE, PR_FALSE, &ok); if (!ok) { return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_SECURITY_ERR); } @@ -797,7 +801,7 @@ XULTreeElementSelectCellRange(JSContext *cx, JSObject *obj, uintN argc, jsval *a } { PRBool ok; - secMan->CheckScriptAccess(scriptCX, obj, NS_DOM_PROP_XULTREEELEMENT_SELECTCELLRANGE,PR_FALSE , &ok); + secMan->CheckScriptAccess(scriptCX, obj, NS_DOM_PROP_XULTREEELEMENT_SELECTCELLRANGE, PR_FALSE, &ok); if (!ok) { return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_SECURITY_ERR); } @@ -858,7 +862,7 @@ XULTreeElementSelectAll(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, j } { PRBool ok; - secMan->CheckScriptAccess(scriptCX, obj, NS_DOM_PROP_XULTREEELEMENT_SELECTALL,PR_FALSE , &ok); + secMan->CheckScriptAccess(scriptCX, obj, NS_DOM_PROP_XULTREEELEMENT_SELECTALL, PR_FALSE, &ok); if (!ok) { return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_SECURITY_ERR); } @@ -901,7 +905,7 @@ XULTreeElementInvertSelection(JSContext *cx, JSObject *obj, uintN argc, jsval *a } { PRBool ok; - secMan->CheckScriptAccess(scriptCX, obj, NS_DOM_PROP_XULTREEELEMENT_INVERTSELECTION,PR_FALSE , &ok); + secMan->CheckScriptAccess(scriptCX, obj, NS_DOM_PROP_XULTREEELEMENT_INVERTSELECTION, PR_FALSE, &ok); if (!ok) { return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_SECURITY_ERR); } diff --git a/mozilla/rdf/content/public/idl/XULCommandDispatcher.idl b/mozilla/rdf/content/public/idl/XULCommandDispatcher.idl index cf74b8e76d9..d985b0b9d6d 100644 --- a/mozilla/rdf/content/public/idl/XULCommandDispatcher.idl +++ b/mozilla/rdf/content/public/idl/XULCommandDispatcher.idl @@ -3,7 +3,8 @@ interface XULCommandDispatcher { /* IID: { 0xf3c50361, 0x14fe, 0x11d3, \ { 0xbf, 0x87, 0x0, 0x10, 0x5a, 0x1b, 0x6, 0x27 } } */ - attribute Node focusedNode; + attribute Element focusedElement; + attribute Window focusedWindow; void addCommandUpdater(in Element updater, in DOMString events, in DOMString targets); void removeCommandUpdater(in Element updater); diff --git a/mozilla/rdf/content/public/nsIDOMXULCommandDispatcher.h b/mozilla/rdf/content/public/nsIDOMXULCommandDispatcher.h index 93864e44fb4..a188c55ad9e 100644 --- a/mozilla/rdf/content/public/nsIDOMXULCommandDispatcher.h +++ b/mozilla/rdf/content/public/nsIDOMXULCommandDispatcher.h @@ -1,19 +1,23 @@ /* -*- Mode: C++; tab-width: 2; 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/ + * The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License 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. + * Software distributed under the License is distributed on an "AS + * 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. * - * The Initial Developer of this code under the NPL is Netscape + * The Original Code is mozilla.org code. + * + * The Initial Developer of the Original Code is Netscape * Communications Corporation. Portions created by Netscape are - * Copyright (C) 1998 Netscape Communications Corporation. All Rights - * Reserved. + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): */ /* AUTO-GENERATED. DO NOT EDIT!!! */ @@ -26,7 +30,7 @@ class nsIController; class nsIDOMElement; -class nsIDOMNode; +class nsIDOMWindow; class nsIControllers; #define NS_IDOMXULCOMMANDDISPATCHER_IID \ @@ -37,8 +41,11 @@ class nsIDOMXULCommandDispatcher : public nsISupports { public: static const nsIID& GetIID() { static nsIID iid = NS_IDOMXULCOMMANDDISPATCHER_IID; return iid; } - NS_IMETHOD GetFocusedNode(nsIDOMNode** aFocusedNode)=0; - NS_IMETHOD SetFocusedNode(nsIDOMNode* aFocusedNode)=0; + NS_IMETHOD GetFocusedElement(nsIDOMElement** aFocusedElement)=0; + NS_IMETHOD SetFocusedElement(nsIDOMElement* aFocusedElement)=0; + + NS_IMETHOD GetFocusedWindow(nsIDOMWindow** aFocusedWindow)=0; + NS_IMETHOD SetFocusedWindow(nsIDOMWindow* aFocusedWindow)=0; NS_IMETHOD AddCommandUpdater(nsIDOMElement* aUpdater, const nsString& aEvents, const nsString& aTargets)=0; @@ -53,8 +60,10 @@ public: #define NS_DECL_IDOMXULCOMMANDDISPATCHER \ - NS_IMETHOD GetFocusedNode(nsIDOMNode** aFocusedNode); \ - NS_IMETHOD SetFocusedNode(nsIDOMNode* aFocusedNode); \ + NS_IMETHOD GetFocusedElement(nsIDOMElement** aFocusedElement); \ + NS_IMETHOD SetFocusedElement(nsIDOMElement* aFocusedElement); \ + NS_IMETHOD GetFocusedWindow(nsIDOMWindow** aFocusedWindow); \ + NS_IMETHOD SetFocusedWindow(nsIDOMWindow* aFocusedWindow); \ NS_IMETHOD AddCommandUpdater(nsIDOMElement* aUpdater, const nsString& aEvents, const nsString& aTargets); \ NS_IMETHOD RemoveCommandUpdater(nsIDOMElement* aUpdater); \ NS_IMETHOD UpdateCommands(const nsString& aEventName); \ @@ -64,8 +73,10 @@ public: #define NS_FORWARD_IDOMXULCOMMANDDISPATCHER(_to) \ - NS_IMETHOD GetFocusedNode(nsIDOMNode** aFocusedNode) { return _to GetFocusedNode(aFocusedNode); } \ - NS_IMETHOD SetFocusedNode(nsIDOMNode* aFocusedNode) { return _to SetFocusedNode(aFocusedNode); } \ + NS_IMETHOD GetFocusedElement(nsIDOMElement** aFocusedElement) { return _to GetFocusedElement(aFocusedElement); } \ + NS_IMETHOD SetFocusedElement(nsIDOMElement* aFocusedElement) { return _to SetFocusedElement(aFocusedElement); } \ + NS_IMETHOD GetFocusedWindow(nsIDOMWindow** aFocusedWindow) { return _to GetFocusedWindow(aFocusedWindow); } \ + NS_IMETHOD SetFocusedWindow(nsIDOMWindow* aFocusedWindow) { return _to SetFocusedWindow(aFocusedWindow); } \ NS_IMETHOD AddCommandUpdater(nsIDOMElement* aUpdater, const nsString& aEvents, const nsString& aTargets) { return _to AddCommandUpdater(aUpdater, aEvents, aTargets); } \ NS_IMETHOD RemoveCommandUpdater(nsIDOMElement* aUpdater) { return _to RemoveCommandUpdater(aUpdater); } \ NS_IMETHOD UpdateCommands(const nsString& aEventName) { return _to UpdateCommands(aEventName); } \ diff --git a/mozilla/rdf/content/public/nsIDOMXULDocument.h b/mozilla/rdf/content/public/nsIDOMXULDocument.h index 09d3ed86bb1..f88879301a7 100644 --- a/mozilla/rdf/content/public/nsIDOMXULDocument.h +++ b/mozilla/rdf/content/public/nsIDOMXULDocument.h @@ -1,19 +1,23 @@ /* -*- Mode: C++; tab-width: 2; 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/ + * The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License 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. + * Software distributed under the License is distributed on an "AS + * 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. * - * The Initial Developer of this code under the NPL is Netscape + * The Original Code is mozilla.org code. + * + * The Initial Developer of the Original Code is Netscape * Communications Corporation. Portions created by Netscape are - * Copyright (C) 1998 Netscape Communications Corporation. All Rights - * Reserved. + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): */ /* AUTO-GENERATED. DO NOT EDIT!!! */ diff --git a/mozilla/rdf/content/public/nsIDOMXULEditorElement.h b/mozilla/rdf/content/public/nsIDOMXULEditorElement.h index be62662814f..54c298142d3 100644 --- a/mozilla/rdf/content/public/nsIDOMXULEditorElement.h +++ b/mozilla/rdf/content/public/nsIDOMXULEditorElement.h @@ -1,19 +1,23 @@ /* -*- Mode: C++; tab-width: 2; 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/ + * The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License 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. + * Software distributed under the License is distributed on an "AS + * 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. * - * The Initial Developer of this code under the NPL is Netscape + * The Original Code is mozilla.org code. + * + * The Initial Developer of the Original Code is Netscape * Communications Corporation. Portions created by Netscape are - * Copyright (C) 1998 Netscape Communications Corporation. All Rights - * Reserved. + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): */ /* AUTO-GENERATED. DO NOT EDIT!!! */ diff --git a/mozilla/rdf/content/public/nsIDOMXULElement.h b/mozilla/rdf/content/public/nsIDOMXULElement.h index 987b4c9bde8..6cf47fee4f8 100644 --- a/mozilla/rdf/content/public/nsIDOMXULElement.h +++ b/mozilla/rdf/content/public/nsIDOMXULElement.h @@ -1,19 +1,23 @@ /* -*- Mode: C++; tab-width: 2; 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/ + * The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License 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. + * Software distributed under the License is distributed on an "AS + * 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. * - * The Initial Developer of this code under the NPL is Netscape + * The Original Code is mozilla.org code. + * + * The Initial Developer of the Original Code is Netscape * Communications Corporation. Portions created by Netscape are - * Copyright (C) 1998 Netscape Communications Corporation. All Rights - * Reserved. + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): */ /* AUTO-GENERATED. DO NOT EDIT!!! */ diff --git a/mozilla/rdf/content/public/nsIDOMXULTreeElement.h b/mozilla/rdf/content/public/nsIDOMXULTreeElement.h index 1c5f6eb63a9..6691e834ca9 100644 --- a/mozilla/rdf/content/public/nsIDOMXULTreeElement.h +++ b/mozilla/rdf/content/public/nsIDOMXULTreeElement.h @@ -1,19 +1,23 @@ /* -*- Mode: C++; tab-width: 2; 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/ + * The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License 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. + * Software distributed under the License is distributed on an "AS + * 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. * - * The Initial Developer of this code under the NPL is Netscape + * The Original Code is mozilla.org code. + * + * The Initial Developer of the Original Code is Netscape * Communications Corporation. Portions created by Netscape are - * Copyright (C) 1998 Netscape Communications Corporation. All Rights - * Reserved. + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): */ /* AUTO-GENERATED. DO NOT EDIT!!! */ diff --git a/mozilla/rdf/content/public/nsIXULDocument.h b/mozilla/rdf/content/public/nsIXULDocument.h index 953bf747bd3..973a66db811 100644 --- a/mozilla/rdf/content/public/nsIXULDocument.h +++ b/mozilla/rdf/content/public/nsIXULDocument.h @@ -46,6 +46,7 @@ class nsIRDFContentModelBuilder; class nsIRDFResource; class nsISupportsArray; class nsIXULPrototypeDocument; +class nsIURI; // {954F0811-81DC-11d2-B52A-000000000000} #define NS_IRDFDOCUMENT_IID \ @@ -56,6 +57,7 @@ class nsIXULPrototypeDocument; */ class nsIRDFDataSource; +class nsIXULPrototypeDocument; class nsIXULDocument : public nsIXMLDocument { @@ -105,6 +107,26 @@ public: * Resolve the all of the document's forward references. */ NS_IMETHOD ResolveForwardReferences() = 0; + + /** + * Set the master prototype. + */ + NS_IMETHOD SetMasterPrototype(nsIXULPrototypeDocument* aDocument) = 0; + + /** + * Set the current prototype + */ + NS_IMETHOD SetCurrentPrototype(nsIXULPrototypeDocument* aDocument) = 0; + + /** + * Set the doc's URL + */ + NS_IMETHOD SetDocumentURL(nsIURI* aURI) = 0; + + /** + * Load inline and attribute style sheets + */ + NS_IMETHOD PrepareStyleSheets(nsIURI* aURI) = 0; }; // factory functions diff --git a/mozilla/rdf/content/src/nsJSXULCommandDispatcher.cpp b/mozilla/rdf/content/src/nsJSXULCommandDispatcher.cpp index 1a736702bd0..aa8c24d4716 100644 --- a/mozilla/rdf/content/src/nsJSXULCommandDispatcher.cpp +++ b/mozilla/rdf/content/src/nsJSXULCommandDispatcher.cpp @@ -1,19 +1,23 @@ /* -*- Mode: C++; tab-width: 2; 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/ + * The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License 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. + * Software distributed under the License is distributed on an "AS + * 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. * - * The Initial Developer of this code under the NPL is Netscape + * The Original Code is mozilla.org code. + * + * The Initial Developer of the Original Code is Netscape * Communications Corporation. Portions created by Netscape are - * Copyright (C) 1998 Netscape Communications Corporation. All Rights - * Reserved. + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): */ /* AUTO-GENERATED. DO NOT EDIT!!! */ @@ -32,8 +36,8 @@ #include "nsString.h" #include "nsIController.h" #include "nsIDOMElement.h" -#include "nsIDOMNode.h" #include "nsIDOMXULCommandDispatcher.h" +#include "nsIDOMWindow.h" #include "nsIControllers.h" @@ -42,21 +46,22 @@ static NS_DEFINE_IID(kIJSScriptObjectIID, NS_IJSSCRIPTOBJECT_IID); static NS_DEFINE_IID(kIScriptGlobalObjectIID, NS_ISCRIPTGLOBALOBJECT_IID); static NS_DEFINE_IID(kIControllerIID, NS_ICONTROLLER_IID); static NS_DEFINE_IID(kIElementIID, NS_IDOMELEMENT_IID); -static NS_DEFINE_IID(kINodeIID, NS_IDOMNODE_IID); static NS_DEFINE_IID(kIXULCommandDispatcherIID, NS_IDOMXULCOMMANDDISPATCHER_IID); +static NS_DEFINE_IID(kIWindowIID, NS_IDOMWINDOW_IID); static NS_DEFINE_IID(kIControllersIID, NS_ICONTROLLERS_IID); NS_DEF_PTR(nsIController); NS_DEF_PTR(nsIDOMElement); -NS_DEF_PTR(nsIDOMNode); NS_DEF_PTR(nsIDOMXULCommandDispatcher); +NS_DEF_PTR(nsIDOMWindow); NS_DEF_PTR(nsIControllers); // // XULCommandDispatcher property ids // enum XULCommandDispatcher_slots { - XULCOMMANDDISPATCHER_FOCUSEDNODE = -1 + XULCOMMANDDISPATCHER_FOCUSEDELEMENT = -1, + XULCOMMANDDISPATCHER_FOCUSEDWINDOW = -2 }; /***********************************************************************/ @@ -80,16 +85,35 @@ GetXULCommandDispatcherProperty(JSContext *cx, JSObject *obj, jsval id, jsval *v return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_SECMAN_ERR); } switch(JSVAL_TO_INT(id)) { - case XULCOMMANDDISPATCHER_FOCUSEDNODE: + case XULCOMMANDDISPATCHER_FOCUSEDELEMENT: { PRBool ok = PR_FALSE; - secMan->CheckScriptAccess(scriptCX, obj, NS_DOM_PROP_XULCOMMANDDISPATCHER_FOCUSEDNODE, PR_FALSE, &ok); + secMan->CheckScriptAccess(scriptCX, obj, NS_DOM_PROP_XULCOMMANDDISPATCHER_FOCUSEDELEMENT, PR_FALSE, &ok); if (!ok) { return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_SECURITY_ERR); } - nsIDOMNode* prop; + nsIDOMElement* prop; nsresult result = NS_OK; - result = a->GetFocusedNode(&prop); + result = a->GetFocusedElement(&prop); + if (NS_SUCCEEDED(result)) { + // get the js object + nsJSUtils::nsConvertObjectToJSVal((nsISupports *)prop, cx, vp); + } + else { + return nsJSUtils::nsReportError(cx, result); + } + break; + } + case XULCOMMANDDISPATCHER_FOCUSEDWINDOW: + { + PRBool ok = PR_FALSE; + secMan->CheckScriptAccess(scriptCX, obj, NS_DOM_PROP_XULCOMMANDDISPATCHER_FOCUSEDWINDOW, PR_FALSE, &ok); + if (!ok) { + return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_SECURITY_ERR); + } + nsIDOMWindow* prop; + nsresult result = NS_OK; + result = a->GetFocusedWindow(&prop); if (NS_SUCCEEDED(result)) { // get the js object nsJSUtils::nsConvertObjectToJSVal((nsISupports *)prop, cx, vp); @@ -131,21 +155,39 @@ SetXULCommandDispatcherProperty(JSContext *cx, JSObject *obj, jsval id, jsval *v return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_SECMAN_ERR); } switch(JSVAL_TO_INT(id)) { - case XULCOMMANDDISPATCHER_FOCUSEDNODE: + case XULCOMMANDDISPATCHER_FOCUSEDELEMENT: { PRBool ok = PR_FALSE; - secMan->CheckScriptAccess(scriptCX, obj, NS_DOM_PROP_XULCOMMANDDISPATCHER_FOCUSEDNODE, PR_TRUE, &ok); + secMan->CheckScriptAccess(scriptCX, obj, NS_DOM_PROP_XULCOMMANDDISPATCHER_FOCUSEDELEMENT, PR_TRUE, &ok); if (!ok) { return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_SECURITY_ERR); } - nsIDOMNode* prop; + nsIDOMElement* prop; if (PR_FALSE == nsJSUtils::nsConvertJSValToObject((nsISupports **)&prop, - kINodeIID, "Node", + kIElementIID, "Element", cx, *vp)) { return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_NOT_OBJECT_ERR); } - a->SetFocusedNode(prop); + a->SetFocusedElement(prop); + NS_IF_RELEASE(prop); + break; + } + case XULCOMMANDDISPATCHER_FOCUSEDWINDOW: + { + PRBool ok = PR_FALSE; + secMan->CheckScriptAccess(scriptCX, obj, NS_DOM_PROP_XULCOMMANDDISPATCHER_FOCUSEDWINDOW, PR_TRUE, &ok); + if (!ok) { + return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_SECURITY_ERR); + } + nsIDOMWindow* prop; + if (PR_FALSE == nsJSUtils::nsConvertJSValToObject((nsISupports **)&prop, + kIWindowIID, "Window", + cx, *vp)) { + return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_NOT_OBJECT_ERR); + } + + a->SetFocusedWindow(prop); NS_IF_RELEASE(prop); break; } @@ -212,7 +254,7 @@ XULCommandDispatcherAddCommandUpdater(JSContext *cx, JSObject *obj, uintN argc, } { PRBool ok; - secMan->CheckScriptAccess(scriptCX, obj, NS_DOM_PROP_XULCOMMANDDISPATCHER_ADDCOMMANDUPDATER,PR_FALSE , &ok); + secMan->CheckScriptAccess(scriptCX, obj, NS_DOM_PROP_XULCOMMANDDISPATCHER_ADDCOMMANDUPDATER, PR_FALSE, &ok); if (!ok) { return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_SECURITY_ERR); } @@ -269,7 +311,7 @@ XULCommandDispatcherRemoveCommandUpdater(JSContext *cx, JSObject *obj, uintN arg } { PRBool ok; - secMan->CheckScriptAccess(scriptCX, obj, NS_DOM_PROP_XULCOMMANDDISPATCHER_REMOVECOMMANDUPDATER,PR_FALSE , &ok); + secMan->CheckScriptAccess(scriptCX, obj, NS_DOM_PROP_XULCOMMANDDISPATCHER_REMOVECOMMANDUPDATER, PR_FALSE, &ok); if (!ok) { return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_SECURITY_ERR); } @@ -324,7 +366,7 @@ XULCommandDispatcherUpdateCommands(JSContext *cx, JSObject *obj, uintN argc, jsv } { PRBool ok; - secMan->CheckScriptAccess(scriptCX, obj, NS_DOM_PROP_XULCOMMANDDISPATCHER_UPDATECOMMANDS,PR_FALSE , &ok); + secMan->CheckScriptAccess(scriptCX, obj, NS_DOM_PROP_XULCOMMANDDISPATCHER_UPDATECOMMANDS, PR_FALSE, &ok); if (!ok) { return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_SECURITY_ERR); } @@ -374,7 +416,7 @@ XULCommandDispatcherGetControllerForCommand(JSContext *cx, JSObject *obj, uintN } { PRBool ok; - secMan->CheckScriptAccess(scriptCX, obj, NS_DOM_PROP_XULCOMMANDDISPATCHER_GETCONTROLLERFORCOMMAND,PR_FALSE , &ok); + secMan->CheckScriptAccess(scriptCX, obj, NS_DOM_PROP_XULCOMMANDDISPATCHER_GETCONTROLLERFORCOMMAND, PR_FALSE, &ok); if (!ok) { return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_SECURITY_ERR); } @@ -424,7 +466,7 @@ XULCommandDispatcherGetControllers(JSContext *cx, JSObject *obj, uintN argc, jsv } { PRBool ok; - secMan->CheckScriptAccess(scriptCX, obj, NS_DOM_PROP_XULCOMMANDDISPATCHER_GETCONTROLLERS,PR_FALSE , &ok); + secMan->CheckScriptAccess(scriptCX, obj, NS_DOM_PROP_XULCOMMANDDISPATCHER_GETCONTROLLERS, PR_FALSE, &ok); if (!ok) { return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_SECURITY_ERR); } @@ -473,7 +515,8 @@ JSClass XULCommandDispatcherClass = { // static JSPropertySpec XULCommandDispatcherProperties[] = { - {"focusedNode", XULCOMMANDDISPATCHER_FOCUSEDNODE, JSPROP_ENUMERATE}, + {"focusedElement", XULCOMMANDDISPATCHER_FOCUSEDELEMENT, JSPROP_ENUMERATE}, + {"focusedWindow", XULCOMMANDDISPATCHER_FOCUSEDWINDOW, JSPROP_ENUMERATE}, {0} }; diff --git a/mozilla/rdf/content/src/nsJSXULDocument.cpp b/mozilla/rdf/content/src/nsJSXULDocument.cpp index 1a5fffc02a6..db84f7e3c22 100644 --- a/mozilla/rdf/content/src/nsJSXULDocument.cpp +++ b/mozilla/rdf/content/src/nsJSXULDocument.cpp @@ -1,19 +1,23 @@ /* -*- Mode: C++; tab-width: 2; 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/ + * The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License 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. + * Software distributed under the License is distributed on an "AS + * 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. * - * The Initial Developer of this code under the NPL is Netscape + * The Original Code is mozilla.org code. + * + * The Initial Developer of the Original Code is Netscape * Communications Corporation. Portions created by Netscape are - * Copyright (C) 1998 Netscape Communications Corporation. All Rights - * Reserved. + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): */ /* AUTO-GENERATED. DO NOT EDIT!!! */ @@ -269,7 +273,7 @@ XULDocumentGetElementById(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, } { PRBool ok; - secMan->CheckScriptAccess(scriptCX, obj, NS_DOM_PROP_XULDOCUMENT_GETELEMENTBYID,PR_FALSE , &ok); + secMan->CheckScriptAccess(scriptCX, obj, NS_DOM_PROP_XULDOCUMENT_GETELEMENTBYID, PR_FALSE, &ok); if (!ok) { return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_SECURITY_ERR); } @@ -320,7 +324,7 @@ XULDocumentGetElementsByAttribute(JSContext *cx, JSObject *obj, uintN argc, jsva } { PRBool ok; - secMan->CheckScriptAccess(scriptCX, obj, NS_DOM_PROP_XULDOCUMENT_GETELEMENTSBYATTRIBUTE,PR_FALSE , &ok); + secMan->CheckScriptAccess(scriptCX, obj, NS_DOM_PROP_XULDOCUMENT_GETELEMENTSBYATTRIBUTE, PR_FALSE, &ok); if (!ok) { return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_SECURITY_ERR); } @@ -371,7 +375,7 @@ XULDocumentPersist(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval } { PRBool ok; - secMan->CheckScriptAccess(scriptCX, obj, NS_DOM_PROP_XULDOCUMENT_PERSIST,PR_FALSE , &ok); + secMan->CheckScriptAccess(scriptCX, obj, NS_DOM_PROP_XULDOCUMENT_PERSIST, PR_FALSE, &ok); if (!ok) { return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_SECURITY_ERR); } diff --git a/mozilla/rdf/content/src/nsJSXULEditorElement.cpp b/mozilla/rdf/content/src/nsJSXULEditorElement.cpp index 3d133caf129..63bd2d38658 100644 --- a/mozilla/rdf/content/src/nsJSXULEditorElement.cpp +++ b/mozilla/rdf/content/src/nsJSXULEditorElement.cpp @@ -1,19 +1,23 @@ /* -*- Mode: C++; tab-width: 2; 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/ + * The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License 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. + * Software distributed under the License is distributed on an "AS + * 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. * - * The Initial Developer of this code under the NPL is Netscape + * The Original Code is mozilla.org code. + * + * The Initial Developer of the Original Code is Netscape * Communications Corporation. Portions created by Netscape are - * Copyright (C) 1998 Netscape Communications Corporation. All Rights - * Reserved. + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): */ /* AUTO-GENERATED. DO NOT EDIT!!! */ diff --git a/mozilla/rdf/content/src/nsJSXULElement.cpp b/mozilla/rdf/content/src/nsJSXULElement.cpp index 720d863d2a9..51bd30107e6 100644 --- a/mozilla/rdf/content/src/nsJSXULElement.cpp +++ b/mozilla/rdf/content/src/nsJSXULElement.cpp @@ -1,19 +1,23 @@ /* -*- Mode: C++; tab-width: 2; 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/ + * The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License 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. + * Software distributed under the License is distributed on an "AS + * 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. * - * The Initial Developer of this code under the NPL is Netscape + * The Original Code is mozilla.org code. + * + * The Initial Developer of the Original Code is Netscape * Communications Corporation. Portions created by Netscape are - * Copyright (C) 1998 Netscape Communications Corporation. All Rights - * Reserved. + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): */ /* AUTO-GENERATED. DO NOT EDIT!!! */ @@ -342,7 +346,7 @@ XULElementAddBroadcastListener(JSContext *cx, JSObject *obj, uintN argc, jsval * } { PRBool ok; - secMan->CheckScriptAccess(scriptCX, obj, NS_DOM_PROP_XULELEMENT_ADDBROADCASTLISTENER,PR_FALSE , &ok); + secMan->CheckScriptAccess(scriptCX, obj, NS_DOM_PROP_XULELEMENT_ADDBROADCASTLISTENER, PR_FALSE, &ok); if (!ok) { return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_SECURITY_ERR); } @@ -399,7 +403,7 @@ XULElementRemoveBroadcastListener(JSContext *cx, JSObject *obj, uintN argc, jsva } { PRBool ok; - secMan->CheckScriptAccess(scriptCX, obj, NS_DOM_PROP_XULELEMENT_REMOVEBROADCASTLISTENER,PR_FALSE , &ok); + secMan->CheckScriptAccess(scriptCX, obj, NS_DOM_PROP_XULELEMENT_REMOVEBROADCASTLISTENER, PR_FALSE, &ok); if (!ok) { return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_SECURITY_ERR); } @@ -454,7 +458,7 @@ XULElementDoCommand(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval } { PRBool ok; - secMan->CheckScriptAccess(scriptCX, obj, NS_DOM_PROP_XULELEMENT_DOCOMMAND,PR_FALSE , &ok); + secMan->CheckScriptAccess(scriptCX, obj, NS_DOM_PROP_XULELEMENT_DOCOMMAND, PR_FALSE, &ok); if (!ok) { return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_SECURITY_ERR); } @@ -500,7 +504,7 @@ XULElementGetElementsByAttribute(JSContext *cx, JSObject *obj, uintN argc, jsval } { PRBool ok; - secMan->CheckScriptAccess(scriptCX, obj, NS_DOM_PROP_XULELEMENT_GETELEMENTSBYATTRIBUTE,PR_FALSE , &ok); + secMan->CheckScriptAccess(scriptCX, obj, NS_DOM_PROP_XULELEMENT_GETELEMENTSBYATTRIBUTE, PR_FALSE, &ok); if (!ok) { return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_SECURITY_ERR); } diff --git a/mozilla/rdf/content/src/nsJSXULTreeElement.cpp b/mozilla/rdf/content/src/nsJSXULTreeElement.cpp index d451997cd58..9a8a426a793 100644 --- a/mozilla/rdf/content/src/nsJSXULTreeElement.cpp +++ b/mozilla/rdf/content/src/nsJSXULTreeElement.cpp @@ -1,19 +1,23 @@ /* -*- Mode: C++; tab-width: 2; 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/ + * The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License 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. + * Software distributed under the License is distributed on an "AS + * 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. * - * The Initial Developer of this code under the NPL is Netscape + * The Original Code is mozilla.org code. + * + * The Initial Developer of the Original Code is Netscape * Communications Corporation. Portions created by Netscape are - * Copyright (C) 1998 Netscape Communications Corporation. All Rights - * Reserved. + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): */ /* AUTO-GENERATED. DO NOT EDIT!!! */ @@ -207,7 +211,7 @@ XULTreeElementSelectItem(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, } { PRBool ok; - secMan->CheckScriptAccess(scriptCX, obj, NS_DOM_PROP_XULTREEELEMENT_SELECTITEM,PR_FALSE , &ok); + secMan->CheckScriptAccess(scriptCX, obj, NS_DOM_PROP_XULTREEELEMENT_SELECTITEM, PR_FALSE, &ok); if (!ok) { return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_SECURITY_ERR); } @@ -262,7 +266,7 @@ XULTreeElementSelectCell(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, } { PRBool ok; - secMan->CheckScriptAccess(scriptCX, obj, NS_DOM_PROP_XULTREEELEMENT_SELECTCELL,PR_FALSE , &ok); + secMan->CheckScriptAccess(scriptCX, obj, NS_DOM_PROP_XULTREEELEMENT_SELECTCELL, PR_FALSE, &ok); if (!ok) { return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_SECURITY_ERR); } @@ -316,7 +320,7 @@ XULTreeElementClearItemSelection(JSContext *cx, JSObject *obj, uintN argc, jsval } { PRBool ok; - secMan->CheckScriptAccess(scriptCX, obj, NS_DOM_PROP_XULTREEELEMENT_CLEARITEMSELECTION,PR_FALSE , &ok); + secMan->CheckScriptAccess(scriptCX, obj, NS_DOM_PROP_XULTREEELEMENT_CLEARITEMSELECTION, PR_FALSE, &ok); if (!ok) { return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_SECURITY_ERR); } @@ -359,7 +363,7 @@ XULTreeElementClearCellSelection(JSContext *cx, JSObject *obj, uintN argc, jsval } { PRBool ok; - secMan->CheckScriptAccess(scriptCX, obj, NS_DOM_PROP_XULTREEELEMENT_CLEARCELLSELECTION,PR_FALSE , &ok); + secMan->CheckScriptAccess(scriptCX, obj, NS_DOM_PROP_XULTREEELEMENT_CLEARCELLSELECTION, PR_FALSE, &ok); if (!ok) { return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_SECURITY_ERR); } @@ -403,7 +407,7 @@ XULTreeElementAddItemToSelection(JSContext *cx, JSObject *obj, uintN argc, jsval } { PRBool ok; - secMan->CheckScriptAccess(scriptCX, obj, NS_DOM_PROP_XULTREEELEMENT_ADDITEMTOSELECTION,PR_FALSE , &ok); + secMan->CheckScriptAccess(scriptCX, obj, NS_DOM_PROP_XULTREEELEMENT_ADDITEMTOSELECTION, PR_FALSE, &ok); if (!ok) { return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_SECURITY_ERR); } @@ -458,7 +462,7 @@ XULTreeElementRemoveItemFromSelection(JSContext *cx, JSObject *obj, uintN argc, } { PRBool ok; - secMan->CheckScriptAccess(scriptCX, obj, NS_DOM_PROP_XULTREEELEMENT_REMOVEITEMFROMSELECTION,PR_FALSE , &ok); + secMan->CheckScriptAccess(scriptCX, obj, NS_DOM_PROP_XULTREEELEMENT_REMOVEITEMFROMSELECTION, PR_FALSE, &ok); if (!ok) { return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_SECURITY_ERR); } @@ -513,7 +517,7 @@ XULTreeElementAddCellToSelection(JSContext *cx, JSObject *obj, uintN argc, jsval } { PRBool ok; - secMan->CheckScriptAccess(scriptCX, obj, NS_DOM_PROP_XULTREEELEMENT_ADDCELLTOSELECTION,PR_FALSE , &ok); + secMan->CheckScriptAccess(scriptCX, obj, NS_DOM_PROP_XULTREEELEMENT_ADDCELLTOSELECTION, PR_FALSE, &ok); if (!ok) { return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_SECURITY_ERR); } @@ -568,7 +572,7 @@ XULTreeElementRemoveCellFromSelection(JSContext *cx, JSObject *obj, uintN argc, } { PRBool ok; - secMan->CheckScriptAccess(scriptCX, obj, NS_DOM_PROP_XULTREEELEMENT_REMOVECELLFROMSELECTION,PR_FALSE , &ok); + secMan->CheckScriptAccess(scriptCX, obj, NS_DOM_PROP_XULTREEELEMENT_REMOVECELLFROMSELECTION, PR_FALSE, &ok); if (!ok) { return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_SECURITY_ERR); } @@ -623,7 +627,7 @@ XULTreeElementToggleItemSelection(JSContext *cx, JSObject *obj, uintN argc, jsva } { PRBool ok; - secMan->CheckScriptAccess(scriptCX, obj, NS_DOM_PROP_XULTREEELEMENT_TOGGLEITEMSELECTION,PR_FALSE , &ok); + secMan->CheckScriptAccess(scriptCX, obj, NS_DOM_PROP_XULTREEELEMENT_TOGGLEITEMSELECTION, PR_FALSE, &ok); if (!ok) { return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_SECURITY_ERR); } @@ -678,7 +682,7 @@ XULTreeElementToggleCellSelection(JSContext *cx, JSObject *obj, uintN argc, jsva } { PRBool ok; - secMan->CheckScriptAccess(scriptCX, obj, NS_DOM_PROP_XULTREEELEMENT_TOGGLECELLSELECTION,PR_FALSE , &ok); + secMan->CheckScriptAccess(scriptCX, obj, NS_DOM_PROP_XULTREEELEMENT_TOGGLECELLSELECTION, PR_FALSE, &ok); if (!ok) { return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_SECURITY_ERR); } @@ -734,7 +738,7 @@ XULTreeElementSelectItemRange(JSContext *cx, JSObject *obj, uintN argc, jsval *a } { PRBool ok; - secMan->CheckScriptAccess(scriptCX, obj, NS_DOM_PROP_XULTREEELEMENT_SELECTITEMRANGE,PR_FALSE , &ok); + secMan->CheckScriptAccess(scriptCX, obj, NS_DOM_PROP_XULTREEELEMENT_SELECTITEMRANGE, PR_FALSE, &ok); if (!ok) { return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_SECURITY_ERR); } @@ -797,7 +801,7 @@ XULTreeElementSelectCellRange(JSContext *cx, JSObject *obj, uintN argc, jsval *a } { PRBool ok; - secMan->CheckScriptAccess(scriptCX, obj, NS_DOM_PROP_XULTREEELEMENT_SELECTCELLRANGE,PR_FALSE , &ok); + secMan->CheckScriptAccess(scriptCX, obj, NS_DOM_PROP_XULTREEELEMENT_SELECTCELLRANGE, PR_FALSE, &ok); if (!ok) { return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_SECURITY_ERR); } @@ -858,7 +862,7 @@ XULTreeElementSelectAll(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, j } { PRBool ok; - secMan->CheckScriptAccess(scriptCX, obj, NS_DOM_PROP_XULTREEELEMENT_SELECTALL,PR_FALSE , &ok); + secMan->CheckScriptAccess(scriptCX, obj, NS_DOM_PROP_XULTREEELEMENT_SELECTALL, PR_FALSE, &ok); if (!ok) { return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_SECURITY_ERR); } @@ -901,7 +905,7 @@ XULTreeElementInvertSelection(JSContext *cx, JSObject *obj, uintN argc, jsval *a } { PRBool ok; - secMan->CheckScriptAccess(scriptCX, obj, NS_DOM_PROP_XULTREEELEMENT_INVERTSELECTION,PR_FALSE , &ok); + secMan->CheckScriptAccess(scriptCX, obj, NS_DOM_PROP_XULTREEELEMENT_INVERTSELECTION, PR_FALSE, &ok); if (!ok) { return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_SECURITY_ERR); } diff --git a/mozilla/rdf/content/src/nsXULCommandDispatcher.cpp b/mozilla/rdf/content/src/nsXULCommandDispatcher.cpp index 4357d4fb2b4..cea17d4a278 100644 --- a/mozilla/rdf/content/src/nsXULCommandDispatcher.cpp +++ b/mozilla/rdf/content/src/nsXULCommandDispatcher.cpp @@ -29,6 +29,8 @@ #include "nsIContent.h" #include "nsIControllers.h" #include "nsIDOMDocument.h" +#include "nsIDOMXULDocument.h" +#include "nsIDOMHTMLDocument.h" #include "nsIDOMElement.h" #include "nsIDOMNSHTMLInputElement.h" #include "nsIDOMNSHTMLTextAreaElement.h" @@ -51,7 +53,7 @@ static PRLogModuleInfo* gLog; //////////////////////////////////////////////////////////////////////// nsXULCommandDispatcher::nsXULCommandDispatcher(void) - : mScriptObject(nsnull), mCurrentNode(nsnull), mUpdaters(nsnull) + : mScriptObject(nsnull), mUpdaters(nsnull) { NS_INIT_REFCNT(); @@ -63,11 +65,11 @@ nsXULCommandDispatcher::nsXULCommandDispatcher(void) nsXULCommandDispatcher::~nsXULCommandDispatcher(void) { - while (mUpdaters) { - Updater* doomed = mUpdaters; - mUpdaters = mUpdaters->mNext; - delete doomed; - } + while (mUpdaters) { + Updater* doomed = mUpdaters; + mUpdaters = mUpdaters->mNext; + delete doomed; + } } NS_IMPL_ADDREF(nsXULCommandDispatcher) @@ -120,24 +122,37 @@ nsXULCommandDispatcher::Create(nsIDOMXULCommandDispatcher** aResult) // nsIDOMXULTracker Interface NS_IMETHODIMP -nsXULCommandDispatcher::GetFocusedNode(nsIDOMNode** aNode) +nsXULCommandDispatcher::GetFocusedElement(nsIDOMElement** aElement) { - *aNode = mCurrentNode; - NS_IF_ADDREF(*aNode); + *aElement = mCurrentElement; + NS_IF_ADDREF(*aElement); return NS_OK; } NS_IMETHODIMP -nsXULCommandDispatcher::SetFocusedNode(nsIDOMNode* aNode) +nsXULCommandDispatcher::GetFocusedWindow(nsIDOMWindow** aWindow) { - // XXX On a blur, will need to fire an updatecommands (focus) on the - // parent window. - mCurrentNode = aNode; - if (mCurrentNode) + *aWindow = mCurrentWindow; + NS_IF_ADDREF(*aWindow); + return NS_OK; +} + +NS_IMETHODIMP +nsXULCommandDispatcher::SetFocusedElement(nsIDOMElement* aElement) +{ + mCurrentElement = aElement; + if (mCurrentElement) UpdateCommands(nsAutoString("focus")); return NS_OK; } +NS_IMETHODIMP +nsXULCommandDispatcher::SetFocusedWindow(nsIDOMWindow* aWindow) +{ + mCurrentWindow = aWindow; + return NS_OK; +} + NS_IMETHODIMP nsXULCommandDispatcher::AddCommandUpdater(nsIDOMElement* aElement, const nsString& aEvents, @@ -224,13 +239,12 @@ nsXULCommandDispatcher::UpdateCommands(const nsString& aEventName) nsresult rv; nsAutoString id; - nsCOMPtr element = do_QueryInterface(mCurrentNode); - if (element) { - rv = element->GetAttribute(nsAutoString("id"), id); + if (mCurrentElement) { + rv = mCurrentElement->GetAttribute(nsAutoString("id"), id); NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get element's id"); if (NS_FAILED(rv)) return rv; } - + for (Updater* updater = mUpdaters; updater != nsnull; updater = updater->mNext) { // Skip any nodes that don't match our 'events' or 'targets' // filters. @@ -286,20 +300,21 @@ nsXULCommandDispatcher::GetControllers(nsIControllers** aResult) { //XXX: we should fix this so there's a generic interface that describes controllers, // so this code would have no special knowledge of what object might have controllers. - if (mCurrentNode) { - nsCOMPtr xulElement = do_QueryInterface(mCurrentNode); + if (mCurrentElement) { + nsCOMPtr xulElement = do_QueryInterface(mCurrentElement); if (xulElement) return xulElement->GetControllers(aResult); - nsCOMPtr htmlTextArea = do_QueryInterface(mCurrentNode); + nsCOMPtr htmlTextArea = do_QueryInterface(mCurrentElement); if (htmlTextArea) return htmlTextArea->GetControllers(aResult); - nsCOMPtr htmlInputElement = do_QueryInterface(mCurrentNode); + nsCOMPtr htmlInputElement = do_QueryInterface(mCurrentElement); if (htmlInputElement) return htmlInputElement->GetControllers(aResult); - - nsCOMPtr domWindow = do_QueryInterface(mCurrentNode); + } + else if (mCurrentWindow) { + nsCOMPtr domWindow = do_QueryInterface(mCurrentWindow); if (domWindow) return domWindow->GetControllers(aResult); } @@ -318,10 +333,40 @@ nsXULCommandDispatcher::Focus(nsIDOMEvent* aEvent) nsCOMPtr t; aEvent->GetTarget(getter_AddRefs(t)); - // XXX: Bad fix - nsCOMPtr element = do_QueryInterface(t); - if(element) { - SetFocusedNode(t); +/* + printf("%d : Focus occurred on: ", this); + nsCOMPtr domDebugElement = do_QueryInterface(t); + if (domDebugElement) { + printf("A Focusable DOM Element"); + } + nsCOMPtr domDebugDocument = do_QueryInterface(t); + if (domDebugDocument) { + nsCOMPtr htmlDoc = do_QueryInterface(t); + if (htmlDoc) { + printf("Window with an HTML doc (happens twice)"); + } + else printf("Window with a XUL doc (happens twice)"); + } + printf("\n"); +*/ + + nsCOMPtr domElement = do_QueryInterface(t); + if (domElement && (domElement != mCurrentElement)) { + SetFocusedElement(domElement); + } + else { + // We're focusing a window. We only want to do an update commands + // if no element is focused. + nsCOMPtr domWindow; + nsCOMPtr domDoc = do_QueryInterface(t); + if (domDoc) { + GetParentWindowFromDocument(domDoc, getter_AddRefs(domWindow)); + if (domWindow && (domWindow != mCurrentWindow)) { + SetFocusedWindow(domWindow); + if (!mCurrentElement) + UpdateCommands(nsAutoString("focus")); + } + } } return NS_OK; @@ -332,8 +377,35 @@ nsXULCommandDispatcher::Blur(nsIDOMEvent* aEvent) { nsCOMPtr t; aEvent->GetTarget(getter_AddRefs(t)); - if( t == mCurrentNode ) { - SetFocusedNode(nsnull); + +/* + printf("%d : Blur occurred on: ", this); + nsCOMPtr domDebugElement = do_QueryInterface(t); + if (domDebugElement) { + printf("A Focusable DOM Element"); + } + nsCOMPtr domDebugDocument = do_QueryInterface(t); + if (domDebugDocument) { + nsCOMPtr htmlDoc = do_QueryInterface(t); + if (htmlDoc) { + printf("Window with an HTML doc (happens twice)"); + } + else printf("Window with a XUL doc (happens twice)"); + } + printf("\n"); +*/ + + nsCOMPtr domElement = do_QueryInterface(t); + if (domElement) { + SetFocusedElement(nsnull); + } + + nsCOMPtr domWindow; + nsCOMPtr domDoc = do_QueryInterface(t); + if (domDoc) { + GetParentWindowFromDocument(domDoc, getter_AddRefs(domWindow)); + if (domWindow) + SetFocusedWindow(nsnull); } return NS_OK; @@ -393,25 +465,19 @@ nsXULCommandDispatcher::Matches(const nsString& aList, const nsString& aElement) } -NS_IMETHODIMP -nsXULCommandDispatcher::GetParentWindowFromElement(nsIDOMElement* aElement, nsPIDOMWindow** aPWindow) +nsresult +nsXULCommandDispatcher::GetParentWindowFromDocument(nsIDOMDocument* aDocument, nsIDOMWindow** aWindow) { - nsCOMPtr document; - aElement->GetOwnerDocument(getter_AddRefs(document)); - if(!document) return NS_OK; - - nsCOMPtr objectOwner = do_QueryInterface(document); + nsCOMPtr objectOwner = do_QueryInterface(aDocument); if(!objectOwner) return NS_OK; nsCOMPtr globalObject; objectOwner->GetScriptGlobalObject(getter_AddRefs(globalObject)); if(!globalObject) return NS_OK; - nsCOMPtr privateDOMWindow = do_QueryInterface(globalObject); - if(!privateDOMWindow) return NS_OK; - - privateDOMWindow->GetPrivateParent(aPWindow); - + nsCOMPtr domWindow = do_QueryInterface(globalObject); + *aWindow = domWindow; + NS_IF_ADDREF(*aWindow); return NS_OK; } @@ -423,46 +489,47 @@ nsXULCommandDispatcher::GetControllerForCommand(const nsString& command, nsICont nsCOMPtr controllers; GetControllers(getter_AddRefs(controllers)); if(controllers) { - nsCOMPtr controller; - controllers->GetControllerForCommand(command.GetUnicode(), getter_AddRefs(controller)); - if(controller) { + nsCOMPtr controller; + controllers->GetControllerForCommand(command.GetUnicode(), getter_AddRefs(controller)); + if(controller) { + *_retval = controller; + NS_ADDREF(*_retval); + return NS_OK; + } + } + + nsCOMPtr currentWindow; + if (mCurrentElement) { + // Move up to the window. + nsCOMPtr domDoc; + mCurrentElement->GetOwnerDocument(getter_AddRefs(domDoc)); + nsCOMPtr domWindow; + GetParentWindowFromDocument(domDoc, getter_AddRefs(domWindow)); + currentWindow = do_QueryInterface(domWindow); + } + else if (mCurrentWindow) { + nsCOMPtr privateWin = do_QueryInterface(mCurrentWindow); + privateWin->GetPrivateParent(getter_AddRefs(currentWindow)); + } + else return NS_OK; + + while(currentWindow) { + nsCOMPtr domWindow = do_QueryInterface(currentWindow); + if(domWindow) { + nsCOMPtr controllers2; + domWindow->GetControllers(getter_AddRefs(controllers2)); + if(controllers2) { + nsCOMPtr controller; + controllers2->GetControllerForCommand(command.GetUnicode(), getter_AddRefs(controller)); + if(controller) { *_retval = controller; NS_ADDREF(*_retval); return NS_OK; + } } - } - - if(!mCurrentNode) return NS_OK; - - nsCOMPtr currentWindow; - - nsCOMPtr element = do_QueryInterface(mCurrentNode); - if(element) { - GetParentWindowFromElement(element, getter_AddRefs(currentWindow)); - } else { - nsCOMPtr window = do_QueryInterface(mCurrentNode); - if(!window) return NS_OK; - - window->GetPrivateParent(getter_AddRefs(currentWindow)); - } - - while(currentWindow) { - nsCOMPtr domWindow = do_QueryInterface(currentWindow); - if(domWindow) { - nsCOMPtr controllers2; - domWindow->GetControllers(getter_AddRefs(controllers2)); - if(controllers2) { - nsCOMPtr controller; - controllers2->GetControllerForCommand(command.GetUnicode(), getter_AddRefs(controller)); - if(controller) { - *_retval = controller; - NS_ADDREF(*_retval); - return NS_OK; - } - } - } - nsCOMPtr parentPWindow = currentWindow; - parentPWindow->GetPrivateParent(getter_AddRefs(currentWindow)); + } + nsCOMPtr parentPWindow = currentWindow; + parentPWindow->GetPrivateParent(getter_AddRefs(currentWindow)); } return NS_OK; diff --git a/mozilla/rdf/content/src/nsXULCommandDispatcher.h b/mozilla/rdf/content/src/nsXULCommandDispatcher.h index 39438250ecb..bc850314c9a 100644 --- a/mozilla/rdf/content/src/nsXULCommandDispatcher.h +++ b/mozilla/rdf/content/src/nsXULCommandDispatcher.h @@ -73,15 +73,17 @@ public: NS_IMETHOD GetScriptObject(nsIScriptContext *aContext, void** aScriptObject); NS_IMETHOD SetScriptObject(void *aScriptObject); -protected: - NS_IMETHOD GetParentWindowFromElement(nsIDOMElement* aElement, nsPIDOMWindow** aPWindow); +public: + static nsresult GetParentWindowFromDocument(nsIDOMDocument* aElement, nsIDOMWindow** aWindow); +protected: void* mScriptObject; // ???? // XXX THis was supposed to be WEAK, but c'mon, that's an accident // waiting to happen! If somebody deletes the node, then asks us // for the focus, we'll get killed! - nsCOMPtr mCurrentNode; // [OWNER] + nsCOMPtr mCurrentElement; // [OWNER] + nsCOMPtr mCurrentWindow; // [OWNER] class Updater { public: diff --git a/mozilla/rdf/content/src/nsXULDocument.cpp b/mozilla/rdf/content/src/nsXULDocument.cpp index fb9f140a826..a63878b170d 100644 --- a/mozilla/rdf/content/src/nsXULDocument.cpp +++ b/mozilla/rdf/content/src/nsXULDocument.cpp @@ -601,11 +601,11 @@ nsXULDocument::PrepareStyleSheets(nsIURI* anURL) return NS_OK; } -void -nsXULDocument::SetDocumentURLAndGroup(nsIURI* anURL) +NS_IMETHODIMP +nsXULDocument::SetDocumentURL(nsIURI* anURL) { mDocumentURL = dont_QueryInterface(anURL); - // XXX help + return NS_OK; } NS_IMETHODIMP @@ -2021,6 +2021,19 @@ nsXULDocument::ResolveForwardReferences() return NS_OK; } +NS_IMETHODIMP +nsXULDocument::SetMasterPrototype(nsIXULPrototypeDocument* aDocument) +{ + mMasterPrototype = aDocument; + return NS_OK; +} + +NS_IMETHODIMP +nsXULDocument::SetCurrentPrototype(nsIXULPrototypeDocument* aDocument) +{ + mCurrentPrototype = aDocument; + return NS_OK; +} //---------------------------------------------------------------------- // @@ -4360,8 +4373,7 @@ nsXULDocument::PrepareToWalk() if (NS_FAILED(rv)) return rv; nsCOMPtr group = do_QueryReferent(mDocumentLoadGroup); - NS_ASSERTION(group != nsnull, "no load group"); - + if (group) { rv = mPlaceholderChannel->SetLoadGroup(group); if (NS_FAILED(rv)) return rv; diff --git a/mozilla/rdf/content/src/nsXULDocument.h b/mozilla/rdf/content/src/nsXULDocument.h index 1bfb50ddca9..1da445193e4 100644 --- a/mozilla/rdf/content/src/nsXULDocument.h +++ b/mozilla/rdf/content/src/nsXULDocument.h @@ -285,7 +285,11 @@ public: NS_IMETHOD SetForm(nsIDOMHTMLFormElement* aForm); NS_IMETHOD AddForwardReference(nsForwardReference* aRef); NS_IMETHOD ResolveForwardReferences(); - + NS_IMETHOD SetMasterPrototype(nsIXULPrototypeDocument* aDocument); + NS_IMETHOD SetCurrentPrototype(nsIXULPrototypeDocument* aDocument); + NS_IMETHOD SetDocumentURL(nsIURI* anURL); + NS_IMETHOD PrepareStyleSheets(nsIURI* anURL); + // nsIStreamLoadableDocument interface NS_IMETHOD LoadFromStream(nsIInputStream& xulStream, nsISupports* aContainer, @@ -413,9 +417,6 @@ protected: nsresult ParseTagString(const nsString& aTagName, nsIAtom*& aName, PRInt32& aNameSpaceID); - NS_IMETHOD PrepareStyleSheets(nsIURI* anURL); - - void SetDocumentURLAndGroup(nsIURI* anURL); void SetIsPopup(PRBool isPopup) { mIsPopup = isPopup; }; nsresult CreateElement(PRInt32 aNameSpaceID, diff --git a/mozilla/rdf/content/src/nsXULKeyListener.cpp b/mozilla/rdf/content/src/nsXULKeyListener.cpp index 6a577609044..ab17c9668a5 100644 --- a/mozilla/rdf/content/src/nsXULKeyListener.cpp +++ b/mozilla/rdf/content/src/nsXULKeyListener.cpp @@ -6,7 +6,8 @@ * the License at http://www.mozilla.org/NPL/ * * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * IS" basis, WITHOUT WA + RRANTY OF ANY KIND, either express or * implied. See the License for the specific language governing * rights and limitations under the License. * @@ -21,7 +22,10 @@ */ #include "nsCOMPtr.h" +#include "nsIComponentManager.h" #include "nsIContent.h" +#include "nsIPrincipal.h" +#include "nsIJSEventListener.h" #include "nsIDocument.h" #include "nsIDOMElement.h" #include "nsIDOMFocusListener.h" @@ -29,13 +33,29 @@ #include "nsIDOMMouseListener.h" #include "nsIDOMKeyEvent.h" #include "nsIDOMWindow.h" +#include "nsPIDOMWindow.h" #include "nsIDOMXULDocument.h" #include "nsINSEvent.h" #include "nsIPresContext.h" #include "nsIPresShell.h" #include "nsIScriptGlobalObject.h" #include "nsIXULKeyListener.h" +#include "nsIXULDocument.h" +#include "nsIDOMXULCommandDispatcher.h" +#include "nsIXULPrototypeDocument.h" +#include "nsIScriptObjectOwner.h" +#include "nsIXULContentSink.h" #include "nsRDFCID.h" +#include "nsINameSpaceManager.h" +#include "nsHashtable.h" +#include "nsIURI.h" +#include "nsIURL.h" +#include "nsIChannel.h" +#include "nsXPIDLString.h" +#include "nsIParser.h" +#include "nsParserCIID.h" +#include "nsNetUtil.h" +#include "plstr.h" enum { VK_CANCEL = 3, @@ -154,7 +174,11 @@ //////////////////////////////////////////////////////////////////////// -static NS_DEFINE_IID(kXULKeyListenerCID, NS_XULKEYLISTENER_CID); +static NS_DEFINE_CID(kXULKeyListenerCID, NS_XULKEYLISTENER_CID); +static NS_DEFINE_CID(kXULDocumentCID, NS_XULDOCUMENT_CID); +static NS_DEFINE_CID(kXULContentSinkCID, NS_XULCONTENTSINK_CID); +static NS_DEFINE_CID(kParserCID, NS_PARSER_IID); // XXX + static NS_DEFINE_IID(kIXULKeyListenerIID, NS_IXULKEYLISTENER_IID); static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); @@ -217,21 +241,109 @@ public: virtual nsresult HandleEvent(nsIDOMEvent* anEvent) { return NS_OK; }; protected: + class nsIURIKey : public nsHashKey { + protected: + nsCOMPtr mKey; + + public: + nsIURIKey(nsIURI* key) : mKey(key) {} + ~nsIURIKey(void) {} + + PRUint32 HashValue(void) const { + nsXPIDLCString spec; + mKey->GetSpec(getter_Copies(spec)); + return (PRUint32) PL_HashString(spec); + } + + PRBool Equals(const nsHashKey *aKey) const { + PRBool eq; + mKey->Equals( ((nsIURIKey*) aKey)->mKey, &eq ); + return eq; + } + + nsHashKey *Clone(void) const { + return new nsIURIKey(mKey); + } + }; private: nsresult DoKey(nsIDOMEvent* aKeyEvent, eEventType aEventType); inline PRBool IsMatchingKeyCode(const PRUint32 theChar, const nsString &keyName); inline PRBool IsMatchingCharCode(const nsString &theChar, const nsString &keyName); + NS_IMETHOD GetKeyBindingDocument(nsCAutoString& aURLStr, nsIDOMXULDocument** aResult); + NS_IMETHOD LoadKeyBindingDocument(nsIURI* aURI, nsIDOMXULDocument** aResult); + NS_IMETHOD LocateAndExecuteKeyBinding(nsIDOMKeyEvent* aKeyEvent, eEventType aEventType, + nsIDOMXULDocument* aDocument, PRBool& aHandled); + NS_IMETHOD HandleEventUsingKeyset(nsIDOMElement* aKeysetElement, nsIDOMKeyEvent* aEvent, eEventType aEventType, + nsIDOMXULDocument* aDocument, PRBool& aHandledFlag); + nsIDOMElement* element; // Weak reference. The element will go away first. - nsIDOMDocument* mDOMDocument; // Weak reference. + nsIDOMXULDocument* mDOMDocument; // Weak reference. + static nsSupportsHashtable mKeyBindingTable; + // The "xul key" modifier can be any of the known modifiers: enum { xulKeyNone, xulKeyShift, xulKeyControl, xulKeyAlt, xulKeyMeta } mXULKeyModifier; }; +nsSupportsHashtable nsXULKeyListenerImpl::mKeyBindingTable = nsSupportsHashtable(); + +class nsProxyStream : public nsIInputStream +{ +private: + const char* mBuffer; + PRUint32 mSize; + PRUint32 mIndex; + +public: + nsProxyStream(void) : mBuffer(nsnull) + { + NS_INIT_REFCNT(); + } + + virtual ~nsProxyStream(void) { + } + + // nsISupports + NS_DECL_ISUPPORTS + + // nsIBaseStream + NS_IMETHOD Close(void) { + return NS_OK; + } + + // nsIInputStream + NS_IMETHOD Available(PRUint32 *aLength) { + *aLength = mSize - mIndex; + return NS_OK; + } + + NS_IMETHOD Read(char* aBuf, PRUint32 aCount, PRUint32 *aReadCount) { + PRUint32 readCount = 0; + while (mIndex < mSize && aCount > 0) { + *aBuf = mBuffer[mIndex]; + aBuf++; + mIndex++; + readCount++; + aCount--; + } + *aReadCount = readCount; + return NS_OK; + } + + // Implementation + void SetBuffer(const char* aBuffer, PRUint32 aSize) { + mBuffer = aBuffer; + mSize = aSize; + mIndex = 0; + } +}; + +NS_IMPL_ISUPPORTS(nsProxyStream, nsIInputStream::GetIID()); + //////////////////////////////////////////////////////////////////////// @@ -283,15 +395,22 @@ nsXULKeyListenerImpl::Init( nsIDOMElement * aElement, nsIDOMDocument * aDocument) { - printf("nsXULKeyListenerImpl::Init()\n"); + printf("nsXULKeyListenerImpl::Init()\n"); element = aElement; // Weak reference. Don't addref it. - mDOMDocument = aDocument; // Weak reference. + + nsCOMPtr xulDoc = do_QueryInterface(aDocument); + if (!xulDoc) + return NS_ERROR_FAILURE; + + mDOMDocument = xulDoc; // Weak reference. // Set the default for the xul key modifier #ifdef XP_MAC mXULKeyModifier = xulKeyMeta; -#else +#elif XP_PC mXULKeyModifier = xulKeyControl; +#else + mXULKeyModifier = xulKeyAlt; #endif return NS_OK; } @@ -339,9 +458,7 @@ nsresult nsXULKeyListenerImpl::DoKey(nsIDOMEvent* aKeyEvent, eEventType aEventTy { static PRBool executingKeyBind = PR_FALSE; nsresult ret = NS_OK; - nsAutoString trueString = "true"; - nsAutoString falseString = "false"; - + if(executingKeyBind) return NS_OK; else @@ -361,329 +478,79 @@ nsresult nsXULKeyListenerImpl::DoKey(nsIDOMEvent* aKeyEvent, eEventType aEventTy nsCOMPtr target = nsnull; aKeyEvent->GetTarget(getter_AddRefs(target)); + nsCOMPtr piWindow; + nsCOMPtr keyEvent = do_QueryInterface(aKeyEvent); // Find a keyset node + // Get the current focused object from the command dispatcher + nsCOMPtr commandDispatcher; + mDOMDocument->GetCommandDispatcher(getter_AddRefs(commandDispatcher)); + nsCOMPtr focusedElement; + commandDispatcher->GetFocusedElement(getter_AddRefs(focusedElement)); - // locate the window element which holds the top level key bindings - nsCOMPtr rootElement; - mDOMDocument->GetDocumentElement(getter_AddRefs(rootElement)); - if (!rootElement) { - executingKeyBind = PR_FALSE; - return !NS_OK; - } - - nsAutoString rootName; - rootElement->GetNodeName(rootName); - //printf("Root Node [%s] \n", rootName.ToNewCString()); // this leaks - nsCOMPtr rootNode(do_QueryInterface(rootElement)); + nsCOMPtr domWindow; + commandDispatcher->GetFocusedWindow(getter_AddRefs(domWindow)); + piWindow = do_QueryInterface(domWindow); - nsresult rv = NS_ERROR_FAILURE; - - nsCOMPtr keysetNode; - rootNode->GetFirstChild(getter_AddRefs(keysetNode)); - -#undef DEBUG_XUL_KEYS -#ifdef DEBUG_XUL_KEYS - if (aEventType == eKeyPress) - { - PRUint32 charcode, keycode; - keyEvent->GetCharCode(&charcode); - keyEvent->GetKeyCode(&keycode); - printf("DoKey [%s]: key code 0x%d, char code '%c', ", - (aEventType == eKeyPress ? "KeyPress" : ""), keycode, charcode); - PRBool ismod; - keyEvent->GetShiftKey(&ismod); - if (ismod) printf("[Shift] "); - keyEvent->GetCtrlKey(&ismod); - if (ismod) printf("[Ctrl] "); - keyEvent->GetAltKey(&ismod); - if (ismod) printf("[Alt] "); - keyEvent->GetMetaKey(&ismod); - if (ismod) printf("[Meta] "); - printf("\n"); + nsCAutoString keyFile; + if (focusedElement) { + // See if it's a textarea or input field. + // XXX Check to see if the "key-bindings" CSS property points us to a file. + // Hopefully we can get Pierre to add this. ;) + + nsAutoString tagName; + focusedElement->GetTagName(tagName); + if (tagName.EqualsIgnoreCase("input")) { + nsAutoString type; + focusedElement->GetAttribute(nsAutoString("type"), type); + if (type == "" || type.EqualsIgnoreCase("text")) + keyFile = "chrome://global/content/inputBindings.xul"; } -#endif /* DEBUG_XUL_KEYS */ + else if (tagName.EqualsIgnoreCase("textarea")) + keyFile = "chrome://global/content/textAreaBindings.xul"; + } + + nsCOMPtr document; + GetKeyBindingDocument(keyFile, getter_AddRefs(document)); + + // Locate the key node and execute the JS on a match. + PRBool handled = PR_FALSE; + if (document) // Local focused ELEMENT handling stage. + LocateAndExecuteKeyBinding(keyEvent, aEventType, document, handled); - while (keysetNode) { - nsAutoString keysetNodeType; - nsCOMPtr keysetElement(do_QueryInterface(keysetNode)); - if(!keysetElement) { - executingKeyBind = PR_FALSE; - return rv; - } - - keysetElement->GetNodeName(keysetNodeType); - if (!keysetNodeType.Equals("keyset")) { - nsCOMPtr oldkeysetNode(keysetNode); - oldkeysetNode->GetNextSibling(getter_AddRefs(keysetNode)); - continue; - } + nsCAutoString browserFile = "chrome://global/content/browserBindings.xul"; + nsCAutoString editorFile = "chrome://global/content/editorBindings.xul"; - // Given the DOM node and Key Event - // Walk the node's children looking for 'key' types + if (!handled) { + while (piWindow && !handled) { + // See if we have a XUL document. Give it a crack. + nsCOMPtr domWindow = do_QueryInterface(piWindow); + nsCOMPtr windowDoc; + domWindow->GetDocument(getter_AddRefs(windowDoc)); + nsCOMPtr xulWindowDoc = do_QueryInterface(windowDoc); + if (xulWindowDoc) { + // Give the local key bindings in this XUL file a shot. + LocateAndExecuteKeyBinding(keyEvent, aEventType, xulWindowDoc, handled); + } - // If the node isn't tagged disabled - // Compares the received key code to found 'key' types - // Executes command if found - // Marks event as consumed - nsCOMPtr keyNode; - keysetNode->GetFirstChild(getter_AddRefs(keyNode)); - while (keyNode) { - nsCOMPtr keyElement(do_QueryInterface(keyNode)); - if (!keyElement) { - continue; - } - - nsAutoString property; - keyElement->GetNodeName(property); - //printf("keyNodeType [%s] \n", keyNodeType.ToNewCString()); // this leaks + if (!handled) { + // Give the DOM window's associated key binding doc a shot. + // XXX Check to see if we're in edit mode (how??!) + // For now just assume we aren't. + GetKeyBindingDocument(browserFile, getter_AddRefs(document)); + if (document) + LocateAndExecuteKeyBinding(keyEvent, aEventType, document, handled); + } - // See if we're redefining the special XUL modifier key - if (property.Equals("xulkey")) { - keyElement->GetAttribute(nsAutoString("key"), property); - if (property.Equals("shift")) - mXULKeyModifier = xulKeyShift; - else if (property.Equals("control")) - mXULKeyModifier = xulKeyControl; - else if (property.Equals("alt")) - mXULKeyModifier = xulKeyAlt; - else if (property.Equals("meta")) - mXULKeyModifier = xulKeyMeta; - else if (property.Equals("none")) - mXULKeyModifier = xulKeyNone; -#ifdef DEBUG_XUL_KEYS - else printf("Property didn't match: %s\n", - property.ToNewCString()); - char* propstr = property.ToNewCString(); - printf("Set xul key to %s(%d)\n", propstr, mXULKeyModifier); - Recycle(propstr); -#endif - } - if (property.Equals("key")) { - //printf("onkeypress [%s] \n", cmdToExecute.ToNewCString()); // this leaks - do { - property = falseString; - keyElement->GetAttribute(nsAutoString("disabled"), property); - if (property == trueString) { - break; - } - - nsAutoString keyName; // This should be phased out for keycode and charcode - keyElement->GetAttribute(nsAutoString("key"), keyName); - //printf("Found key [%s] \n", keyName.ToNewCString()); // this leaks - - PRUint32 theChar; - nsAutoString code; // either keycode or charcode - PRBool gotCharCode = PR_FALSE; - PRBool gotKeyCode = PR_FALSE; - keyElement->GetAttribute(nsAutoString("charcode"), code); - if(code.IsEmpty()) { - keyElement->GetAttribute(nsAutoString("keycode"), code); - if(code.IsEmpty()) { - // HACK for temporary compatibility - if(aEventType == eKeyPress) - keyEvent->GetCharCode(&theChar); - else - keyEvent->GetKeyCode(&theChar); - - } else { - // We want a keycode - keyEvent->GetKeyCode(&theChar); - gotKeyCode = PR_TRUE; - } - } else { - // We want a charcode - keyEvent->GetCharCode(&theChar); - gotCharCode = PR_TRUE; - } - - char tempChar[2]; - tempChar[0] = theChar; - tempChar[1] = 0; - nsAutoString tempChar2 = tempChar; - //printf("compare key [%s] \n", tempChar2.ToNewCString()); // this leaks - // NOTE - convert theChar and keyName to upper - keyName.ToUpperCase(); - tempChar2.ToUpperCase(); - - PRBool isMatching; - if(gotCharCode){ - isMatching = IsMatchingCharCode(tempChar2, code); - } else if(gotKeyCode){ - isMatching = IsMatchingKeyCode(theChar, code); - } - - // HACK for backward compatibility - if(!gotCharCode && ! gotKeyCode){ - isMatching = IsMatchingCharCode(tempChar2, keyName); - } - - if (!isMatching) { - break; - } + // Move up to the parent DOM window. Need to use the private API + // to cross sandboxes + nsCOMPtr piParent; + piWindow->GetPrivateParent(getter_AddRefs(piParent)); + piWindow = piParent; + } + } - // This is gross -- we're doing string compares - // every time we loop over this list! - - // Modifiers in XUL files are tri-state -- - // true, false, and unspecified. - // If a modifier is unspecified, we don't check - // the status of that modifier (always match). - - // Get the attribute for the "xulkey" modifier. - nsAutoString xproperty = ""; - keyElement->GetAttribute(nsAutoString("xulkey"), - xproperty); - - // Is the modifier key set in the event? - PRBool isModKey = PR_FALSE; - - // Check whether the shift key fails to match: - keyEvent->GetShiftKey(&isModKey); - property = ""; - keyElement->GetAttribute(nsAutoString("shift"), property); - if ((property == trueString && !isModKey) - || (property == falseString && isModKey)) - break; - // and also the xul key, if it's specified to be shift: - if (xulKeyShift == mXULKeyModifier && - ((xproperty == trueString && !isModKey) - || (xproperty == falseString && isModKey))) - break; - - // and the control key: - keyEvent->GetCtrlKey(&isModKey); - property = ""; - keyElement->GetAttribute(nsAutoString("control"), property); - if ((property == trueString && !isModKey) - || (property == falseString && isModKey)) - break; - // and if xul is control: - if (xulKeyControl == mXULKeyModifier && - ((xproperty == trueString && !isModKey) - || (xproperty == falseString && isModKey))) - break; - - // and the alt key - keyEvent->GetAltKey(&isModKey); - property = ""; - keyElement->GetAttribute(nsAutoString("alt"), property); - if ((property == trueString && !isModKey) - || (property == falseString && isModKey)) - break; - // and if xul is alt: - if (xulKeyAlt == mXULKeyModifier && - ((xproperty == trueString && !isModKey) - || (xproperty == falseString && isModKey))) - break; - - // and the meta key - keyEvent->GetMetaKey(&isModKey); - property = ""; - keyElement->GetAttribute(nsAutoString("meta"), property); - if ((property == trueString && !isModKey) - || (property == falseString && isModKey)) - break; - // and if xul is meta: - if (xulKeyMeta == mXULKeyModifier && - ((xproperty == trueString && !isModKey) - || (xproperty == falseString && isModKey))) - break; - - // Modifier tests passed so execute onclick command - nsAutoString cmdToExecute; - nsAutoString oncommand; - switch(aEventType) { - case eKeyPress: - keyElement->GetAttribute(nsAutoString("onkeypress"), cmdToExecute); -#if defined(DEBUG_saari) || defined(DEBUG_akkana) - printf("onkeypress = %s\n", - cmdToExecute.ToNewCString()); -#endif - - keyElement->GetAttribute(nsAutoString("oncommand"), oncommand); -#if defined(DEBUG_saari) || defined(DEBUG_akkana) - printf("oncommand = %s\n", oncommand.ToNewCString()); -#endif - break; - case eKeyDown: - keyElement->GetAttribute(nsAutoString("onkeydown"), cmdToExecute); - break; - case eKeyUp: - keyElement->GetAttribute(nsAutoString("onkeyup"), cmdToExecute); - break; - } - - - - // This code executes in every presentation context in which this - // document is appearing. - nsCOMPtr content; - content = do_QueryInterface(keyElement); - if (!content) { - executingKeyBind = PR_FALSE; - return NS_OK; - } - - nsCOMPtr document; - content->GetDocument(*getter_AddRefs(document)); - - if (!document) { - executingKeyBind = PR_FALSE; - return NS_OK; - } - - PRInt32 count = document->GetNumberOfShells(); - for (PRInt32 i = 0; i < count; i++) { - nsIPresShell* shell = document->GetShellAt(i); - if (nsnull == shell) - continue; - - // Retrieve the context in which our DOM event will fire. - nsCOMPtr aPresContext; - shell->GetPresContext(getter_AddRefs(aPresContext)); - - NS_RELEASE(shell); - - // Handle the DOM event - nsEventStatus status = nsEventStatus_eIgnore; - nsKeyEvent event; - event.eventStructType = NS_KEY_EVENT; - switch (aEventType) - { - case eKeyPress: event.message = NS_KEY_PRESS; break; - case eKeyDown: event.message = NS_KEY_DOWN; break; - default: event.message = NS_KEY_UP; break; - } - aKeyEvent->PreventBubble(); - aKeyEvent->PreventCapture(); - content->HandleDOMEvent(aPresContext, &event, nsnull, NS_EVENT_FLAG_INIT, &status); - ret = NS_ERROR_BASE; - - if (aEventType == eKeyPress) { - // Also execute the oncommand handler on a key press. - // Execute the oncommand event handler. - nsEventStatus stat = nsEventStatus_eIgnore; - nsMouseEvent evt; - evt.eventStructType = NS_EVENT; - evt.message = NS_MENU_ACTION; - content->HandleDOMEvent(aPresContext, &evt, nsnull, NS_EVENT_FLAG_INIT, &stat); - } - // Ok, we got this far and handled the event, so don't continue scanning nodes - //printf("Keybind executed \n"); - executingKeyBind = PR_FALSE; - return ret; - } // end for (PRInt32 i = 0; i < count; i++) - } while (PR_FALSE); - } // end if (keyNodeType.Equals("key")) - nsCOMPtr oldkeyNode(keyNode); - oldkeyNode->GetNextSibling(getter_AddRefs(keyNode)); - } // end while(keynode) - //nsCOMPtr oldkeysetNode(keysetNode); - //oldkeysetNode->GetNextSibling(getter_AddRefs(keysetNode)); - keysetNode = nsnull; - } // end while(keysetNode) - executingKeyBind = PR_FALSE; + executingKeyBind = PR_FALSE; return ret; } @@ -1162,6 +1029,530 @@ PRBool nsXULKeyListenerImpl::IsMatchingCharCode(const nsString &theChar, const n return ret; } +NS_IMETHODIMP nsXULKeyListenerImpl::GetKeyBindingDocument(nsCAutoString& aURLStr, nsIDOMXULDocument** aResult) +{ + nsCOMPtr document; + if (aURLStr != nsCAutoString("")) { + nsCOMPtr uri; + nsComponentManager::CreateInstance("component://netscape/network/standard-url", + nsnull, + NS_GET_IID(nsIURL), + getter_AddRefs(uri)); + uri->SetSpec(aURLStr); + + // We've got a file. Check our key binding file cache. + nsIURIKey key(uri); + document = NS_STATIC_CAST(nsIDOMXULDocument*, mKeyBindingTable.Get(&key)); + + if (!document) { + LoadKeyBindingDocument(uri, getter_AddRefs(document)); + if (document) { + // Put the key binding doc into our table. + mKeyBindingTable.Put(&key, document); + } + } + } + + *aResult = document; + NS_IF_ADDREF(*aResult); + + return NS_OK; +} + +NS_IMETHODIMP nsXULKeyListenerImpl::LoadKeyBindingDocument(nsIURI* aURI, nsIDOMXULDocument** aResult) +{ + *aResult = nsnull; + + // Create the XUL document + nsCOMPtr doc; + nsresult rv = nsComponentManager::CreateInstance(kXULDocumentCID, nsnull, + nsIDOMXULDocument::GetIID(), + getter_AddRefs(doc)); + + // 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. + + nsCOMPtr channel; + rv = NS_OpenURI(getter_AddRefs(channel), aURI, nsnull); + if (NS_FAILED(rv)) return rv; + + // Create a new prototype document + nsCOMPtr proto; + rv = NS_NewXULPrototypeDocument(nsnull, NS_GET_IID(nsIXULPrototypeDocument), getter_AddRefs(proto)); + if (NS_FAILED(rv)) return rv; + + nsCOMPtr owner; + rv = channel->GetOwner(getter_AddRefs(owner)); + if (NS_FAILED(rv)) return rv; + nsCOMPtr principal = do_QueryInterface(owner); + proto->SetDocumentPrincipal(principal); + + // Set master and current prototype + nsCOMPtr xulDoc = do_QueryInterface(doc); + xulDoc->SetMasterPrototype(proto); + xulDoc->SetCurrentPrototype(proto); + + + rv = proto->SetURI(aURI); + if (NS_FAILED(rv)) return rv; + + xulDoc->SetDocumentURL(aURI); + xulDoc->PrepareStyleSheets(aURI); + + nsCOMPtr sink; + rv = nsComponentManager::CreateInstance(kXULContentSinkCID, + nsnull, + NS_GET_IID(nsIXULContentSink), + getter_AddRefs(sink)); + NS_ASSERTION(NS_SUCCEEDED(rv), "unable to create XUL content sink"); + if (NS_FAILED(rv)) return rv; + + nsCOMPtr document = do_QueryInterface(doc); + rv = sink->Init(document, proto); + NS_ASSERTION(NS_SUCCEEDED(rv), "Unable to initialize content sink"); + if (NS_FAILED(rv)) return rv; + + nsCOMPtr parser; + rv = nsComponentManager::CreateInstance(kParserCID, + nsnull, + NS_GET_IID(nsIParser), + getter_AddRefs(parser)); + NS_ASSERTION(NS_SUCCEEDED(rv), "unable to create parser"); + if (NS_FAILED(rv)) return rv; + + parser->SetCommand("view"); + + nsAutoString utf8("UTF-8"); + parser->SetDocumentCharset(utf8, kCharsetFromDocTypeDefault); + parser->SetContentSink(sink); // grabs a reference to the parser + + // Now do a blocking synchronous parse of the file. + nsCOMPtr listener = do_QueryInterface(parser, &rv); + if (NS_FAILED(rv)) return rv; + + rv = parser->Parse(aURI); + if (NS_FAILED(rv)) return rv; + + nsCOMPtr in; + PRUint32 sourceOffset = 0; + rv = channel->OpenInputStream(0, -1, getter_AddRefs(in)); + + // If we couldn't open the channel, then just return. + if (NS_FAILED(rv)) return NS_OK; + + NS_ASSERTION(in != nsnull, "no input stream"); + if (! in) return NS_ERROR_FAILURE; + + rv = NS_ERROR_OUT_OF_MEMORY; + nsProxyStream* proxy = new nsProxyStream(); + if (! proxy) + return NS_ERROR_FAILURE; + + listener->OnStartRequest(channel, nsnull); + while (PR_TRUE) { + char buf[1024]; + PRUint32 readCount; + + if (NS_FAILED(rv = in->Read(buf, sizeof(buf), &readCount))) + break; // error + + if (readCount == 0) + break; // eof + + proxy->SetBuffer(buf, readCount); + + rv = listener->OnDataAvailable(channel, nsnull, proxy, sourceOffset, readCount); + sourceOffset += readCount; + if (NS_FAILED(rv)) + break; + } + listener->OnStopRequest(channel, nsnull, NS_OK, nsnull); + + // don't leak proxy! + proxy->Close(); + delete proxy; + + // The document is parsed. We now have a prototype document. + // Everything worked, so we can just hand this back now. + *aResult = doc; + NS_IF_ADDREF(*aResult); + return NS_OK; +} + +NS_IMETHODIMP +nsXULKeyListenerImpl::LocateAndExecuteKeyBinding(nsIDOMKeyEvent* aEvent, eEventType aEventType, nsIDOMXULDocument* aDocument, + PRBool& aHandledFlag) +{ + aHandledFlag = PR_FALSE; + + // locate the window element which holds the top level key bindings + nsCOMPtr rootElement; + aDocument->GetDocumentElement(getter_AddRefs(rootElement)); + if (!rootElement) + return NS_OK; + + //nsAutoString rootName; + //rootElement->GetNodeName(rootName); + //printf("Root Node [%s] \n", rootName.ToNewCString()); // this leaks + + nsCOMPtr currNode; + rootElement->GetFirstChild(getter_AddRefs(currNode)); + + while (currNode) { + nsAutoString currNodeType; + nsCOMPtr currElement(do_QueryInterface(currNode)); + if (currElement) { + currElement->GetNodeName(currNodeType); + if (currNodeType.Equals("keyset")) + return HandleEventUsingKeyset(currElement, aEvent, aEventType, aDocument, aHandledFlag); + } + + nsCOMPtr prevNode(currNode); + prevNode->GetNextSibling(getter_AddRefs(currNode)); + } + + return NS_OK; +} + +NS_IMETHODIMP +nsXULKeyListenerImpl::HandleEventUsingKeyset(nsIDOMElement* aKeysetElement, nsIDOMKeyEvent* aKeyEvent, eEventType aEventType, + nsIDOMXULDocument* aDocument, PRBool& aHandledFlag) +{ + + nsAutoString trueString = "true"; + nsAutoString falseString = "false"; + +#undef DEBUG_XUL_KEYS +#ifdef DEBUG_XUL_KEYS + if (aEventType == eKeyPress) + { + PRUint32 charcode, keycode; + keyEvent->GetCharCode(&charcode); + keyEvent->GetKeyCode(&keycode); + printf("DoKey [%s]: key code 0x%d, char code '%c', ", + (aEventType == eKeyPress ? "KeyPress" : ""), keycode, charcode); + PRBool ismod; + keyEvent->GetShiftKey(&ismod); + if (ismod) printf("[Shift] "); + keyEvent->GetCtrlKey(&ismod); + if (ismod) printf("[Ctrl] "); + keyEvent->GetAltKey(&ismod); + if (ismod) printf("[Alt] "); + keyEvent->GetMetaKey(&ismod); + if (ismod) printf("[Meta] "); + printf("\n"); + } +#endif /* DEBUG_XUL_KEYS */ + + // Given the DOM node and Key Event + // Walk the node's children looking for 'key' types + + // XXX Use the key-equivalent CSS3 property to obtain the + // appropriate modifier for this keyset. + // TODO. For now it's hardcoded. + + // If the node isn't tagged disabled + // Compares the received key code to found 'key' types + // Executes command if found + // Marks event as consumed + + nsCOMPtr keyNode; + aKeysetElement->GetFirstChild(getter_AddRefs(keyNode)); + while (keyNode) { + nsCOMPtr keyElement(do_QueryInterface(keyNode)); + if (!keyElement) + continue; + + nsAutoString property; + keyElement->GetNodeName(property); + //printf("keyNodeType [%s] \n", keyNodeType.ToNewCString()); // this leaks + + if (property.Equals("key")) { + //printf("onkeypress [%s] \n", cmdToExecute.ToNewCString()); // this leaks + do { + property = falseString; + keyElement->GetAttribute(nsAutoString("disabled"), property); + if (property == trueString) { + break; + } + + nsAutoString keyName; // This should be phased out for keycode and charcode + keyElement->GetAttribute(nsAutoString("key"), keyName); + //printf("Found key [%s] \n", keyName.ToNewCString()); // this leaks + + PRUint32 theChar; + nsAutoString code; // either keycode or charcode + PRBool gotCharCode = PR_FALSE; + PRBool gotKeyCode = PR_FALSE; + keyElement->GetAttribute(nsAutoString("charcode"), code); + if(code.IsEmpty()) { + keyElement->GetAttribute(nsAutoString("keycode"), code); + if(code.IsEmpty()) { + // HACK for temporary compatibility + if(aEventType == eKeyPress) + aKeyEvent->GetCharCode(&theChar); + else + aKeyEvent->GetKeyCode(&theChar); + + } else { + // We want a keycode + aKeyEvent->GetKeyCode(&theChar); + gotKeyCode = PR_TRUE; + } + } else { + // We want a charcode + aKeyEvent->GetCharCode(&theChar); + gotCharCode = PR_TRUE; + } + + char tempChar[2]; + tempChar[0] = theChar; + tempChar[1] = 0; + nsAutoString tempChar2 = tempChar; + //printf("compare key [%s] \n", tempChar2.ToNewCString()); // this leaks + // NOTE - convert theChar and keyName to upper + keyName.ToUpperCase(); + tempChar2.ToUpperCase(); + + PRBool isMatching; + if(gotCharCode){ + isMatching = IsMatchingCharCode(tempChar2, code); + } else if(gotKeyCode){ + isMatching = IsMatchingKeyCode(theChar, code); + } + + // HACK for backward compatibility + if(!gotCharCode && ! gotKeyCode){ + isMatching = IsMatchingCharCode(tempChar2, keyName); + } + + if (!isMatching) { + break; + } + + // This is gross -- we're doing string compares + // every time we loop over this list! + + // Modifiers in XUL files are tri-state -- + // true, false, and unspecified. + // If a modifier is unspecified, we don't check + // the status of that modifier (always match). + + // Get the attribute for the "xulkey" modifier. + nsAutoString xproperty = ""; + keyElement->GetAttribute(nsAutoString("xulkey"), + xproperty); + + // Is the modifier key set in the event? + PRBool isModKey = PR_FALSE; + + // Check whether the shift key fails to match: + aKeyEvent->GetShiftKey(&isModKey); + property = ""; + keyElement->GetAttribute(nsAutoString("shift"), property); + if ((property == trueString && !isModKey) + || (property == falseString && isModKey)) + break; + // and also the xul key, if it's specified to be shift: + if (xulKeyShift == mXULKeyModifier && + ((xproperty == trueString && !isModKey) + || (xproperty == falseString && isModKey))) + break; + + // and the control key: + aKeyEvent->GetCtrlKey(&isModKey); + property = ""; + keyElement->GetAttribute(nsAutoString("control"), property); + if ((property == trueString && !isModKey) + || (property == falseString && isModKey)) + break; + // and if xul is control: + if (xulKeyControl == mXULKeyModifier && + ((xproperty == trueString && !isModKey) + || (xproperty == falseString && isModKey))) + break; + + // and the alt key + aKeyEvent->GetAltKey(&isModKey); + property = ""; + keyElement->GetAttribute(nsAutoString("alt"), property); + if ((property == trueString && !isModKey) + || (property == falseString && isModKey)) + break; + // and if xul is alt: + if (xulKeyAlt == mXULKeyModifier && + ((xproperty == trueString && !isModKey) + || (xproperty == falseString && isModKey))) + break; + + // and the meta key + aKeyEvent->GetMetaKey(&isModKey); + property = ""; + keyElement->GetAttribute(nsAutoString("meta"), property); + if ((property == trueString && !isModKey) + || (property == falseString && isModKey)) + break; + // and if xul is meta: + if (xulKeyMeta == mXULKeyModifier && + ((xproperty == trueString && !isModKey) + || (xproperty == falseString && isModKey))) + break; + + // Modifier tests passed so execute onclick command + nsAutoString cmdToExecute; + nsAutoString oncommand; + switch(aEventType) { + case eKeyPress: + keyElement->GetAttribute(nsAutoString("onkeypress"), cmdToExecute); +#if defined(DEBUG_saari) || defined(DEBUG_akkana) + printf("onkeypress = %s\n", + cmdToExecute.ToNewCString()); +#endif + + keyElement->GetAttribute(nsAutoString("oncommand"), oncommand); +#if defined(DEBUG_saari) || defined(DEBUG_akkana) + printf("oncommand = %s\n", oncommand.ToNewCString()); +#endif + break; + case eKeyDown: + keyElement->GetAttribute(nsAutoString("onkeydown"), cmdToExecute); + break; + case eKeyUp: + keyElement->GetAttribute(nsAutoString("onkeyup"), cmdToExecute); + break; + } + + // This code executes in every presentation context in which this + // document is appearing. + nsCOMPtr document = do_QueryInterface(aDocument); + aHandledFlag = PR_TRUE; + nsCOMPtr content = do_QueryInterface(keyElement); + if (aDocument != mDOMDocument) { + nsCOMPtr handlerOwner = do_QueryInterface(keyElement); + if (handlerOwner) { + nsAutoString eventStr; + switch(aEventType) { + case eKeyPress: + eventStr = "onkeypress"; + break; + case eKeyDown: + eventStr = "onkeydown"; + break; + case eKeyUp: + eventStr = "onkeyup"; + break; + } + + // Look for a compiled event handler on the key element itself. + nsCOMPtr eventName = getter_AddRefs(NS_NewAtom(eventStr)); + void* handler = nsnull; + handlerOwner->GetCompiledEventHandler(eventName, &handler); + + nsCOMPtr masterGlobalObject; + nsCOMPtr masterDoc = do_QueryInterface(mDOMDocument); + masterDoc->GetScriptGlobalObject(getter_AddRefs(masterGlobalObject)); + nsCOMPtr masterContext; + masterGlobalObject->GetContext(getter_AddRefs(masterContext)); + + if (!handler) { + // It hasn't been compiled before. + nsCOMPtr globalObject; + document->GetScriptGlobalObject(getter_AddRefs(globalObject)); + if (!globalObject) { + NS_NewScriptGlobalObject(getter_AddRefs(globalObject)); + document->SetScriptGlobalObject(globalObject); + } + + nsCOMPtr context; + globalObject->GetContext(getter_AddRefs(context)); + if (!context) { + NS_CreateScriptContext(globalObject, getter_AddRefs(context)); + } + + globalObject->SetNewDocument(aDocument); + + nsCOMPtr owner = do_QueryInterface(keyElement); + void* scriptObject; + owner->GetScriptObject(context, &scriptObject); + + nsCOMPtr keyContent = do_QueryInterface(keyElement); + nsAutoString value; + keyContent->GetAttribute(kNameSpaceID_None, eventName, value); + if (value != "") { + context->CompileEventHandler(scriptObject, eventName, value, &handler); + } + + if (handler) + handlerOwner->SetCompiledEventHandler(eventName, handler); + } + + if (handler) { + nsCOMPtr rootElement; + mDOMDocument->GetDocumentElement(getter_AddRefs(rootElement)); + nsCOMPtr owner = do_QueryInterface(rootElement); + void* scriptObject; + owner->GetScriptObject(masterContext, &scriptObject); + + masterContext->BindCompiledEventHandler(scriptObject, eventName, handler); + + nsCOMPtr eventListener; + NS_NewJSEventListener(getter_AddRefs(eventListener), masterContext, owner); + eventListener->HandleEvent(aKeyEvent); + + masterContext->BindCompiledEventHandler(scriptObject, eventName, nsnull); + + return NS_OK; + } + } + } + + PRInt32 count = document->GetNumberOfShells(); + for (PRInt32 i = 0; i < count; i++) { + nsCOMPtr shell = getter_AddRefs(document->GetShellAt(i)); + + // Retrieve the context in which our DOM event will fire. + nsCOMPtr aPresContext; + shell->GetPresContext(getter_AddRefs(aPresContext)); + + // Handle the DOM event + nsEventStatus status = nsEventStatus_eIgnore; + nsKeyEvent event; + event.eventStructType = NS_KEY_EVENT; + switch (aEventType) + { + case eKeyPress: event.message = NS_KEY_PRESS; break; + case eKeyDown: event.message = NS_KEY_DOWN; break; + default: event.message = NS_KEY_UP; break; + } + aKeyEvent->PreventBubble(); + aKeyEvent->PreventCapture(); + content->HandleDOMEvent(aPresContext, &event, nsnull, NS_EVENT_FLAG_INIT, &status); + nsresult ret = NS_ERROR_BASE; + + if (aEventType == eKeyPress) { + // Also execute the oncommand handler on a key press. + // Execute the oncommand event handler. + nsEventStatus stat = nsEventStatus_eIgnore; + nsMouseEvent evt; + evt.eventStructType = NS_EVENT; + evt.message = NS_MENU_ACTION; + content->HandleDOMEvent(aPresContext, &evt, nsnull, NS_EVENT_FLAG_INIT, &stat); + } + // Ok, we got this far and handled the event, so don't continue scanning nodes + //printf("Keybind executed \n"); + return ret; + } // end for (PRInt32 i = 0; i < count; i++) + } while (PR_FALSE); // do { ... + } // end if (keyNodeType.Equals("key")) + + nsCOMPtr oldkeyNode(keyNode); + oldkeyNode->GetNextSibling(getter_AddRefs(keyNode)); + } // end while(keynode) + + return NS_OK; +} + //////////////////////////////////////////////////////////////// nsresult NS_NewXULKeyListener(nsIXULKeyListener** aListener)