e90ae71793e0cf7efe022e1157a92d433c8dde83
[WebKit-https.git] / PerformanceTests / Animometer / tests / text / resources / text-boxes.js
1 function BouncingTextBox(stage, sampleText)
2 {
3     BouncingParticle.call(this, stage);
4
5     this.element = document.createElement("div");
6     this.element.classList.add('particle');
7     this.element.style.width = this._size.x + "px";
8     this.element.style.height = this._size.y + "px";
9     this.element.textContent = sampleText;
10     
11     stage.element.appendChild(this.element);
12     this._move();
13 }
14
15 BouncingTextBox.prototype = Object.create(BouncingParticle.prototype);
16 BouncingTextBox.prototype.constructor = BouncingTextBox;
17
18 BouncingTextBox.prototype._move = function()
19 {
20     this.element.style.left = this._position.x + "px";
21     this.element.style.top = this._position.y + "px";
22 }
23     
24 BouncingTextBox.prototype.animate = function(timeDelta)
25 {
26     BouncingParticle.prototype.animate.call(this, timeDelta);
27     this._move();
28 }
29
30 function BouncingTextBoxStage(element, options)
31 {
32     BouncingParticlesStage.call(this, element, options);
33     this._sampleText = document.getElementById('sample-text').textContent;
34 }
35
36 BouncingTextBoxStage.prototype = Object.create(BouncingParticlesStage.prototype);
37 BouncingTextBoxStage.prototype.constructor = BouncingTextBoxStage;
38
39 BouncingTextBoxStage.prototype.createParticle = function()
40 {
41     return new BouncingTextBox(this, this._sampleText);
42 }
43
44 BouncingTextBoxStage.prototype.particleWillBeRemoved = function(particle)
45 {
46     particle.element.remove();
47 }
48
49 function BouncingTextBoxsBenchmark(suite, test, options, recordTable, progressBar)
50 {
51     BouncingParticlesBenchmark.call(this, suite, test, options, recordTable, progressBar);
52 }
53
54 BouncingTextBoxsBenchmark.prototype = Object.create(BouncingParticlesBenchmark.prototype);
55 BouncingTextBoxsBenchmark.prototype.constructor = BouncingTextBoxsBenchmark;
56
57 BouncingTextBoxsBenchmark.prototype.createStage = function(element)
58 {
59     return new BouncingTextBoxStage(element, this._options);
60 }
61
62 window.benchmarkClient.create = function(suite, test, options, recordTable, progressBar)
63 {
64     return new BouncingTextBoxsBenchmark(suite, test, options, recordTable, progressBar);
65 }