Fixes for 3 PDT+ bugs (THAT'S RIGHT). Bugs 21895, 21832, and 21610. r=mjudge,

a=i'm leaving now for vacation, and i can't find anyone around, but i'm assuming that you
actually want them before January 3rd, so I'm checking them in.
This commit is contained in:
hyatt%netscape.com 1999-12-18 04:02:28 +00:00
parent 5d7a14b4f7
commit d3e0848c19
12 changed files with 209 additions and 89 deletions

View File

@ -48,6 +48,8 @@
#include "nsIScriptGlobalObject.h"
#include "nsISelfScrollingFrame.h"
#include "nsIPrivateDOMEvent.h"
#include "nsIGfxTextControlFrame.h"
#include "nsPIDOMWindow.h"
#undef DEBUG_scroll // define to see ugly mousewheel messages
@ -87,6 +89,8 @@ nsEventStateManager::nsEventStateManager()
mLastMiddleMouseDownContent = nsnull;
mLastRightMouseDownContent = nsnull;
mConsumeFocusEvents = PR_FALSE;
// init d&d gesture state machine variables
mIsTrackingDragGesture = PR_FALSE;
mGestureDownFrame = nsnull;
@ -194,35 +198,18 @@ nsEventStateManager::PreHandleEvent(nsIPresContext* aPresContext,
break;
case NS_GOTFOCUS:
{
if (!mDocument) {
nsCOMPtr<nsIPresShell> presShell;
aPresContext->GetShell(getter_AddRefs(presShell));
nsCOMPtr<nsIPresShell> presShell;
aPresContext->GetShell(getter_AddRefs(presShell));
if (!mDocument) {
if (presShell) {
presShell->GetDocument(&mDocument);
}
}
if (gLastFocusedDocument == mDocument)
break;
if (gLastFocusedDocument) {
nsCOMPtr<nsIScriptGlobalObject> globalObject;
gLastFocusedDocument->GetScriptGlobalObject(getter_AddRefs(globalObject));
if(globalObject) {
nsEventStatus status = nsEventStatus_eIgnore;
nsEvent event;
event.eventStructType = NS_EVENT;
event.message = NS_BLUR_CONTENT;
nsCOMPtr<nsIEventStateManager> esm;
gLastFocusedPresContext->GetEventStateManager(getter_AddRefs(esm));
esm->SetFocusedContent(nsnull);
gLastFocusedDocument->HandleDOMEvent(gLastFocusedPresContext, &event, nsnull, NS_EVENT_FLAG_INIT, &status);
globalObject->HandleDOMEvent(gLastFocusedPresContext, &event, nsnull, NS_EVENT_FLAG_INIT, &status);
}
}
break;
//fire focus
nsEventStatus status = nsEventStatus_eIgnore;
nsEvent focusevent;
@ -241,6 +228,7 @@ nsEventStateManager::PreHandleEvent(nsIPresContext* aPresContext,
mCurrentFocus = currentFocus;
}
NS_IF_RELEASE(gLastFocusedDocument);
gLastFocusedDocument = mDocument;
gLastFocusedPresContext = aPresContext;
@ -477,6 +465,11 @@ nsEventStateManager::PostHandleEvent(nsIPresContext* aPresContext,
case NS_MOUSE_MIDDLE_BUTTON_DOWN:
case NS_MOUSE_RIGHT_BUTTON_DOWN:
{
if (mConsumeFocusEvents) {
mConsumeFocusEvents = PR_FALSE;
break;
}
if (nsEventStatus_eConsumeNoDefault != *aStatus) {
nsCOMPtr<nsIContent> newFocus;
mCurrentTarget->GetContent(getter_AddRefs(newFocus));
@ -1924,18 +1917,56 @@ nsEventStateManager::SendFocusBlur(nsIPresContext* aPresContext, nsIContent *aCo
}
}
if (nsnull != gLastFocusedPresContext && gLastFocusedContent) {
//fire blur
nsEventStatus status = nsEventStatus_eIgnore;
nsEvent event;
event.eventStructType = NS_EVENT;
event.message = NS_BLUR_CONTENT;
if (nsnull != gLastFocusedPresContext) {
if (gLastFocusedContent) {
nsCOMPtr<nsIEventStateManager> esm;
gLastFocusedPresContext->GetEventStateManager(getter_AddRefs(esm));
esm->SetFocusedContent(gLastFocusedContent);
gLastFocusedContent->HandleDOMEvent(gLastFocusedPresContext, &event, nsnull, NS_EVENT_FLAG_INIT, &status);
esm->SetFocusedContent(nsnull);
// Retrieve this content node's pres context. it can be out of sync in
// the Ender widget case.
nsCOMPtr<nsIDocument> doc;
gLastFocusedContent->GetDocument(*getter_AddRefs(doc));
nsCOMPtr<nsIPresShell> shell = getter_AddRefs(doc->GetShellAt(0));
nsCOMPtr<nsIPresContext> oldPresContext;
shell->GetPresContext(getter_AddRefs(oldPresContext));
//fire blur
nsEventStatus status = nsEventStatus_eIgnore;
nsEvent event;
event.eventStructType = NS_EVENT;
event.message = NS_BLUR_CONTENT;
nsCOMPtr<nsIEventStateManager> esm;
oldPresContext->GetEventStateManager(getter_AddRefs(esm));
esm->SetFocusedContent(gLastFocusedContent);
gLastFocusedContent->HandleDOMEvent(oldPresContext, &event, nsnull, NS_EVENT_FLAG_INIT, &status);
esm->SetFocusedContent(nsnull);
}
// Go ahead and fire a blur on the window.
nsCOMPtr<nsIScriptGlobalObject> globalObject;
gLastFocusedDocument->GetScriptGlobalObject(getter_AddRefs(globalObject));
nsCOMPtr<nsIPresShell> presShell;
aPresContext->GetShell(getter_AddRefs(presShell));
if (!mDocument) {
if (presShell) {
presShell->GetDocument(&mDocument);
}
}
if ((gLastFocusedDocument != mDocument) && globalObject) {
nsEventStatus status = nsEventStatus_eIgnore;
nsEvent event;
event.eventStructType = NS_EVENT;
event.message = NS_BLUR_CONTENT;
nsCOMPtr<nsIEventStateManager> esm;
gLastFocusedPresContext->GetEventStateManager(getter_AddRefs(esm));
esm->SetFocusedContent(nsnull);
gLastFocusedDocument->HandleDOMEvent(gLastFocusedPresContext, &event, nsnull, NS_EVENT_FLAG_INIT, &status);
globalObject->HandleDOMEvent(gLastFocusedPresContext, &event, nsnull, NS_EVENT_FLAG_INIT, &status);
}
}
NS_IF_RELEASE(gLastFocusedContent);

View File

@ -107,6 +107,8 @@ protected:
void GenerateDragGesture ( nsIPresContext* aPresContext, nsGUIEvent *aEvent ) ;
PRBool IsTrackingDragGesture ( ) const { return mIsTrackingDragGesture; }
PRBool mSuppressFocusChange; // Used only for Ender text fields to suppress a focus firing on mouse down
//Any frames here must be checked for validity in ClearFrameRefs
nsIFrame* mCurrentTarget;
nsIContent* mCurrentTargetContent;

View File

@ -333,7 +333,6 @@ nsXULCommandDispatcher::Focus(nsIDOMEvent* aEvent)
nsCOMPtr<nsIDOMNode> t;
aEvent->GetTarget(getter_AddRefs(t));
/*
printf("%d : Focus occurred on: ", this);
nsCOMPtr<nsIDOMElement> domDebugElement = do_QueryInterface(t);
if (domDebugElement) {
@ -348,7 +347,6 @@ nsXULCommandDispatcher::Focus(nsIDOMEvent* aEvent)
else printf("Window with a XUL doc (happens twice)");
}
printf("\n");
*/
nsCOMPtr<nsIDOMElement> domElement = do_QueryInterface(t);
if (domElement && (domElement != mCurrentElement)) {
@ -388,7 +386,6 @@ nsXULCommandDispatcher::Blur(nsIDOMEvent* aEvent)
nsCOMPtr<nsIDOMNode> t;
aEvent->GetTarget(getter_AddRefs(t));
/*
printf("%d : Blur occurred on: ", this);
nsCOMPtr<nsIDOMElement> domDebugElement = do_QueryInterface(t);
if (domDebugElement) {
@ -403,7 +400,6 @@ nsXULCommandDispatcher::Blur(nsIDOMEvent* aEvent)
else printf("Window with a XUL doc (happens twice)");
}
printf("\n");
*/
nsCOMPtr<nsIDOMElement> domElement = do_QueryInterface(t);
if (domElement) {

View File

@ -48,6 +48,8 @@
#include "nsIScriptGlobalObject.h"
#include "nsISelfScrollingFrame.h"
#include "nsIPrivateDOMEvent.h"
#include "nsIGfxTextControlFrame.h"
#include "nsPIDOMWindow.h"
#undef DEBUG_scroll // define to see ugly mousewheel messages
@ -87,6 +89,8 @@ nsEventStateManager::nsEventStateManager()
mLastMiddleMouseDownContent = nsnull;
mLastRightMouseDownContent = nsnull;
mConsumeFocusEvents = PR_FALSE;
// init d&d gesture state machine variables
mIsTrackingDragGesture = PR_FALSE;
mGestureDownFrame = nsnull;
@ -194,35 +198,18 @@ nsEventStateManager::PreHandleEvent(nsIPresContext* aPresContext,
break;
case NS_GOTFOCUS:
{
if (!mDocument) {
nsCOMPtr<nsIPresShell> presShell;
aPresContext->GetShell(getter_AddRefs(presShell));
nsCOMPtr<nsIPresShell> presShell;
aPresContext->GetShell(getter_AddRefs(presShell));
if (!mDocument) {
if (presShell) {
presShell->GetDocument(&mDocument);
}
}
if (gLastFocusedDocument == mDocument)
break;
if (gLastFocusedDocument) {
nsCOMPtr<nsIScriptGlobalObject> globalObject;
gLastFocusedDocument->GetScriptGlobalObject(getter_AddRefs(globalObject));
if(globalObject) {
nsEventStatus status = nsEventStatus_eIgnore;
nsEvent event;
event.eventStructType = NS_EVENT;
event.message = NS_BLUR_CONTENT;
nsCOMPtr<nsIEventStateManager> esm;
gLastFocusedPresContext->GetEventStateManager(getter_AddRefs(esm));
esm->SetFocusedContent(nsnull);
gLastFocusedDocument->HandleDOMEvent(gLastFocusedPresContext, &event, nsnull, NS_EVENT_FLAG_INIT, &status);
globalObject->HandleDOMEvent(gLastFocusedPresContext, &event, nsnull, NS_EVENT_FLAG_INIT, &status);
}
}
break;
//fire focus
nsEventStatus status = nsEventStatus_eIgnore;
nsEvent focusevent;
@ -241,6 +228,7 @@ nsEventStateManager::PreHandleEvent(nsIPresContext* aPresContext,
mCurrentFocus = currentFocus;
}
NS_IF_RELEASE(gLastFocusedDocument);
gLastFocusedDocument = mDocument;
gLastFocusedPresContext = aPresContext;
@ -477,6 +465,11 @@ nsEventStateManager::PostHandleEvent(nsIPresContext* aPresContext,
case NS_MOUSE_MIDDLE_BUTTON_DOWN:
case NS_MOUSE_RIGHT_BUTTON_DOWN:
{
if (mConsumeFocusEvents) {
mConsumeFocusEvents = PR_FALSE;
break;
}
if (nsEventStatus_eConsumeNoDefault != *aStatus) {
nsCOMPtr<nsIContent> newFocus;
mCurrentTarget->GetContent(getter_AddRefs(newFocus));
@ -1924,18 +1917,56 @@ nsEventStateManager::SendFocusBlur(nsIPresContext* aPresContext, nsIContent *aCo
}
}
if (nsnull != gLastFocusedPresContext && gLastFocusedContent) {
//fire blur
nsEventStatus status = nsEventStatus_eIgnore;
nsEvent event;
event.eventStructType = NS_EVENT;
event.message = NS_BLUR_CONTENT;
if (nsnull != gLastFocusedPresContext) {
if (gLastFocusedContent) {
nsCOMPtr<nsIEventStateManager> esm;
gLastFocusedPresContext->GetEventStateManager(getter_AddRefs(esm));
esm->SetFocusedContent(gLastFocusedContent);
gLastFocusedContent->HandleDOMEvent(gLastFocusedPresContext, &event, nsnull, NS_EVENT_FLAG_INIT, &status);
esm->SetFocusedContent(nsnull);
// Retrieve this content node's pres context. it can be out of sync in
// the Ender widget case.
nsCOMPtr<nsIDocument> doc;
gLastFocusedContent->GetDocument(*getter_AddRefs(doc));
nsCOMPtr<nsIPresShell> shell = getter_AddRefs(doc->GetShellAt(0));
nsCOMPtr<nsIPresContext> oldPresContext;
shell->GetPresContext(getter_AddRefs(oldPresContext));
//fire blur
nsEventStatus status = nsEventStatus_eIgnore;
nsEvent event;
event.eventStructType = NS_EVENT;
event.message = NS_BLUR_CONTENT;
nsCOMPtr<nsIEventStateManager> esm;
oldPresContext->GetEventStateManager(getter_AddRefs(esm));
esm->SetFocusedContent(gLastFocusedContent);
gLastFocusedContent->HandleDOMEvent(oldPresContext, &event, nsnull, NS_EVENT_FLAG_INIT, &status);
esm->SetFocusedContent(nsnull);
}
// Go ahead and fire a blur on the window.
nsCOMPtr<nsIScriptGlobalObject> globalObject;
gLastFocusedDocument->GetScriptGlobalObject(getter_AddRefs(globalObject));
nsCOMPtr<nsIPresShell> presShell;
aPresContext->GetShell(getter_AddRefs(presShell));
if (!mDocument) {
if (presShell) {
presShell->GetDocument(&mDocument);
}
}
if ((gLastFocusedDocument != mDocument) && globalObject) {
nsEventStatus status = nsEventStatus_eIgnore;
nsEvent event;
event.eventStructType = NS_EVENT;
event.message = NS_BLUR_CONTENT;
nsCOMPtr<nsIEventStateManager> esm;
gLastFocusedPresContext->GetEventStateManager(getter_AddRefs(esm));
esm->SetFocusedContent(nsnull);
gLastFocusedDocument->HandleDOMEvent(gLastFocusedPresContext, &event, nsnull, NS_EVENT_FLAG_INIT, &status);
globalObject->HandleDOMEvent(gLastFocusedPresContext, &event, nsnull, NS_EVENT_FLAG_INIT, &status);
}
}
NS_IF_RELEASE(gLastFocusedContent);

View File

@ -107,6 +107,8 @@ protected:
void GenerateDragGesture ( nsIPresContext* aPresContext, nsGUIEvent *aEvent ) ;
PRBool IsTrackingDragGesture ( ) const { return mIsTrackingDragGesture; }
PRBool mSuppressFocusChange; // Used only for Ender text fields to suppress a focus firing on mouse down
//Any frames here must be checked for validity in ClearFrameRefs
nsIFrame* mCurrentTarget;
nsIContent* mCurrentTargetContent;

View File

@ -23,6 +23,7 @@
#include "nsISupports.h"
class nsIEditor;
class nsIWebShell;
#define NS_IGFXTEXTCONTROLFRAME_IID \
{/* d3ea33ea-9e00-11d3-bccc-0060b0fc76bd*/ \
@ -35,4 +36,5 @@ public:
static const nsIID& GetIID() { static nsIID iid = NS_IGFXTEXTCONTROLFRAME_IID; return iid; }
NS_IMETHOD GetEditor(nsIEditor **aEditor) = 0;
NS_IMETHOD GetWebShell(nsIWebShell** aWebShell) = 0;
};

View File

@ -23,6 +23,7 @@
#include "nsISupports.h"
class nsIEditor;
class nsIWebShell;
#define NS_IGFXTEXTCONTROLFRAME_IID \
{/* d3ea33ea-9e00-11d3-bccc-0060b0fc76bd*/ \
@ -35,4 +36,5 @@ public:
static const nsIID& GetIID() { static nsIID iid = NS_IGFXTEXTCONTROLFRAME_IID; return iid; }
NS_IMETHOD GetEditor(nsIEditor **aEditor) = 0;
NS_IMETHOD GetWebShell(nsIWebShell** aWebShell) = 0;
};

View File

@ -23,6 +23,7 @@
#include "nsISupports.h"
class nsIEditor;
class nsIWebShell;
#define NS_IGFXTEXTCONTROLFRAME_IID \
{/* d3ea33ea-9e00-11d3-bccc-0060b0fc76bd*/ \
@ -35,4 +36,5 @@ public:
static const nsIID& GetIID() { static nsIID iid = NS_IGFXTEXTCONTROLFRAME_IID; return iid; }
NS_IMETHOD GetEditor(nsIEditor **aEditor) = 0;
NS_IMETHOD GetWebShell(nsIWebShell** aWebShell) = 0;
};

View File

@ -208,6 +208,16 @@ nsGfxTextControlFrame::Init(nsIPresContext* aPresContext,
return (nsTextControlFrame::Init(aPresContext, aContent, aParent, aContext, aPrevInFlow));
}
NS_IMETHODIMP
nsGfxTextControlFrame::GetEditor(nsIEditor **aEditor)
{
NS_ENSURE_ARG_POINTER(aEditor);
*aEditor = mEditor;
NS_IF_ADDREF(*aEditor);
return NS_OK;
}
NS_IMETHODIMP
nsGfxTextControlFrame::GetFrameType(nsIAtom** aType) const
{
@ -219,12 +229,12 @@ nsGfxTextControlFrame::GetFrameType(nsIAtom** aType) const
NS_IMETHODIMP
nsGfxTextControlFrame::GetEditor(nsIEditor **aEditor)
nsGfxTextControlFrame::GetWebShell(nsIWebShell **aWebShell)
{
NS_ENSURE_ARG_POINTER(aEditor);
NS_ENSURE_ARG_POINTER(aWebShell);
*aEditor = mEditor;
NS_IF_ADDREF(*aEditor);
*aWebShell = mWebShell;
NS_IF_ADDREF(*aWebShell);
return NS_OK;
}
@ -2483,6 +2493,7 @@ nsGfxTextControlFrame::InstallEventListeners()
if (NS_FAILED(result)) { return result ; }
if (!mEventListener) { return NS_ERROR_NULL_POINTER; }
mEventListener->SetFrame(this);
mEventListener->SetInnerPresShell(presShell);
mEventListener->SetPresContext(mFramePresContext);
mEventListener->SetView(view);
@ -3413,6 +3424,22 @@ nsEnderEventListener::DispatchMouseEvent(nsIDOMMouseEvent *aEvent, PRInt32 aEven
result = manager->PostHandleEvent(mContext, &event, gfxFrame, &status, mView);
}
NS_IF_RELEASE(manager);
if ((aEventType == NS_MOUSE_LEFT_BUTTON_DOWN) ||
(aEventType == NS_MOUSE_MIDDLE_BUTTON_DOWN) ||
(aEventType == NS_MOUSE_RIGHT_BUTTON_DOWN))
{
// Call consume focus events on the inner event state manager to prevent its
// PostHandleEvent from immediately blurring us.
nsCOMPtr<nsIPresContext> pc;
mInnerShell->GetPresContext(getter_AddRefs(pc));
nsCOMPtr<nsIEventStateManager> esm;
pc->GetEventStateManager(getter_AddRefs(esm));
esm->ConsumeFocusEvents(PR_TRUE);
// Now set the focus in to the widget.
mFrame->SetFocus();
}
}
}
}
@ -3625,6 +3652,7 @@ nsEnderEventListener::MouseOut(nsIDOMEvent* aEvent)
nsresult
nsEnderEventListener::Focus(nsIDOMEvent* aEvent)
{
/*
// In this case, the focus has all ready been set because of the mouse down
// and setting it on the native widget causes an event to be dispatched
// and this listener then gets call. So we want to skip it here
@ -3684,14 +3712,14 @@ nsEnderEventListener::Focus(nsIDOMEvent* aEvent)
NS_RELEASE(manager);
}
}
*/
return NS_OK;
}
nsresult
nsEnderEventListener::Blur(nsIDOMEvent* aEvent)
{
/*
nsCOMPtr<nsIDOMUIEvent>uiEvent;
uiEvent = do_QueryInterface(aEvent);
if (!uiEvent) {
@ -3737,7 +3765,7 @@ nsEnderEventListener::Blur(nsIDOMEvent* aEvent)
mContent->HandleDOMEvent(mContext, &event, nsnull, NS_EVENT_FLAG_INIT, &status);
}
*/
return NS_OK;
}

View File

@ -202,6 +202,8 @@ public:
/** set the view associated with this listener instance */
NS_IMETHOD SetView(nsIView *aView)=0;
NS_IMETHOD SetInnerPresShell(nsIPresShell* aPresShell)=0; // Weak ref
};
/******************************************************************************
@ -236,6 +238,7 @@ public:
NS_IMETHOD SetFrame(nsGfxTextControlFrame *aFrame);
NS_IMETHOD SetPresContext(nsIPresContext *aCx) {mContext = do_QueryInterface(aCx); return NS_OK;}
NS_IMETHOD SetView(nsIView *aView) {mView = aView; return NS_OK;} // views are not ref counted
NS_IMETHOD SetInnerPresShell(nsIPresShell* aPresShell) { mInnerShell = aPresShell; return NS_OK; }
/** nsIDOMKeyListener interfaces
* @see nsIDOMKeyListener
@ -287,6 +290,7 @@ protected:
nsCWeakReference<nsGfxTextControlFrame> mFrame;
nsIView *mView; // not ref counted
nsCOMPtr<nsIPresContext> mContext; // ref counted
nsIPresShell* mInnerShell; // not ref counted
nsCOMPtr<nsIContent> mContent; // ref counted
nsString mTextValue; // the value of the text field at focus
PRBool mSkipFocusDispatch; // On Mouse down we don't want to dispatch
@ -505,6 +509,7 @@ public:
/* ============= nsIGfxTextControlFrame ================= */
NS_IMETHOD GetEditor(nsIEditor **aEditor);
NS_IMETHOD GetWebShell(nsIWebShell **aWebShell);
protected:

View File

@ -333,7 +333,6 @@ nsXULCommandDispatcher::Focus(nsIDOMEvent* aEvent)
nsCOMPtr<nsIDOMNode> t;
aEvent->GetTarget(getter_AddRefs(t));
/*
printf("%d : Focus occurred on: ", this);
nsCOMPtr<nsIDOMElement> domDebugElement = do_QueryInterface(t);
if (domDebugElement) {
@ -348,7 +347,6 @@ nsXULCommandDispatcher::Focus(nsIDOMEvent* aEvent)
else printf("Window with a XUL doc (happens twice)");
}
printf("\n");
*/
nsCOMPtr<nsIDOMElement> domElement = do_QueryInterface(t);
if (domElement && (domElement != mCurrentElement)) {
@ -388,7 +386,6 @@ nsXULCommandDispatcher::Blur(nsIDOMEvent* aEvent)
nsCOMPtr<nsIDOMNode> t;
aEvent->GetTarget(getter_AddRefs(t));
/*
printf("%d : Blur occurred on: ", this);
nsCOMPtr<nsIDOMElement> domDebugElement = do_QueryInterface(t);
if (domDebugElement) {
@ -403,7 +400,6 @@ nsXULCommandDispatcher::Blur(nsIDOMEvent* aEvent)
else printf("Window with a XUL doc (happens twice)");
}
printf("\n");
*/
nsCOMPtr<nsIDOMElement> domElement = do_QueryInterface(t);
if (domElement) {

View File

@ -500,7 +500,7 @@ nsresult nsXULKeyListenerImpl::DoKey(nsIDOMEvent* aKeyEvent, eEventType aEventTy
commandDispatcher->GetFocusedWindow(getter_AddRefs(domWindow));
piWindow = do_QueryInterface(domWindow);
nsCAutoString keyFile;
nsCAutoString keyFile, platformKeyFile;
if (focusedElement) {
// See if it's a textarea or input field.
// XXX Check to see if the "key-bindings" CSS property points us to a file.
@ -511,23 +511,37 @@ nsresult nsXULKeyListenerImpl::DoKey(nsIDOMEvent* aKeyEvent, eEventType aEventTy
if (tagName.EqualsIgnoreCase("input")) {
nsAutoString type;
focusedElement->GetAttribute(nsAutoString("type"), type);
if (type == "" || type.EqualsIgnoreCase("text"))
if (type == "" || type.EqualsIgnoreCase("text") ||
type.EqualsIgnoreCase("password")) {
keyFile = "chrome://global/content/inputBindings.xul";
platformKeyFile = "chrome://global/content/platformInputBindings.xul";
}
}
else if (tagName.EqualsIgnoreCase("textarea"))
else if (tagName.EqualsIgnoreCase("textarea")) {
keyFile = "chrome://global/content/textAreaBindings.xul";
platformKeyFile = "chrome://global/content/platformTextAreaBindings.xul";
}
}
nsCOMPtr<nsIDOMXULDocument> document;
GetKeyBindingDocument(keyFile, getter_AddRefs(document));
GetKeyBindingDocument(platformKeyFile, getter_AddRefs(document));
// Locate the key node and execute the JS on a match.
PRBool handled = PR_FALSE;
if (document) // Local focused ELEMENT handling stage.
LocateAndExecuteKeyBinding(keyEvent, aEventType, document, handled);
if (!handled) {
GetKeyBindingDocument(keyFile, getter_AddRefs(document));
if (document) // Local focused ELEMENT handling stage.
LocateAndExecuteKeyBinding(keyEvent, aEventType, document, handled);
}
nsCAutoString browserFile = "chrome://global/content/browserBindings.xul";
nsCAutoString editorFile = "chrome://global/content/editorBindings.xul";
nsCAutoString browserPlatformFile = "chrome://global/content/platformBrowserBindings.xul";
nsCAutoString editorPlatformFile = "chrome://global/content/platformEditorBindings.xul";
nsresult result;
if (!handled) {
@ -568,19 +582,26 @@ nsresult nsXULKeyListenerImpl::DoKey(nsIDOMEvent* aKeyEvent, eEventType aEventTy
PRBool editorHasBindings = PR_FALSE;
nsCOMPtr<nsIDOMXULDocument> platformDoc;
if (presShell)
{
PRBool isEditor;
if (NS_SUCCEEDED(presShell->GetDisplayNonTextSelection(&isEditor)) && isEditor)
{
editorHasBindings = PR_TRUE;
GetKeyBindingDocument(editorPlatformFile, getter_AddRefs(platformDoc));
GetKeyBindingDocument(editorFile, getter_AddRefs(document));
}
}
if (!editorHasBindings)
if (!editorHasBindings) {
GetKeyBindingDocument(browserPlatformFile, getter_AddRefs(platformDoc));
GetKeyBindingDocument(browserFile, getter_AddRefs(document));
}
if (document)
if (platformDoc)
LocateAndExecuteKeyBinding(keyEvent, aEventType, platformDoc, handled);
if (!handled && document)
LocateAndExecuteKeyBinding(keyEvent, aEventType, document, handled);
}
@ -1559,6 +1580,8 @@ nsXULKeyListenerImpl::HandleEventUsingKeyset(nsIDOMElement* aKeysetElement, nsID
masterContext->BindCompiledEventHandler(scriptObject, eventName, nsnull);
aKeyEvent->PreventBubble();
aKeyEvent->PreventCapture();
return NS_OK;
}
}