Bug 1164338 - Move styles markers to be generated in DoProcessRestyles rather than when the Flush_Style queue is flushed. r=smaug,heycam

This commit is contained in:
Jordan Santell 2015-05-18 16:03:04 -07:00
parent 81516937a7
commit dcc02005ba
5 changed files with 68 additions and 11 deletions

View File

@ -25,4 +25,6 @@ dictionary ProfileTimelineMarker {
unsigned short eventPhase;
/* For Paint markers. */
sequence<ProfileTimelineLayerRect> rectangles;
/* For Style markers. */
DOMString restyleHint;
};

View File

@ -4186,7 +4186,6 @@ RestyleManager::StructsToLog()
}
#endif
#ifdef DEBUG
/* static */ nsCString
RestyleManager::RestyleHintToString(nsRestyleHint aHint)
{
@ -4219,6 +4218,7 @@ RestyleManager::RestyleHintToString(nsRestyleHint aHint)
return result;
}
#ifdef DEBUG
/* static */ nsCString
RestyleManager::ChangeHintToString(nsChangeHint aHint)
{

View File

@ -348,8 +348,9 @@ public:
mOverflowChangedTracker.Flush();
}
#ifdef DEBUG
static nsCString RestyleHintToString(nsRestyleHint aHint);
#ifdef DEBUG
static nsCString ChangeHintToString(nsChangeHint aHint);
#endif

View File

@ -96,6 +96,30 @@ struct RestyleCollector {
#endif
};
class RestyleTimelineMarker : public TimelineMarker
{
public:
RestyleTimelineMarker(nsDocShell* aDocShell,
TracingMetadata aMetaData,
nsRestyleHint aRestyleHint)
: TimelineMarker(aDocShell, "Styles", aMetaData)
{
if (aRestyleHint) {
mRestyleHint.AssignWithConversion(RestyleManager::RestyleHintToString(aRestyleHint));
}
}
virtual void AddDetails(mozilla::dom::ProfileTimelineMarker& aMarker) override
{
if (GetMetaData() == TRACING_INTERVAL_START) {
aMarker.mRestyleHint.Construct(mRestyleHint);
}
}
private:
nsAutoString mRestyleHint;
};
static PLDHashOperator
CollectRestyles(nsISupports* aElement,
nsAutoPtr<RestyleTracker::RestyleData>& aData,
@ -202,6 +226,13 @@ RestyleTracker::DoProcessRestyles()
PROFILER_LABEL("RestyleTracker", "ProcessRestyles",
js::ProfileEntry::Category::CSS);
bool isTimelineRecording = false;
nsDocShell* docShell =
static_cast<nsDocShell*>(mRestyleManager->PresContext()->GetDocShell());
if (docShell) {
docShell->GetRecordProfileTimelineMarkers(&isTimelineRecording);
}
// Create a ReframingStyleContexts struct on the stack and put it in our
// mReframingStyleContexts for almost all of the remaining scope of
// this function.
@ -311,6 +342,14 @@ RestyleTracker::DoProcessRestyles()
continue;
}
if (isTimelineRecording) {
mozilla::UniquePtr<TimelineMarker> marker =
MakeUnique<RestyleTimelineMarker>(docShell,
TRACING_INTERVAL_START,
data->mRestyleHint);
docShell->AddProfileTimelineMarker(Move(marker));
}
#if defined(MOZ_ENABLE_PROFILER_SPS) && !defined(MOZILLA_XPCOMRT_API)
Maybe<GeckoProfilerTracingRAII> profilerRAII;
if (profiler_feature_active("restyle")) {
@ -319,6 +358,14 @@ RestyleTracker::DoProcessRestyles()
#endif
ProcessOneRestyle(element, data->mRestyleHint, data->mChangeHint);
AddRestyleRootsIfAwaitingRestyle(data->mDescendants);
if (isTimelineRecording) {
mozilla::UniquePtr<TimelineMarker> marker =
MakeUnique<RestyleTimelineMarker>(docShell,
TRACING_INTERVAL_END,
data->mRestyleHint);
docShell->AddProfileTimelineMarker(Move(marker));
}
}
if (mHaveLaterSiblingRestyles) {
@ -359,9 +406,25 @@ RestyleTracker::DoProcessRestyles()
profilerRAII.emplace("Paint", "Styles", Move(currentRestyle->mBacktrace));
}
#endif
if (isTimelineRecording) {
mozilla::UniquePtr<TimelineMarker> marker =
MakeUnique<RestyleTimelineMarker>(docShell,
TRACING_INTERVAL_START,
currentRestyle->mRestyleHint);
docShell->AddProfileTimelineMarker(Move(marker));
}
ProcessOneRestyle(currentRestyle->mElement,
currentRestyle->mRestyleHint,
currentRestyle->mChangeHint);
if (isTimelineRecording) {
mozilla::UniquePtr<TimelineMarker> marker =
MakeUnique<RestyleTimelineMarker>(docShell,
TRACING_INTERVAL_END,
currentRestyle->mRestyleHint);
docShell->AddProfileTimelineMarker(Move(marker));
}
}
}
}

View File

@ -1656,11 +1656,6 @@ nsRefreshDriver::Tick(int64_t aNowEpoch, TimeStamp aNowTime)
if (!mStyleFlushObservers.Contains(shell))
continue;
nsRefPtr<nsDocShell> docShell = GetDocShell(shell->GetPresContext());
if (docShell) {
docShell->AddProfileTimelineMarker("Styles", TRACING_INTERVAL_START);
}
if (!tracingStyleFlush) {
tracingStyleFlush = true;
profiler_tracing("Paint", "Styles", mStyleCause, TRACING_INTERVAL_START);
@ -1679,10 +1674,6 @@ nsRefreshDriver::Tick(int64_t aNowEpoch, TimeStamp aNowTime)
presContext->NotifyFontFaceSetOnRefresh();
}
NS_RELEASE(shell);
if (docShell) {
docShell->AddProfileTimelineMarker("Styles", TRACING_INTERVAL_END);
}
}
if (tracingStyleFlush) {