<commit_before>// Copyright 2014 Google Inc. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
//     You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//     See the License for the specific language governing permissions and
// limitations under the License.

(function(shared, scope, testing) {

  shared.AnimationPlayerEvent = function(target, currentTime, timelineTime) {
    this.target = target;
    this.currentTime = currentTime;
    this.timelineTime = timelineTime;

    this.type = 'finish';
    this.bubbles = false;
    this.cancelable = false;
    this.currentTarget = target;
    this.defaultPrevented = false;
    this.eventPhase = Event.AT_TARGET;
    this.timeStamp = Date.now();
  };

  var sequenceNumber = 0;

  shared.Player = function(source) {
    this.__currentTime = 0;
    this._startTime = null;
    this._source = source;
    this.paused = false;
    this._playbackRate = 1;
    this._sequenceNumber = sequenceNumber++;
    this._inTimeline = true;
    this._finishedFlag = false;
    this.onfinish = null;
    this._finishHandlers = [];
    this._hasTicked = false;
    this._startOffset = 0;
    this._parent = null;
  };

  shared.Player.prototype = {
    get currentTime() { return this.__currentTime; },
    set _currentTime(newTime) {
      if (newTime != this.__currentTime || !this._hasTicked) {
        this._hasTicked = true;
        this.__currentTime = newTime;
        if (this.finished)
          this.__currentTime = this._playbackRate > 0 ? this.totalDuration : 0;
        this.ensureAlive();
      }
    },
    ensureAlive: function() {
      this._inEffect = this._source.update(this.__currentTime);
      if (!this._inTimeline && this._inEffect) {
        this._inTimeline = true;
        document.timeline.players.push(this);
      }
    },
    get playbackRate() { return this._playbackRate; },
    set playbackRate(newRate) {
      var previousTime = this.currentTime;
      this._playbackRate = newRate;
      this.currentTime = previousTime;
    },
    set currentTime(newTime) {
      this._currentTime = newTime;
      if (!this.paused) {
        this._startTime = this._timeline.currentTime - this.__currentTime / this._playbackRate;
      }
      if (!this.paused)
        this.startTime += (this.currentTime - newTime) / this.playbackRate;
      this._currentTime = newTime - this.offset;
      scope.invalidateEffects();
    },
    get finished() {
      return this._playbackRate > 0 && this.__currentTime >= this.totalDuration ||
          this._playbackRate < 0 && this.__currentTime <= 0;
    },
    get startTime() {
      if (!this.paused && this._startTime == null)
        scope.tickNow();
      return this._startTime;
    },
    set startTime(newTime) {
      if (this.paused)
        return;
      this._startTime = newTime + this.offset;
      this._currentTime = this._timeline.currentTime - this._startTime;
      scope.invalidateEffects();
    },<commit_msg>Remove set playbackRate from Player.<commit_after>// Copyright 2014 Google Inc. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
//     You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//     See the License for the specific language governing permissions and
// limitations under the License.

(function(shared, scope, testing) {

  shared.AnimationPlayerEvent = function(target, currentTime, timelineTime) {
    this.target = target;
    this.currentTime = currentTime;
    this.timelineTime = timelineTime;

    this.type = 'finish';
    this.bubbles = false;
    this.cancelable = false;
    this.currentTarget = target;
    this.defaultPrevented = false;
    this.eventPhase = Event.AT_TARGET;
    this.timeStamp = Date.now();
  };

  var sequenceNumber = 0;

  shared.Player = function(source) {
    this.__currentTime = 0;
    this._startTime = null;
    this._source = source;
    this.paused = false;
    this._playbackRate = 1;
    this._sequenceNumber = sequenceNumber++;
    this._inTimeline = true;
    this._finishedFlag = false;
    this.onfinish = null;
    this._finishHandlers = [];
    this._hasTicked = false;
    this._startOffset = 0;
    this._parent = null;
  };

  shared.Player.prototype = {
    get currentTime() { return this.__currentTime; },
    set _currentTime(newTime) {
      if (newTime != this.__currentTime || !this._hasTicked) {
        this._hasTicked = true;
        this.__currentTime = newTime;
        if (this.finished)
          this.__currentTime = this._playbackRate > 0 ? this.totalDuration : 0;
        this.ensureAlive();
      }
    },
    ensureAlive: function() {
      this._inEffect = this._source.update(this.__currentTime);
      if (!this._inTimeline && this._inEffect) {
        this._inTimeline = true;
        document.timeline.players.push(this);
      }
    },
    get playbackRate() { return this._playbackRate; },
    set currentTime(newTime) {
      this._currentTime = newTime;
      if (!this.paused) {
        this._startTime = this._timeline.currentTime - this.__currentTime / this._playbackRate;
      }
      if (!this.paused)
        this.startTime += (this.currentTime - newTime) / this.playbackRate;
      this._currentTime = newTime - this.offset;
      scope.invalidateEffects();
    },
    get finished() {
      return this._playbackRate > 0 && this.__currentTime >= this.totalDuration ||
          this._playbackRate < 0 && this.__currentTime <= 0;
    },
    get startTime() {
      if (!this.paused && this._startTime == null)
        scope.tickNow();
      return this._startTime;
    },
    set startTime(newTime) {
      if (this.paused)
        return;
      this._startTime = newTime + this.offset;
      this._currentTime = this._timeline.currentTime - this._startTime;
      scope.invalidateEffects();
    },
{'fraction_non_alphanumeric': 0.11336220228889576, 'fraction_numerical': 0.005258274048871018, 'mean_word_length': 2.735990756787984, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5235385', 'n_tokens_mistral': 1917, 'n_tokens_neox': 1860, 'n_words': 477}