Bug 1351783 part 20 - Report async keyboard scrolling to telemetry. r=botond
authorRyan Hunt <rhunt@eqrion.net>
Thu, 22 Jun 2017 19:26:07 -0400
changeset 600768 6c3e7dff790ac4105e4287575f946931a5eff783
parent 600767 bbe0888e6d97bae668f6e8215d7c33d4a059b9a3
child 600769 d084672cc9fc4315ddbb50e86f6ef32c2f2c01c7
push id65868
push userbmo:rail@mozilla.com
push dateTue, 27 Jun 2017 20:33:55 +0000
reviewersbotond
bugs1351783
milestone56.0a1
Bug 1351783 part 20 - Report async keyboard scrolling to telemetry. r=botond MozReview-Commit-ID: IwLL2xg3BgY
gfx/layers/apz/src/AsyncPanZoomController.cpp
gfx/layers/apz/util/ScrollInputMethods.h
--- a/gfx/layers/apz/src/AsyncPanZoomController.cpp
+++ b/gfx/layers/apz/src/AsyncPanZoomController.cpp
@@ -1660,19 +1660,54 @@ AsyncPanZoomController::GetScrollWheelDe
     delta.y = (delta.y >= 0)
               ? pageScrollSize.height
               : -pageScrollSize.height;
   }
 
   return delta;
 }
 
+static
+void ReportKeyboardScrollAction(const KeyboardScrollAction& aAction)
+{
+  ScrollInputMethod scrollMethod;
+
+  switch (aAction.mType) {
+    case KeyboardScrollAction::eScrollLine: {
+      scrollMethod = ScrollInputMethod::ApzScrollLine;
+      break;
+    }
+    case KeyboardScrollAction::eScrollCharacter: {
+      scrollMethod = ScrollInputMethod::ApzScrollCharacter;
+      break;
+    }
+    case KeyboardScrollAction::eScrollPage: {
+      scrollMethod = ScrollInputMethod::ApzScrollPage;
+      break;
+    }
+    case KeyboardScrollAction::eScrollComplete: {
+      scrollMethod = ScrollInputMethod::ApzCompleteScroll;
+      break;
+    }
+    case KeyboardScrollAction::eSentinel: {
+      MOZ_ASSERT_UNREACHABLE("Invalid KeyboardScrollAction.");
+      return;
+    }
+  }
+
+  mozilla::Telemetry::Accumulate(mozilla::Telemetry::SCROLL_INPUT_METHODS,
+      (uint32_t)scrollMethod);
+}
+
 nsEventStatus
 AsyncPanZoomController::OnKeyboard(const KeyboardInput& aEvent)
 {
+  // Report the type of scroll action to telemetry
+  ReportKeyboardScrollAction(aEvent.mAction);
+
   // Calculate the destination for this keyboard scroll action
   nsPoint destination = CSSPoint::ToAppUnits(GetKeyboardDestination(aEvent.mAction));
 
   // The lock must be held across the entire update operation, so the
   // compositor doesn't end the animation before we get a chance to
   // update it.
   ReentrantMonitorAutoEnter lock(mMonitor);
 
--- a/gfx/layers/apz/util/ScrollInputMethods.h
+++ b/gfx/layers/apz/util/ScrollInputMethods.h
@@ -46,16 +46,26 @@ enum class ScrollInputMethod {
   MainThreadScrollbarButtonClick,  // clicking the buttons at the ends of the
                                    // scrollback track
   MainThreadScrollbarTrackClick,   // clicking the scrollbar track above or
                                    // below the thumb
 
   // Autoscrolling
   MainThreadAutoscrolling,    // autoscrolling
 
+  // Async Keyboard
+  ApzScrollLine,       // line scrolling
+                       // (generally triggered by up/down arrow keys)
+  ApzScrollCharacter,  // character scrolling
+                       // (generally triggered by left/right arrow keys)
+  ApzScrollPage,       // page scrolling
+                       // (generally triggered by PageUp/PageDown keys)
+  ApzCompleteScroll,   // scrolling to the end of the scroll range
+                       // (generally triggered by Home/End keys)
+
   // New input methods can be added at the end, up to a maximum of 64.
   // They should only be added at the end, to preserve the numerical values
   // of the existing enumerators.
 };
 
 } // namespace layers
 } // namespace mozilla