зеркало из https://github.com/mozilla/gecko-dev.git
Bug 685073 part.2 Consume key event which causes nested key event r=smichaud
This commit is contained in:
Родитель
eeb6716dfb
Коммит
a79188fbc7
|
@ -481,6 +481,8 @@ protected:
|
|||
bool mKeyPressDispatched;
|
||||
// Whether keypress event was consumed by web contents or chrome contents.
|
||||
bool mKeyPressHandled;
|
||||
// Whether the key event causes other key events via IME or something.
|
||||
bool mCausedOtherKeyEvents;
|
||||
|
||||
KeyEventState() : mKeyEvent(nsnull)
|
||||
{
|
||||
|
@ -502,6 +504,7 @@ protected:
|
|||
mKeyDownHandled = aOther.mKeyDownHandled;
|
||||
mKeyPressDispatched = aOther.mKeyPressDispatched;
|
||||
mKeyPressHandled = aOther.mKeyPressHandled;
|
||||
mCausedOtherKeyEvents = aOther.mCausedOtherKeyEvents;
|
||||
}
|
||||
|
||||
~KeyEventState()
|
||||
|
@ -525,6 +528,7 @@ protected:
|
|||
mKeyDownHandled = false;
|
||||
mKeyPressDispatched = false;
|
||||
mKeyPressHandled = false;
|
||||
mCausedOtherKeyEvents = false;
|
||||
}
|
||||
|
||||
bool KeyDownOrPressHandled()
|
||||
|
@ -570,8 +574,15 @@ protected:
|
|||
*/
|
||||
KeyEventState* PushKeyEvent(NSEvent* aNativeKeyEvent)
|
||||
{
|
||||
PRUint32 nestCount = mCurrentKeyEvents.Length();
|
||||
for (PRUint32 i = 0; i < nestCount; i++) {
|
||||
// When the key event is caused by another key event, all key events
|
||||
// which are being handled should be marked as "consumed".
|
||||
mCurrentKeyEvents[i]->mCausedOtherKeyEvents = true;
|
||||
}
|
||||
|
||||
KeyEventState* keyEvent = nsnull;
|
||||
if (mCurrentKeyEvents.Length() == 0) {
|
||||
if (nestCount == 0) {
|
||||
mFirstKeyEvent.Set(aNativeKeyEvent);
|
||||
keyEvent = &mFirstKeyEvent;
|
||||
} else {
|
||||
|
|
|
@ -1124,7 +1124,8 @@ TextInputHandler::HandleKeyDownEvent(NSEvent* aNativeEvent)
|
|||
// our default action for this key.
|
||||
if (!(interpretKeyEventsCalled &&
|
||||
IsNormalCharInputtingEvent(keypressEvent))) {
|
||||
if (currentKeyEvent->mKeyDownHandled) {
|
||||
if (currentKeyEvent->mKeyDownHandled ||
|
||||
currentKeyEvent->mCausedOtherKeyEvents) {
|
||||
keypressEvent.flags |= NS_EVENT_FLAG_NO_DEFAULT;
|
||||
}
|
||||
currentKeyEvent->mKeyPressHandled = DispatchEvent(keypressEvent);
|
||||
|
@ -1419,12 +1420,16 @@ TextInputHandler::DoCommandBySelector(const char* aSelector)
|
|||
|
||||
PR_LOG(gLog, PR_LOG_ALWAYS,
|
||||
("%p TextInputHandler::DoCommandBySelector, aSelector=\"%s\", "
|
||||
"Destroyed()=%s, keypressHandled=%s",
|
||||
"Destroyed()=%s, keypressHandled=%s, causedOtherKeyEvents=%s",
|
||||
this, aSelector ? aSelector : "", TrueOrFalse(Destroyed()),
|
||||
currentKeyEvent ?
|
||||
TrueOrFalse(currentKeyEvent->mKeyPressHandled) : "N/A"));
|
||||
TrueOrFalse(currentKeyEvent->mKeyPressHandled) : "N/A",
|
||||
currentKeyEvent ?
|
||||
TrueOrFalse(currentKeyEvent->mCausedOtherKeyEvents) : "N/A"));
|
||||
|
||||
return !Destroyed() && currentKeyEvent && currentKeyEvent->mKeyPressHandled;
|
||||
return !Destroyed() && currentKeyEvent &&
|
||||
(currentKeyEvent->mKeyPressHandled ||
|
||||
currentKeyEvent->mCausedOtherKeyEvents);
|
||||
}
|
||||
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче