fitTimeline() {
    if (!this.templateInfo_ || this.getIsImmutable()) {
      return;
    }
    const timeline = this.templateInfo_.timeline;
    goog.asserts.assert(timeline, 'Timeline should be non-null!');
    const newTimeline = [];
    for (const range of timeline) {
      if (range.start >= this.periodEnd_) {
        // Starts after end of period.
      } else if (range.end <= 0) {
        // Ends before start of period.
      } else {
        // Usable.
        newTimeline.push(range);
      }
    }
    this.templateInfo_.timeline = newTimeline;

    this.evict(this.periodStart_);

    // Do NOT adjust last range to match period end! With high precision
    // timestamps several recalculations may give wrong results on less precise
    // platforms. To mitigate that, we're using cached |periodEnd_| value in
    // find/get() methods whenever possible.
  }
Fit timeline entries to period boundaries