зеркало из https://github.com/mozilla/gecko-dev.git
Changing focus tracker to be the command dispatcher.
This commit is contained in:
Родитель
9ebb081112
Коммит
49d00452b7
|
@ -25,8 +25,8 @@
|
|||
#include "nsVoidArray.h"
|
||||
|
||||
#include "nsIDOMElement.h"
|
||||
#include "nsIDOMXULFocusTracker.h"
|
||||
#include "nsIXULFocusTracker.h"
|
||||
#include "nsIDOMXULCommandDispatcher.h"
|
||||
#include "nsIXULCommandDispatcher.h"
|
||||
#include "nsIDOMFocusListener.h"
|
||||
#include "nsRDFCID.h"
|
||||
|
||||
|
@ -41,6 +41,9 @@
|
|||
#include "nsIDOMXULElement.h"
|
||||
#include "nsIController.h"
|
||||
|
||||
#include "nsIPresContext.h"
|
||||
#include "nsIPresShell.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||
|
@ -50,24 +53,24 @@ static NS_DEFINE_IID(kIDomElementIID, NS_IDOMELEMENT_IID);
|
|||
static NS_DEFINE_IID(kIDomEventListenerIID, NS_IDOMEVENTLISTENER_IID);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// XULFocusTrackerImpl
|
||||
// XULCommandDispatcherImpl
|
||||
//
|
||||
// This is the focus manager for XUL documents.
|
||||
//
|
||||
class XULFocusTrackerImpl : public nsIDOMXULFocusTracker,
|
||||
public nsIXULFocusTracker,
|
||||
public nsIDOMFocusListener
|
||||
class XULCommandDispatcherImpl : public nsIDOMXULCommandDispatcher,
|
||||
public nsIXULCommandDispatcher,
|
||||
public nsIDOMFocusListener
|
||||
{
|
||||
public:
|
||||
XULFocusTrackerImpl(void);
|
||||
virtual ~XULFocusTrackerImpl(void);
|
||||
XULCommandDispatcherImpl(void);
|
||||
virtual ~XULCommandDispatcherImpl(void);
|
||||
|
||||
public:
|
||||
// nsISupports
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// nsIDOMXULFocusTracker interface
|
||||
NS_DECL_IDOMXULFOCUSTRACKER
|
||||
// nsIDOMXULCommandDispatcher interface
|
||||
NS_DECL_IDOMXULCOMMANDDISPATCHER
|
||||
|
||||
// nsIDOMFocusListener
|
||||
virtual nsresult Focus(nsIDOMEvent* aEvent);
|
||||
|
@ -83,36 +86,36 @@ private:
|
|||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
XULFocusTrackerImpl::XULFocusTrackerImpl(void)
|
||||
XULCommandDispatcherImpl::XULCommandDispatcherImpl(void)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
mCurrentElement = nsnull;
|
||||
mFocusListeners = nsnull;
|
||||
}
|
||||
|
||||
XULFocusTrackerImpl::~XULFocusTrackerImpl(void)
|
||||
XULCommandDispatcherImpl::~XULCommandDispatcherImpl(void)
|
||||
{
|
||||
delete mFocusListeners;
|
||||
}
|
||||
|
||||
NS_IMPL_ADDREF(XULFocusTrackerImpl)
|
||||
NS_IMPL_RELEASE(XULFocusTrackerImpl)
|
||||
NS_IMPL_ADDREF(XULCommandDispatcherImpl)
|
||||
NS_IMPL_RELEASE(XULCommandDispatcherImpl)
|
||||
|
||||
NS_IMETHODIMP
|
||||
XULFocusTrackerImpl::QueryInterface(REFNSIID iid, void** result)
|
||||
XULCommandDispatcherImpl::QueryInterface(REFNSIID iid, void** result)
|
||||
{
|
||||
if (! result)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
*result = nsnull;
|
||||
if (iid.Equals(nsIXULFocusTracker::GetIID()) ||
|
||||
if (iid.Equals(nsIXULCommandDispatcher::GetIID()) ||
|
||||
iid.Equals(kISupportsIID)) {
|
||||
*result = NS_STATIC_CAST(nsIXULFocusTracker*, this);
|
||||
*result = NS_STATIC_CAST(nsIXULCommandDispatcher*, this);
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
else if (iid.Equals(nsIDOMXULFocusTracker::GetIID())) {
|
||||
*result = NS_STATIC_CAST(nsIDOMXULFocusTracker*, this);
|
||||
else if (iid.Equals(nsIDOMXULCommandDispatcher::GetIID())) {
|
||||
*result = NS_STATIC_CAST(nsIDOMXULCommandDispatcher*, this);
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -135,7 +138,7 @@ XULFocusTrackerImpl::QueryInterface(REFNSIID iid, void** result)
|
|||
// nsIDOMXULTracker Interface
|
||||
|
||||
NS_IMETHODIMP
|
||||
XULFocusTrackerImpl::GetCurrent(nsIDOMElement** aElement)
|
||||
XULCommandDispatcherImpl::GetFocusedElement(nsIDOMElement** aElement)
|
||||
{
|
||||
NS_IF_ADDREF(mCurrentElement);
|
||||
*aElement = mCurrentElement;
|
||||
|
@ -143,15 +146,29 @@ XULFocusTrackerImpl::GetCurrent(nsIDOMElement** aElement)
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
XULFocusTrackerImpl::SetCurrent(nsIDOMElement* aElement)
|
||||
XULCommandDispatcherImpl::SetFocusedElement(nsIDOMElement* aElement)
|
||||
{
|
||||
mCurrentElement = aElement;
|
||||
FocusChanged();
|
||||
UpdateCommands();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
XULFocusTrackerImpl::AddFocusListener(nsIDOMElement* aElement)
|
||||
XULCommandDispatcherImpl::GetFocusedWindow(nsIDOMWindow** aElement)
|
||||
{
|
||||
// XXX Implement
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
XULCommandDispatcherImpl::SetFocusedWindow(nsIDOMWindow* aElement)
|
||||
{
|
||||
// XXX Implement
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
XULCommandDispatcherImpl::AddCommand(nsIDOMElement* aElement)
|
||||
{
|
||||
if (!mFocusListeners) {
|
||||
mFocusListeners = new nsVoidArray();
|
||||
|
@ -161,7 +178,7 @@ XULFocusTrackerImpl::AddFocusListener(nsIDOMElement* aElement)
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
XULFocusTrackerImpl::RemoveFocusListener(nsIDOMElement* aElement)
|
||||
XULCommandDispatcherImpl::RemoveCommand(nsIDOMElement* aElement)
|
||||
{
|
||||
if (mFocusListeners) {
|
||||
mFocusListeners->RemoveElement((void*)aElement); // Weak ref to element
|
||||
|
@ -171,19 +188,45 @@ XULFocusTrackerImpl::RemoveFocusListener(nsIDOMElement* aElement)
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
XULFocusTrackerImpl::FocusChanged()
|
||||
XULCommandDispatcherImpl::UpdateCommands()
|
||||
{
|
||||
if (mFocusListeners) {
|
||||
PRInt32 count = mFocusListeners->Count();
|
||||
for (PRInt32 i = 0; i < count; i++) {
|
||||
printf("Notifying an element of a focus change!\n");
|
||||
nsIDOMElement* domElement = (nsIDOMElement*)mFocusListeners->ElementAt(i);
|
||||
|
||||
nsCOMPtr<nsIContent> content;
|
||||
content = do_QueryInterface(domElement);
|
||||
|
||||
nsCOMPtr<nsIDocument> document;
|
||||
content->GetDocument(*getter_AddRefs(document));
|
||||
|
||||
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<nsIPresContext> aPresContext;
|
||||
shell->GetPresContext(getter_AddRefs(aPresContext));
|
||||
|
||||
NS_RELEASE(shell);
|
||||
|
||||
// Handle the DOM event
|
||||
nsEventStatus status = nsEventStatus_eIgnore;
|
||||
nsEvent event;
|
||||
event.eventStructType = NS_EVENT;
|
||||
event.message = NS_FORM_CHANGE; // XXX: I feel dirty and evil for subverting this.
|
||||
content->HandleDOMEvent(*aPresContext, &event, nsnull, NS_EVENT_FLAG_INIT, status);
|
||||
}
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
XULFocusTrackerImpl::GetController(nsIController** aResult)
|
||||
XULCommandDispatcherImpl::GetController(nsIController** aResult)
|
||||
{
|
||||
if (mCurrentElement) {
|
||||
nsCOMPtr<nsIDOMXULElement> xulElement = do_QueryInterface(mCurrentElement);
|
||||
|
@ -196,7 +239,7 @@ XULFocusTrackerImpl::GetController(nsIController** aResult)
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
XULFocusTrackerImpl::SetController(nsIController* aController)
|
||||
XULCommandDispatcherImpl::SetController(nsIController* aController)
|
||||
{
|
||||
if (mCurrentElement) {
|
||||
nsCOMPtr<nsIDOMXULElement> xulElement = do_QueryInterface(mCurrentElement);
|
||||
|
@ -212,30 +255,30 @@ XULFocusTrackerImpl::SetController(nsIController* aController)
|
|||
/////
|
||||
|
||||
nsresult
|
||||
XULFocusTrackerImpl::Focus(nsIDOMEvent* aEvent)
|
||||
XULCommandDispatcherImpl::Focus(nsIDOMEvent* aEvent)
|
||||
{
|
||||
nsCOMPtr<nsIDOMNode> t;
|
||||
aEvent->GetTarget(getter_AddRefs(t));
|
||||
nsCOMPtr<nsIDOMElement> target = do_QueryInterface(t);
|
||||
|
||||
if (target) {
|
||||
SetCurrent(target);
|
||||
FocusChanged();
|
||||
SetFocusedElement(target);
|
||||
UpdateCommands();
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
XULFocusTrackerImpl::Blur(nsIDOMEvent* aEvent)
|
||||
XULCommandDispatcherImpl::Blur(nsIDOMEvent* aEvent)
|
||||
{
|
||||
nsCOMPtr<nsIDOMNode> t;
|
||||
aEvent->GetTarget(getter_AddRefs(t));
|
||||
nsCOMPtr<nsIDOMElement> target = do_QueryInterface(t);
|
||||
|
||||
if (target.get() == mCurrentElement) {
|
||||
SetCurrent(nsnull);
|
||||
FocusChanged();
|
||||
SetFocusedElement(nsnull);
|
||||
UpdateCommands();
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
|
@ -243,13 +286,13 @@ XULFocusTrackerImpl::Blur(nsIDOMEvent* aEvent)
|
|||
|
||||
////////////////////////////////////////////////////////////////
|
||||
nsresult
|
||||
NS_NewXULFocusTracker(nsIXULFocusTracker** focusTracker)
|
||||
NS_NewXULCommandDispatcher(nsIXULCommandDispatcher** CommandDispatcher)
|
||||
{
|
||||
XULFocusTrackerImpl* focus = new XULFocusTrackerImpl();
|
||||
XULCommandDispatcherImpl* focus = new XULCommandDispatcherImpl();
|
||||
if (!focus)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
NS_ADDREF(focus);
|
||||
*focusTracker = focus;
|
||||
*CommandDispatcher = focus;
|
||||
return NS_OK;
|
||||
}
|
|
@ -108,8 +108,8 @@
|
|||
|
||||
#include "nsIFrameReflow.h"
|
||||
#include "nsIBrowserWindow.h"
|
||||
#include "nsIDOMXULFocusTracker.h"
|
||||
#include "nsIXULFocusTracker.h"
|
||||
#include "nsIDOMXULCommandDispatcher.h"
|
||||
#include "nsIXULCommandDispatcher.h"
|
||||
#include "nsIDOMEventCapturer.h"
|
||||
#include "nsIDOMEventReceiver.h"
|
||||
#include "nsIDOMEventListener.h"
|
||||
|
@ -176,8 +176,8 @@ static NS_DEFINE_CID(kTextNodeCID, NS_TEXTNODE_CID);
|
|||
static NS_DEFINE_CID(kWellFormedDTDCID, NS_WELLFORMEDDTD_CID);
|
||||
static NS_DEFINE_CID(kXULContentSinkCID, NS_XULCONTENTSINK_CID);
|
||||
|
||||
static NS_DEFINE_CID(kXULFocusTrackerCID, NS_XULFOCUSTRACKER_CID);
|
||||
static NS_DEFINE_IID(kIXULFocusTrackerIID, NS_IXULFOCUSTRACKER_IID);
|
||||
static NS_DEFINE_CID(kXULCommandDispatcherCID, NS_XULCOMMANDDISPATCHER_CID);
|
||||
static NS_DEFINE_IID(kIXULCommandDispatcherIID, NS_IXULCOMMANDDISPATCHER_IID);
|
||||
static NS_DEFINE_IID(kLWBrkCID, NS_LWBRK_CID);
|
||||
static NS_DEFINE_IID(kILineBreakerFactoryIID, NS_ILINEBREAKERFACTORY_IID);
|
||||
static NS_DEFINE_IID(kIWordBreakerFactoryIID, NS_IWORDBREAKERFACTORY_IID);
|
||||
|
@ -793,7 +793,7 @@ protected:
|
|||
nsVoidArray mSubDocuments; // [OWNER] of subelements
|
||||
PRBool mIsPopup;
|
||||
nsCOMPtr<nsIDOMHTMLFormElement> mHiddenForm; // [OWNER] of this content element
|
||||
nsCOMPtr<nsIDOMXULFocusTracker> mFocusTracker; // [OWNER] of the focus tracker
|
||||
nsCOMPtr<nsIDOMXULCommandDispatcher> mCommandDispatcher; // [OWNER] of the focus tracker
|
||||
|
||||
// The following are pointers into the content model which provide access to
|
||||
// the objects triggering either a popup or a tooltip. These are marked as
|
||||
|
@ -2956,9 +2956,9 @@ XULDocumentImpl::SetTooltipElement(nsIDOMElement* anElement)
|
|||
|
||||
|
||||
NS_IMETHODIMP
|
||||
XULDocumentImpl::GetFocus(nsIDOMXULFocusTracker** aTracker)
|
||||
XULDocumentImpl::GetCommandDispatcher(nsIDOMXULCommandDispatcher** aTracker)
|
||||
{
|
||||
*aTracker = mFocusTracker;
|
||||
*aTracker = mCommandDispatcher;
|
||||
NS_IF_ADDREF(*aTracker);
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -3904,19 +3904,19 @@ XULDocumentImpl::Init(void)
|
|||
return rv;
|
||||
|
||||
// Create our focus tracker and hook it up.
|
||||
if (NS_FAILED(rv = nsComponentManager::CreateInstance(kXULFocusTrackerCID,
|
||||
if (NS_FAILED(rv = nsComponentManager::CreateInstance(kXULCommandDispatcherCID,
|
||||
nsnull,
|
||||
kIXULFocusTrackerIID,
|
||||
(void**) &mFocusTracker))) {
|
||||
kIXULCommandDispatcherIID,
|
||||
(void**) &mCommandDispatcher))) {
|
||||
NS_ERROR("unable to create a focus tracker");
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDOMEventListener> focusTracker = do_QueryInterface(mFocusTracker);
|
||||
if (focusTracker) {
|
||||
nsCOMPtr<nsIDOMEventListener> CommandDispatcher = do_QueryInterface(mCommandDispatcher);
|
||||
if (CommandDispatcher) {
|
||||
// Take the focus tracker and add it as an event listener for focus and blur events.
|
||||
AddEventListener("focus", focusTracker, PR_TRUE);
|
||||
AddEventListener("blur", focusTracker, PR_TRUE);
|
||||
AddEventListener("focus", CommandDispatcher, PR_TRUE);
|
||||
AddEventListener("blur", CommandDispatcher, PR_TRUE);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
interface XULCommandDispatcher {
|
||||
|
||||
/* IID: { 0xf3c50361, 0x14fe, 0x11d3, \
|
||||
{ 0xbf, 0x87, 0x0, 0x10, 0x5a, 0x1b, 0x6, 0x27 } } */
|
||||
|
||||
attribute Element focusedElement;
|
||||
attribute Window focusedWindow;
|
||||
|
||||
void addCommand(in Element listener);
|
||||
void removeCommand(in Element listener);
|
||||
|
||||
void updateCommands();
|
||||
|
||||
xpidl nsIController getController();
|
||||
void setController(in xpidl nsIController controller);
|
||||
};
|
|
@ -6,7 +6,7 @@ interface XULDocument : Document {
|
|||
attribute Element popupElement;
|
||||
attribute Element tooltipElement;
|
||||
|
||||
readonly attribute XULFocusTracker focus;
|
||||
readonly attribute XULCommandDispatcher commandDispatcher;
|
||||
|
||||
Element getElementById(in DOMString id);
|
||||
NodeList getElementsByAttribute(in DOMString name, in DOMString value);
|
||||
|
|
|
@ -0,0 +1,86 @@
|
|||
/* -*- 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/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
/* AUTO-GENERATED. DO NOT EDIT!!! */
|
||||
|
||||
#ifndef nsIDOMXULCommandDispatcher_h__
|
||||
#define nsIDOMXULCommandDispatcher_h__
|
||||
|
||||
#include "nsISupports.h"
|
||||
#include "nsString.h"
|
||||
#include "nsIScriptContext.h"
|
||||
|
||||
class nsIController;
|
||||
class nsIDOMElement;
|
||||
class nsIDOMWindow;
|
||||
|
||||
#define NS_IDOMXULCOMMANDDISPATCHER_IID \
|
||||
{ 0xf3c50361, 0x14fe, 0x11d3, \
|
||||
{ 0xbf, 0x87, 0x0, 0x10, 0x5a, 0x1b, 0x6, 0x27 } }
|
||||
|
||||
class nsIDOMXULCommandDispatcher : public nsISupports {
|
||||
public:
|
||||
static const nsIID& GetIID() { static nsIID iid = NS_IDOMXULCOMMANDDISPATCHER_IID; return iid; }
|
||||
|
||||
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 AddCommand(nsIDOMElement* aListener)=0;
|
||||
|
||||
NS_IMETHOD RemoveCommand(nsIDOMElement* aListener)=0;
|
||||
|
||||
NS_IMETHOD UpdateCommands()=0;
|
||||
|
||||
NS_IMETHOD GetController(nsIController** aReturn)=0;
|
||||
|
||||
NS_IMETHOD SetController(nsIController* aController)=0;
|
||||
};
|
||||
|
||||
|
||||
#define NS_DECL_IDOMXULCOMMANDDISPATCHER \
|
||||
NS_IMETHOD GetFocusedElement(nsIDOMElement** aFocusedElement); \
|
||||
NS_IMETHOD SetFocusedElement(nsIDOMElement* aFocusedElement); \
|
||||
NS_IMETHOD GetFocusedWindow(nsIDOMWindow** aFocusedWindow); \
|
||||
NS_IMETHOD SetFocusedWindow(nsIDOMWindow* aFocusedWindow); \
|
||||
NS_IMETHOD AddCommand(nsIDOMElement* aListener); \
|
||||
NS_IMETHOD RemoveCommand(nsIDOMElement* aListener); \
|
||||
NS_IMETHOD UpdateCommands(); \
|
||||
NS_IMETHOD GetController(nsIController** aReturn); \
|
||||
NS_IMETHOD SetController(nsIController* aController); \
|
||||
|
||||
|
||||
|
||||
#define NS_FORWARD_IDOMXULCOMMANDDISPATCHER(_to) \
|
||||
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 AddCommand(nsIDOMElement* aListener) { return _to AddCommand(aListener); } \
|
||||
NS_IMETHOD RemoveCommand(nsIDOMElement* aListener) { return _to RemoveCommand(aListener); } \
|
||||
NS_IMETHOD UpdateCommands() { return _to UpdateCommands(); } \
|
||||
NS_IMETHOD GetController(nsIController** aReturn) { return _to GetController(aReturn); } \
|
||||
NS_IMETHOD SetController(nsIController* aController) { return _to SetController(aController); } \
|
||||
|
||||
|
||||
extern "C" NS_DOM nsresult NS_InitXULCommandDispatcherClass(nsIScriptContext *aContext, void **aPrototype);
|
||||
|
||||
extern "C" NS_DOM nsresult NS_NewScriptXULCommandDispatcher(nsIScriptContext *aContext, nsISupports *aSupports, nsISupports *aParent, void **aReturn);
|
||||
|
||||
#endif // nsIDOMXULCommandDispatcher_h__
|
|
@ -26,7 +26,7 @@
|
|||
#include "nsIDOMDocument.h"
|
||||
|
||||
class nsIDOMElement;
|
||||
class nsIDOMXULFocusTracker;
|
||||
class nsIDOMXULCommandDispatcher;
|
||||
class nsIDOMNodeList;
|
||||
|
||||
#define NS_IDOMXULDOCUMENT_IID \
|
||||
|
@ -43,7 +43,7 @@ public:
|
|||
NS_IMETHOD GetTooltipElement(nsIDOMElement** aTooltipElement)=0;
|
||||
NS_IMETHOD SetTooltipElement(nsIDOMElement* aTooltipElement)=0;
|
||||
|
||||
NS_IMETHOD GetFocus(nsIDOMXULFocusTracker** aFocus)=0;
|
||||
NS_IMETHOD GetCommandDispatcher(nsIDOMXULCommandDispatcher** aCommandDispatcher)=0;
|
||||
|
||||
NS_IMETHOD GetElementById(const nsString& aId, nsIDOMElement** aReturn)=0;
|
||||
|
||||
|
@ -56,7 +56,7 @@ public:
|
|||
NS_IMETHOD SetPopupElement(nsIDOMElement* aPopupElement); \
|
||||
NS_IMETHOD GetTooltipElement(nsIDOMElement** aTooltipElement); \
|
||||
NS_IMETHOD SetTooltipElement(nsIDOMElement* aTooltipElement); \
|
||||
NS_IMETHOD GetFocus(nsIDOMXULFocusTracker** aFocus); \
|
||||
NS_IMETHOD GetCommandDispatcher(nsIDOMXULCommandDispatcher** aCommandDispatcher); \
|
||||
NS_IMETHOD GetElementById(const nsString& aId, nsIDOMElement** aReturn); \
|
||||
NS_IMETHOD GetElementsByAttribute(const nsString& aName, const nsString& aValue, nsIDOMNodeList** aReturn); \
|
||||
|
||||
|
@ -67,7 +67,7 @@ public:
|
|||
NS_IMETHOD SetPopupElement(nsIDOMElement* aPopupElement) { return _to SetPopupElement(aPopupElement); } \
|
||||
NS_IMETHOD GetTooltipElement(nsIDOMElement** aTooltipElement) { return _to GetTooltipElement(aTooltipElement); } \
|
||||
NS_IMETHOD SetTooltipElement(nsIDOMElement* aTooltipElement) { return _to SetTooltipElement(aTooltipElement); } \
|
||||
NS_IMETHOD GetFocus(nsIDOMXULFocusTracker** aFocus) { return _to GetFocus(aFocus); } \
|
||||
NS_IMETHOD GetCommandDispatcher(nsIDOMXULCommandDispatcher** aCommandDispatcher) { return _to GetCommandDispatcher(aCommandDispatcher); } \
|
||||
NS_IMETHOD GetElementById(const nsString& aId, nsIDOMElement** aReturn) { return _to GetElementById(aId, aReturn); } \
|
||||
NS_IMETHOD GetElementsByAttribute(const nsString& aName, const nsString& aValue, nsIDOMNodeList** aReturn) { return _to GetElementsByAttribute(aName, aValue, aReturn); } \
|
||||
|
||||
|
|
|
@ -29,7 +29,8 @@
|
|||
#include "nsString.h"
|
||||
#include "nsIController.h"
|
||||
#include "nsIDOMElement.h"
|
||||
#include "nsIDOMXULFocusTracker.h"
|
||||
#include "nsIDOMXULCommandDispatcher.h"
|
||||
#include "nsIDOMWindow.h"
|
||||
|
||||
|
||||
static NS_DEFINE_IID(kIScriptObjectOwnerIID, NS_ISCRIPTOBJECTOWNER_IID);
|
||||
|
@ -37,27 +38,30 @@ 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(kIXULFocusTrackerIID, NS_IDOMXULFOCUSTRACKER_IID);
|
||||
static NS_DEFINE_IID(kIXULCommandDispatcherIID, NS_IDOMXULCOMMANDDISPATCHER_IID);
|
||||
static NS_DEFINE_IID(kIWindowIID, NS_IDOMWINDOW_IID);
|
||||
|
||||
NS_DEF_PTR(nsIController);
|
||||
NS_DEF_PTR(nsIDOMElement);
|
||||
NS_DEF_PTR(nsIDOMXULFocusTracker);
|
||||
NS_DEF_PTR(nsIDOMXULCommandDispatcher);
|
||||
NS_DEF_PTR(nsIDOMWindow);
|
||||
|
||||
//
|
||||
// XULFocusTracker property ids
|
||||
// XULCommandDispatcher property ids
|
||||
//
|
||||
enum XULFocusTracker_slots {
|
||||
XULFOCUSTRACKER_CURRENT = -1
|
||||
enum XULCommandDispatcher_slots {
|
||||
XULCOMMANDDISPATCHER_FOCUSEDELEMENT = -1,
|
||||
XULCOMMANDDISPATCHER_FOCUSEDWINDOW = -2
|
||||
};
|
||||
|
||||
/***********************************************************************/
|
||||
//
|
||||
// XULFocusTracker Properties Getter
|
||||
// XULCommandDispatcher Properties Getter
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
GetXULFocusTrackerProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
GetXULCommandDispatcherProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
{
|
||||
nsIDOMXULFocusTracker *a = (nsIDOMXULFocusTracker*)nsJSUtils::nsGetNativeThis(cx, obj);
|
||||
nsIDOMXULCommandDispatcher *a = (nsIDOMXULCommandDispatcher*)nsJSUtils::nsGetNativeThis(cx, obj);
|
||||
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
if (nsnull == a) {
|
||||
|
@ -72,15 +76,32 @@ GetXULFocusTrackerProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
|||
return JS_FALSE;
|
||||
}
|
||||
switch(JSVAL_TO_INT(id)) {
|
||||
case XULFOCUSTRACKER_CURRENT:
|
||||
case XULCOMMANDDISPATCHER_FOCUSEDELEMENT:
|
||||
{
|
||||
secMan->CheckScriptAccess(scriptCX, obj, "xulfocustracker.current", &ok);
|
||||
secMan->CheckScriptAccess(scriptCX, obj, "xulcommanddispatcher.focusedelement", &ok);
|
||||
if (!ok) {
|
||||
//Need to throw error here
|
||||
return JS_FALSE;
|
||||
}
|
||||
nsIDOMElement* prop;
|
||||
if (NS_SUCCEEDED(a->GetCurrent(&prop))) {
|
||||
if (NS_SUCCEEDED(a->GetFocusedElement(&prop))) {
|
||||
// get the js object
|
||||
nsJSUtils::nsConvertObjectToJSVal((nsISupports *)prop, cx, vp);
|
||||
}
|
||||
else {
|
||||
return JS_FALSE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case XULCOMMANDDISPATCHER_FOCUSEDWINDOW:
|
||||
{
|
||||
secMan->CheckScriptAccess(scriptCX, obj, "xulcommanddispatcher.focusedwindow", &ok);
|
||||
if (!ok) {
|
||||
//Need to throw error here
|
||||
return JS_FALSE;
|
||||
}
|
||||
nsIDOMWindow* prop;
|
||||
if (NS_SUCCEEDED(a->GetFocusedWindow(&prop))) {
|
||||
// get the js object
|
||||
nsJSUtils::nsConvertObjectToJSVal((nsISupports *)prop, cx, vp);
|
||||
}
|
||||
|
@ -103,12 +124,12 @@ GetXULFocusTrackerProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
|||
|
||||
/***********************************************************************/
|
||||
//
|
||||
// XULFocusTracker Properties Setter
|
||||
// XULCommandDispatcher Properties Setter
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
SetXULFocusTrackerProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
SetXULCommandDispatcherProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
{
|
||||
nsIDOMXULFocusTracker *a = (nsIDOMXULFocusTracker*)nsJSUtils::nsGetNativeThis(cx, obj);
|
||||
nsIDOMXULCommandDispatcher *a = (nsIDOMXULCommandDispatcher*)nsJSUtils::nsGetNativeThis(cx, obj);
|
||||
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
if (nsnull == a) {
|
||||
|
@ -123,9 +144,9 @@ SetXULFocusTrackerProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
|||
return JS_FALSE;
|
||||
}
|
||||
switch(JSVAL_TO_INT(id)) {
|
||||
case XULFOCUSTRACKER_CURRENT:
|
||||
case XULCOMMANDDISPATCHER_FOCUSEDELEMENT:
|
||||
{
|
||||
secMan->CheckScriptAccess(scriptCX, obj, "xulfocustracker.current", &ok);
|
||||
secMan->CheckScriptAccess(scriptCX, obj, "xulcommanddispatcher.focusedelement", &ok);
|
||||
if (!ok) {
|
||||
//Need to throw error here
|
||||
return JS_FALSE;
|
||||
|
@ -137,7 +158,25 @@ SetXULFocusTrackerProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
|||
return JS_FALSE;
|
||||
}
|
||||
|
||||
a->SetCurrent(prop);
|
||||
a->SetFocusedElement(prop);
|
||||
NS_IF_RELEASE(prop);
|
||||
break;
|
||||
}
|
||||
case XULCOMMANDDISPATCHER_FOCUSEDWINDOW:
|
||||
{
|
||||
secMan->CheckScriptAccess(scriptCX, obj, "xulcommanddispatcher.focusedwindow", &ok);
|
||||
if (!ok) {
|
||||
//Need to throw error here
|
||||
return JS_FALSE;
|
||||
}
|
||||
nsIDOMWindow* prop;
|
||||
if (PR_FALSE == nsJSUtils::nsConvertJSValToObject((nsISupports **)&prop,
|
||||
kIWindowIID, "Window",
|
||||
cx, *vp)) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
a->SetFocusedWindow(prop);
|
||||
NS_IF_RELEASE(prop);
|
||||
break;
|
||||
}
|
||||
|
@ -155,42 +194,42 @@ SetXULFocusTrackerProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
|||
|
||||
|
||||
//
|
||||
// XULFocusTracker finalizer
|
||||
// XULCommandDispatcher finalizer
|
||||
//
|
||||
PR_STATIC_CALLBACK(void)
|
||||
FinalizeXULFocusTracker(JSContext *cx, JSObject *obj)
|
||||
FinalizeXULCommandDispatcher(JSContext *cx, JSObject *obj)
|
||||
{
|
||||
nsJSUtils::nsGenericFinalize(cx, obj);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// XULFocusTracker enumerate
|
||||
// XULCommandDispatcher enumerate
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
EnumerateXULFocusTracker(JSContext *cx, JSObject *obj)
|
||||
EnumerateXULCommandDispatcher(JSContext *cx, JSObject *obj)
|
||||
{
|
||||
return nsJSUtils::nsGenericEnumerate(cx, obj);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// XULFocusTracker resolve
|
||||
// XULCommandDispatcher resolve
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
ResolveXULFocusTracker(JSContext *cx, JSObject *obj, jsval id)
|
||||
ResolveXULCommandDispatcher(JSContext *cx, JSObject *obj, jsval id)
|
||||
{
|
||||
return nsJSUtils::nsGenericResolve(cx, obj, id);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Native method AddFocusListener
|
||||
// Native method AddCommand
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
XULFocusTrackerAddFocusListener(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
XULCommandDispatcherAddCommand(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
nsIDOMXULFocusTracker *nativeThis = (nsIDOMXULFocusTracker*)nsJSUtils::nsGetNativeThis(cx, obj);
|
||||
nsIDOMXULCommandDispatcher *nativeThis = (nsIDOMXULCommandDispatcher*)nsJSUtils::nsGetNativeThis(cx, obj);
|
||||
nsIDOMElementPtr b0;
|
||||
|
||||
*rval = JSVAL_NULL;
|
||||
|
@ -202,7 +241,7 @@ XULFocusTrackerAddFocusListener(JSContext *cx, JSObject *obj, uintN argc, jsval
|
|||
}
|
||||
{
|
||||
PRBool ok;
|
||||
secMan->CheckScriptAccess(scriptCX, obj, "xulfocustracker.addfocuslistener", &ok);
|
||||
secMan->CheckScriptAccess(scriptCX, obj, "xulcommanddispatcher.addcommand", &ok);
|
||||
if (!ok) {
|
||||
//Need to throw error here
|
||||
return JS_FALSE;
|
||||
|
@ -217,7 +256,7 @@ XULFocusTrackerAddFocusListener(JSContext *cx, JSObject *obj, uintN argc, jsval
|
|||
|
||||
{
|
||||
if (argc < 1) {
|
||||
JS_ReportError(cx, "Function addFocusListener requires 1 parameter");
|
||||
JS_ReportError(cx, "Function addCommand requires 1 parameter");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
|
@ -229,7 +268,7 @@ XULFocusTrackerAddFocusListener(JSContext *cx, JSObject *obj, uintN argc, jsval
|
|||
return JS_FALSE;
|
||||
}
|
||||
|
||||
if (NS_OK != nativeThis->AddFocusListener(b0)) {
|
||||
if (NS_OK != nativeThis->AddCommand(b0)) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
|
@ -241,12 +280,12 @@ XULFocusTrackerAddFocusListener(JSContext *cx, JSObject *obj, uintN argc, jsval
|
|||
|
||||
|
||||
//
|
||||
// Native method RemoveFocusListener
|
||||
// Native method RemoveCommand
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
XULFocusTrackerRemoveFocusListener(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
XULCommandDispatcherRemoveCommand(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
nsIDOMXULFocusTracker *nativeThis = (nsIDOMXULFocusTracker*)nsJSUtils::nsGetNativeThis(cx, obj);
|
||||
nsIDOMXULCommandDispatcher *nativeThis = (nsIDOMXULCommandDispatcher*)nsJSUtils::nsGetNativeThis(cx, obj);
|
||||
nsIDOMElementPtr b0;
|
||||
|
||||
*rval = JSVAL_NULL;
|
||||
|
@ -258,7 +297,7 @@ XULFocusTrackerRemoveFocusListener(JSContext *cx, JSObject *obj, uintN argc, jsv
|
|||
}
|
||||
{
|
||||
PRBool ok;
|
||||
secMan->CheckScriptAccess(scriptCX, obj, "xulfocustracker.removefocuslistener", &ok);
|
||||
secMan->CheckScriptAccess(scriptCX, obj, "xulcommanddispatcher.removecommand", &ok);
|
||||
if (!ok) {
|
||||
//Need to throw error here
|
||||
return JS_FALSE;
|
||||
|
@ -273,7 +312,7 @@ XULFocusTrackerRemoveFocusListener(JSContext *cx, JSObject *obj, uintN argc, jsv
|
|||
|
||||
{
|
||||
if (argc < 1) {
|
||||
JS_ReportError(cx, "Function removeFocusListener requires 1 parameter");
|
||||
JS_ReportError(cx, "Function removeCommand requires 1 parameter");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
|
@ -285,7 +324,7 @@ XULFocusTrackerRemoveFocusListener(JSContext *cx, JSObject *obj, uintN argc, jsv
|
|||
return JS_FALSE;
|
||||
}
|
||||
|
||||
if (NS_OK != nativeThis->RemoveFocusListener(b0)) {
|
||||
if (NS_OK != nativeThis->RemoveCommand(b0)) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
|
@ -297,12 +336,12 @@ XULFocusTrackerRemoveFocusListener(JSContext *cx, JSObject *obj, uintN argc, jsv
|
|||
|
||||
|
||||
//
|
||||
// Native method FocusChanged
|
||||
// Native method UpdateCommands
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
XULFocusTrackerFocusChanged(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
XULCommandDispatcherUpdateCommands(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
nsIDOMXULFocusTracker *nativeThis = (nsIDOMXULFocusTracker*)nsJSUtils::nsGetNativeThis(cx, obj);
|
||||
nsIDOMXULCommandDispatcher *nativeThis = (nsIDOMXULCommandDispatcher*)nsJSUtils::nsGetNativeThis(cx, obj);
|
||||
|
||||
*rval = JSVAL_NULL;
|
||||
|
||||
|
@ -313,7 +352,7 @@ XULFocusTrackerFocusChanged(JSContext *cx, JSObject *obj, uintN argc, jsval *arg
|
|||
}
|
||||
{
|
||||
PRBool ok;
|
||||
secMan->CheckScriptAccess(scriptCX, obj, "xulfocustracker.focuschanged", &ok);
|
||||
secMan->CheckScriptAccess(scriptCX, obj, "xulcommanddispatcher.updatecommands", &ok);
|
||||
if (!ok) {
|
||||
//Need to throw error here
|
||||
return JS_FALSE;
|
||||
|
@ -328,7 +367,7 @@ XULFocusTrackerFocusChanged(JSContext *cx, JSObject *obj, uintN argc, jsval *arg
|
|||
|
||||
{
|
||||
|
||||
if (NS_OK != nativeThis->FocusChanged()) {
|
||||
if (NS_OK != nativeThis->UpdateCommands()) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
|
@ -343,9 +382,9 @@ XULFocusTrackerFocusChanged(JSContext *cx, JSObject *obj, uintN argc, jsval *arg
|
|||
// Native method GetController
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
XULFocusTrackerGetController(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
XULCommandDispatcherGetController(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
nsIDOMXULFocusTracker *nativeThis = (nsIDOMXULFocusTracker*)nsJSUtils::nsGetNativeThis(cx, obj);
|
||||
nsIDOMXULCommandDispatcher *nativeThis = (nsIDOMXULCommandDispatcher*)nsJSUtils::nsGetNativeThis(cx, obj);
|
||||
nsIController* nativeRet;
|
||||
|
||||
*rval = JSVAL_NULL;
|
||||
|
@ -357,7 +396,7 @@ XULFocusTrackerGetController(JSContext *cx, JSObject *obj, uintN argc, jsval *ar
|
|||
}
|
||||
{
|
||||
PRBool ok;
|
||||
secMan->CheckScriptAccess(scriptCX, obj, "xulfocustracker.getcontroller", &ok);
|
||||
secMan->CheckScriptAccess(scriptCX, obj, "xulcommanddispatcher.getcontroller", &ok);
|
||||
if (!ok) {
|
||||
//Need to throw error here
|
||||
return JS_FALSE;
|
||||
|
@ -388,9 +427,9 @@ XULFocusTrackerGetController(JSContext *cx, JSObject *obj, uintN argc, jsval *ar
|
|||
// Native method SetController
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
XULFocusTrackerSetController(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
XULCommandDispatcherSetController(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
nsIDOMXULFocusTracker *nativeThis = (nsIDOMXULFocusTracker*)nsJSUtils::nsGetNativeThis(cx, obj);
|
||||
nsIDOMXULCommandDispatcher *nativeThis = (nsIDOMXULCommandDispatcher*)nsJSUtils::nsGetNativeThis(cx, obj);
|
||||
nsIControllerPtr b0;
|
||||
|
||||
*rval = JSVAL_NULL;
|
||||
|
@ -402,7 +441,7 @@ XULFocusTrackerSetController(JSContext *cx, JSObject *obj, uintN argc, jsval *ar
|
|||
}
|
||||
{
|
||||
PRBool ok;
|
||||
secMan->CheckScriptAccess(scriptCX, obj, "xulfocustracker.setcontroller", &ok);
|
||||
secMan->CheckScriptAccess(scriptCX, obj, "xulcommanddispatcher.setcontroller", &ok);
|
||||
if (!ok) {
|
||||
//Need to throw error here
|
||||
return JS_FALSE;
|
||||
|
@ -439,60 +478,61 @@ XULFocusTrackerSetController(JSContext *cx, JSObject *obj, uintN argc, jsval *ar
|
|||
|
||||
/***********************************************************************/
|
||||
//
|
||||
// class for XULFocusTracker
|
||||
// class for XULCommandDispatcher
|
||||
//
|
||||
JSClass XULFocusTrackerClass = {
|
||||
"XULFocusTracker",
|
||||
JSClass XULCommandDispatcherClass = {
|
||||
"XULCommandDispatcher",
|
||||
JSCLASS_HAS_PRIVATE | JSCLASS_PRIVATE_IS_NSISUPPORTS,
|
||||
JS_PropertyStub,
|
||||
JS_PropertyStub,
|
||||
GetXULFocusTrackerProperty,
|
||||
SetXULFocusTrackerProperty,
|
||||
EnumerateXULFocusTracker,
|
||||
ResolveXULFocusTracker,
|
||||
GetXULCommandDispatcherProperty,
|
||||
SetXULCommandDispatcherProperty,
|
||||
EnumerateXULCommandDispatcher,
|
||||
ResolveXULCommandDispatcher,
|
||||
JS_ConvertStub,
|
||||
FinalizeXULFocusTracker
|
||||
FinalizeXULCommandDispatcher
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// XULFocusTracker class properties
|
||||
// XULCommandDispatcher class properties
|
||||
//
|
||||
static JSPropertySpec XULFocusTrackerProperties[] =
|
||||
static JSPropertySpec XULCommandDispatcherProperties[] =
|
||||
{
|
||||
{"current", XULFOCUSTRACKER_CURRENT, JSPROP_ENUMERATE},
|
||||
{"focusedElement", XULCOMMANDDISPATCHER_FOCUSEDELEMENT, JSPROP_ENUMERATE},
|
||||
{"focusedWindow", XULCOMMANDDISPATCHER_FOCUSEDWINDOW, JSPROP_ENUMERATE},
|
||||
{0}
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// XULFocusTracker class methods
|
||||
// XULCommandDispatcher class methods
|
||||
//
|
||||
static JSFunctionSpec XULFocusTrackerMethods[] =
|
||||
static JSFunctionSpec XULCommandDispatcherMethods[] =
|
||||
{
|
||||
{"addFocusListener", XULFocusTrackerAddFocusListener, 1},
|
||||
{"removeFocusListener", XULFocusTrackerRemoveFocusListener, 1},
|
||||
{"focusChanged", XULFocusTrackerFocusChanged, 0},
|
||||
{"getController", XULFocusTrackerGetController, 0},
|
||||
{"setController", XULFocusTrackerSetController, 1},
|
||||
{"addCommand", XULCommandDispatcherAddCommand, 1},
|
||||
{"removeCommand", XULCommandDispatcherRemoveCommand, 1},
|
||||
{"updateCommands", XULCommandDispatcherUpdateCommands, 0},
|
||||
{"getController", XULCommandDispatcherGetController, 0},
|
||||
{"setController", XULCommandDispatcherSetController, 1},
|
||||
{0}
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// XULFocusTracker constructor
|
||||
// XULCommandDispatcher constructor
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
XULFocusTracker(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
XULCommandDispatcher(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// XULFocusTracker class initialization
|
||||
// XULCommandDispatcher class initialization
|
||||
//
|
||||
extern "C" NS_DOM nsresult NS_InitXULFocusTrackerClass(nsIScriptContext *aContext, void **aPrototype)
|
||||
extern "C" NS_DOM nsresult NS_InitXULCommandDispatcherClass(nsIScriptContext *aContext, void **aPrototype)
|
||||
{
|
||||
JSContext *jscontext = (JSContext *)aContext->GetNativeContext();
|
||||
JSObject *proto = nsnull;
|
||||
|
@ -501,7 +541,7 @@ extern "C" NS_DOM nsresult NS_InitXULFocusTrackerClass(nsIScriptContext *aContex
|
|||
JSObject *global = JS_GetGlobalObject(jscontext);
|
||||
jsval vp;
|
||||
|
||||
if ((PR_TRUE != JS_LookupProperty(jscontext, global, "XULFocusTracker", &vp)) ||
|
||||
if ((PR_TRUE != JS_LookupProperty(jscontext, global, "XULCommandDispatcher", &vp)) ||
|
||||
!JSVAL_IS_OBJECT(vp) ||
|
||||
((constructor = JSVAL_TO_OBJECT(vp)) == nsnull) ||
|
||||
(PR_TRUE != JS_LookupProperty(jscontext, JSVAL_TO_OBJECT(vp), "prototype", &vp)) ||
|
||||
|
@ -510,11 +550,11 @@ extern "C" NS_DOM nsresult NS_InitXULFocusTrackerClass(nsIScriptContext *aContex
|
|||
proto = JS_InitClass(jscontext, // context
|
||||
global, // global object
|
||||
parent_proto, // parent proto
|
||||
&XULFocusTrackerClass, // JSClass
|
||||
XULFocusTracker, // JSNative ctor
|
||||
&XULCommandDispatcherClass, // JSClass
|
||||
XULCommandDispatcher, // JSNative ctor
|
||||
0, // ctor args
|
||||
XULFocusTrackerProperties, // proto props
|
||||
XULFocusTrackerMethods, // proto funcs
|
||||
XULCommandDispatcherProperties, // proto props
|
||||
XULCommandDispatcherMethods, // proto funcs
|
||||
nsnull, // ctor props (static)
|
||||
nsnull); // ctor funcs (static)
|
||||
if (nsnull == proto) {
|
||||
|
@ -537,17 +577,17 @@ extern "C" NS_DOM nsresult NS_InitXULFocusTrackerClass(nsIScriptContext *aContex
|
|||
|
||||
|
||||
//
|
||||
// Method for creating a new XULFocusTracker JavaScript object
|
||||
// Method for creating a new XULCommandDispatcher JavaScript object
|
||||
//
|
||||
extern "C" NS_DOM nsresult NS_NewScriptXULFocusTracker(nsIScriptContext *aContext, nsISupports *aSupports, nsISupports *aParent, void **aReturn)
|
||||
extern "C" NS_DOM nsresult NS_NewScriptXULCommandDispatcher(nsIScriptContext *aContext, nsISupports *aSupports, nsISupports *aParent, void **aReturn)
|
||||
{
|
||||
NS_PRECONDITION(nsnull != aContext && nsnull != aSupports && nsnull != aReturn, "null argument to NS_NewScriptXULFocusTracker");
|
||||
NS_PRECONDITION(nsnull != aContext && nsnull != aSupports && nsnull != aReturn, "null argument to NS_NewScriptXULCommandDispatcher");
|
||||
JSObject *proto;
|
||||
JSObject *parent;
|
||||
nsIScriptObjectOwner *owner;
|
||||
JSContext *jscontext = (JSContext *)aContext->GetNativeContext();
|
||||
nsresult result = NS_OK;
|
||||
nsIDOMXULFocusTracker *aXULFocusTracker;
|
||||
nsIDOMXULCommandDispatcher *aXULCommandDispatcher;
|
||||
|
||||
if (nsnull == aParent) {
|
||||
parent = nsnull;
|
||||
|
@ -563,23 +603,23 @@ extern "C" NS_DOM nsresult NS_NewScriptXULFocusTracker(nsIScriptContext *aContex
|
|||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
if (NS_OK != NS_InitXULFocusTrackerClass(aContext, (void **)&proto)) {
|
||||
if (NS_OK != NS_InitXULCommandDispatcherClass(aContext, (void **)&proto)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
result = aSupports->QueryInterface(kIXULFocusTrackerIID, (void **)&aXULFocusTracker);
|
||||
result = aSupports->QueryInterface(kIXULCommandDispatcherIID, (void **)&aXULCommandDispatcher);
|
||||
if (NS_OK != result) {
|
||||
return result;
|
||||
}
|
||||
|
||||
// create a js object for this class
|
||||
*aReturn = JS_NewObject(jscontext, &XULFocusTrackerClass, proto, parent);
|
||||
*aReturn = JS_NewObject(jscontext, &XULCommandDispatcherClass, proto, parent);
|
||||
if (nsnull != *aReturn) {
|
||||
// connect the native object to the js object
|
||||
JS_SetPrivate(jscontext, (JSObject *)*aReturn, aXULFocusTracker);
|
||||
JS_SetPrivate(jscontext, (JSObject *)*aReturn, aXULCommandDispatcher);
|
||||
}
|
||||
else {
|
||||
NS_RELEASE(aXULFocusTracker);
|
||||
NS_RELEASE(aXULCommandDispatcher);
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
|
@ -28,7 +28,7 @@
|
|||
#include "nsIPtr.h"
|
||||
#include "nsString.h"
|
||||
#include "nsIDOMElement.h"
|
||||
#include "nsIDOMXULFocusTracker.h"
|
||||
#include "nsIDOMXULCommandDispatcher.h"
|
||||
#include "nsIDOMXULDocument.h"
|
||||
#include "nsIDOMNodeList.h"
|
||||
|
||||
|
@ -37,12 +37,12 @@ static NS_DEFINE_IID(kIScriptObjectOwnerIID, NS_ISCRIPTOBJECTOWNER_IID);
|
|||
static NS_DEFINE_IID(kIJSScriptObjectIID, NS_IJSSCRIPTOBJECT_IID);
|
||||
static NS_DEFINE_IID(kIScriptGlobalObjectIID, NS_ISCRIPTGLOBALOBJECT_IID);
|
||||
static NS_DEFINE_IID(kIElementIID, NS_IDOMELEMENT_IID);
|
||||
static NS_DEFINE_IID(kIXULFocusTrackerIID, NS_IDOMXULFOCUSTRACKER_IID);
|
||||
static NS_DEFINE_IID(kIXULCommandDispatcherIID, NS_IDOMXULCOMMANDDISPATCHER_IID);
|
||||
static NS_DEFINE_IID(kIXULDocumentIID, NS_IDOMXULDOCUMENT_IID);
|
||||
static NS_DEFINE_IID(kINodeListIID, NS_IDOMNODELIST_IID);
|
||||
|
||||
NS_DEF_PTR(nsIDOMElement);
|
||||
NS_DEF_PTR(nsIDOMXULFocusTracker);
|
||||
NS_DEF_PTR(nsIDOMXULCommandDispatcher);
|
||||
NS_DEF_PTR(nsIDOMXULDocument);
|
||||
NS_DEF_PTR(nsIDOMNodeList);
|
||||
|
||||
|
@ -52,7 +52,7 @@ NS_DEF_PTR(nsIDOMNodeList);
|
|||
enum XULDocument_slots {
|
||||
XULDOCUMENT_POPUPELEMENT = -1,
|
||||
XULDOCUMENT_TOOLTIPELEMENT = -2,
|
||||
XULDOCUMENT_FOCUS = -3
|
||||
XULDOCUMENT_COMMANDDISPATCHER = -3
|
||||
};
|
||||
|
||||
/***********************************************************************/
|
||||
|
@ -111,15 +111,15 @@ GetXULDocumentProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
|||
}
|
||||
break;
|
||||
}
|
||||
case XULDOCUMENT_FOCUS:
|
||||
case XULDOCUMENT_COMMANDDISPATCHER:
|
||||
{
|
||||
secMan->CheckScriptAccess(scriptCX, obj, "xuldocument.focus", &ok);
|
||||
secMan->CheckScriptAccess(scriptCX, obj, "xuldocument.commanddispatcher", &ok);
|
||||
if (!ok) {
|
||||
//Need to throw error here
|
||||
return JS_FALSE;
|
||||
}
|
||||
nsIDOMXULFocusTracker* prop;
|
||||
if (NS_SUCCEEDED(a->GetFocus(&prop))) {
|
||||
nsIDOMXULCommandDispatcher* prop;
|
||||
if (NS_SUCCEEDED(a->GetCommandDispatcher(&prop))) {
|
||||
// get the js object
|
||||
nsJSUtils::nsConvertObjectToJSVal((nsISupports *)prop, cx, vp);
|
||||
}
|
||||
|
@ -370,7 +370,7 @@ static JSPropertySpec XULDocumentProperties[] =
|
|||
{
|
||||
{"popupElement", XULDOCUMENT_POPUPELEMENT, JSPROP_ENUMERATE},
|
||||
{"tooltipElement", XULDOCUMENT_TOOLTIPELEMENT, JSPROP_ENUMERATE},
|
||||
{"focus", XULDOCUMENT_FOCUS, JSPROP_ENUMERATE | JSPROP_READONLY},
|
||||
{"commandDispatcher", XULDOCUMENT_COMMANDDISPATCHER, JSPROP_ENUMERATE | JSPROP_READONLY},
|
||||
{0}
|
||||
};
|
||||
|
||||
|
|
|
@ -120,7 +120,7 @@
|
|||
{ 0x3986b301, 0x97c, 0x11d3, { 0xbf, 0x87, 0x0, 0x11, 0x5a, 0x1b, 0x6, 0x27 } }
|
||||
|
||||
// {FE71D561-1501-11d3-BF87-00105A1B0627}
|
||||
#define NS_XULFOCUSTRACKER_CID \
|
||||
#define NS_XULCOMMANDDISPATCHER_CID \
|
||||
{ 0xfe71d561, 0x1501, 0x11d3, { 0xbf, 0x87, 0x0, 0x10, 0x5a, 0x1b, 0x6, 0x27 } }
|
||||
|
||||
#endif // nsRDFCID_h__
|
||||
|
|
|
@ -46,7 +46,7 @@
|
|||
#include "nsIXULDocumentInfo.h"
|
||||
#include "nsIXULPopupListener.h"
|
||||
#include "nsIXULKeyListener.h"
|
||||
#include "nsIXULFocusTracker.h"
|
||||
#include "nsIXULCommandDispatcher.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
|
@ -75,7 +75,7 @@ static NS_DEFINE_CID(kXULSortServiceCID, NS_XULSORTSERVICE_CID)
|
|||
static NS_DEFINE_CID(kXULDocumentInfoCID, NS_XULDOCUMENTINFO_CID);
|
||||
static NS_DEFINE_CID(kXULPopupListenerCID, NS_XULPOPUPLISTENER_CID);
|
||||
static NS_DEFINE_CID(kXULKeyListenerCID, NS_XULKEYLISTENER_CID);
|
||||
static NS_DEFINE_CID(kXULFocusTrackerCID, NS_XULFOCUSTRACKER_CID);
|
||||
static NS_DEFINE_CID(kXULCommandDispatcherCID, NS_XULCOMMANDDISPATCHER_CID);
|
||||
static NS_DEFINE_CID(kXULTemplateBuilderCID, NS_XULTEMPLATEBUILDER_CID);
|
||||
|
||||
class RDFFactoryImpl : public nsIFactory
|
||||
|
@ -177,8 +177,8 @@ RDFFactoryImpl::CreateInstance(nsISupports *aOuter,
|
|||
if (NS_FAILED(rv = NS_NewXULKeyListener((nsIXULKeyListener**) &inst)))
|
||||
return rv;
|
||||
}
|
||||
else if (mClassID.Equals(kXULFocusTrackerCID)) {
|
||||
if (NS_FAILED(rv = NS_NewXULFocusTracker((nsIXULFocusTracker**) &inst)))
|
||||
else if (mClassID.Equals(kXULCommandDispatcherCID)) {
|
||||
if (NS_FAILED(rv = NS_NewXULCommandDispatcher((nsIXULCommandDispatcher**) &inst)))
|
||||
return rv;
|
||||
}
|
||||
else if (mClassID.Equals(kRDFXMLDataSourceCID)) {
|
||||
|
@ -449,8 +449,8 @@ NSRegisterSelf(nsISupports* aServMgr , const char* aPath)
|
|||
aPath, PR_TRUE, PR_TRUE);
|
||||
|
||||
if (NS_FAILED(rv)) goto done;
|
||||
rv = compMgr->RegisterComponent(kXULFocusTrackerCID,
|
||||
"XUL FocusTracker",
|
||||
rv = compMgr->RegisterComponent(kXULCommandDispatcherCID,
|
||||
"XUL CommandDispatcher",
|
||||
NS_RDF_PROGID "/xul-focus-tracker",
|
||||
aPath, PR_TRUE, PR_TRUE);
|
||||
|
||||
|
@ -510,7 +510,7 @@ NSUnregisterSelf(nsISupports* aServMgr, const char* aPath)
|
|||
if (NS_FAILED(rv)) goto done;
|
||||
rv = compMgr->UnregisterComponent(kXULPopupListenerCID, aPath);
|
||||
if (NS_FAILED(rv)) goto done;
|
||||
rv = compMgr->UnregisterComponent(kXULFocusTrackerCID, aPath);
|
||||
rv = compMgr->UnregisterComponent(kXULCommandDispatcherCID, aPath);
|
||||
|
||||
done:
|
||||
(void)servMgr->ReleaseService(kComponentManagerCID, compMgr);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
nsIDOMXULFocusTracker.h
|
||||
nsIDOMXULCommandDispatcher.h
|
||||
nsIDOMElementObserver.h
|
||||
nsIDOMNodeObserver.h
|
||||
nsIDOMXULDocument.h
|
||||
|
@ -11,6 +11,6 @@ nsIXULParentDocument.h
|
|||
nsIXULChildDocument.h
|
||||
nsIXULDocumentInfo.h
|
||||
nsIXULPopupListener.h
|
||||
nsIXULFocusTracker.h
|
||||
nsIXULCommandDispatcher.h
|
||||
nsIXULKeyListener.h
|
||||
nsIStreamLoadableDocument.h
|
||||
|
|
|
@ -37,8 +37,8 @@ EXPORTS = \
|
|||
nsIXULChildDocument.h \
|
||||
nsIXULDocumentInfo.h \
|
||||
nsIXULPopupListener.h \
|
||||
nsIDOMXULFocusTracker.h \
|
||||
nsIXULFocusTracker.h \
|
||||
nsIDOMXULCommandDispatcher.h \
|
||||
nsIXULCommandDispatcher.h \
|
||||
nsIStreamLoadableDocument.h \
|
||||
nsIXULKeyListener.h \
|
||||
$(NULL)
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
interface XULCommandDispatcher {
|
||||
|
||||
/* IID: { 0xf3c50361, 0x14fe, 0x11d3, \
|
||||
{ 0xbf, 0x87, 0x0, 0x10, 0x5a, 0x1b, 0x6, 0x27 } } */
|
||||
|
||||
attribute Element focusedElement;
|
||||
attribute Window focusedWindow;
|
||||
|
||||
void addCommand(in Element listener);
|
||||
void removeCommand(in Element listener);
|
||||
|
||||
void updateCommands();
|
||||
|
||||
xpidl nsIController getController();
|
||||
void setController(in xpidl nsIController controller);
|
||||
};
|
|
@ -6,7 +6,7 @@ interface XULDocument : Document {
|
|||
attribute Element popupElement;
|
||||
attribute Element tooltipElement;
|
||||
|
||||
readonly attribute XULFocusTracker focus;
|
||||
readonly attribute XULCommandDispatcher commandDispatcher;
|
||||
|
||||
Element getElementById(in DOMString id);
|
||||
NodeList getElementsByAttribute(in DOMString name, in DOMString value);
|
||||
|
|
|
@ -1,15 +0,0 @@
|
|||
interface XULFocusTracker {
|
||||
|
||||
/* IID: { 0xf3c50361, 0x14fe, 0x11d3, \
|
||||
{ 0xbf, 0x87, 0x0, 0x10, 0x5a, 0x1b, 0x6, 0x27 } } */
|
||||
|
||||
attribute Element current;
|
||||
|
||||
void addFocusListener(in Element listener);
|
||||
void removeFocusListener(in Element listener);
|
||||
|
||||
void focusChanged();
|
||||
|
||||
xpidl nsIController getController();
|
||||
void setController(in xpidl nsIController controller);
|
||||
};
|
|
@ -25,7 +25,7 @@ IDLSRCS = \
|
|||
NodeObserver.idl \
|
||||
XULDocument.idl \
|
||||
XULElement.idl \
|
||||
XULFocusTracker.idl \
|
||||
XULCommandDispatcher.idl \
|
||||
XULTreeElement.idl \
|
||||
$(NULL)
|
||||
|
||||
|
|
|
@ -33,8 +33,8 @@ EXPORTS = \
|
|||
nsIXULChildDocument.h \
|
||||
nsIXULDocumentInfo.h \
|
||||
nsIXULPopupListener.h \
|
||||
nsIDOMXULFocusTracker.h \
|
||||
nsIXULFocusTracker.h \
|
||||
nsIDOMXULCommandDispatcher.h \
|
||||
nsIXULCommandDispatcher.h \
|
||||
nsIStreamLoadableDocument.h \
|
||||
nsIXULKeyListener.h \
|
||||
$(NULL)
|
||||
|
|
|
@ -0,0 +1,86 @@
|
|||
/* -*- 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/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
/* AUTO-GENERATED. DO NOT EDIT!!! */
|
||||
|
||||
#ifndef nsIDOMXULCommandDispatcher_h__
|
||||
#define nsIDOMXULCommandDispatcher_h__
|
||||
|
||||
#include "nsISupports.h"
|
||||
#include "nsString.h"
|
||||
#include "nsIScriptContext.h"
|
||||
|
||||
class nsIController;
|
||||
class nsIDOMElement;
|
||||
class nsIDOMWindow;
|
||||
|
||||
#define NS_IDOMXULCOMMANDDISPATCHER_IID \
|
||||
{ 0xf3c50361, 0x14fe, 0x11d3, \
|
||||
{ 0xbf, 0x87, 0x0, 0x10, 0x5a, 0x1b, 0x6, 0x27 } }
|
||||
|
||||
class nsIDOMXULCommandDispatcher : public nsISupports {
|
||||
public:
|
||||
static const nsIID& GetIID() { static nsIID iid = NS_IDOMXULCOMMANDDISPATCHER_IID; return iid; }
|
||||
|
||||
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 AddCommand(nsIDOMElement* aListener)=0;
|
||||
|
||||
NS_IMETHOD RemoveCommand(nsIDOMElement* aListener)=0;
|
||||
|
||||
NS_IMETHOD UpdateCommands()=0;
|
||||
|
||||
NS_IMETHOD GetController(nsIController** aReturn)=0;
|
||||
|
||||
NS_IMETHOD SetController(nsIController* aController)=0;
|
||||
};
|
||||
|
||||
|
||||
#define NS_DECL_IDOMXULCOMMANDDISPATCHER \
|
||||
NS_IMETHOD GetFocusedElement(nsIDOMElement** aFocusedElement); \
|
||||
NS_IMETHOD SetFocusedElement(nsIDOMElement* aFocusedElement); \
|
||||
NS_IMETHOD GetFocusedWindow(nsIDOMWindow** aFocusedWindow); \
|
||||
NS_IMETHOD SetFocusedWindow(nsIDOMWindow* aFocusedWindow); \
|
||||
NS_IMETHOD AddCommand(nsIDOMElement* aListener); \
|
||||
NS_IMETHOD RemoveCommand(nsIDOMElement* aListener); \
|
||||
NS_IMETHOD UpdateCommands(); \
|
||||
NS_IMETHOD GetController(nsIController** aReturn); \
|
||||
NS_IMETHOD SetController(nsIController* aController); \
|
||||
|
||||
|
||||
|
||||
#define NS_FORWARD_IDOMXULCOMMANDDISPATCHER(_to) \
|
||||
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 AddCommand(nsIDOMElement* aListener) { return _to AddCommand(aListener); } \
|
||||
NS_IMETHOD RemoveCommand(nsIDOMElement* aListener) { return _to RemoveCommand(aListener); } \
|
||||
NS_IMETHOD UpdateCommands() { return _to UpdateCommands(); } \
|
||||
NS_IMETHOD GetController(nsIController** aReturn) { return _to GetController(aReturn); } \
|
||||
NS_IMETHOD SetController(nsIController* aController) { return _to SetController(aController); } \
|
||||
|
||||
|
||||
extern "C" NS_DOM nsresult NS_InitXULCommandDispatcherClass(nsIScriptContext *aContext, void **aPrototype);
|
||||
|
||||
extern "C" NS_DOM nsresult NS_NewScriptXULCommandDispatcher(nsIScriptContext *aContext, nsISupports *aSupports, nsISupports *aParent, void **aReturn);
|
||||
|
||||
#endif // nsIDOMXULCommandDispatcher_h__
|
|
@ -26,7 +26,7 @@
|
|||
#include "nsIDOMDocument.h"
|
||||
|
||||
class nsIDOMElement;
|
||||
class nsIDOMXULFocusTracker;
|
||||
class nsIDOMXULCommandDispatcher;
|
||||
class nsIDOMNodeList;
|
||||
|
||||
#define NS_IDOMXULDOCUMENT_IID \
|
||||
|
@ -43,7 +43,7 @@ public:
|
|||
NS_IMETHOD GetTooltipElement(nsIDOMElement** aTooltipElement)=0;
|
||||
NS_IMETHOD SetTooltipElement(nsIDOMElement* aTooltipElement)=0;
|
||||
|
||||
NS_IMETHOD GetFocus(nsIDOMXULFocusTracker** aFocus)=0;
|
||||
NS_IMETHOD GetCommandDispatcher(nsIDOMXULCommandDispatcher** aCommandDispatcher)=0;
|
||||
|
||||
NS_IMETHOD GetElementById(const nsString& aId, nsIDOMElement** aReturn)=0;
|
||||
|
||||
|
@ -56,7 +56,7 @@ public:
|
|||
NS_IMETHOD SetPopupElement(nsIDOMElement* aPopupElement); \
|
||||
NS_IMETHOD GetTooltipElement(nsIDOMElement** aTooltipElement); \
|
||||
NS_IMETHOD SetTooltipElement(nsIDOMElement* aTooltipElement); \
|
||||
NS_IMETHOD GetFocus(nsIDOMXULFocusTracker** aFocus); \
|
||||
NS_IMETHOD GetCommandDispatcher(nsIDOMXULCommandDispatcher** aCommandDispatcher); \
|
||||
NS_IMETHOD GetElementById(const nsString& aId, nsIDOMElement** aReturn); \
|
||||
NS_IMETHOD GetElementsByAttribute(const nsString& aName, const nsString& aValue, nsIDOMNodeList** aReturn); \
|
||||
|
||||
|
@ -67,7 +67,7 @@ public:
|
|||
NS_IMETHOD SetPopupElement(nsIDOMElement* aPopupElement) { return _to SetPopupElement(aPopupElement); } \
|
||||
NS_IMETHOD GetTooltipElement(nsIDOMElement** aTooltipElement) { return _to GetTooltipElement(aTooltipElement); } \
|
||||
NS_IMETHOD SetTooltipElement(nsIDOMElement* aTooltipElement) { return _to SetTooltipElement(aTooltipElement); } \
|
||||
NS_IMETHOD GetFocus(nsIDOMXULFocusTracker** aFocus) { return _to GetFocus(aFocus); } \
|
||||
NS_IMETHOD GetCommandDispatcher(nsIDOMXULCommandDispatcher** aCommandDispatcher) { return _to GetCommandDispatcher(aCommandDispatcher); } \
|
||||
NS_IMETHOD GetElementById(const nsString& aId, nsIDOMElement** aReturn) { return _to GetElementById(aId, aReturn); } \
|
||||
NS_IMETHOD GetElementsByAttribute(const nsString& aName, const nsString& aValue, nsIDOMNodeList** aReturn) { return _to GetElementsByAttribute(aName, aValue, aReturn); } \
|
||||
|
||||
|
|
|
@ -1,78 +0,0 @@
|
|||
/* -*- 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/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
/* AUTO-GENERATED. DO NOT EDIT!!! */
|
||||
|
||||
#ifndef nsIDOMXULFocusTracker_h__
|
||||
#define nsIDOMXULFocusTracker_h__
|
||||
|
||||
#include "nsISupports.h"
|
||||
#include "nsString.h"
|
||||
#include "nsIScriptContext.h"
|
||||
|
||||
class nsIController;
|
||||
class nsIDOMElement;
|
||||
|
||||
#define NS_IDOMXULFOCUSTRACKER_IID \
|
||||
{ 0xf3c50361, 0x14fe, 0x11d3, \
|
||||
{ 0xbf, 0x87, 0x0, 0x10, 0x5a, 0x1b, 0x6, 0x27 } }
|
||||
|
||||
class nsIDOMXULFocusTracker : public nsISupports {
|
||||
public:
|
||||
static const nsIID& GetIID() { static nsIID iid = NS_IDOMXULFOCUSTRACKER_IID; return iid; }
|
||||
|
||||
NS_IMETHOD GetCurrent(nsIDOMElement** aCurrent)=0;
|
||||
NS_IMETHOD SetCurrent(nsIDOMElement* aCurrent)=0;
|
||||
|
||||
NS_IMETHOD AddFocusListener(nsIDOMElement* aListener)=0;
|
||||
|
||||
NS_IMETHOD RemoveFocusListener(nsIDOMElement* aListener)=0;
|
||||
|
||||
NS_IMETHOD FocusChanged()=0;
|
||||
|
||||
NS_IMETHOD GetController(nsIController** aReturn)=0;
|
||||
|
||||
NS_IMETHOD SetController(nsIController* aController)=0;
|
||||
};
|
||||
|
||||
|
||||
#define NS_DECL_IDOMXULFOCUSTRACKER \
|
||||
NS_IMETHOD GetCurrent(nsIDOMElement** aCurrent); \
|
||||
NS_IMETHOD SetCurrent(nsIDOMElement* aCurrent); \
|
||||
NS_IMETHOD AddFocusListener(nsIDOMElement* aListener); \
|
||||
NS_IMETHOD RemoveFocusListener(nsIDOMElement* aListener); \
|
||||
NS_IMETHOD FocusChanged(); \
|
||||
NS_IMETHOD GetController(nsIController** aReturn); \
|
||||
NS_IMETHOD SetController(nsIController* aController); \
|
||||
|
||||
|
||||
|
||||
#define NS_FORWARD_IDOMXULFOCUSTRACKER(_to) \
|
||||
NS_IMETHOD GetCurrent(nsIDOMElement** aCurrent) { return _to GetCurrent(aCurrent); } \
|
||||
NS_IMETHOD SetCurrent(nsIDOMElement* aCurrent) { return _to SetCurrent(aCurrent); } \
|
||||
NS_IMETHOD AddFocusListener(nsIDOMElement* aListener) { return _to AddFocusListener(aListener); } \
|
||||
NS_IMETHOD RemoveFocusListener(nsIDOMElement* aListener) { return _to RemoveFocusListener(aListener); } \
|
||||
NS_IMETHOD FocusChanged() { return _to FocusChanged(); } \
|
||||
NS_IMETHOD GetController(nsIController** aReturn) { return _to GetController(aReturn); } \
|
||||
NS_IMETHOD SetController(nsIController* aController) { return _to SetController(aController); } \
|
||||
|
||||
|
||||
extern "C" NS_DOM nsresult NS_InitXULFocusTrackerClass(nsIScriptContext *aContext, void **aPrototype);
|
||||
|
||||
extern "C" NS_DOM nsresult NS_NewScriptXULFocusTracker(nsIScriptContext *aContext, nsISupports *aSupports, nsISupports *aParent, void **aReturn);
|
||||
|
||||
#endif // nsIDOMXULFocusTracker_h__
|
|
@ -16,19 +16,19 @@
|
|||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef nsIXULFocusTracker_h__
|
||||
#define nsIXULFocusTracker_h__
|
||||
#ifndef nsIXULCommandDispatcher_h__
|
||||
#define nsIXULCommandDispatcher_h__
|
||||
|
||||
// {A7033701-1502-11d3-BF87-00105A1B0627}
|
||||
#define NS_IXULFOCUSTRACKER_IID \
|
||||
#define NS_IXULCOMMANDDISPATCHER_IID \
|
||||
{ 0xa7033701, 0x1502, 0x11d3, { 0xbf, 0x87, 0x0, 0x10, 0x5a, 0x1b, 0x6, 0x27 } }
|
||||
|
||||
class nsIXULFocusTracker: public nsISupports {
|
||||
class nsIXULCommandDispatcher: public nsISupports {
|
||||
public:
|
||||
static const nsIID& GetIID() { static nsIID iid = NS_IXULFOCUSTRACKER_IID; return iid; }
|
||||
static const nsIID& GetIID() { static nsIID iid = NS_IXULCOMMANDDISPATCHER_IID; return iid; }
|
||||
};
|
||||
|
||||
extern nsresult
|
||||
NS_NewXULFocusTracker(nsIXULFocusTracker** result);
|
||||
NS_NewXULCommandDispatcher(nsIXULCommandDispatcher** result);
|
||||
|
||||
#endif // nsIXULFocusTracker_h__
|
||||
#endif // nsIXULCommandDispatcher_h__
|
|
@ -31,7 +31,7 @@ CPPSRCS = \
|
|||
nsJSNodeObserver.cpp \
|
||||
nsJSXULDocument.cpp \
|
||||
nsJSXULElement.cpp \
|
||||
nsJSXULFocusTracker.cpp \
|
||||
nsJSXULCommandDispatcher.cpp \
|
||||
nsJSXULTreeElement.cpp \
|
||||
nsRDFContentUtils.cpp \
|
||||
nsRDFDOMNodeList.cpp \
|
||||
|
@ -43,7 +43,7 @@ CPPSRCS = \
|
|||
nsXULSortService.cpp \
|
||||
nsXULDocumentInfo.cpp \
|
||||
nsXULPopupListener.cpp \
|
||||
nsXULFocusTracker.cpp \
|
||||
nsXULCommandDispatcher.cpp \
|
||||
nsXULKeyListener.cpp \
|
||||
nsXULTreeElement.cpp \
|
||||
$(NULL)
|
||||
|
|
|
@ -27,10 +27,10 @@ LCFLAGS = \
|
|||
$(NULL)
|
||||
|
||||
CPP_OBJS=\
|
||||
.\$(OBJDIR)\nsJSXULFocusTracker.obj \
|
||||
.\$(OBJDIR)\nsJSXULCommandDispatcher.obj \
|
||||
.\$(OBJDIR)\nsRDFGenericBuilder.obj \
|
||||
.\$(OBJDIR)\nsXULAttributes.obj \
|
||||
.\$(OBJDIR)\nsXULFocusTracker.obj \
|
||||
.\$(OBJDIR)\nsXULCommandDispatcher.obj \
|
||||
.\$(OBJDIR)\nsXULPopupListener.obj \
|
||||
.\$(OBJDIR)\nsJSElementObserver.obj \
|
||||
.\$(OBJDIR)\nsJSNodeObserver.obj \
|
||||
|
|
|
@ -0,0 +1,627 @@
|
|||
/* -*- 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/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
/* AUTO-GENERATED. DO NOT EDIT!!! */
|
||||
|
||||
#include "jsapi.h"
|
||||
#include "nsJSUtils.h"
|
||||
#include "nscore.h"
|
||||
#include "nsIScriptContext.h"
|
||||
#include "nsIScriptSecurityManager.h"
|
||||
#include "nsIJSScriptObject.h"
|
||||
#include "nsIScriptObjectOwner.h"
|
||||
#include "nsIScriptGlobalObject.h"
|
||||
#include "nsIPtr.h"
|
||||
#include "nsString.h"
|
||||
#include "nsIController.h"
|
||||
#include "nsIDOMElement.h"
|
||||
#include "nsIDOMXULCommandDispatcher.h"
|
||||
#include "nsIDOMWindow.h"
|
||||
|
||||
|
||||
static NS_DEFINE_IID(kIScriptObjectOwnerIID, NS_ISCRIPTOBJECTOWNER_IID);
|
||||
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(kIXULCommandDispatcherIID, NS_IDOMXULCOMMANDDISPATCHER_IID);
|
||||
static NS_DEFINE_IID(kIWindowIID, NS_IDOMWINDOW_IID);
|
||||
|
||||
NS_DEF_PTR(nsIController);
|
||||
NS_DEF_PTR(nsIDOMElement);
|
||||
NS_DEF_PTR(nsIDOMXULCommandDispatcher);
|
||||
NS_DEF_PTR(nsIDOMWindow);
|
||||
|
||||
//
|
||||
// XULCommandDispatcher property ids
|
||||
//
|
||||
enum XULCommandDispatcher_slots {
|
||||
XULCOMMANDDISPATCHER_FOCUSEDELEMENT = -1,
|
||||
XULCOMMANDDISPATCHER_FOCUSEDWINDOW = -2
|
||||
};
|
||||
|
||||
/***********************************************************************/
|
||||
//
|
||||
// XULCommandDispatcher Properties Getter
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
GetXULCommandDispatcherProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
{
|
||||
nsIDOMXULCommandDispatcher *a = (nsIDOMXULCommandDispatcher*)nsJSUtils::nsGetNativeThis(cx, obj);
|
||||
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
if (nsnull == a) {
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
if (JSVAL_IS_INT(id)) {
|
||||
nsIScriptContext *scriptCX = (nsIScriptContext *)JS_GetContextPrivate(cx);
|
||||
nsIScriptSecurityManager *secMan;
|
||||
PRBool ok = PR_FALSE;
|
||||
if (NS_OK != scriptCX->GetSecurityManager(&secMan)) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
switch(JSVAL_TO_INT(id)) {
|
||||
case XULCOMMANDDISPATCHER_FOCUSEDELEMENT:
|
||||
{
|
||||
secMan->CheckScriptAccess(scriptCX, obj, "xulcommanddispatcher.focusedelement", &ok);
|
||||
if (!ok) {
|
||||
//Need to throw error here
|
||||
return JS_FALSE;
|
||||
}
|
||||
nsIDOMElement* prop;
|
||||
if (NS_SUCCEEDED(a->GetFocusedElement(&prop))) {
|
||||
// get the js object
|
||||
nsJSUtils::nsConvertObjectToJSVal((nsISupports *)prop, cx, vp);
|
||||
}
|
||||
else {
|
||||
return JS_FALSE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case XULCOMMANDDISPATCHER_FOCUSEDWINDOW:
|
||||
{
|
||||
secMan->CheckScriptAccess(scriptCX, obj, "xulcommanddispatcher.focusedwindow", &ok);
|
||||
if (!ok) {
|
||||
//Need to throw error here
|
||||
return JS_FALSE;
|
||||
}
|
||||
nsIDOMWindow* prop;
|
||||
if (NS_SUCCEEDED(a->GetFocusedWindow(&prop))) {
|
||||
// get the js object
|
||||
nsJSUtils::nsConvertObjectToJSVal((nsISupports *)prop, cx, vp);
|
||||
}
|
||||
else {
|
||||
return JS_FALSE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
return nsJSUtils::nsCallJSScriptObjectGetProperty(a, cx, id, vp);
|
||||
}
|
||||
NS_RELEASE(secMan);
|
||||
}
|
||||
else {
|
||||
return nsJSUtils::nsCallJSScriptObjectGetProperty(a, cx, id, vp);
|
||||
}
|
||||
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
/***********************************************************************/
|
||||
//
|
||||
// XULCommandDispatcher Properties Setter
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
SetXULCommandDispatcherProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
{
|
||||
nsIDOMXULCommandDispatcher *a = (nsIDOMXULCommandDispatcher*)nsJSUtils::nsGetNativeThis(cx, obj);
|
||||
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
if (nsnull == a) {
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
if (JSVAL_IS_INT(id)) {
|
||||
nsIScriptContext *scriptCX = (nsIScriptContext *)JS_GetContextPrivate(cx);
|
||||
nsIScriptSecurityManager *secMan;
|
||||
PRBool ok = PR_FALSE;
|
||||
if (NS_OK != scriptCX->GetSecurityManager(&secMan)) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
switch(JSVAL_TO_INT(id)) {
|
||||
case XULCOMMANDDISPATCHER_FOCUSEDELEMENT:
|
||||
{
|
||||
secMan->CheckScriptAccess(scriptCX, obj, "xulcommanddispatcher.focusedelement", &ok);
|
||||
if (!ok) {
|
||||
//Need to throw error here
|
||||
return JS_FALSE;
|
||||
}
|
||||
nsIDOMElement* prop;
|
||||
if (PR_FALSE == nsJSUtils::nsConvertJSValToObject((nsISupports **)&prop,
|
||||
kIElementIID, "Element",
|
||||
cx, *vp)) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
a->SetFocusedElement(prop);
|
||||
NS_IF_RELEASE(prop);
|
||||
break;
|
||||
}
|
||||
case XULCOMMANDDISPATCHER_FOCUSEDWINDOW:
|
||||
{
|
||||
secMan->CheckScriptAccess(scriptCX, obj, "xulcommanddispatcher.focusedwindow", &ok);
|
||||
if (!ok) {
|
||||
//Need to throw error here
|
||||
return JS_FALSE;
|
||||
}
|
||||
nsIDOMWindow* prop;
|
||||
if (PR_FALSE == nsJSUtils::nsConvertJSValToObject((nsISupports **)&prop,
|
||||
kIWindowIID, "Window",
|
||||
cx, *vp)) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
a->SetFocusedWindow(prop);
|
||||
NS_IF_RELEASE(prop);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
return nsJSUtils::nsCallJSScriptObjectSetProperty(a, cx, id, vp);
|
||||
}
|
||||
NS_RELEASE(secMan);
|
||||
}
|
||||
else {
|
||||
return nsJSUtils::nsCallJSScriptObjectSetProperty(a, cx, id, vp);
|
||||
}
|
||||
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// XULCommandDispatcher finalizer
|
||||
//
|
||||
PR_STATIC_CALLBACK(void)
|
||||
FinalizeXULCommandDispatcher(JSContext *cx, JSObject *obj)
|
||||
{
|
||||
nsJSUtils::nsGenericFinalize(cx, obj);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// XULCommandDispatcher enumerate
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
EnumerateXULCommandDispatcher(JSContext *cx, JSObject *obj)
|
||||
{
|
||||
return nsJSUtils::nsGenericEnumerate(cx, obj);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// XULCommandDispatcher resolve
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
ResolveXULCommandDispatcher(JSContext *cx, JSObject *obj, jsval id)
|
||||
{
|
||||
return nsJSUtils::nsGenericResolve(cx, obj, id);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Native method AddCommand
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
XULCommandDispatcherAddCommand(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
nsIDOMXULCommandDispatcher *nativeThis = (nsIDOMXULCommandDispatcher*)nsJSUtils::nsGetNativeThis(cx, obj);
|
||||
nsIDOMElementPtr b0;
|
||||
|
||||
*rval = JSVAL_NULL;
|
||||
|
||||
nsIScriptContext *scriptCX = (nsIScriptContext *)JS_GetContextPrivate(cx);
|
||||
nsIScriptSecurityManager *secMan;
|
||||
if (NS_OK != scriptCX->GetSecurityManager(&secMan)) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
{
|
||||
PRBool ok;
|
||||
secMan->CheckScriptAccess(scriptCX, obj, "xulcommanddispatcher.addcommand", &ok);
|
||||
if (!ok) {
|
||||
//Need to throw error here
|
||||
return JS_FALSE;
|
||||
}
|
||||
NS_RELEASE(secMan);
|
||||
}
|
||||
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
if (nsnull == nativeThis) {
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
{
|
||||
if (argc < 1) {
|
||||
JS_ReportError(cx, "Function addCommand requires 1 parameter");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
if (JS_FALSE == nsJSUtils::nsConvertJSValToObject((nsISupports **)&b0,
|
||||
kIElementIID,
|
||||
"Element",
|
||||
cx,
|
||||
argv[0])) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
if (NS_OK != nativeThis->AddCommand(b0)) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
*rval = JSVAL_VOID;
|
||||
}
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Native method RemoveCommand
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
XULCommandDispatcherRemoveCommand(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
nsIDOMXULCommandDispatcher *nativeThis = (nsIDOMXULCommandDispatcher*)nsJSUtils::nsGetNativeThis(cx, obj);
|
||||
nsIDOMElementPtr b0;
|
||||
|
||||
*rval = JSVAL_NULL;
|
||||
|
||||
nsIScriptContext *scriptCX = (nsIScriptContext *)JS_GetContextPrivate(cx);
|
||||
nsIScriptSecurityManager *secMan;
|
||||
if (NS_OK != scriptCX->GetSecurityManager(&secMan)) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
{
|
||||
PRBool ok;
|
||||
secMan->CheckScriptAccess(scriptCX, obj, "xulcommanddispatcher.removecommand", &ok);
|
||||
if (!ok) {
|
||||
//Need to throw error here
|
||||
return JS_FALSE;
|
||||
}
|
||||
NS_RELEASE(secMan);
|
||||
}
|
||||
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
if (nsnull == nativeThis) {
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
{
|
||||
if (argc < 1) {
|
||||
JS_ReportError(cx, "Function removeCommand requires 1 parameter");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
if (JS_FALSE == nsJSUtils::nsConvertJSValToObject((nsISupports **)&b0,
|
||||
kIElementIID,
|
||||
"Element",
|
||||
cx,
|
||||
argv[0])) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
if (NS_OK != nativeThis->RemoveCommand(b0)) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
*rval = JSVAL_VOID;
|
||||
}
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Native method UpdateCommands
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
XULCommandDispatcherUpdateCommands(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
nsIDOMXULCommandDispatcher *nativeThis = (nsIDOMXULCommandDispatcher*)nsJSUtils::nsGetNativeThis(cx, obj);
|
||||
|
||||
*rval = JSVAL_NULL;
|
||||
|
||||
nsIScriptContext *scriptCX = (nsIScriptContext *)JS_GetContextPrivate(cx);
|
||||
nsIScriptSecurityManager *secMan;
|
||||
if (NS_OK != scriptCX->GetSecurityManager(&secMan)) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
{
|
||||
PRBool ok;
|
||||
secMan->CheckScriptAccess(scriptCX, obj, "xulcommanddispatcher.updatecommands", &ok);
|
||||
if (!ok) {
|
||||
//Need to throw error here
|
||||
return JS_FALSE;
|
||||
}
|
||||
NS_RELEASE(secMan);
|
||||
}
|
||||
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
if (nsnull == nativeThis) {
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
{
|
||||
|
||||
if (NS_OK != nativeThis->UpdateCommands()) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
*rval = JSVAL_VOID;
|
||||
}
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Native method GetController
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
XULCommandDispatcherGetController(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
nsIDOMXULCommandDispatcher *nativeThis = (nsIDOMXULCommandDispatcher*)nsJSUtils::nsGetNativeThis(cx, obj);
|
||||
nsIController* nativeRet;
|
||||
|
||||
*rval = JSVAL_NULL;
|
||||
|
||||
nsIScriptContext *scriptCX = (nsIScriptContext *)JS_GetContextPrivate(cx);
|
||||
nsIScriptSecurityManager *secMan;
|
||||
if (NS_OK != scriptCX->GetSecurityManager(&secMan)) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
{
|
||||
PRBool ok;
|
||||
secMan->CheckScriptAccess(scriptCX, obj, "xulcommanddispatcher.getcontroller", &ok);
|
||||
if (!ok) {
|
||||
//Need to throw error here
|
||||
return JS_FALSE;
|
||||
}
|
||||
NS_RELEASE(secMan);
|
||||
}
|
||||
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
if (nsnull == nativeThis) {
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
{
|
||||
|
||||
if (NS_OK != nativeThis->GetController(&nativeRet)) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
// n.b., this will release nativeRet
|
||||
nsJSUtils::nsConvertXPCObjectToJSVal(nativeRet, nsIController::GetIID(), cx, rval);
|
||||
}
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Native method SetController
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
XULCommandDispatcherSetController(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
nsIDOMXULCommandDispatcher *nativeThis = (nsIDOMXULCommandDispatcher*)nsJSUtils::nsGetNativeThis(cx, obj);
|
||||
nsIControllerPtr b0;
|
||||
|
||||
*rval = JSVAL_NULL;
|
||||
|
||||
nsIScriptContext *scriptCX = (nsIScriptContext *)JS_GetContextPrivate(cx);
|
||||
nsIScriptSecurityManager *secMan;
|
||||
if (NS_OK != scriptCX->GetSecurityManager(&secMan)) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
{
|
||||
PRBool ok;
|
||||
secMan->CheckScriptAccess(scriptCX, obj, "xulcommanddispatcher.setcontroller", &ok);
|
||||
if (!ok) {
|
||||
//Need to throw error here
|
||||
return JS_FALSE;
|
||||
}
|
||||
NS_RELEASE(secMan);
|
||||
}
|
||||
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
if (nsnull == nativeThis) {
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
{
|
||||
if (argc < 1) {
|
||||
JS_ReportError(cx, "Function setController requires 1 parameter");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
if (JS_FALSE == nsJSUtils::nsConvertJSValToXPCObject((nsISupports**) &b0,
|
||||
kIControllerIID, cx, argv[0])) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
if (NS_OK != nativeThis->SetController(b0)) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
*rval = JSVAL_VOID;
|
||||
}
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************/
|
||||
//
|
||||
// class for XULCommandDispatcher
|
||||
//
|
||||
JSClass XULCommandDispatcherClass = {
|
||||
"XULCommandDispatcher",
|
||||
JSCLASS_HAS_PRIVATE | JSCLASS_PRIVATE_IS_NSISUPPORTS,
|
||||
JS_PropertyStub,
|
||||
JS_PropertyStub,
|
||||
GetXULCommandDispatcherProperty,
|
||||
SetXULCommandDispatcherProperty,
|
||||
EnumerateXULCommandDispatcher,
|
||||
ResolveXULCommandDispatcher,
|
||||
JS_ConvertStub,
|
||||
FinalizeXULCommandDispatcher
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// XULCommandDispatcher class properties
|
||||
//
|
||||
static JSPropertySpec XULCommandDispatcherProperties[] =
|
||||
{
|
||||
{"focusedElement", XULCOMMANDDISPATCHER_FOCUSEDELEMENT, JSPROP_ENUMERATE},
|
||||
{"focusedWindow", XULCOMMANDDISPATCHER_FOCUSEDWINDOW, JSPROP_ENUMERATE},
|
||||
{0}
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// XULCommandDispatcher class methods
|
||||
//
|
||||
static JSFunctionSpec XULCommandDispatcherMethods[] =
|
||||
{
|
||||
{"addCommand", XULCommandDispatcherAddCommand, 1},
|
||||
{"removeCommand", XULCommandDispatcherRemoveCommand, 1},
|
||||
{"updateCommands", XULCommandDispatcherUpdateCommands, 0},
|
||||
{"getController", XULCommandDispatcherGetController, 0},
|
||||
{"setController", XULCommandDispatcherSetController, 1},
|
||||
{0}
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// XULCommandDispatcher constructor
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
XULCommandDispatcher(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// XULCommandDispatcher class initialization
|
||||
//
|
||||
extern "C" NS_DOM nsresult NS_InitXULCommandDispatcherClass(nsIScriptContext *aContext, void **aPrototype)
|
||||
{
|
||||
JSContext *jscontext = (JSContext *)aContext->GetNativeContext();
|
||||
JSObject *proto = nsnull;
|
||||
JSObject *constructor = nsnull;
|
||||
JSObject *parent_proto = nsnull;
|
||||
JSObject *global = JS_GetGlobalObject(jscontext);
|
||||
jsval vp;
|
||||
|
||||
if ((PR_TRUE != JS_LookupProperty(jscontext, global, "XULCommandDispatcher", &vp)) ||
|
||||
!JSVAL_IS_OBJECT(vp) ||
|
||||
((constructor = JSVAL_TO_OBJECT(vp)) == nsnull) ||
|
||||
(PR_TRUE != JS_LookupProperty(jscontext, JSVAL_TO_OBJECT(vp), "prototype", &vp)) ||
|
||||
!JSVAL_IS_OBJECT(vp)) {
|
||||
|
||||
proto = JS_InitClass(jscontext, // context
|
||||
global, // global object
|
||||
parent_proto, // parent proto
|
||||
&XULCommandDispatcherClass, // JSClass
|
||||
XULCommandDispatcher, // JSNative ctor
|
||||
0, // ctor args
|
||||
XULCommandDispatcherProperties, // proto props
|
||||
XULCommandDispatcherMethods, // proto funcs
|
||||
nsnull, // ctor props (static)
|
||||
nsnull); // ctor funcs (static)
|
||||
if (nsnull == proto) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
}
|
||||
else if ((nsnull != constructor) && JSVAL_IS_OBJECT(vp)) {
|
||||
proto = JSVAL_TO_OBJECT(vp);
|
||||
}
|
||||
else {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
if (aPrototype) {
|
||||
*aPrototype = proto;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Method for creating a new XULCommandDispatcher JavaScript object
|
||||
//
|
||||
extern "C" NS_DOM nsresult NS_NewScriptXULCommandDispatcher(nsIScriptContext *aContext, nsISupports *aSupports, nsISupports *aParent, void **aReturn)
|
||||
{
|
||||
NS_PRECONDITION(nsnull != aContext && nsnull != aSupports && nsnull != aReturn, "null argument to NS_NewScriptXULCommandDispatcher");
|
||||
JSObject *proto;
|
||||
JSObject *parent;
|
||||
nsIScriptObjectOwner *owner;
|
||||
JSContext *jscontext = (JSContext *)aContext->GetNativeContext();
|
||||
nsresult result = NS_OK;
|
||||
nsIDOMXULCommandDispatcher *aXULCommandDispatcher;
|
||||
|
||||
if (nsnull == aParent) {
|
||||
parent = nsnull;
|
||||
}
|
||||
else if (NS_OK == aParent->QueryInterface(kIScriptObjectOwnerIID, (void**)&owner)) {
|
||||
if (NS_OK != owner->GetScriptObject(aContext, (void **)&parent)) {
|
||||
NS_RELEASE(owner);
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
NS_RELEASE(owner);
|
||||
}
|
||||
else {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
if (NS_OK != NS_InitXULCommandDispatcherClass(aContext, (void **)&proto)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
result = aSupports->QueryInterface(kIXULCommandDispatcherIID, (void **)&aXULCommandDispatcher);
|
||||
if (NS_OK != result) {
|
||||
return result;
|
||||
}
|
||||
|
||||
// create a js object for this class
|
||||
*aReturn = JS_NewObject(jscontext, &XULCommandDispatcherClass, proto, parent);
|
||||
if (nsnull != *aReturn) {
|
||||
// connect the native object to the js object
|
||||
JS_SetPrivate(jscontext, (JSObject *)*aReturn, aXULCommandDispatcher);
|
||||
}
|
||||
else {
|
||||
NS_RELEASE(aXULCommandDispatcher);
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
|
@ -28,7 +28,7 @@
|
|||
#include "nsIPtr.h"
|
||||
#include "nsString.h"
|
||||
#include "nsIDOMElement.h"
|
||||
#include "nsIDOMXULFocusTracker.h"
|
||||
#include "nsIDOMXULCommandDispatcher.h"
|
||||
#include "nsIDOMXULDocument.h"
|
||||
#include "nsIDOMNodeList.h"
|
||||
|
||||
|
@ -37,12 +37,12 @@ static NS_DEFINE_IID(kIScriptObjectOwnerIID, NS_ISCRIPTOBJECTOWNER_IID);
|
|||
static NS_DEFINE_IID(kIJSScriptObjectIID, NS_IJSSCRIPTOBJECT_IID);
|
||||
static NS_DEFINE_IID(kIScriptGlobalObjectIID, NS_ISCRIPTGLOBALOBJECT_IID);
|
||||
static NS_DEFINE_IID(kIElementIID, NS_IDOMELEMENT_IID);
|
||||
static NS_DEFINE_IID(kIXULFocusTrackerIID, NS_IDOMXULFOCUSTRACKER_IID);
|
||||
static NS_DEFINE_IID(kIXULCommandDispatcherIID, NS_IDOMXULCOMMANDDISPATCHER_IID);
|
||||
static NS_DEFINE_IID(kIXULDocumentIID, NS_IDOMXULDOCUMENT_IID);
|
||||
static NS_DEFINE_IID(kINodeListIID, NS_IDOMNODELIST_IID);
|
||||
|
||||
NS_DEF_PTR(nsIDOMElement);
|
||||
NS_DEF_PTR(nsIDOMXULFocusTracker);
|
||||
NS_DEF_PTR(nsIDOMXULCommandDispatcher);
|
||||
NS_DEF_PTR(nsIDOMXULDocument);
|
||||
NS_DEF_PTR(nsIDOMNodeList);
|
||||
|
||||
|
@ -52,7 +52,7 @@ NS_DEF_PTR(nsIDOMNodeList);
|
|||
enum XULDocument_slots {
|
||||
XULDOCUMENT_POPUPELEMENT = -1,
|
||||
XULDOCUMENT_TOOLTIPELEMENT = -2,
|
||||
XULDOCUMENT_FOCUS = -3
|
||||
XULDOCUMENT_COMMANDDISPATCHER = -3
|
||||
};
|
||||
|
||||
/***********************************************************************/
|
||||
|
@ -111,15 +111,15 @@ GetXULDocumentProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
|||
}
|
||||
break;
|
||||
}
|
||||
case XULDOCUMENT_FOCUS:
|
||||
case XULDOCUMENT_COMMANDDISPATCHER:
|
||||
{
|
||||
secMan->CheckScriptAccess(scriptCX, obj, "xuldocument.focus", &ok);
|
||||
secMan->CheckScriptAccess(scriptCX, obj, "xuldocument.commanddispatcher", &ok);
|
||||
if (!ok) {
|
||||
//Need to throw error here
|
||||
return JS_FALSE;
|
||||
}
|
||||
nsIDOMXULFocusTracker* prop;
|
||||
if (NS_SUCCEEDED(a->GetFocus(&prop))) {
|
||||
nsIDOMXULCommandDispatcher* prop;
|
||||
if (NS_SUCCEEDED(a->GetCommandDispatcher(&prop))) {
|
||||
// get the js object
|
||||
nsJSUtils::nsConvertObjectToJSVal((nsISupports *)prop, cx, vp);
|
||||
}
|
||||
|
@ -370,7 +370,7 @@ static JSPropertySpec XULDocumentProperties[] =
|
|||
{
|
||||
{"popupElement", XULDOCUMENT_POPUPELEMENT, JSPROP_ENUMERATE},
|
||||
{"tooltipElement", XULDOCUMENT_TOOLTIPELEMENT, JSPROP_ENUMERATE},
|
||||
{"focus", XULDOCUMENT_FOCUS, JSPROP_ENUMERATE | JSPROP_READONLY},
|
||||
{"commandDispatcher", XULDOCUMENT_COMMANDDISPATCHER, JSPROP_ENUMERATE | JSPROP_READONLY},
|
||||
{0}
|
||||
};
|
||||
|
||||
|
|
|
@ -0,0 +1,298 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
/*
|
||||
This file provides the implementation for the sort service manager.
|
||||
*/
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
#include "nsVoidArray.h"
|
||||
|
||||
#include "nsIDOMElement.h"
|
||||
#include "nsIDOMXULCommandDispatcher.h"
|
||||
#include "nsIXULCommandDispatcher.h"
|
||||
#include "nsIDOMFocusListener.h"
|
||||
#include "nsRDFCID.h"
|
||||
|
||||
#include "nsIScriptGlobalObject.h"
|
||||
#include "nsIDOMWindow.h"
|
||||
#include "nsIScriptContextOwner.h"
|
||||
#include "nsIDOMXULDocument.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsIDOMUIEvent.h"
|
||||
|
||||
#include "nsIDOMXULElement.h"
|
||||
#include "nsIController.h"
|
||||
|
||||
#include "nsIPresContext.h"
|
||||
#include "nsIPresShell.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||
|
||||
static NS_DEFINE_IID(kIDomNodeIID, NS_IDOMNODE_IID);
|
||||
static NS_DEFINE_IID(kIDomElementIID, NS_IDOMELEMENT_IID);
|
||||
static NS_DEFINE_IID(kIDomEventListenerIID, NS_IDOMEVENTLISTENER_IID);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// XULCommandDispatcherImpl
|
||||
//
|
||||
// This is the focus manager for XUL documents.
|
||||
//
|
||||
class XULCommandDispatcherImpl : public nsIDOMXULCommandDispatcher,
|
||||
public nsIXULCommandDispatcher,
|
||||
public nsIDOMFocusListener
|
||||
{
|
||||
public:
|
||||
XULCommandDispatcherImpl(void);
|
||||
virtual ~XULCommandDispatcherImpl(void);
|
||||
|
||||
public:
|
||||
// nsISupports
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// nsIDOMXULCommandDispatcher interface
|
||||
NS_DECL_IDOMXULCOMMANDDISPATCHER
|
||||
|
||||
// nsIDOMFocusListener
|
||||
virtual nsresult Focus(nsIDOMEvent* aEvent);
|
||||
virtual nsresult Blur(nsIDOMEvent* aEvent);
|
||||
|
||||
// nsIDOMEventListener
|
||||
virtual nsresult HandleEvent(nsIDOMEvent* anEvent) { return NS_OK; };
|
||||
|
||||
private:
|
||||
nsIDOMElement* mCurrentElement; // Weak. The focus must obviously be lost if the node goes away.
|
||||
nsVoidArray* mFocusListeners; // Holds weak references to listener elements.
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
XULCommandDispatcherImpl::XULCommandDispatcherImpl(void)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
mCurrentElement = nsnull;
|
||||
mFocusListeners = nsnull;
|
||||
}
|
||||
|
||||
XULCommandDispatcherImpl::~XULCommandDispatcherImpl(void)
|
||||
{
|
||||
delete mFocusListeners;
|
||||
}
|
||||
|
||||
NS_IMPL_ADDREF(XULCommandDispatcherImpl)
|
||||
NS_IMPL_RELEASE(XULCommandDispatcherImpl)
|
||||
|
||||
NS_IMETHODIMP
|
||||
XULCommandDispatcherImpl::QueryInterface(REFNSIID iid, void** result)
|
||||
{
|
||||
if (! result)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
*result = nsnull;
|
||||
if (iid.Equals(nsIXULCommandDispatcher::GetIID()) ||
|
||||
iid.Equals(kISupportsIID)) {
|
||||
*result = NS_STATIC_CAST(nsIXULCommandDispatcher*, this);
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
else if (iid.Equals(nsIDOMXULCommandDispatcher::GetIID())) {
|
||||
*result = NS_STATIC_CAST(nsIDOMXULCommandDispatcher*, this);
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
else if (iid.Equals(nsIDOMFocusListener::GetIID())) {
|
||||
*result = NS_STATIC_CAST(nsIDOMFocusListener*, this);
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
else if (iid.Equals(kIDomEventListenerIID)) {
|
||||
*result = (nsIDOMEventListener*)(nsIDOMFocusListener*)this;
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
// nsIDOMXULTracker Interface
|
||||
|
||||
NS_IMETHODIMP
|
||||
XULCommandDispatcherImpl::GetFocusedElement(nsIDOMElement** aElement)
|
||||
{
|
||||
NS_IF_ADDREF(mCurrentElement);
|
||||
*aElement = mCurrentElement;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
XULCommandDispatcherImpl::SetFocusedElement(nsIDOMElement* aElement)
|
||||
{
|
||||
mCurrentElement = aElement;
|
||||
UpdateCommands();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
XULCommandDispatcherImpl::GetFocusedWindow(nsIDOMWindow** aElement)
|
||||
{
|
||||
// XXX Implement
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
XULCommandDispatcherImpl::SetFocusedWindow(nsIDOMWindow* aElement)
|
||||
{
|
||||
// XXX Implement
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
XULCommandDispatcherImpl::AddCommand(nsIDOMElement* aElement)
|
||||
{
|
||||
if (!mFocusListeners) {
|
||||
mFocusListeners = new nsVoidArray();
|
||||
mFocusListeners->AppendElement((void*)aElement); // Weak ref to element.
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
XULCommandDispatcherImpl::RemoveCommand(nsIDOMElement* aElement)
|
||||
{
|
||||
if (mFocusListeners) {
|
||||
mFocusListeners->RemoveElement((void*)aElement); // Weak ref to element
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
XULCommandDispatcherImpl::UpdateCommands()
|
||||
{
|
||||
if (mFocusListeners) {
|
||||
PRInt32 count = mFocusListeners->Count();
|
||||
for (PRInt32 i = 0; i < count; i++) {
|
||||
nsIDOMElement* domElement = (nsIDOMElement*)mFocusListeners->ElementAt(i);
|
||||
|
||||
nsCOMPtr<nsIContent> content;
|
||||
content = do_QueryInterface(domElement);
|
||||
|
||||
nsCOMPtr<nsIDocument> document;
|
||||
content->GetDocument(*getter_AddRefs(document));
|
||||
|
||||
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<nsIPresContext> aPresContext;
|
||||
shell->GetPresContext(getter_AddRefs(aPresContext));
|
||||
|
||||
NS_RELEASE(shell);
|
||||
|
||||
// Handle the DOM event
|
||||
nsEventStatus status = nsEventStatus_eIgnore;
|
||||
nsEvent event;
|
||||
event.eventStructType = NS_EVENT;
|
||||
event.message = NS_FORM_CHANGE; // XXX: I feel dirty and evil for subverting this.
|
||||
content->HandleDOMEvent(*aPresContext, &event, nsnull, NS_EVENT_FLAG_INIT, status);
|
||||
}
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
XULCommandDispatcherImpl::GetController(nsIController** aResult)
|
||||
{
|
||||
if (mCurrentElement) {
|
||||
nsCOMPtr<nsIDOMXULElement> xulElement = do_QueryInterface(mCurrentElement);
|
||||
if (xulElement)
|
||||
return xulElement->GetController(aResult);
|
||||
}
|
||||
|
||||
*aResult = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
XULCommandDispatcherImpl::SetController(nsIController* aController)
|
||||
{
|
||||
if (mCurrentElement) {
|
||||
nsCOMPtr<nsIDOMXULElement> xulElement = do_QueryInterface(mCurrentElement);
|
||||
if (xulElement)
|
||||
return xulElement->SetController(aController);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/////
|
||||
// nsIDOMFocusListener
|
||||
/////
|
||||
|
||||
nsresult
|
||||
XULCommandDispatcherImpl::Focus(nsIDOMEvent* aEvent)
|
||||
{
|
||||
nsCOMPtr<nsIDOMNode> t;
|
||||
aEvent->GetTarget(getter_AddRefs(t));
|
||||
nsCOMPtr<nsIDOMElement> target = do_QueryInterface(t);
|
||||
|
||||
if (target) {
|
||||
SetFocusedElement(target);
|
||||
UpdateCommands();
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
XULCommandDispatcherImpl::Blur(nsIDOMEvent* aEvent)
|
||||
{
|
||||
nsCOMPtr<nsIDOMNode> t;
|
||||
aEvent->GetTarget(getter_AddRefs(t));
|
||||
nsCOMPtr<nsIDOMElement> target = do_QueryInterface(t);
|
||||
|
||||
if (target.get() == mCurrentElement) {
|
||||
SetFocusedElement(nsnull);
|
||||
UpdateCommands();
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
nsresult
|
||||
NS_NewXULCommandDispatcher(nsIXULCommandDispatcher** CommandDispatcher)
|
||||
{
|
||||
XULCommandDispatcherImpl* focus = new XULCommandDispatcherImpl();
|
||||
if (!focus)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
NS_ADDREF(focus);
|
||||
*CommandDispatcher = focus;
|
||||
return NS_OK;
|
||||
}
|
|
@ -108,8 +108,8 @@
|
|||
|
||||
#include "nsIFrameReflow.h"
|
||||
#include "nsIBrowserWindow.h"
|
||||
#include "nsIDOMXULFocusTracker.h"
|
||||
#include "nsIXULFocusTracker.h"
|
||||
#include "nsIDOMXULCommandDispatcher.h"
|
||||
#include "nsIXULCommandDispatcher.h"
|
||||
#include "nsIDOMEventCapturer.h"
|
||||
#include "nsIDOMEventReceiver.h"
|
||||
#include "nsIDOMEventListener.h"
|
||||
|
@ -176,8 +176,8 @@ static NS_DEFINE_CID(kTextNodeCID, NS_TEXTNODE_CID);
|
|||
static NS_DEFINE_CID(kWellFormedDTDCID, NS_WELLFORMEDDTD_CID);
|
||||
static NS_DEFINE_CID(kXULContentSinkCID, NS_XULCONTENTSINK_CID);
|
||||
|
||||
static NS_DEFINE_CID(kXULFocusTrackerCID, NS_XULFOCUSTRACKER_CID);
|
||||
static NS_DEFINE_IID(kIXULFocusTrackerIID, NS_IXULFOCUSTRACKER_IID);
|
||||
static NS_DEFINE_CID(kXULCommandDispatcherCID, NS_XULCOMMANDDISPATCHER_CID);
|
||||
static NS_DEFINE_IID(kIXULCommandDispatcherIID, NS_IXULCOMMANDDISPATCHER_IID);
|
||||
static NS_DEFINE_IID(kLWBrkCID, NS_LWBRK_CID);
|
||||
static NS_DEFINE_IID(kILineBreakerFactoryIID, NS_ILINEBREAKERFACTORY_IID);
|
||||
static NS_DEFINE_IID(kIWordBreakerFactoryIID, NS_IWORDBREAKERFACTORY_IID);
|
||||
|
@ -793,7 +793,7 @@ protected:
|
|||
nsVoidArray mSubDocuments; // [OWNER] of subelements
|
||||
PRBool mIsPopup;
|
||||
nsCOMPtr<nsIDOMHTMLFormElement> mHiddenForm; // [OWNER] of this content element
|
||||
nsCOMPtr<nsIDOMXULFocusTracker> mFocusTracker; // [OWNER] of the focus tracker
|
||||
nsCOMPtr<nsIDOMXULCommandDispatcher> mCommandDispatcher; // [OWNER] of the focus tracker
|
||||
|
||||
// The following are pointers into the content model which provide access to
|
||||
// the objects triggering either a popup or a tooltip. These are marked as
|
||||
|
@ -2956,9 +2956,9 @@ XULDocumentImpl::SetTooltipElement(nsIDOMElement* anElement)
|
|||
|
||||
|
||||
NS_IMETHODIMP
|
||||
XULDocumentImpl::GetFocus(nsIDOMXULFocusTracker** aTracker)
|
||||
XULDocumentImpl::GetCommandDispatcher(nsIDOMXULCommandDispatcher** aTracker)
|
||||
{
|
||||
*aTracker = mFocusTracker;
|
||||
*aTracker = mCommandDispatcher;
|
||||
NS_IF_ADDREF(*aTracker);
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -3904,19 +3904,19 @@ XULDocumentImpl::Init(void)
|
|||
return rv;
|
||||
|
||||
// Create our focus tracker and hook it up.
|
||||
if (NS_FAILED(rv = nsComponentManager::CreateInstance(kXULFocusTrackerCID,
|
||||
if (NS_FAILED(rv = nsComponentManager::CreateInstance(kXULCommandDispatcherCID,
|
||||
nsnull,
|
||||
kIXULFocusTrackerIID,
|
||||
(void**) &mFocusTracker))) {
|
||||
kIXULCommandDispatcherIID,
|
||||
(void**) &mCommandDispatcher))) {
|
||||
NS_ERROR("unable to create a focus tracker");
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDOMEventListener> focusTracker = do_QueryInterface(mFocusTracker);
|
||||
if (focusTracker) {
|
||||
nsCOMPtr<nsIDOMEventListener> CommandDispatcher = do_QueryInterface(mCommandDispatcher);
|
||||
if (CommandDispatcher) {
|
||||
// Take the focus tracker and add it as an event listener for focus and blur events.
|
||||
AddEventListener("focus", focusTracker, PR_TRUE);
|
||||
AddEventListener("blur", focusTracker, PR_TRUE);
|
||||
AddEventListener("focus", CommandDispatcher, PR_TRUE);
|
||||
AddEventListener("blur", CommandDispatcher, PR_TRUE);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
|
|
Загрузка…
Ссылка в новой задаче