Bug 1238137 - Telemetry pings for main thread scrollbar-driven scroll input methods. r=kats
--- a/layout/xul/nsScrollbarButtonFrame.cpp
+++ b/layout/xul/nsScrollbarButtonFrame.cpp
@@ -17,18 +17,21 @@
#include "nsNameSpaceManager.h"
#include "nsGkAtoms.h"
#include "nsSliderFrame.h"
#include "nsScrollbarFrame.h"
#include "nsIScrollbarMediator.h"
#include "nsRepeatService.h"
#include "mozilla/LookAndFeel.h"
#include "mozilla/MouseEvents.h"
+#include "mozilla/Telemetry.h"
+#include "mozilla/layers/ScrollInputMethods.h"
using namespace mozilla;
+using mozilla::layers::ScrollInputMethod;
//
// NS_NewToolbarFrame
//
// Creates a new Toolbar frame and returns it
//
nsIFrame*
NS_NewScrollbarButtonFrame (nsIPresShell* aPresShell, nsStyleContext* aContext)
@@ -162,16 +165,20 @@ nsScrollbarButtonFrame::HandleButtonPres
default:
// We were told to ignore this click, or someone assigned a non-standard
// value to the button's action.
return false;
}
if (!weakFrame.IsAlive()) {
return false;
}
+
+ mozilla::Telemetry::Accumulate(mozilla::Telemetry::SCROLL_INPUT_METHODS,
+ (uint32_t) ScrollInputMethod::MainThreadScrollbarButtonClick);
+
if (!m) {
sb->MoveToNewPosition();
if (!weakFrame.IsAlive()) {
return false;
}
}
}
if (repeat) {
--- a/layout/xul/nsSliderFrame.cpp
+++ b/layout/xul/nsSliderFrame.cpp
@@ -31,23 +31,26 @@
#include "nsSprocketLayout.h"
#include "nsIServiceManager.h"
#include "nsContentUtils.h"
#include "nsLayoutUtils.h"
#include "nsDisplayList.h"
#include "mozilla/Preferences.h"
#include "mozilla/LookAndFeel.h"
#include "mozilla/MouseEvents.h"
+#include "mozilla/Telemetry.h"
#include "mozilla/layers/AsyncDragMetrics.h"
#include "mozilla/layers/InputAPZContext.h"
+#include "mozilla/layers/ScrollInputMethods.h"
#include <algorithm>
using namespace mozilla;
using mozilla::layers::AsyncDragMetrics;
using mozilla::layers::InputAPZContext;
+using mozilla::layers::ScrollInputMethod;
bool nsSliderFrame::gMiddlePref = false;
int32_t nsSliderFrame::gSnapMultiplier;
// Turn this on if you want to debug slider frames.
#undef DEBUG_SLIDER
static already_AddRefed<nsIContent>
@@ -508,16 +511,19 @@ nsSliderFrame::HandleEvent(nsPresContext
nscoord pos = isHorizontal ? eventPoint.x : eventPoint.y;
nsIFrame* thumbFrame = mFrames.FirstChild();
if (!thumbFrame) {
return NS_OK;
}
+ mozilla::Telemetry::Accumulate(mozilla::Telemetry::SCROLL_INPUT_METHODS,
+ (uint32_t) ScrollInputMethod::MainThreadScrollbarDrag);
+
// take our current position and subtract the start location
pos -= mDragStart;
bool isMouseOutsideThumb = false;
if (gSnapMultiplier) {
nsSize thumbSize = thumbFrame->GetSize();
if (isHorizontal) {
// horizontal scrollbar - check if mouse is above or below thumb
// XXXbz what about looking at the .y of the thumb's rect? Is that
@@ -574,16 +580,19 @@ nsSliderFrame::HandleEvent(nsPresContext
// adjust so that the middle of the thumb is placed under the click
nsIFrame* thumbFrame = mFrames.FirstChild();
if (!thumbFrame) {
return NS_OK;
}
nsSize thumbSize = thumbFrame->GetSize();
nscoord thumbLength = isHorizontal ? thumbSize.width : thumbSize.height;
+ mozilla::Telemetry::Accumulate(mozilla::Telemetry::SCROLL_INPUT_METHODS,
+ (uint32_t) ScrollInputMethod::MainThreadScrollbarTrackClick);
+
// set it
nsWeakFrame weakFrame(this);
// should aMaySnap be true here?
SetCurrentThumbPosition(scrollbar, pos - thumbLength/2, false, false);
NS_ENSURE_TRUE(weakFrame.IsAlive(), NS_OK);
DragThumb(true);