зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1323076 - Part 2: EventDispatcher with flag checking for TaskTracer. r=smaug
This commit is contained in:
Родитель
885084ba60
Коммит
84c4fd2c69
|
@ -245,24 +245,11 @@ Event::WrapObjectInternal(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
|
|||
NS_IMETHODIMP
|
||||
Event::GetType(nsAString& aType)
|
||||
{
|
||||
if (!mIsMainThreadEvent || !mEvent->mSpecifiedEventTypeString.IsEmpty()) {
|
||||
if (!mIsMainThreadEvent) {
|
||||
aType = mEvent->mSpecifiedEventTypeString;
|
||||
return NS_OK;
|
||||
}
|
||||
const char* name = GetEventName(mEvent->mMessage);
|
||||
|
||||
if (name) {
|
||||
CopyASCIItoUTF16(name, aType);
|
||||
return NS_OK;
|
||||
} else if (mEvent->mMessage == eUnidentifiedEvent &&
|
||||
mEvent->mSpecifiedEventType) {
|
||||
// Remove "on"
|
||||
aType = Substring(nsDependentAtomString(mEvent->mSpecifiedEventType), 2);
|
||||
mEvent->mSpecifiedEventTypeString = aType;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
aType.Truncate();
|
||||
GetWidgetEventType(mEvent, aType);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -1291,6 +1278,30 @@ Event::GetShadowRelatedTarget(nsIContent* aCurrentTarget,
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
void
|
||||
Event::GetWidgetEventType(WidgetEvent* aEvent, nsAString& aType)
|
||||
{
|
||||
if (!aEvent->mSpecifiedEventTypeString.IsEmpty()) {
|
||||
aType = aEvent->mSpecifiedEventTypeString;
|
||||
return;
|
||||
}
|
||||
|
||||
const char* name = GetEventName(aEvent->mMessage);
|
||||
|
||||
if (name) {
|
||||
CopyASCIItoUTF16(name, aType);
|
||||
return;
|
||||
} else if (aEvent->mMessage == eUnidentifiedEvent &&
|
||||
aEvent->mSpecifiedEventType) {
|
||||
// Remove "on"
|
||||
aType = Substring(nsDependentAtomString(aEvent->mSpecifiedEventType), 2);
|
||||
aEvent->mSpecifiedEventTypeString = aType;
|
||||
return;
|
||||
}
|
||||
|
||||
aType.Truncate();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
Event::GetCancelBubble(bool* aCancelBubble)
|
||||
{
|
||||
|
|
|
@ -265,6 +265,14 @@ public:
|
|||
mEvent->mSpecifiedEventType = nullptr;
|
||||
}
|
||||
|
||||
/**
|
||||
* For WidgetEvent, return it's type in string.
|
||||
*
|
||||
* @param aEvent is a WidgetEvent to get its type.
|
||||
* @param aType is a string where to return the type.
|
||||
*/
|
||||
static void GetWidgetEventType(WidgetEvent* aEvent, nsAString& aType);
|
||||
|
||||
protected:
|
||||
|
||||
// Internal helper functions
|
||||
|
|
|
@ -64,6 +64,7 @@
|
|||
#ifdef MOZ_TASK_TRACER
|
||||
#include "GeckoTaskTracer.h"
|
||||
#include "mozilla/dom/Element.h"
|
||||
#include "mozilla/Likely.h"
|
||||
using namespace mozilla::tasktracer;
|
||||
#endif
|
||||
|
||||
|
@ -606,23 +607,27 @@ EventDispatcher::Dispatch(nsISupports* aTarget,
|
|||
NS_ERROR_DOM_INVALID_STATE_ERR);
|
||||
|
||||
#ifdef MOZ_TASK_TRACER
|
||||
{
|
||||
if (MOZ_UNLIKELY(mozilla::tasktracer::IsStartLogging())) {
|
||||
nsAutoCString eventType;
|
||||
nsAutoString eventTypeU16;
|
||||
if (aDOMEvent) {
|
||||
nsAutoString eventType;
|
||||
aDOMEvent->GetType(eventType);
|
||||
|
||||
nsCOMPtr<Element> element = do_QueryInterface(aTarget);
|
||||
nsAutoString elementId;
|
||||
nsAutoString elementTagName;
|
||||
if (element) {
|
||||
element->GetId(elementId);
|
||||
element->GetTagName(elementTagName);
|
||||
}
|
||||
AddLabel("Event [%s] dispatched at target [id:%s tag:%s]",
|
||||
NS_ConvertUTF16toUTF8(eventType).get(),
|
||||
NS_ConvertUTF16toUTF8(elementId).get(),
|
||||
NS_ConvertUTF16toUTF8(elementTagName).get());
|
||||
aDOMEvent->GetType(eventTypeU16);
|
||||
} else {
|
||||
Event::GetWidgetEventType(aEvent, eventTypeU16);
|
||||
}
|
||||
eventType = NS_ConvertUTF16toUTF8(eventTypeU16);
|
||||
|
||||
nsCOMPtr<Element> element = do_QueryInterface(aTarget);
|
||||
nsAutoString elementId;
|
||||
nsAutoString elementTagName;
|
||||
if (element) {
|
||||
element->GetId(elementId);
|
||||
element->GetTagName(elementTagName);
|
||||
}
|
||||
AddLabel("Event [%s] dispatched at target [id:%s tag:%s]",
|
||||
eventType.get(),
|
||||
NS_ConvertUTF16toUTF8(elementId).get(),
|
||||
NS_ConvertUTF16toUTF8(elementTagName).get());
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче