Bug 1342874 - (Part 7) DocGroup labeling for timer callbacks in nsTreeBodyFrame. r?dholbert
MozReview-Commit-ID: L8IHAGDAC5Q
--- a/layout/xul/tree/nsTreeBodyFrame.cpp
+++ b/layout/xul/tree/nsTreeBodyFrame.cpp
@@ -1791,29 +1791,32 @@ nsTreeBodyFrame::MarkDirtyIfSelect()
nsIPresShell::eTreeChange,
NS_FRAME_IS_DIRTY);
}
}
nsresult
nsTreeBodyFrame::CreateTimer(const LookAndFeel::IntID aID,
nsTimerCallbackFunc aFunc, int32_t aType,
- nsITimer** aTimer)
+ nsITimer** aTimer, const char* aName)
{
// Get the delay from the look and feel service.
int32_t delay = LookAndFeel::GetInt(aID, 0);
nsCOMPtr<nsITimer> timer;
// Create a new timer only if the delay is greater than zero.
// Zero value means that this feature is completely disabled.
if (delay > 0) {
timer = do_CreateInstance("@mozilla.org/timer;1");
- if (timer)
- timer->InitWithFuncCallback(aFunc, this, delay, aType);
+ if (timer) {
+ timer->SetTarget(
+ mContent->OwnerDoc()->EventTargetFor(TaskCategory::Other));
+ timer->InitWithNamedFuncCallback(aFunc, this, delay, aType, aName);
+ }
}
NS_IF_ADDREF(*aTimer = timer);
return NS_OK;
}
nsresult
@@ -2637,17 +2640,18 @@ nsTreeBodyFrame::HandleEvent(nsPresConte
if (mSlots->mTimer) {
mSlots->mTimer->Cancel();
mSlots->mTimer = nullptr;
}
// Set a timer to trigger the tree scrolling.
CreateTimer(LookAndFeel::eIntID_TreeLazyScrollDelay,
LazyScrollCallback, nsITimer::TYPE_ONE_SHOT,
- getter_AddRefs(mSlots->mTimer));
+ getter_AddRefs(mSlots->mTimer),
+ "nsTreeBodyFrame::LazyScrollCallback");
}
#endif
// Bail out to prevent spring loaded timer and feedback line settings.
return NS_OK;
}
// If changed from last time, invalidate primary cell at the old location and if allowed,
// invalidate primary cell at the new location. If nothing changed, just bail.
@@ -2675,17 +2679,18 @@ nsTreeBodyFrame::HandleEvent(nsPresConte
mView->IsContainer(mSlots->mDropRow, &isContainer);
if (isContainer) {
bool isOpen = false;
mView->IsContainerOpen(mSlots->mDropRow, &isOpen);
if (!isOpen) {
// This node isn't expanded, set a timer to expand it.
CreateTimer(LookAndFeel::eIntID_TreeOpenDelay,
OpenCallback, nsITimer::TYPE_ONE_SHOT,
- getter_AddRefs(mSlots->mTimer));
+ getter_AddRefs(mSlots->mTimer),
+ "nsTreeBodyFrame::OpenCallback");
}
}
}
// The dataTransfer was initialized by the call to GetDropEffect above.
bool canDropAtNewLocation = false;
mView->CanDrop(mSlots->mDropRow, mSlots->mDropOrient,
aEvent->AsDragEvent()->mDataTransfer,
@@ -2749,17 +2754,18 @@ nsTreeBodyFrame::HandleEvent(nsPresConte
mSlots->mTimer->Cancel();
mSlots->mTimer = nullptr;
}
if (!mSlots->mArray.IsEmpty()) {
// Close all spring loaded folders except the drop folder.
CreateTimer(LookAndFeel::eIntID_TreeCloseDelay,
CloseCallback, nsITimer::TYPE_ONE_SHOT,
- getter_AddRefs(mSlots->mTimer));
+ getter_AddRefs(mSlots->mTimer),
+ "nsTreeBodyFrame::CloseCallback");
}
}
return NS_OK;
}
class nsDisplayTreeBody final : public nsDisplayItem {
public:
@@ -4686,17 +4692,18 @@ nsTreeBodyFrame::LazyScrollCallback(nsIT
if (self) {
aTimer->Cancel();
self->mSlots->mTimer = nullptr;
if (self->mView) {
// Set a new timer to scroll the tree repeatedly.
self->CreateTimer(LookAndFeel::eIntID_TreeScrollDelay,
ScrollCallback, nsITimer::TYPE_REPEATING_SLACK,
- getter_AddRefs(self->mSlots->mTimer));
+ getter_AddRefs(self->mSlots->mTimer),
+ "nsTreeBodyFrame::ScrollCallback");
self->ScrollByLines(self->mSlots->mScrollLines);
// ScrollByLines may have deleted |self|.
}
}
}
void
nsTreeBodyFrame::ScrollCallback(nsITimer *aTimer, void *aClosure)
--- a/layout/xul/tree/nsTreeBodyFrame.h
+++ b/layout/xul/tree/nsTreeBodyFrame.h
@@ -457,17 +457,17 @@ public:
protected:
// Create a new timer. This method is used to delay various actions like
// opening/closing folders or tree scrolling.
// aID is type of the action, aFunc is the function to be called when
// the timer fires and aType is type of timer - one shot or repeating.
nsresult CreateTimer(const mozilla::LookAndFeel::IntID aID,
nsTimerCallbackFunc aFunc, int32_t aType,
- nsITimer** aTimer);
+ nsITimer** aTimer, const char* aName);
static void OpenCallback(nsITimer *aTimer, void *aClosure);
static void CloseCallback(nsITimer *aTimer, void *aClosure);
static void LazyScrollCallback(nsITimer *aTimer, void *aClosure);
static void ScrollCallback(nsITimer *aTimer, void *aClosure);