mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 406407 - "Accelerators for textEdit should not be affected by keyboard group/level" [p=lolkaantimat@gmail.com (Evgeniy Ivanov) r+sr=roc a1.9=damons]
This commit is contained in:
parent
6d4aa754bc
commit
64c4b90d72
@ -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;
|
||||
@ -1126,6 +1129,16 @@ public:
|
||||
*/
|
||||
static const nsDependentString GetLocalizedEllipsis();
|
||||
|
||||
/**
|
||||
* The routine GetNativeEvent is used to fill nsNativeKeyEvent
|
||||
* nsNativeKeyEvent. It's also used in DOMEventToNativeKeyEvent.
|
||||
* See bug 406407 for details.
|
||||
*/
|
||||
static nsEvent* GetNativeEvent(nsIDOMEvent* aDOMEvent);
|
||||
static PRBool DOMEventToNativeKeyEvent(nsIDOMEvent* aDOMEvent,
|
||||
nsNativeKeyEvent* aNativeEvent,
|
||||
PRBool aGetCharCode);
|
||||
|
||||
private:
|
||||
|
||||
static PRBool InitializeEventTable();
|
||||
|
@ -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,54 @@ nsContentUtils::GetLocalizedEllipsis()
|
||||
return nsDependentString(sBuf);
|
||||
}
|
||||
|
||||
//static
|
||||
nsEvent*
|
||||
nsContentUtils::GetNativeEvent(nsIDOMEvent* aDOMEvent)
|
||||
{
|
||||
nsCOMPtr<nsIPrivateDOMEvent> privateEvent(do_QueryInterface(aDOMEvent));
|
||||
if (!privateEvent)
|
||||
return nsnull;
|
||||
nsEvent* nativeEvent;
|
||||
privateEvent->GetInternalNSEvent(&nativeEvent);
|
||||
return nativeEvent;
|
||||
}
|
||||
|
||||
//static
|
||||
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()
|
||||
|
@ -348,14 +348,6 @@ nsXBLWindowKeyHandler::WalkHandlers(nsIDOMEvent* aKeyEvent, nsIAtom* aEventType)
|
||||
nsINativeKeyBindings *nativeBindings;
|
||||
if (isEditor && (nativeBindings = GetEditorKeyBindings())) {
|
||||
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);
|
||||
|
||||
// get the DOM window we're attached to
|
||||
nsCOMPtr<nsIControllers> controllers;
|
||||
nsCOMPtr<nsPIWindowRoot> root = do_QueryInterface(mTarget);
|
||||
@ -369,13 +361,15 @@ nsXBLWindowKeyHandler::WalkHandlers(nsIDOMEvent* aKeyEvent, nsIAtom* aEventType)
|
||||
|
||||
PRBool handled;
|
||||
if (aEventType == nsGkAtoms::keypress) {
|
||||
keyEvent->GetCharCode(&nativeEvent.charCode);
|
||||
nsContentUtils::DOMEventToNativeKeyEvent(aKeyEvent, &nativeEvent, PR_TRUE);
|
||||
handled = sNativeEditorBindings->KeyPress(nativeEvent,
|
||||
DoCommandCallback, controllers);
|
||||
} else if (aEventType == nsGkAtoms::keyup) {
|
||||
nsContentUtils::DOMEventToNativeKeyEvent(aKeyEvent, &nativeEvent, PR_FALSE);
|
||||
handled = sNativeEditorBindings->KeyUp(nativeEvent,
|
||||
DoCommandCallback, controllers);
|
||||
} else {
|
||||
nsContentUtils::DOMEventToNativeKeyEvent(aKeyEvent, &nativeEvent, PR_FALSE);
|
||||
handled = sNativeEditorBindings->KeyDown(nativeEvent,
|
||||
DoCommandCallback, controllers);
|
||||
}
|
||||
|
@ -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 this 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,18 @@ 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->message == NS_KEY_UP || guiEvent->message == NS_KEY_DOWN) &&
|
||||
guiEvent->nativeMsg)
|
||||
gtk_bindings_activate_event(GTK_OBJECT(mNativeTarget),
|
||||
static_cast<GdkEventKey*>(guiEvent->nativeMsg)); // used for ctrl+x/c/v shortcuts, see bug 406407
|
||||
|
||||
if (!gHandled)
|
||||
gtk_bindings_activate(GTK_OBJECT(mNativeTarget),
|
||||
keyCode, GdkModifierType(modifiers)); /* used for non-shortcuts operations (I didn't find the way to remove it and
|
||||
to make gtk_bindings_activate_event work alone */
|
||||
|
||||
gCurrentCallback = nsnull;
|
||||
gCurrentCallbackData = nsnull;
|
||||
|
Loading…
Reference in New Issue
Block a user