Simplify the test harness
[WebKit-https.git] / PerformanceTests / Animometer / tests / text / resources / text-boxes.js
1 (function() {
2
3 BouncingTextBox = Utilities.createSubclass(BouncingParticle,
4     function(stage, sampleText)
5     {
6         BouncingParticle.call(this, stage);
7
8         this.element = document.createElement("div");
9         this.element.classList.add('particle');
10         this.element.style.width = this.size.x + "px";
11         this.element.style.height = this.size.y + "px";
12         this.element.textContent = sampleText;
13
14         stage.element.appendChild(this.element);
15         this._move();
16     }, {
17
18     _move: function()
19     {
20         this.element.style.left = this.position.x + "px";
21         this.element.style.top = this.position.y + "px";
22     },
23
24     animate: function(timeDelta)
25     {
26         BouncingParticle.prototype.animate.call(this, timeDelta);
27         this._move();
28     }
29 });
30
31 BouncingTextBoxStage = Utilities.createSubclass(BouncingParticlesStage,
32     function()
33     {
34         BouncingParticlesStage.call(this);
35         this._sampleText = document.getElementById('sample-text').textContent;
36     }, {
37
38     createParticle: function()
39     {
40         return new BouncingTextBox(this, this._sampleText);
41     },
42
43     particleWillBeRemoved: function(particle)
44     {
45         particle.element.remove();
46     }
47 });
48
49 BouncingTextBoxBenchmark = Utilities.createSubclass(Benchmark,
50     function(options)
51     {
52         Benchmark.call(this, new BouncingTextBoxStage(), options);
53     }
54 );
55
56 window.benchmarkClass = BouncingTextBoxBenchmark;
57
58 })();