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 --- .../resources/bouncing-svg-particles.js | 67 ++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 third_party/webkit/PerformanceTests/MotionMark/tests/bouncing-particles/resources/bouncing-svg-particles.js (limited to 'third_party/webkit/PerformanceTests/MotionMark/tests/bouncing-particles/resources/bouncing-svg-particles.js') diff --git a/third_party/webkit/PerformanceTests/MotionMark/tests/bouncing-particles/resources/bouncing-svg-particles.js b/third_party/webkit/PerformanceTests/MotionMark/tests/bouncing-particles/resources/bouncing-svg-particles.js new file mode 100644 index 0000000000..0988c42d8e --- /dev/null +++ b/third_party/webkit/PerformanceTests/MotionMark/tests/bouncing-particles/resources/bouncing-svg-particles.js @@ -0,0 +1,67 @@ +BouncingSvgParticle = Utilities.createSubclass(BouncingParticle, + function(stage, shape) + { + BouncingParticle.call(this, stage); + this._shape = shape; + }, { + + _applyClipping: function(stage) + { + if (stage.clip != "star") + return; + + stage.ensureClipStarIsCreated(); + this.element.setAttribute("clip-path", "url(#star-clip)"); + }, + + _move: function() + { + var transform = "translate(" + this.position.x + ", " + this.position.y + ")"; + if (this._shape != "circle") + transform += this.rotater.rotate(this.size.center); + this.element.setAttribute("transform", transform); + }, + + animate: function(timeDelta) + { + BouncingParticle.prototype.animate.call(this, timeDelta); + this._move(); + } +}); + +BouncingSvgParticlesStage = Utilities.createSubclass(BouncingParticlesStage, + function() + { + BouncingParticlesStage.call(this); + }, { + + _createDefs: function() + { + return Utilities.createSVGElement("defs", {}, {}, this.element); + }, + + _ensureDefsIsCreated: function() + { + return this.element.querySelector("defs") || this._createDefs(); + }, + + _createClipStar: function() + { + var attrs = { id: "star-clip", clipPathUnits: "objectBoundingBox" }; + var clipPath = Utilities.createSVGElement("clipPath", attrs, {}, this._ensureDefsIsCreated()); + + attrs = { d: "M.50,0L.38,.38L0,.38L.30,.60L.18,1L.50,.75L.82,1L.70,.60L1,.38L.62,.38z" }; + Utilities.createSVGElement("path", attrs, {}, clipPath); + return clipPath; + }, + + ensureClipStarIsCreated: function() + { + return this.element.querySelector("#star-clip") || this._createClipStar(); + }, + + particleWillBeRemoved: function(particle) + { + particle.element.remove(); + } +}); -- cgit v1.2.3