Thu, 15 Jan 2015 21:03:48 +0100
Integrate friendly tips from Tor colleagues to make (or not) 4.5 alpha 3;
This includes removal of overloaded (but unused) methods, and addition of
a overlooked call to DataStruct::SetData(nsISupports, uint32_t, bool.)
1 /* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=2 sw=2 sts=2 et: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 /* Javascript library for dynamically generating a simple SVG/SMIL reftest
8 * with several copies of the same animation, each seeked to a different time.
9 */
11 // Global variables
12 const START_TIMES = [ "4.0s", "3.0s", "2.7s",
13 "2.25s", "2.01s", "1.5s",
14 "1.4s", "1.0s", "0.5s" ];
16 const X_POSNS = [ "20px", "70px", "120px",
17 "20px", "70px", "120px",
18 "20px", "70px", "120px" ];
20 const Y_POSNS = [ "20px", "20px", "20px",
21 "70px", "70px", "70px",
22 "120px", "120px", "120px" ];
24 const DURATION = "2s";
25 const SNAPSHOT_TIME ="3";
26 const SVGNS = "http://www.w3.org/2000/svg";
28 // Convenience wrapper using testAnimatedGrid to make 15pt-by-15pt rects
29 function testAnimatedRectGrid(animationTagName, animationAttrHashList) {
30 var targetTagName = "rect";
31 var targetAttrHash = {"width" : "15px",
32 "height" : "15px" };
33 testAnimatedGrid(targetTagName, targetAttrHash,
34 animationTagName, animationAttrHashList);
35 }
37 // Convenience wrapper using testAnimatedGrid to make grid of text
38 function testAnimatedTextGrid(animationTagName, animationAttrHashList) {
39 var targetTagName = "text";
40 var targetAttrHash = { };
41 testAnimatedGrid(targetTagName, targetAttrHash,
42 animationTagName, animationAttrHashList);
43 }
45 // Generates a visual grid of elements of type "targetTagName", with the
46 // attribute values given in targetAttrHash. Each generated element has
47 // exactly one child -- an animation element of type "animationTagName", with
48 // the attribute values given in animationAttrHash.
49 function testAnimatedGrid(targetTagName, targetAttrHash,
50 animationTagName, animationAttrHashList) {
51 // SANITY CHECK
52 const numElementsToMake = START_TIMES.length;
53 if (X_POSNS.length != numElementsToMake ||
54 Y_POSNS.length != numElementsToMake) {
55 return;
56 }
58 for (var i = 0; i < animationAttrHashList.length; i++) {
59 var animationAttrHash = animationAttrHashList[i];
60 // Default to fill="freeze" so we can test the final value of the animation
61 if (!animationAttrHash["fill"]) {
62 animationAttrHash["fill"] = "freeze";
63 }
64 }
66 // Build the grid!
67 var svg = document.documentElement;
68 for (var i = 0; i < numElementsToMake; i++) {
69 // Build target & animation elements
70 var targetElem = buildElement(targetTagName, targetAttrHash);
71 for (var j = 0; j < animationAttrHashList.length; j++) {
72 var animationAttrHash = animationAttrHashList[j];
73 var animElem = buildElement(animationTagName, animationAttrHash);
75 // Customize them using global constant values
76 targetElem.setAttribute("x", X_POSNS[i]);
77 targetElem.setAttribute("y", Y_POSNS[i]);
78 animElem.setAttribute("begin", START_TIMES[i]);
79 animElem.setAttribute("dur", DURATION);
81 // Append to target
82 targetElem.appendChild(animElem);
83 }
84 // Insert target into DOM
85 svg.appendChild(targetElem);
86 }
88 // Take snapshot
89 setTimeAndSnapshot(SNAPSHOT_TIME, true);
90 }
92 function buildElement(tagName, attrHash) {
93 var elem = document.createElementNS(SVGNS, tagName);
94 for (var attrName in attrHash) {
95 var attrValue = attrHash[attrName];
96 elem.setAttribute(attrName, attrValue);
97 }
98 // If we're creating a text node, populate it with some text.
99 if (tagName == "text") {
100 elem.appendChild(document.createTextNode("abc"));
101 }
102 return elem;
103 }