From 36d22d82aa202bb199967e9512281e9a53db42c9 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 21:33:14 +0200 Subject: Adding upstream version 115.7.0esr. Signed-off-by: Daniel Baumann --- .../tests/dom/resources/dom-particles.js | 73 ++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 third_party/webkit/PerformanceTests/MotionMark/tests/dom/resources/dom-particles.js (limited to 'third_party/webkit/PerformanceTests/MotionMark/tests/dom/resources/dom-particles.js') diff --git a/third_party/webkit/PerformanceTests/MotionMark/tests/dom/resources/dom-particles.js b/third_party/webkit/PerformanceTests/MotionMark/tests/dom/resources/dom-particles.js new file mode 100644 index 0000000000..471444b2e7 --- /dev/null +++ b/third_party/webkit/PerformanceTests/MotionMark/tests/dom/resources/dom-particles.js @@ -0,0 +1,73 @@ +(function() { + +DOMParticle = Utilities.createSubclass(Particle, + function(stage) + { + this.element = document.createElement("div"); + stage.element.appendChild(this.element); + + Particle.call(this, stage); + }, { + + reset: function() + { + Particle.prototype.reset.call(this); + + this.position = Stage.randomElementInArray(this.stage.emitLocation); + + var angle = Stage.randomInt(0, this.stage.emitSteps) / this.stage.emitSteps * Math.PI * 2 + Stage.dateCounterValue(100) * this.stage.emissionSpin; + this.velocity = new Point(Math.sin(angle), Math.cos(angle)) + .multiply(Stage.random(.5, 2.5)); + + this.element.style.width = this.size.x + "px"; + this.element.style.height = this.size.y + "px"; + this.stage.colorOffset = (this.stage.colorOffset + 1) % 360; + this.element.style.backgroundColor = "hsl(" + this.stage.colorOffset + ", 70%, 45%)"; + }, + + move: function() + { + this.element.style.transform = "translate(" + this.position.x + "px, " + this.position.y + "px)" + this.rotater.rotateZ(); + } +}); + +DOMParticleStage = Utilities.createSubclass(ParticlesStage, + function() + { + ParticlesStage.call(this); + }, { + + initialize: function(benchmark) + { + ParticlesStage.prototype.initialize.call(this, benchmark); + this.emissionSpin = Stage.random(0, 3); + this.emitSteps = Stage.randomInt(4, 6); + this.emitLocation = [ + new Point(this.size.x * .25, this.size.y * .333), + new Point(this.size.x * .5, this.size.y * .25), + new Point(this.size.x * .75, this.size.y * .333) + ]; + this.colorOffset = Stage.randomInt(0, 359); + }, + + createParticle: function() + { + return new DOMParticle(this); + }, + + willRemoveParticle: function(particle) + { + particle.element.remove(); + } +}); + +DOMParticleBenchmark = Utilities.createSubclass(Benchmark, + function(options) + { + Benchmark.call(this, new DOMParticleStage(), options); + } +); + +window.benchmarkClass = DOMParticleBenchmark; + +})(); -- cgit v1.2.3