layout/reftests/bidi/dirAuto/setDir.js

Thu, 15 Jan 2015 21:03:48 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 21:03:48 +0100
branch
TOR_BUG_9701
changeset 11
deefc01c0e14
permissions
-rw-r--r--

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.)

michael@0 1 function setAllDir(value)
michael@0 2 {
michael@0 3 for (var i = 0; ; ++i) {
michael@0 4 try {
michael@0 5 theElement = document.getElementById("set" + i);
michael@0 6 theElement.dir = value;
michael@0 7 } catch(e) {
michael@0 8 break;
michael@0 9 }
michael@0 10 }
michael@0 11 }
michael@0 12
michael@0 13 function setAllDirAttribute(value)
michael@0 14 {
michael@0 15 for (var i = 0; ; ++i) {
michael@0 16 try {
michael@0 17 theElement = document.getElementById("set" + i);
michael@0 18 theElement.setAttribute("dir", value);
michael@0 19 } catch(e) {
michael@0 20 break;
michael@0 21 }
michael@0 22 }
michael@0 23 }
michael@0 24
michael@0 25 function removeAllDirAttribute()
michael@0 26 {
michael@0 27 for (var i = 0; ; ++i) {
michael@0 28 try {
michael@0 29 theElement = document.getElementById("set" + i);
michael@0 30 theElement.removeAttribute("dir");
michael@0 31 } catch(e) {
michael@0 32 break;
michael@0 33 }
michael@0 34 }
michael@0 35 }
michael@0 36
michael@0 37 function addOneElement(innerHTML)
michael@0 38 {
michael@0 39 var container = document.getElementById("container");
michael@0 40 var elem = document.createElement("div");
michael@0 41 elem.innerHTML = innerHTML;
michael@0 42 container.appendChild(elem);
michael@0 43 }
michael@0 44
michael@0 45 function addLTRAutoElements()
michael@0 46 {
michael@0 47 addOneElement('<input type="text" value="ABC אבג" id="set0" dir="auto">');
michael@0 48 addOneElement('<span id="set1" dir="auto">ABC אבג</span>');
michael@0 49 addOneElement('<textarea id="set2" dir="auto">ABC אבג</textarea>');
michael@0 50 addOneElement('<button id="set3" dir="auto">ABC אבג</button>');
michael@0 51 addOneElement('<bdi id="set4">ABC אבג</bdi>');
michael@0 52 }
michael@0 53
michael@0 54 function addRTLAutoElements()
michael@0 55 {
michael@0 56 addOneElement('<input type="text" value="אבג ABC" id="set0" dir="auto">');
michael@0 57 addOneElement('<span id="set1" dir="auto">אבג ABC</span>');
michael@0 58 addOneElement('<textarea id="set2" dir="auto">אבג ABC</textarea>');
michael@0 59 addOneElement('<button id="set3" dir="auto">אבג ABC</button>');
michael@0 60 addOneElement('<bdi id="set4">אבג ABC</bdi>');
michael@0 61 }
michael@0 62
michael@0 63 function setAllTextValuesTo(newText)
michael@0 64 {
michael@0 65 for (var i = 0; ; ++i) {
michael@0 66 theElement = document.getElementById("set" + i);
michael@0 67 if (!theElement) {
michael@0 68 break;
michael@0 69 }
michael@0 70 if (theElement.tagName == "INPUT" ||
michael@0 71 theElement.tagName == "TEXTAREA") {
michael@0 72 theElement.value = newText;
michael@0 73 } else {
michael@0 74 theElement.firstChild.textContent = newText;
michael@0 75 }
michael@0 76 }
michael@0 77 }
michael@0 78
michael@0 79 function setAllTextDefaultValuesTo(newText)
michael@0 80 {
michael@0 81 for (var i = 0; ; ++i) {
michael@0 82 theElement = document.getElementById("set" + i);
michael@0 83 if (!theElement) {
michael@0 84 break;
michael@0 85 }
michael@0 86 if (theElement.tagName == "INPUT" ||
michael@0 87 theElement.tagName == "TEXTAREA") {
michael@0 88 theElement.defaultValue = newText;
michael@0 89 } else {
michael@0 90 theElement.firstChild.textContent = newText;
michael@0 91 }
michael@0 92 }
michael@0 93 }
michael@0 94
michael@0 95 function setAllTextChildrenTo(newText)
michael@0 96 {
michael@0 97 for (var i = 0; ; ++i) {
michael@0 98 theElement = document.getElementById("set" + i);
michael@0 99 if (!theElement) {
michael@0 100 break;
michael@0 101 }
michael@0 102 if (theElement.tagName == "INPUT") {
michael@0 103 theElement.value = newText;
michael@0 104 } else {
michael@0 105 theElement.firstChild.textContent = newText;
michael@0 106 }
michael@0 107 }
michael@0 108 }
michael@0 109
michael@0 110 function appendTextFromArray(textArray)
michael@0 111 {
michael@0 112 for (var i = 0; ; ++i) {
michael@0 113 theElement = document.getElementById("set" + i);
michael@0 114 if (!theElement) {
michael@0 115 break;
michael@0 116 }
michael@0 117 for (var j = 0; j < textArray.length; ++j) {
michael@0 118 if (theElement.tagName == "INPUT") {
michael@0 119 theElement.value += textArray[j];
michael@0 120 } else {
michael@0 121 var textNode = document.createTextNode(textArray[j]);
michael@0 122 theElement.appendChild(textNode);
michael@0 123 }
michael@0 124 }
michael@0 125 }
michael@0 126 }
michael@0 127
michael@0 128 function appendSpansFromArray(textArray)
michael@0 129 {
michael@0 130 for (var i = 0; ; ++i) {
michael@0 131 theElement = document.getElementById("set" + i);
michael@0 132 if (!theElement) {
michael@0 133 break;
michael@0 134 }
michael@0 135 for (var j = 0; j < textArray.length; ++j) {
michael@0 136 // fake the result for elements that can't have markup content
michael@0 137 if (theElement.tagName == "INPUT") {
michael@0 138 theElement.value += textArray[j];
michael@0 139 } else if (theElement.tagName == "TEXTAREA") {
michael@0 140 theElement.innerHTML += textArray[j];
michael@0 141 } else {
michael@0 142 var span = document.createElement("span");
michael@0 143 span.innerHTML = textArray[j];
michael@0 144 theElement.appendChild(span);
michael@0 145 }
michael@0 146 }
michael@0 147 }
michael@0 148 }
michael@0 149
michael@0 150 function prependTextFromArray(textArray)
michael@0 151 {
michael@0 152 for (var i = 0; ; ++i) {
michael@0 153 theElement = document.getElementById("set" + i);
michael@0 154 if (!theElement) {
michael@0 155 break;
michael@0 156 }
michael@0 157 for (var j = 0; j < textArray.length; ++j) {
michael@0 158 if (theElement.tagName == "INPUT") {
michael@0 159 theElement.value = textArray[j] + theElement.value;
michael@0 160 } else {
michael@0 161 var textNode = document.createTextNode(textArray[j]);
michael@0 162 theElement.insertBefore(textNode, theElement.firstChild);
michael@0 163 }
michael@0 164 }
michael@0 165 }
michael@0 166 }
michael@0 167
michael@0 168 function prependSpansFromArray(textArray)
michael@0 169 {
michael@0 170 for (var i = 0; ; ++i) {
michael@0 171 theElement = document.getElementById("set" + i);
michael@0 172 if (!theElement) {
michael@0 173 break;
michael@0 174 }
michael@0 175 for (var j = 0; j < textArray.length; ++j) {
michael@0 176 // fake the result for elements that can't have markup content
michael@0 177 if (theElement.tagName == "INPUT") {
michael@0 178 theElement.value = textArray[j] + theElement.value;
michael@0 179 } else if (theElement.tagName == "TEXTAREA") {
michael@0 180 theElement.innerHTML = textArray[j] + theElement.innerHTML;
michael@0 181 } else {
michael@0 182 var span = document.createElement("span");
michael@0 183 span.innerHTML = textArray[j];
michael@0 184 theElement.insertBefore(span, theElement.firstChild);
michael@0 185 }
michael@0 186 }
michael@0 187 }
michael@0 188 }
michael@0 189
michael@0 190 function removeElements()
michael@0 191 {
michael@0 192 for (var i = 0; ; ++i) {
michael@0 193 theElement = document.getElementById("set" + i);
michael@0 194 if (!theElement) {
michael@0 195 break;
michael@0 196 }
michael@0 197 theElement.parentNode.removeChild(theElement);
michael@0 198 }
michael@0 199 }

mercurial