Bug 1351783 part 20 - Report async keyboard scrolling to telemetry. r?botond draft
authorRyan Hunt <rhunt@eqrion.net>
Thu, 22 Jun 2017 19:26:07 -0400
changeset 599320 86d82de8a1740a0b01e1f6651dc1b9280e8edfd5
parent 599283 1347f18bf194affa91714bf443707805fbe688de
child 634732 b723b5ba508782dbe9dffbe3384b78e2775e5d71
push id65480
push userbmo:rhunt@eqrion.net
push dateThu, 22 Jun 2017 23:26:36 +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
@@ -1656,19 +1656,53 @@ 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.");
+    }
+  }
+
+  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