зеркало из https://github.com/mozilla/pjs.git
Bug 406407 - "Accelerators for textEdit should not be affected by keyboard group/level" [p=lolkaantimat@gmail.com (Evgeniy Ivanov) r+sr=roc a1.9=stuart]
This commit is contained in:
Родитель
f1ff06b1c0
Коммит
e54c45c68a
|
@ -55,6 +55,9 @@
|
|||
#include "nsDataHashtable.h"
|
||||
#include "nsIScriptRuntime.h"
|
||||
#include "nsIScriptGlobalObject.h"
|
||||
#include "nsIDOMEvent.h"
|
||||
|
||||
struct nsNativeKeyEvent; // Don't include nsINativeKeyBindings.h here: it will force strange compilation error!
|
||||
|
||||
class nsIDOMScriptObjectFactory;
|
||||
class nsIXPConnect;
|
||||
|
@ -1125,6 +1128,13 @@ public:
|
|||
* Return the localized ellipsis for UI.
|
||||
*/
|
||||
static const nsDependentString GetLocalizedEllipsis();
|
||||
|
||||
/*The routine GetNativeEvent is used to fill nsNativeKeyEvent nsNativeKeyEvent and
|
||||
it's used in DOMEventToNativeKeyEvent. See Bug 406407 page for details. */
|
||||
static nsEvent* GetNativeEvent(nsIDOMEvent* aDOMEvent);
|
||||
static PRBool DOMEventToNativeKeyEvent(nsIDOMEvent* aDOMEvent,
|
||||
nsNativeKeyEvent* aNativeEvent,
|
||||
PRBool aGetCharCode);
|
||||
|
||||
private:
|
||||
|
||||
|
|
|
@ -141,6 +141,10 @@ static NS_DEFINE_CID(kXTFServiceCID, NS_XTFSERVICE_CID);
|
|||
#include "nsUnicharUtilCIID.h"
|
||||
#include "nsICaseConversion.h"
|
||||
#include "nsCompressedCharMap.h"
|
||||
#include "nsINativeKeyBindings.h"
|
||||
#include "nsIDOMNSUIEvent.h"
|
||||
#include "nsIDOMNSEvent.h"
|
||||
#include "nsIPrivateDOMEvent.h"
|
||||
|
||||
#ifdef IBMBIDI
|
||||
#include "nsIBidiKeyboard.h"
|
||||
|
@ -3751,6 +3755,52 @@ nsContentUtils::GetLocalizedEllipsis()
|
|||
return nsDependentString(sBuf);
|
||||
}
|
||||
|
||||
nsEvent*
|
||||
nsContentUtils::GetNativeEvent(nsIDOMEvent* aDOMEvent)
|
||||
{
|
||||
nsCOMPtr<nsIPrivateDOMEvent> privateEvent(do_QueryInterface(aDOMEvent));
|
||||
if (!privateEvent)
|
||||
return nsnull;
|
||||
nsEvent* nativeEvent;
|
||||
privateEvent->GetInternalNSEvent(&nativeEvent);
|
||||
return nativeEvent;
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsContentUtils::DOMEventToNativeKeyEvent(nsIDOMEvent* aDOMEvent,
|
||||
nsNativeKeyEvent* aNativeEvent,
|
||||
PRBool aGetCharCode)
|
||||
{
|
||||
nsCOMPtr<nsIDOMNSUIEvent> uievent = do_QueryInterface(aDOMEvent);
|
||||
PRBool defaultPrevented;
|
||||
uievent->GetPreventDefault(&defaultPrevented);
|
||||
if (defaultPrevented)
|
||||
return PR_FALSE;
|
||||
|
||||
nsCOMPtr<nsIDOMNSEvent> nsevent = do_QueryInterface(aDOMEvent);
|
||||
PRBool trusted = PR_FALSE;
|
||||
nsevent->GetIsTrusted(&trusted);
|
||||
if (!trusted)
|
||||
return PR_FALSE;
|
||||
|
||||
nsCOMPtr<nsIDOMKeyEvent> keyEvent = do_QueryInterface(aDOMEvent);
|
||||
|
||||
if (aGetCharCode) {
|
||||
keyEvent->GetCharCode(&aNativeEvent->charCode);
|
||||
} else {
|
||||
aNativeEvent->charCode = 0;
|
||||
}
|
||||
keyEvent->GetKeyCode(&aNativeEvent->keyCode);
|
||||
keyEvent->GetAltKey(&aNativeEvent->altKey);
|
||||
keyEvent->GetCtrlKey(&aNativeEvent->ctrlKey);
|
||||
keyEvent->GetShiftKey(&aNativeEvent->shiftKey);
|
||||
keyEvent->GetMetaKey(&aNativeEvent->metaKey);
|
||||
|
||||
aNativeEvent->nativeEvent = GetNativeEvent(aDOMEvent);
|
||||
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
/* static */
|
||||
void
|
||||
nsAutoGCRoot::Shutdown()
|
||||
|
|
|
@ -350,12 +350,7 @@ nsXBLWindowKeyHandler::WalkHandlers(nsIDOMEvent* aKeyEvent, nsIAtom* aEventType)
|
|||
nsNativeKeyEvent nativeEvent;
|
||||
// Some key events have no useful charCode
|
||||
nativeEvent.charCode = 0;
|
||||
keyEvent->GetKeyCode(&nativeEvent.keyCode);
|
||||
keyEvent->GetAltKey(&nativeEvent.altKey);
|
||||
keyEvent->GetCtrlKey(&nativeEvent.ctrlKey);
|
||||
keyEvent->GetShiftKey(&nativeEvent.shiftKey);
|
||||
keyEvent->GetMetaKey(&nativeEvent.metaKey);
|
||||
|
||||
nsContentUtils::DOMEventToNativeKeyEvent(aKeyEvent, &nativeEvent, PR_FALSE);
|
||||
// get the DOM window we're attached to
|
||||
nsCOMPtr<nsIControllers> controllers;
|
||||
nsCOMPtr<nsPIWindowRoot> root = do_QueryInterface(mTarget);
|
||||
|
|
|
@ -419,38 +419,6 @@ DoCommandCallback(const char *aCommand, void *aData)
|
|||
}
|
||||
}
|
||||
|
||||
static PRBool
|
||||
DOMEventToNativeKeyEvent(nsIDOMEvent *aDOMEvent,
|
||||
nsNativeKeyEvent *aNativeEvent,
|
||||
PRBool aGetCharCode)
|
||||
{
|
||||
nsCOMPtr<nsIDOMNSUIEvent> uievent = do_QueryInterface(aDOMEvent);
|
||||
PRBool defaultPrevented;
|
||||
uievent->GetPreventDefault(&defaultPrevented);
|
||||
if (defaultPrevented)
|
||||
return PR_FALSE;
|
||||
|
||||
nsCOMPtr<nsIDOMNSEvent> nsevent = do_QueryInterface(aDOMEvent);
|
||||
PRBool trusted = PR_FALSE;
|
||||
nsevent->GetIsTrusted(&trusted);
|
||||
if (!trusted)
|
||||
return PR_FALSE;
|
||||
|
||||
nsCOMPtr<nsIDOMKeyEvent> keyEvent = do_QueryInterface(aDOMEvent);
|
||||
|
||||
if (aGetCharCode) {
|
||||
keyEvent->GetCharCode(&aNativeEvent->charCode);
|
||||
} else {
|
||||
aNativeEvent->charCode = 0;
|
||||
}
|
||||
keyEvent->GetKeyCode(&aNativeEvent->keyCode);
|
||||
keyEvent->GetAltKey(&aNativeEvent->altKey);
|
||||
keyEvent->GetCtrlKey(&aNativeEvent->ctrlKey);
|
||||
keyEvent->GetShiftKey(&aNativeEvent->shiftKey);
|
||||
keyEvent->GetMetaKey(&aNativeEvent->metaKey);
|
||||
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsTextInputListener::KeyDown(nsIDOMEvent *aKeyEvent)
|
||||
|
@ -458,7 +426,7 @@ nsTextInputListener::KeyDown(nsIDOMEvent *aKeyEvent)
|
|||
nsNativeKeyEvent nativeEvent;
|
||||
nsINativeKeyBindings *bindings = GetKeyBindings();
|
||||
if (bindings &&
|
||||
DOMEventToNativeKeyEvent(aKeyEvent, &nativeEvent, PR_FALSE)) {
|
||||
nsContentUtils::DOMEventToNativeKeyEvent(aKeyEvent, &nativeEvent, PR_FALSE)) {
|
||||
if (bindings->KeyDown(nativeEvent, DoCommandCallback, mFrame)) {
|
||||
aKeyEvent->PreventDefault();
|
||||
}
|
||||
|
@ -473,7 +441,7 @@ nsTextInputListener::KeyPress(nsIDOMEvent *aKeyEvent)
|
|||
nsNativeKeyEvent nativeEvent;
|
||||
nsINativeKeyBindings *bindings = GetKeyBindings();
|
||||
if (bindings &&
|
||||
DOMEventToNativeKeyEvent(aKeyEvent, &nativeEvent, PR_TRUE)) {
|
||||
nsContentUtils::DOMEventToNativeKeyEvent(aKeyEvent, &nativeEvent, PR_TRUE)) {
|
||||
if (bindings->KeyPress(nativeEvent, DoCommandCallback, mFrame)) {
|
||||
aKeyEvent->PreventDefault();
|
||||
}
|
||||
|
@ -488,7 +456,7 @@ nsTextInputListener::KeyUp(nsIDOMEvent *aKeyEvent)
|
|||
nsNativeKeyEvent nativeEvent;
|
||||
nsINativeKeyBindings *bindings = GetKeyBindings();
|
||||
if (bindings &&
|
||||
DOMEventToNativeKeyEvent(aKeyEvent, &nativeEvent, PR_FALSE)) {
|
||||
nsContentUtils::DOMEventToNativeKeyEvent(aKeyEvent, &nativeEvent, PR_FALSE)) {
|
||||
if (bindings->KeyUp(nativeEvent, DoCommandCallback, mFrame)) {
|
||||
aKeyEvent->PreventDefault();
|
||||
}
|
||||
|
|
|
@ -40,6 +40,7 @@
|
|||
#define nsINativeKeyBindings_h_
|
||||
|
||||
#include "nsISupports.h"
|
||||
#include "nsEvent.h"
|
||||
|
||||
#define NS_INATIVEKEYBINDINGS_IID \
|
||||
{0x606c54e7, 0x0593, 0x4750, {0x99, 0xd9, 0x4e, 0x1b, 0xcc, 0xec, 0x98, 0xd9}}
|
||||
|
@ -49,6 +50,7 @@
|
|||
|
||||
struct nsNativeKeyEvent
|
||||
{
|
||||
nsEvent *nativeEvent; // see bug 406407 to see how it is used
|
||||
PRUint32 keyCode;
|
||||
PRUint32 charCode;
|
||||
PRBool altKey;
|
||||
|
|
|
@ -40,12 +40,14 @@
|
|||
#include "nsString.h"
|
||||
#include "nsMemory.h"
|
||||
#include "nsGtkKeyUtils.h"
|
||||
#include "nsGUIEvent.h"
|
||||
|
||||
#include <gtk/gtkentry.h>
|
||||
#include <gtk/gtktextview.h>
|
||||
#include <gtk/gtkbindings.h>
|
||||
#include <gtk/gtkmain.h>
|
||||
#include <gdk/gdkkeysyms.h>
|
||||
#include <gdk/gdkevents.h>
|
||||
|
||||
static nsINativeKeyBindings::DoCommandCallback gCurrentCallback;
|
||||
static void *gCurrentCallbackData;
|
||||
|
@ -292,8 +294,12 @@ nsNativeKeyBindings::KeyPress(const nsNativeKeyEvent& aEvent,
|
|||
|
||||
gHandled = PR_FALSE;
|
||||
|
||||
gtk_bindings_activate(GTK_OBJECT(mNativeTarget),
|
||||
keyCode, GdkModifierType(modifiers));
|
||||
const nsGUIEvent *guiEvent = static_cast<nsGUIEvent*>(aEvent.nativeEvent);
|
||||
|
||||
if (guiEvent &&
|
||||
guiEvent->message == NS_KEY_PRESS &&
|
||||
guiEvent->nativeMsg)
|
||||
gtk_bindings_activate_event(GTK_OBJECT(mNativeTarget),static_cast<GdkEventKey*>(guiEvent->nativeMsg));
|
||||
|
||||
gCurrentCallback = nsnull;
|
||||
gCurrentCallbackData = nsnull;
|
||||
|
|
Загрузка…
Ссылка в новой задаче