def GetScrollInputLatencyEvents(scroll_type, browser_process, timeline_range):
  """Get scroll events' LatencyInfo from the browser process's trace buffer
     that are within the timeline_range.

  Scroll events (MouseWheel, GestureScrollUpdate or JS scroll on TouchMove)
  dump their LatencyInfo into trace buffer as async trace event with name
  "InputLatency". The trace event has a memeber 'step' containing its event
  type and a memeber 'data' containing its latency history.

  """
  scroll_events = []
  if not browser_process:
    return scroll_events
  for event in browser_process.IterAllAsyncSlicesOfName("InputLatency"):
    if event.start >= timeline_range.min and event.end <= timeline_range.max:
      for ss in event.sub_slices:
        if 'step' not in ss.args:
          continue
        if 'data' not in ss.args:
          continue
        if ss.args['step'] == scroll_type:
          scroll_events.append(ss)
  return scroll_events