animation.js (2355B)
1 /* This Source Code Form is subject to the terms of the Mozilla Public 2 * License, v. 2.0. If a copy of the MPL was not distributed with this 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 4 "use strict"; 5 6 const { 7 Arg, 8 RetVal, 9 generateActorSpec, 10 types, 11 } = require("resource://devtools/shared/protocol.js"); 12 13 /** 14 * Sent with the 'mutations' event as part of an array of changes, used to 15 * inform fronts of the type of change that occured. 16 */ 17 types.addDictType("animationMutationChange", { 18 // The type of change ("added" or "removed"). 19 type: "string", 20 // The changed AnimationPlayerActor. 21 player: "animationplayer", 22 }); 23 24 const animationPlayerSpec = generateActorSpec({ 25 typeName: "animationplayer", 26 27 events: { 28 changed: { 29 type: "changed", 30 state: Arg(0, "json"), 31 }, 32 }, 33 34 methods: { 35 release: { release: true }, 36 getCurrentState: { 37 request: {}, 38 response: { 39 data: RetVal("json"), 40 }, 41 }, 42 getAnimationTypes: { 43 request: { 44 propertyNames: Arg(0, "array:string"), 45 }, 46 response: { 47 animationTypes: RetVal("json"), 48 }, 49 }, 50 }, 51 }); 52 53 exports.animationPlayerSpec = animationPlayerSpec; 54 55 const animationsSpec = generateActorSpec({ 56 typeName: "animations", 57 58 events: { 59 mutations: { 60 type: "mutations", 61 changes: Arg(0, "array:animationMutationChange"), 62 }, 63 }, 64 65 methods: { 66 setWalkerActor: { 67 request: { 68 walker: Arg(0, "domwalker"), 69 }, 70 response: {}, 71 }, 72 getAnimationPlayersForNode: { 73 request: { 74 actorID: Arg(0, "domnode"), 75 }, 76 response: { 77 players: RetVal("array:animationplayer"), 78 }, 79 }, 80 pauseSome: { 81 request: { 82 players: Arg(0, "array:animationplayer"), 83 }, 84 response: {}, 85 }, 86 playSome: { 87 request: { 88 players: Arg(0, "array:animationplayer"), 89 }, 90 response: {}, 91 }, 92 setCurrentTimes: { 93 request: { 94 players: Arg(0, "array:animationplayer"), 95 time: Arg(1, "number"), 96 shouldPause: Arg(2, "boolean"), 97 }, 98 response: {}, 99 }, 100 setPlaybackRates: { 101 request: { 102 players: Arg(0, "array:animationplayer"), 103 rate: Arg(1, "number"), 104 }, 105 response: {}, 106 }, 107 }, 108 }); 109 110 exports.animationsSpec = animationsSpec;