Bug 1348738 - (Part 3) Add a string-label arg to nsRepeatService::Start and upgrade to InitWithNamedFuncCallback from InitWithFuncCallback. r?dholbert
In the new architecture of Quantum DOM, all runnables need a name label.
So, we add the new string-label arg to Start function, and update all
callers.
MozReview-Commit-ID: G9LXFjtFcQv
--- a/dom/html/HTMLInputElement.cpp
+++ b/dom/html/HTMLInputElement.cpp
@@ -4124,17 +4124,18 @@ HTMLInputElement::SetValueOfRangeForUser
void
HTMLInputElement::StartNumberControlSpinnerSpin()
{
MOZ_ASSERT(!mNumberControlSpinnerIsSpinning);
mNumberControlSpinnerIsSpinning = true;
- nsRepeatService::GetInstance()->Start(HandleNumberControlSpin, this);
+ nsRepeatService::GetInstance()->Start(HandleNumberControlSpin, this,
+ NS_LITERAL_CSTRING("HandleNumberControlSpin"));
// Capture the mouse so that we can tell if the pointer moves from one
// spin button to the other, or to some other element:
nsIPresShell::SetCapturingContent(this, CAPTURE_IGNOREALLOWED);
nsNumberControlFrame* numberControlFrame =
do_QueryFrame(GetPrimaryFrame());
if (numberControlFrame) {
--- a/layout/xul/nsRepeatService.cpp
+++ b/layout/xul/nsRepeatService.cpp
@@ -38,23 +38,27 @@ nsRepeatService::GetInstance()
}
/*static*/ void
nsRepeatService::Shutdown()
{
gRepeatService = nullptr;
}
-void nsRepeatService::Start(Callback aCallback, void* aCallbackData,
- uint32_t aInitialDelay)
+void
+nsRepeatService::Start(Callback aCallback, void* aCallbackData,
+ const nsACString& aCallbackName,
+ uint32_t aInitialDelay)
{
NS_PRECONDITION(aCallback != nullptr, "null ptr");
mCallback = aCallback;
mCallbackData = aCallbackData;
+ mCallbackName = aCallbackName;
+
nsresult rv;
mRepeatTimer = do_CreateInstance("@mozilla.org/timer;1", &rv);
if (NS_SUCCEEDED(rv)) {
InitTimerCallback(aInitialDelay);
}
}
@@ -74,25 +78,25 @@ void nsRepeatService::Stop(Callback aCal
void
nsRepeatService::InitTimerCallback(uint32_t aInitialDelay)
{
if (!mRepeatTimer) {
return;
}
- mRepeatTimer->InitWithFuncCallback([](nsITimer* aTimer, void* aClosure) {
+ mRepeatTimer->InitWithNamedFuncCallback([](nsITimer* aTimer, void* aClosure) {
// Use gRepeatService instead of nsRepeatService::GetInstance() (because
// we don't want nsRepeatService::GetInstance() to re-create a new instance
// for us, if we happen to get invoked after nsRepeatService::Shutdown() has
// nulled out gRepeatService).
nsRepeatService* rs = gRepeatService;
if (!rs) {
return;
}
if (rs->mCallback) {
rs->mCallback(rs->mCallbackData);
}
rs->InitTimerCallback(REPEAT_DELAY);
- }, nullptr, aInitialDelay, nsITimer::TYPE_ONE_SHOT);
+ }, nullptr, aInitialDelay, nsITimer::TYPE_ONE_SHOT, mCallbackName.Data());
}
--- a/layout/xul/nsRepeatService.h
+++ b/layout/xul/nsRepeatService.h
@@ -27,17 +27,21 @@ class nsRepeatService final
public:
typedef void (* Callback)(void* aData);
~nsRepeatService();
// Start dispatching timer events to the callback. There is no memory
// management of aData here; it is the caller's responsibility to call
// Stop() before aData's memory is released.
- void Start(Callback aCallback, void* aData,
+ //
+ // aCallbackName is the label of the callback, used to pass to
+ // InitWithNamedCallbackFunc.
+ void Start(Callback aCallback, void* aCallbackData,
+ const nsACString& aCallbackName,
uint32_t aInitialDelay = INITAL_REPEAT_DELAY);
// Stop dispatching timer events to the callback. If the repeat service
// is not currently configured with the given callback and data, this
// is just ignored.
void Stop(Callback aCallback, void* aData);
static nsRepeatService* GetInstance();
static void Shutdown();
@@ -46,13 +50,14 @@ protected:
nsRepeatService();
private:
// helper function to initialize callback function to mRepeatTimer
void InitTimerCallback(uint32_t aInitialDelay);
Callback mCallback;
void* mCallbackData;
+ nsCString mCallbackName;
nsCOMPtr<nsITimer> mRepeatTimer;
}; // class nsRepeatService
#endif
--- a/layout/xul/nsScrollBoxFrame.cpp
+++ b/layout/xul/nsScrollBoxFrame.cpp
@@ -42,19 +42,22 @@ public:
protected:
explicit nsAutoRepeatBoxFrame(nsStyleContext* aContext):
nsButtonBoxFrame(aContext) {}
void StartRepeat() {
if (IsActivatedOnHover()) {
// No initial delay on hover.
- nsRepeatService::GetInstance()->Start(Notify, this, 0);
+ nsRepeatService::GetInstance()->Start(Notify, this,
+ NS_LITERAL_CSTRING("DoMouseClick"),
+ 0);
} else {
- nsRepeatService::GetInstance()->Start(Notify, this);
+ nsRepeatService::GetInstance()->Start(Notify, this,
+ NS_LITERAL_CSTRING("DoMouseClick"));
}
}
void StopRepeat() {
nsRepeatService::GetInstance()->Stop(Notify, this);
}
void Notify();
static void Notify(void* aData) {
static_cast<nsAutoRepeatBoxFrame*>(aData)->Notify();
--- a/layout/xul/nsScrollbarButtonFrame.h
+++ b/layout/xul/nsScrollbarButtonFrame.h
@@ -60,17 +60,18 @@ public:
NS_IMETHOD HandleRelease(nsPresContext* aPresContext,
mozilla::WidgetGUIEvent* aEvent,
nsEventStatus* aEventStatus) override;
protected:
virtual void MouseClicked(mozilla::WidgetGUIEvent* aEvent) override;
void StartRepeat() {
- nsRepeatService::GetInstance()->Start(Notify, this);
+ nsRepeatService::GetInstance()->Start(Notify, this,
+ NS_LITERAL_CSTRING("nsScrollbarButtonFrame"));
}
void StopRepeat() {
nsRepeatService::GetInstance()->Stop(Notify, this);
}
void Notify();
static void Notify(void* aData) {
static_cast<nsScrollbarButtonFrame*>(aData)->Notify();
}
--- a/layout/xul/nsSliderFrame.h
+++ b/layout/xul/nsSliderFrame.h
@@ -162,17 +162,18 @@ private:
void AddListener();
void RemoveListener();
bool isDraggingThumb();
void SuppressDisplayport();
void UnsuppressDisplayport();
void StartRepeat() {
- nsRepeatService::GetInstance()->Start(Notify, this);
+ nsRepeatService::GetInstance()->Start(Notify, this,
+ NS_LITERAL_CSTRING("nsSliderFrame"));
}
void StopRepeat() {
nsRepeatService::GetInstance()->Stop(Notify, this);
}
void Notify();
static void Notify(void* aData) {
(static_cast<nsSliderFrame*>(aData))->Notify();
}