зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1324941 - Add a profiler label and a profiler marker for DOMEvent dispatch. r=smaug
MozReview-Commit-ID: 9nyftWPKRVe --HG-- extra : rebase_source : 0ef900fa5c7749dd5bcec32da6b37aad91f0a518
This commit is contained in:
Родитель
f452728256
Коммит
2319d2881d
|
@ -29,8 +29,11 @@
|
|||
#include "mozilla/dom/TouchEvent.h"
|
||||
#include "mozilla/TimelineConsumers.h"
|
||||
#include "mozilla/EventTimelineMarker.h"
|
||||
#include "mozilla/TimeStamp.h"
|
||||
|
||||
#include "EventListenerService.h"
|
||||
#include "GeckoProfiler.h"
|
||||
#include "ProfilerMarkers.h"
|
||||
#include "nsCOMArray.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsContentUtils.h"
|
||||
|
@ -1281,7 +1284,35 @@ EventListenerManager::HandleEventInternal(nsPresContext* aPresContext,
|
|||
listener = listenerHolder.ptr();
|
||||
hasRemovedListener = true;
|
||||
}
|
||||
if (NS_FAILED(HandleEventSubType(listener, *aDOMEvent, aCurrentTarget))) {
|
||||
|
||||
nsresult rv = NS_OK;
|
||||
if (profiler_is_active()) {
|
||||
// Add a profiler label and a profiler marker for the actual
|
||||
// dispatch of the event.
|
||||
// This is a very hot code path, so we need to make sure not to
|
||||
// do this extra work when we're not profiling.
|
||||
nsAutoString typeStr;
|
||||
(*aDOMEvent)->GetType(typeStr);
|
||||
PROFILER_LABEL_PRINTF("EventListenerManager", "HandleEventInternal",
|
||||
js::ProfileEntry::Category::EVENTS,
|
||||
"%s",
|
||||
NS_LossyConvertUTF16toASCII(typeStr).get());
|
||||
TimeStamp startTime = TimeStamp::Now();
|
||||
|
||||
rv = HandleEventSubType(listener, *aDOMEvent, aCurrentTarget);
|
||||
|
||||
TimeStamp endTime = TimeStamp::Now();
|
||||
uint16_t phase;
|
||||
(*aDOMEvent)->GetEventPhase(&phase);
|
||||
PROFILER_MARKER_PAYLOAD("DOMEvent",
|
||||
new DOMEventMarkerPayload(typeStr, phase,
|
||||
startTime,
|
||||
endTime));
|
||||
} else {
|
||||
rv = HandleEventSubType(listener, *aDOMEvent, aCurrentTarget);
|
||||
}
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
aEvent->mFlags.mExceptionWasRaised = true;
|
||||
}
|
||||
aEvent->mFlags.mInPassiveListener = false;
|
||||
|
|
|
@ -154,6 +154,27 @@ IOMarkerPayload::StreamPayload(SpliceableJSONWriter& aWriter, UniqueStacks& aUni
|
|||
}
|
||||
}
|
||||
|
||||
DOMEventMarkerPayload::DOMEventMarkerPayload(const nsAString& aType, uint16_t aPhase,
|
||||
const mozilla::TimeStamp& aStartTime,
|
||||
const mozilla::TimeStamp& aEndTime)
|
||||
: ProfilerMarkerPayload(aStartTime, aEndTime, nullptr)
|
||||
, mType(aType)
|
||||
, mPhase(aPhase)
|
||||
{
|
||||
}
|
||||
|
||||
DOMEventMarkerPayload::~DOMEventMarkerPayload()
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
DOMEventMarkerPayload::StreamPayload(SpliceableJSONWriter& aWriter, UniqueStacks& aUniqueStacks)
|
||||
{
|
||||
streamCommonProps("DOMEvent", aWriter, aUniqueStacks);
|
||||
aWriter.StringProperty("type", NS_ConvertUTF16toUTF8(mType).get());
|
||||
aWriter.IntProperty("phase", mPhase);
|
||||
}
|
||||
|
||||
void
|
||||
ProfilerJSEventMarker(const char *event)
|
||||
{
|
||||
|
|
|
@ -117,6 +117,22 @@ private:
|
|||
char* mFilename;
|
||||
};
|
||||
|
||||
class DOMEventMarkerPayload : public ProfilerMarkerPayload
|
||||
{
|
||||
public:
|
||||
DOMEventMarkerPayload(const nsAString& aType, uint16_t aPhase,
|
||||
const mozilla::TimeStamp& aStartTime,
|
||||
const mozilla::TimeStamp& aEndTime);
|
||||
~DOMEventMarkerPayload();
|
||||
|
||||
virtual void StreamPayload(SpliceableJSONWriter& aWriter,
|
||||
UniqueStacks& aUniqueStacks) override;
|
||||
|
||||
private:
|
||||
nsString mType;
|
||||
uint16_t mPhase;
|
||||
};
|
||||
|
||||
/**
|
||||
* Contains the translation applied to a 2d layer so we can
|
||||
* track the layer position at each frame.
|
||||
|
|
Загрузка…
Ссылка в новой задаче