Bug 1129066 - Ensure the click event is always dispatched to an element node. r=smaug

This commit is contained in:
Kartikaya Gupta 2015-02-04 22:48:45 -05:00
parent 43c6f6331a
commit 164ea2c10c

View File

@ -4434,6 +4434,14 @@ EventStateManager::CheckForAndDispatchClick(nsPresContext* aPresContext,
nsCOMPtr<nsIPresShell> presShell = mPresContext->GetPresShell();
if (presShell) {
nsCOMPtr<nsIContent> mouseContent = GetEventTargetContent(aEvent);
// Click events apply to *elements* not nodes. At this point the target
// content may have been reset to some non-element content, and so we need
// to walk up the closest ancestor element, just like we do in
// nsPresShell::HandlePositionedEvent.
while (mouseContent && !mouseContent->IsElement()) {
mouseContent = mouseContent->GetParent();
}
if (!mouseContent && !mCurrentTarget) {
return NS_OK;
}