зеркало из https://github.com/mozilla/pjs.git
log the source of a command event if it was retargeted (bug 338591) r=marria
This commit is contained in:
Родитель
9f5aa9ca7d
Коммит
0a24e504f5
|
@ -49,6 +49,9 @@
|
||||||
#include "nsIDOMEventTarget.h"
|
#include "nsIDOMEventTarget.h"
|
||||||
#include "nsIDOMEvent.h"
|
#include "nsIDOMEvent.h"
|
||||||
#include "nsIDOMNSEvent.h"
|
#include "nsIDOMNSEvent.h"
|
||||||
|
#ifndef MOZILLA_1_8_BRANCH
|
||||||
|
#include "nsIDOMXULCommandEvent.h"
|
||||||
|
#endif
|
||||||
#include "nsIDOMElement.h"
|
#include "nsIDOMElement.h"
|
||||||
#include "nsIDOMDocument.h"
|
#include "nsIDOMDocument.h"
|
||||||
#include "nsIDOMDocumentView.h"
|
#include "nsIDOMDocumentView.h"
|
||||||
|
@ -213,10 +216,24 @@ nsUICommandCollector::HandleEvent(nsIDOMEvent* event)
|
||||||
return NS_ERROR_UNEXPECTED;
|
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<nsIDOMEvent> sourceEvent;
|
||||||
|
#ifndef MOZILLA_1_8_BRANCH
|
||||||
|
nsCOMPtr<nsIDOMXULCommandEvent> 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
|
// Get the Original Target id - this is the target after text node
|
||||||
// retargeting. If this id is blank it means the target is anonymous
|
// retargeting. If this id is blank it means the target is anonymous
|
||||||
// content.
|
// content.
|
||||||
nsCOMPtr<nsIDOMNSEvent> nsEvent = do_QueryInterface(event);
|
nsCOMPtr<nsIDOMNSEvent> nsEvent = do_QueryInterface(sourceEvent);
|
||||||
NS_ENSURE_STATE(nsEvent);
|
NS_ENSURE_STATE(nsEvent);
|
||||||
|
|
||||||
nsCOMPtr<nsIDOMEventTarget> original_target;
|
nsCOMPtr<nsIDOMEventTarget> original_target;
|
||||||
|
@ -235,7 +252,7 @@ nsUICommandCollector::HandleEvent(nsIDOMEvent* event)
|
||||||
// In the case of anonymous content, the original target ID will
|
// In the case of anonymous content, the original target ID will
|
||||||
// be blank and the target ID will be set.
|
// be blank and the target ID will be set.
|
||||||
nsCOMPtr<nsIDOMEventTarget> target;
|
nsCOMPtr<nsIDOMEventTarget> target;
|
||||||
event->GetTarget(getter_AddRefs(target));
|
sourceEvent->GetTarget(getter_AddRefs(target));
|
||||||
|
|
||||||
nsString tar_id;
|
nsString tar_id;
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче