diff --git a/docshell/base/nsDocShell.cpp b/docshell/base/nsDocShell.cpp index 6b813af8d3b9..5129c3e9e7f0 100644 --- a/docshell/base/nsDocShell.cpp +++ b/docshell/base/nsDocShell.cpp @@ -96,6 +96,7 @@ #include "nsSHistory.h" #include "nsDocShellEditorData.h" #include "GeckoProfiler.h" +#include "timeline/JavascriptTimelineMarker.h" // Helper Classes #include "nsError.h" @@ -13763,50 +13764,6 @@ nsDocShell::GetOpener() return opener; } -class JavascriptTimelineMarker : public TimelineMarker -{ -public: - explicit JavascriptTimelineMarker(const char* aName, - const char* aReason, - const char16_t* aFunctionName, - const char16_t* aFileName, - uint32_t aLineNumber) - : TimelineMarker(aName, NS_ConvertUTF8toUTF16(aReason), - TRACING_INTERVAL_START, NO_STACK) - , mFunctionName(aFunctionName) - , mFileName(aFileName) - , mLineNumber(aLineNumber) - { - } - - void AddDetails(JSContext* aCx, mozilla::dom::ProfileTimelineMarker& aMarker) - override - { - aMarker.mCauseName.Construct(GetCause()); - - if (!mFunctionName.IsEmpty() || !mFileName.IsEmpty()) { - RootedDictionary stackFrame(aCx); - stackFrame.mLine.Construct(mLineNumber); - stackFrame.mSource.Construct(mFileName); - stackFrame.mFunctionDisplayName.Construct(mFunctionName); - - JS::Rooted newStack(aCx); - if (ToJSValue(aCx, stackFrame, &newStack)) { - if (newStack.isObject()) { - aMarker.mStack = &newStack.toObject(); - } - } else { - JS_ClearPendingException(aCx); - } - } - } - -private: - nsString mFunctionName; - nsString mFileName; - uint32_t mLineNumber; -}; - void nsDocShell::NotifyJSRunToCompletionStart(const char* aReason, const char16_t* aFunctionName, @@ -13817,10 +13774,8 @@ nsDocShell::NotifyJSRunToCompletionStart(const char* aReason, // If first start, mark interval start. if (timelineOn && mJSRunToCompletionDepth == 0) { - mozilla::UniquePtr marker = - MakeUnique("Javascript", aReason, - aFunctionName, aFilename, - aLineNumber); + UniquePtr marker = MakeUnique( + aReason, aFunctionName, aFilename, aLineNumber, TRACING_INTERVAL_START); TimelineConsumers::AddMarkerForDocShell(this, Move(marker)); } mJSRunToCompletionDepth++; diff --git a/docshell/base/nsDocShell.h b/docshell/base/nsDocShell.h index d5f048b061eb..df7a07512478 100644 --- a/docshell/base/nsDocShell.h +++ b/docshell/base/nsDocShell.h @@ -33,9 +33,9 @@ #include "nsAutoPtr.h" #include "nsThreadUtils.h" #include "nsContentUtils.h" -#include "timeline/TimelineMarker.h" -#include "timeline/TimelineConsumers.h" #include "timeline/ObservedDocShell.h" +#include "timeline/TimelineConsumers.h" +#include "timeline/TimelineMarker.h" // Threshold value in ms for META refresh based redirects #define REFRESH_REDIRECT_TIMER 15000 diff --git a/docshell/base/timeline/AutoGlobalTimelineMarker.h b/docshell/base/timeline/AutoGlobalTimelineMarker.h index 3f76b3dcb645..de6ea15c0f5f 100644 --- a/docshell/base/timeline/AutoGlobalTimelineMarker.h +++ b/docshell/base/timeline/AutoGlobalTimelineMarker.h @@ -19,7 +19,7 @@ namespace mozilla { // Similar to `AutoTimelineMarker`, but adds its traced marker to all docshells, // not a single particular one. This is useful for operations that aren't // associated with any one particular doc shell, or when it isn't clear which -// doc shell triggered the operation. +// docshell triggered the operation. // // Example usage: // diff --git a/docshell/base/timeline/ConsoleTimelineMarker.h b/docshell/base/timeline/ConsoleTimelineMarker.h new file mode 100644 index 000000000000..f74929ab3682 --- /dev/null +++ b/docshell/base/timeline/ConsoleTimelineMarker.h @@ -0,0 +1,50 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef mozilla_ConsoleTimelineMarker_h_ +#define mozilla_ConsoleTimelineMarker_h_ + +#include "TimelineMarker.h" +#include "mozilla/dom/ProfileTimelineMarkerBinding.h" + +namespace mozilla { + +class ConsoleTimelineMarker : public TimelineMarker +{ +public: + explicit ConsoleTimelineMarker(const nsAString& aCause, + TracingMetadata aMetaData) + : TimelineMarker("ConsoleTime", aCause, aMetaData) + { + // Stack is captured by default on the "start" marker. Explicitly also + // capture stack on the "end" marker. + if (aMetaData == TRACING_INTERVAL_END) { + CaptureStack(); + } + } + + virtual bool Equals(const TimelineMarker& aOther) override + { + if (!TimelineMarker::Equals(aOther)) { + return false; + } + // Console markers must have matching causes as well. + return GetCause() == aOther.GetCause(); + } + + virtual void AddDetails(JSContext* aCx, dom::ProfileTimelineMarker& aMarker) override + { + if (GetMetaData() == TRACING_INTERVAL_START) { + aMarker.mCauseName.Construct(GetCause()); + } else { + aMarker.mEndStack = GetStack(); + } + } +}; + +} // namespace mozilla + +#endif // mozilla_ConsoleTimelineMarker_h_ diff --git a/docshell/base/timeline/EventTimelineMarker.h b/docshell/base/timeline/EventTimelineMarker.h new file mode 100644 index 000000000000..6bfd7c04a2c8 --- /dev/null +++ b/docshell/base/timeline/EventTimelineMarker.h @@ -0,0 +1,39 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef mozilla_EventTimelineMarker_h_ +#define mozilla_EventTimelineMarker_h_ + +#include "TimelineMarker.h" +#include "mozilla/dom/ProfileTimelineMarkerBinding.h" + +namespace mozilla { + +class EventTimelineMarker : public TimelineMarker +{ +public: + explicit EventTimelineMarker(const nsAString& aCause, + uint16_t aPhase, + TracingMetadata aMetaData) + : TimelineMarker("DOMEvent", aCause, aMetaData) + , mPhase(aPhase) + {} + + virtual void AddDetails(JSContext* aCx, dom::ProfileTimelineMarker& aMarker) override + { + if (GetMetaData() == TRACING_INTERVAL_START) { + aMarker.mType.Construct(GetCause()); + aMarker.mEventPhase.Construct(mPhase); + } + } + +private: + uint16_t mPhase; +}; + +} // namespace mozilla + +#endif // mozilla_EventTimelineMarker_h_ diff --git a/docshell/base/timeline/JavascriptTimelineMarker.h b/docshell/base/timeline/JavascriptTimelineMarker.h new file mode 100644 index 000000000000..6b1ff4d8242b --- /dev/null +++ b/docshell/base/timeline/JavascriptTimelineMarker.h @@ -0,0 +1,60 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef mozilla_JavascriptTimelineMarker_h_ +#define mozilla_JavascriptTimelineMarker_h_ + +#include "TimelineMarker.h" +#include "mozilla/dom/ProfileTimelineMarkerBinding.h" +#include "mozilla/dom/RootedDictionary.h" +#include "mozilla/dom/ToJSValue.h" + +namespace mozilla { + +class JavascriptTimelineMarker : public TimelineMarker +{ +public: + explicit JavascriptTimelineMarker(const char* aReason, + const char16_t* aFunctionName, + const char16_t* aFileName, + uint32_t aLineNumber, + TracingMetadata aMetaData) + : TimelineMarker("Javascript", NS_ConvertUTF8toUTF16(aReason), aMetaData, NO_STACK) + , mFunctionName(aFunctionName) + , mFileName(aFileName) + , mLineNumber(aLineNumber) + {} + + virtual void AddDetails(JSContext* aCx, dom::ProfileTimelineMarker& aMarker) override + { + aMarker.mCauseName.Construct(GetCause()); + + if (!mFunctionName.IsEmpty() || !mFileName.IsEmpty()) { + dom::RootedDictionary stackFrame(aCx); + stackFrame.mLine.Construct(mLineNumber); + stackFrame.mSource.Construct(mFileName); + stackFrame.mFunctionDisplayName.Construct(mFunctionName); + + JS::Rooted newStack(aCx); + if (ToJSValue(aCx, stackFrame, &newStack)) { + if (newStack.isObject()) { + aMarker.mStack = &newStack.toObject(); + } + } else { + JS_ClearPendingException(aCx); + } + } + } + +private: + nsString mFunctionName; + nsString mFileName; + uint32_t mLineNumber; +}; + +} // namespace mozilla + +#endif // mozilla_JavascriptTimelineMarker_h_ diff --git a/docshell/base/timeline/LayerTimelineMarker.h b/docshell/base/timeline/LayerTimelineMarker.h new file mode 100644 index 000000000000..bfa9c02aeb0c --- /dev/null +++ b/docshell/base/timeline/LayerTimelineMarker.h @@ -0,0 +1,45 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef mozilla_LayerTimelineMarker_h_ +#define mozilla_LayerTimelineMarker_h_ + +#include "TimelineMarker.h" +#include "mozilla/dom/ProfileTimelineMarkerBinding.h" + +namespace mozilla { + +class LayerTimelineMarker : public TimelineMarker +{ +public: + explicit LayerTimelineMarker(const nsIntRegion& aRegion) + : TimelineMarker("Layer", TRACING_EVENT) + , mRegion(aRegion) + {} + + ~LayerTimelineMarker() + {} + + void AddLayerRectangles(dom::Sequence& aRectangles) + { + nsIntRegionRectIterator it(mRegion); + while (const nsIntRect* iterRect = it.Next()) { + dom::ProfileTimelineLayerRect rect; + rect.mX = iterRect->X(); + rect.mY = iterRect->Y(); + rect.mWidth = iterRect->Width(); + rect.mHeight = iterRect->Height(); + aRectangles.AppendElement(rect, fallible); + } + } + +private: + nsIntRegion mRegion; +}; + +} // namespace mozilla + +#endif // mozilla_LayerTimelineMarker_h_ diff --git a/docshell/base/timeline/ObservedDocShell.cpp b/docshell/base/timeline/ObservedDocShell.cpp index 03abe410447a..92c0a6851a24 100644 --- a/docshell/base/timeline/ObservedDocShell.cpp +++ b/docshell/base/timeline/ObservedDocShell.cpp @@ -7,6 +7,7 @@ #include "ObservedDocShell.h" #include "TimelineMarker.h" +#include "LayerTimelineMarker.h" #include "mozilla/Move.h" namespace mozilla { @@ -80,8 +81,9 @@ ObservedDocShell::PopMarkers(JSContext* aCx, // Look for "Layer" markers to stream out "Paint" markers. if (startIsPaintType && endIsLayerType) { + LayerTimelineMarker* layerPayload = static_cast(endPayload.get()); + layerPayload->AddLayerRectangles(layerRectangles); hasSeenLayerType = true; - endPayload->AddLayerRectangles(layerRectangles); } if (!startPayload->Equals(*endPayload)) { continue; diff --git a/docshell/base/timeline/ObservedDocShell.h b/docshell/base/timeline/ObservedDocShell.h index e70ffb67580e..f3b8dcf7ea16 100644 --- a/docshell/base/timeline/ObservedDocShell.h +++ b/docshell/base/timeline/ObservedDocShell.h @@ -11,9 +11,10 @@ #include "mozilla/nsRefPtr.h" class nsDocShell; -class TimelineMarker; namespace mozilla { +class TimelineMarker; + namespace dom { struct ProfileTimelineMarker; } diff --git a/docshell/base/timeline/RestyleTimelineMarker.h b/docshell/base/timeline/RestyleTimelineMarker.h new file mode 100644 index 000000000000..f91a787858e3 --- /dev/null +++ b/docshell/base/timeline/RestyleTimelineMarker.h @@ -0,0 +1,40 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef mozilla_RestyleTimelineMarker_h_ +#define mozilla_RestyleTimelineMarker_h_ + +#include "TimelineMarker.h" +#include "mozilla/dom/ProfileTimelineMarkerBinding.h" + +namespace mozilla { + +class RestyleTimelineMarker : public TimelineMarker +{ +public: + explicit RestyleTimelineMarker(nsRestyleHint aRestyleHint, + TracingMetadata aMetaData) + : TimelineMarker("Styles", aMetaData) + { + if (aRestyleHint) { + mRestyleHint.AssignWithConversion(RestyleManager::RestyleHintToString(aRestyleHint)); + } + } + + virtual void AddDetails(JSContext* aCx, dom::ProfileTimelineMarker& aMarker) override + { + if (GetMetaData() == TRACING_INTERVAL_START) { + aMarker.mRestyleHint.Construct(mRestyleHint); + } + } + +private: + nsAutoString mRestyleHint; +}; + +} // namespace mozilla + +#endif // mozilla_RestyleTimelineMarker_h_ diff --git a/docshell/base/timeline/TimelineConsumers.h b/docshell/base/timeline/TimelineConsumers.h index 263df46b13ac..b6258fea55c8 100644 --- a/docshell/base/timeline/TimelineConsumers.h +++ b/docshell/base/timeline/TimelineConsumers.h @@ -14,10 +14,10 @@ class nsDocShell; class nsIDocShell; -class TimelineMarker; namespace mozilla { class ObservedDocShell; +class TimelineMarker; class TimelineConsumers { diff --git a/docshell/base/timeline/TimelineMarker.cpp b/docshell/base/timeline/TimelineMarker.cpp index f822be314367..4c4b2cfe1306 100644 --- a/docshell/base/timeline/TimelineMarker.cpp +++ b/docshell/base/timeline/TimelineMarker.cpp @@ -6,7 +6,7 @@ #include "TimelineMarker.h" -using mozilla::TimeStamp; +namespace mozilla { TimelineMarker::TimelineMarker(const char* aName, TracingMetadata aMetaData, @@ -95,3 +95,5 @@ TimelineMarker::CaptureStackIfNecessary(TracingMetadata aMetaData, CaptureStack(); } } + +} // namespace mozilla diff --git a/docshell/base/timeline/TimelineMarker.h b/docshell/base/timeline/TimelineMarker.h index 7a4878940dec..e010f0fb6e06 100644 --- a/docshell/base/timeline/TimelineMarker.h +++ b/docshell/base/timeline/TimelineMarker.h @@ -4,8 +4,8 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#ifndef TimelineMarker_h_ -#define TimelineMarker_h_ +#ifndef mozilla_TimelineMarker_h_ +#define mozilla_TimelineMarker_h_ #include "nsString.h" #include "nsContentUtils.h" @@ -13,6 +13,11 @@ class nsDocShell; +namespace mozilla { +namespace dom { +struct ProfileTimelineMarker; +} + // Objects of this type can be added to the timeline if there is an interested // consumer. The class can also be subclassed to let a given marker creator // provide custom details. @@ -26,7 +31,7 @@ public: TimelineStackRequest aStackRequest = STACK); TimelineMarker(const char* aName, - const mozilla::TimeStamp& aTime, + const TimeStamp& aTime, TracingMetadata aMetaData, TimelineStackRequest aStackRequest = STACK); @@ -37,7 +42,7 @@ public: TimelineMarker(const char* aName, const nsAString& aCause, - const mozilla::TimeStamp& aTime, + const TimeStamp& aTime, TracingMetadata aMetaData, TimelineStackRequest aStackRequest = STACK); @@ -54,18 +59,13 @@ public: // have already been set. This method is called on both the starting and // ending markers of a pair. Ordinarily the ending marker doesn't need to do // anything here. - virtual void AddDetails(JSContext* aCx, mozilla::dom::ProfileTimelineMarker& aMarker) + virtual void AddDetails(JSContext* aCx, dom::ProfileTimelineMarker& aMarker) {} - virtual void AddLayerRectangles(mozilla::dom::Sequence&) - { - MOZ_ASSERT_UNREACHABLE("can only be called on layer markers"); - } - const char* GetName() const { return mName; } - TracingMetadata GetMetaData() const { return mMetaData; } - DOMHighResTimeStamp GetTime() const { return mTime; } const nsString& GetCause() const { return mCause; } + DOMHighResTimeStamp GetTime() const { return mTime; } + TracingMetadata GetMetaData() const { return mMetaData; } JSObject* GetStack() { @@ -102,9 +102,11 @@ private: JS::PersistentRooted mStackTrace; void SetCurrentTime(); - void SetCustomTime(const mozilla::TimeStamp& aTime); + void SetCustomTime(const TimeStamp& aTime); void CaptureStackIfNecessary(TracingMetadata aMetaData, TimelineStackRequest aStackRequest); }; -#endif /* TimelineMarker_h_ */ +} // namespace mozilla + +#endif /* mozilla_TimelineMarker_h_ */ diff --git a/docshell/base/timeline/TimestampTimelineMarker.h b/docshell/base/timeline/TimestampTimelineMarker.h new file mode 100644 index 000000000000..9eaa6ae07ba2 --- /dev/null +++ b/docshell/base/timeline/TimestampTimelineMarker.h @@ -0,0 +1,32 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef mozilla_TimestampTimelineMarker_h_ +#define mozilla_TimestampTimelineMarker_h_ + +#include "TimelineMarker.h" +#include "mozilla/dom/ProfileTimelineMarkerBinding.h" + +namespace mozilla { + +class TimestampTimelineMarker : public TimelineMarker +{ +public: + explicit TimestampTimelineMarker(const nsAString& aCause) + : TimelineMarker("TimeStamp", aCause, TRACING_TIMESTAMP) + {} + + virtual void AddDetails(JSContext* aCx, dom::ProfileTimelineMarker& aMarker) override + { + if (!GetCause().IsEmpty()) { + aMarker.mCauseName.Construct(GetCause()); + } + } +}; + +} // namespace mozilla + +#endif // mozilla_TimestampTimelineMarker_h_ diff --git a/docshell/base/timeline/moz.build b/docshell/base/timeline/moz.build index 0078dbcdf912..2baa96a86ca0 100644 --- a/docshell/base/timeline/moz.build +++ b/docshell/base/timeline/moz.build @@ -7,9 +7,15 @@ EXPORTS.mozilla += [ 'AutoGlobalTimelineMarker.h', 'AutoTimelineMarker.h', + 'ConsoleTimelineMarker.h', + 'EventTimelineMarker.h', + 'JavascriptTimelineMarker.h', + 'LayerTimelineMarker.h', 'ObservedDocShell.h', + 'RestyleTimelineMarker.h', 'TimelineConsumers.h', 'TimelineMarker.h', + 'TimestampTimelineMarker.h', ] UNIFIED_SOURCES += [ diff --git a/dom/base/Console.cpp b/dom/base/Console.cpp index b4a9f8bd556d..6d60fbf487f6 100644 --- a/dom/base/Console.cpp +++ b/dom/base/Console.cpp @@ -26,6 +26,8 @@ #include "nsContentUtils.h" #include "nsDocShell.h" #include "nsProxyRelease.h" +#include "mozilla/ConsoleTimelineMarker.h" +#include "mozilla/TimestampTimelineMarker.h" #include "nsIConsoleAPIStorage.h" #include "nsIDOMWindowUtils.h" @@ -985,55 +987,6 @@ ReifyStack(nsIStackFrame* aStack, nsTArray& aRefiedStack) return NS_OK; } -class ConsoleTimelineMarker : public TimelineMarker -{ -public: - explicit ConsoleTimelineMarker(const nsAString& aCause, - TracingMetadata aMetaData) - : TimelineMarker("ConsoleTime", aCause, aMetaData) - { - if (aMetaData == TRACING_INTERVAL_END) { - CaptureStack(); - } - } - - virtual bool Equals(const TimelineMarker& aOther) override - { - if (!TimelineMarker::Equals(aOther)) { - return false; - } - // Console markers must have matching causes as well. - return GetCause() == aOther.GetCause(); - } - - virtual void AddDetails(JSContext* aCx, - mozilla::dom::ProfileTimelineMarker& aMarker) override - { - if (GetMetaData() == TRACING_INTERVAL_START) { - aMarker.mCauseName.Construct(GetCause()); - } else { - aMarker.mEndStack = GetStack(); - } - } -}; - -class TimestampTimelineMarker : public TimelineMarker -{ -public: - explicit TimestampTimelineMarker(const nsAString& aCause) - : TimelineMarker("TimeStamp", aCause, TRACING_TIMESTAMP) - { - } - - virtual void AddDetails(JSContext* aCx, - mozilla::dom::ProfileTimelineMarker& aMarker) override - { - if (!GetCause().IsEmpty()) { - aMarker.mCauseName.Construct(GetCause()); - } - } -}; - // Queue a call to a console method. See the CALL_DELAY constant. void Console::Method(JSContext* aCx, MethodName aMethodName, @@ -1140,8 +1093,7 @@ Console::Method(JSContext* aCx, MethodName aMethodName, key.init(aCx, jsString); } - mozilla::UniquePtr marker = - MakeUnique(key); + UniquePtr marker = MakeUnique(key); TimelineConsumers::AddMarkerForDocShell(docShell, Move(marker)); } // For `console.time(foo)` and `console.timeEnd(foo)` @@ -1151,9 +1103,9 @@ Console::Method(JSContext* aCx, MethodName aMethodName, if (jsString) { nsAutoJSString key; if (key.init(aCx, jsString)) { - mozilla::UniquePtr marker = - MakeUnique(key, - aMethodName == MethodTime ? TRACING_INTERVAL_START : TRACING_INTERVAL_END); + UniquePtr marker = MakeUnique( + key, aMethodName == MethodTime ? TRACING_INTERVAL_START + : TRACING_INTERVAL_END); TimelineConsumers::AddMarkerForDocShell(docShell, Move(marker)); } } diff --git a/dom/events/EventListenerManager.cpp b/dom/events/EventListenerManager.cpp index 2c5253af882e..7496bd72f8c7 100644 --- a/dom/events/EventListenerManager.cpp +++ b/dom/events/EventListenerManager.cpp @@ -24,6 +24,7 @@ #include "mozilla/dom/Element.h" #include "mozilla/dom/Event.h" #include "mozilla/TimelineConsumers.h" +#include "mozilla/EventTimelineMarker.h" #include "EventListenerService.h" #include "nsCOMArray.h" @@ -1056,29 +1057,6 @@ EventListenerManager::GetDocShellForTarget() return docShell; } -class EventTimelineMarker : public TimelineMarker -{ -public: - explicit EventTimelineMarker(TracingMetadata aMetaData, - uint16_t aPhase, const nsAString& aCause) - : TimelineMarker("DOMEvent", aCause, aMetaData) - , mPhase(aPhase) - { - } - - virtual void AddDetails(JSContext* aCx, - mozilla::dom::ProfileTimelineMarker& aMarker) override - { - if (GetMetaData() == TRACING_INTERVAL_START) { - aMarker.mType.Construct(GetCause()); - aMarker.mEventPhase.Construct(mPhase); - } - } - -private: - uint16_t mPhase; -}; - /** * Causes a check for event listeners and processing by them if they exist. * @param an event listener @@ -1149,9 +1127,8 @@ EventListenerManager::HandleEventInternal(nsPresContext* aPresContext, (*aDOMEvent)->GetType(typeStr); uint16_t phase; (*aDOMEvent)->GetEventPhase(&phase); - mozilla::UniquePtr marker = - MakeUnique(TRACING_INTERVAL_START, - phase, typeStr); + UniquePtr marker = MakeUnique( + typeStr, phase, TRACING_INTERVAL_START); TimelineConsumers::AddMarkerForDocShell(ds, Move(marker)); } } diff --git a/layout/base/FrameLayerBuilder.cpp b/layout/base/FrameLayerBuilder.cpp index f290d203b4fe..2fac0d9a3b22 100644 --- a/layout/base/FrameLayerBuilder.cpp +++ b/layout/base/FrameLayerBuilder.cpp @@ -30,6 +30,7 @@ #include "nsPrintfCString.h" #include "nsRenderingContext.h" #include "nsSVGIntegrationUtils.h" +#include "mozilla/LayerTimelineMarker.h" #include "mozilla/Move.h" #include "mozilla/ReverseIterator.h" @@ -5497,36 +5498,6 @@ static void DrawForcedBackgroundColor(DrawTarget& aDrawTarget, } } -class LayerTimelineMarker : public TimelineMarker -{ -public: - explicit LayerTimelineMarker(const nsIntRegion& aRegion) - : TimelineMarker("Layer", TRACING_EVENT) - , mRegion(aRegion) - { - } - - ~LayerTimelineMarker() - { - } - - virtual void AddLayerRectangles(mozilla::dom::Sequence& aRectangles) override - { - nsIntRegionRectIterator it(mRegion); - while (const nsIntRect* iterRect = it.Next()) { - mozilla::dom::ProfileTimelineLayerRect rect; - rect.mX = iterRect->X(); - rect.mY = iterRect->Y(); - rect.mWidth = iterRect->Width(); - rect.mHeight = iterRect->Height(); - aRectangles.AppendElement(rect, fallible); - } - } - -private: - nsIntRegion mRegion; -}; - /* * A note on residual transforms: * @@ -5687,8 +5658,7 @@ FrameLayerBuilder::DrawPaintedLayer(PaintedLayer* aLayer, bool isRecording; docShell->GetRecordProfileTimelineMarkers(&isRecording); if (isRecording) { - mozilla::UniquePtr marker = - MakeUnique(aRegionToDraw); + UniquePtr marker = MakeUnique(aRegionToDraw); TimelineConsumers::AddMarkerForDocShell(docShell, Move(marker)); } } diff --git a/layout/base/RestyleTracker.cpp b/layout/base/RestyleTracker.cpp index 3d9a18d04122..c78c4addf8a0 100644 --- a/layout/base/RestyleTracker.cpp +++ b/layout/base/RestyleTracker.cpp @@ -18,6 +18,7 @@ #include "RestyleManager.h" #include "RestyleTrackerInlines.h" #include "nsTransitionManager.h" +#include "mozilla/RestyleTimelineMarker.h" namespace mozilla { @@ -97,30 +98,6 @@ struct RestyleCollector { #endif }; -class RestyleTimelineMarker : public TimelineMarker -{ -public: - explicit RestyleTimelineMarker(TracingMetadata aMetaData, - nsRestyleHint aRestyleHint) - : TimelineMarker("Styles", aMetaData) - { - if (aRestyleHint) { - mRestyleHint.AssignWithConversion(RestyleManager::RestyleHintToString(aRestyleHint)); - } - } - - virtual void AddDetails(JSContext* aCx, - mozilla::dom::ProfileTimelineMarker& aMarker) override - { - if (GetMetaData() == TRACING_INTERVAL_START) { - aMarker.mRestyleHint.Construct(mRestyleHint); - } - } - -private: - nsAutoString mRestyleHint; -}; - static PLDHashOperator CollectRestyles(nsISupports* aElement, nsAutoPtr& aData, @@ -357,9 +334,8 @@ RestyleTracker::DoProcessRestyles() } if (isTimelineRecording) { - mozilla::UniquePtr marker = - MakeUnique(TRACING_INTERVAL_START, - data->mRestyleHint); + UniquePtr marker = MakeUnique( + data->mRestyleHint, TRACING_INTERVAL_START); TimelineConsumers::AddMarkerForDocShell(docShell, Move(marker)); } @@ -374,9 +350,8 @@ RestyleTracker::DoProcessRestyles() AddRestyleRootsIfAwaitingRestyle(data->mDescendants); if (isTimelineRecording) { - mozilla::UniquePtr marker = - MakeUnique(TRACING_INTERVAL_END, - data->mRestyleHint); + UniquePtr marker = MakeUnique( + data->mRestyleHint, TRACING_INTERVAL_END); TimelineConsumers::AddMarkerForDocShell(docShell, Move(marker)); } } @@ -420,9 +395,8 @@ RestyleTracker::DoProcessRestyles() } #endif if (isTimelineRecording) { - mozilla::UniquePtr marker = - MakeUnique(TRACING_INTERVAL_START, - currentRestyle->mRestyleHint); + UniquePtr marker = MakeUnique( + currentRestyle->mRestyleHint, TRACING_INTERVAL_START); TimelineConsumers::AddMarkerForDocShell(docShell, Move(marker)); } @@ -432,9 +406,8 @@ RestyleTracker::DoProcessRestyles() currentRestyle->mRestyleHintData); if (isTimelineRecording) { - mozilla::UniquePtr marker = - MakeUnique(TRACING_INTERVAL_END, - currentRestyle->mRestyleHint); + UniquePtr marker = MakeUnique( + currentRestyle->mRestyleHint, TRACING_INTERVAL_END); TimelineConsumers::AddMarkerForDocShell(docShell, Move(marker)); } }