Bug 1103836, Patch 1: No 'mozbrowserafterkeydown' event is dispatched after preventing the default actions of 'keydown' event, r=smaug.

This commit is contained in:
Gina Yeh 2014-11-26 17:28:52 +08:00
parent 7ca0b31e65
commit 3bfe06797a

View File

@ -7197,12 +7197,11 @@ PresShell::HandleKeyboardEvent(nsINode* aTarget,
DispatchBeforeKeyboardEventInternal(chain, aEvent, chainIndex,
defaultPrevented);
// Dispatch after events to partial items.
// Before event is default-prevented. Dispatch after events with
// embeddedCancelled = false to partial items.
if (defaultPrevented) {
*aStatus = nsEventStatus_eConsumeNoDefault;
DispatchAfterKeyboardEventInternal(chain, aEvent,
aEvent.mFlags.mDefaultPrevented, chainIndex);
DispatchAfterKeyboardEventInternal(chain, aEvent, false, chainIndex);
// No need to forward the event to child process.
aEvent.mFlags.mNoCrossProcessBoundaryForwarding = true;
return;
@ -7217,6 +7216,15 @@ PresShell::HandleKeyboardEvent(nsINode* aTarget,
EventDispatcher::Dispatch(aTarget, mPresContext,
&aEvent, nullptr, aStatus, aEventCB);
if (aEvent.mFlags.mDefaultPrevented) {
// When embedder prevents the default action of actual key event, attribute
// 'embeddedCancelled' of after event is false, i.e. |!targetIsIframe|.
// On the contrary, if the defult action is prevented by embedded iframe,
// 'embeddedCancelled' is true which equals to |!targetIsIframe|.
DispatchAfterKeyboardEventInternal(chain, aEvent, !targetIsIframe, chainIndex);
return;
}
// Event listeners may kill nsPresContext and nsPresShell.
if (targetIsIframe || !CanDispatchEvent()) {
return;