From fb54c66fb26c421df454e2aaf4fa43992e869973 Mon Sep 17 00:00:00 2001 From: "bryner%brianryner.com" Date: Thu, 25 May 2006 21:27:11 +0000 Subject: [PATCH] log the source of a command event if it was retargeted (bug 338591) r=marria git-svn-id: svn://10.0.0.236/trunk@198426 18797224-902f-48f8-a5cc-f745e15eee43 --- .../metrics/src/nsUICommandCollector.cpp | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/mozilla/extensions/metrics/src/nsUICommandCollector.cpp b/mozilla/extensions/metrics/src/nsUICommandCollector.cpp index 87d84a07045..4240738a04f 100644 --- a/mozilla/extensions/metrics/src/nsUICommandCollector.cpp +++ b/mozilla/extensions/metrics/src/nsUICommandCollector.cpp @@ -49,6 +49,9 @@ #include "nsIDOMEventTarget.h" #include "nsIDOMEvent.h" #include "nsIDOMNSEvent.h" +#ifndef MOZILLA_1_8_BRANCH +#include "nsIDOMXULCommandEvent.h" +#endif #include "nsIDOMElement.h" #include "nsIDOMDocument.h" #include "nsIDOMDocumentView.h" @@ -213,10 +216,24 @@ nsUICommandCollector::HandleEvent(nsIDOMEvent* event) return NS_ERROR_UNEXPECTED; } + // Get the source event for the command. This will give us the original + // event in the case where a new event was dispatched due to a command= + // attribute. + nsCOMPtr sourceEvent; +#ifndef MOZILLA_1_8_BRANCH + nsCOMPtr commandEvent = do_QueryInterface(event); + if (commandEvent) { // nsIDOMXULCommandEvent is only in Gecko 1.8.1+ + commandEvent->GetSourceEvent(getter_AddRefs(sourceEvent)); + } +#endif + if (!sourceEvent) { + sourceEvent = event; + } + // Get the Original Target id - this is the target after text node // retargeting. If this id is blank it means the target is anonymous // content. - nsCOMPtr nsEvent = do_QueryInterface(event); + nsCOMPtr nsEvent = do_QueryInterface(sourceEvent); NS_ENSURE_STATE(nsEvent); nsCOMPtr original_target; @@ -235,7 +252,7 @@ nsUICommandCollector::HandleEvent(nsIDOMEvent* event) // In the case of anonymous content, the original target ID will // be blank and the target ID will be set. nsCOMPtr target; - event->GetTarget(getter_AddRefs(target)); + sourceEvent->GetTarget(getter_AddRefs(target)); nsString tar_id;