From 554fd8c5195424bdbcabf5de30fdc183aba391bd Mon Sep 17 00:00:00 2001 From: upstream source tree Date: Sun, 15 Mar 2015 20:14:05 -0400 Subject: obtained gcc-4.6.4.tar.bz2 from upstream website; verified gcc-4.6.4.tar.bz2.sig; imported gcc-4.6.4 source tree from verified upstream tarball. downloading a git-generated archive based on the 'upstream' tag should provide you with a source tree that is binary identical to the one extracted from the above tarball. if you have obtained the source via the command 'git clone', however, do note that line-endings of files in your working directory might differ from line-endings of the respective files in the upstream repository. --- libgo/go/html/testdata/webkit/dom2string.js | 135 ++++++++++++++++++++++++++++ 1 file changed, 135 insertions(+) create mode 100644 libgo/go/html/testdata/webkit/dom2string.js (limited to 'libgo/go/html/testdata/webkit/dom2string.js') diff --git a/libgo/go/html/testdata/webkit/dom2string.js b/libgo/go/html/testdata/webkit/dom2string.js new file mode 100644 index 000000000..45897fda4 --- /dev/null +++ b/libgo/go/html/testdata/webkit/dom2string.js @@ -0,0 +1,135 @@ +String.prototype.toAsciiLowerCase = function () { + var output = ""; + for (var i = 0, len = this.length; i < len; ++i) { + if (this.charCodeAt(i) >= 0x41 && this.charCodeAt(i) <= 0x5A) { + output += String.fromCharCode(this.charCodeAt(i) + 0x20) + } else { + output += this.charAt(i); + } + } + return output; +} + +function indent(ancestors) { + var str = ""; + if (ancestors > 0) { + while (ancestors--) + str += " "; + } + return str; +} + +function dom2string(node, ancestors) { + var str = ""; + if (typeof ancestors == "undefined") + var ancestors = 0; + if (!node.firstChild) + return "| "; + var parent = node; + var current = node.firstChild; + var next = null; + var misnested = null; + for (;;) { + str += "\n| " + indent(ancestors); + switch (current.nodeType) { + case 10: + str += ''; + break; + case 8: + try { + str += ''; + } catch (e) { + str += ''; + } + if (parent != current.parentNode) { + return str += ' (misnested... aborting)'; + } + break; + case 7: + str += ''; + break; + case 4: + str += ''; + break; + case 3: + str += '"' + current.nodeValue + '"'; + if (parent != current.parentNode) { + return str += ' (misnested... aborting)'; + } + break; + case 1: + str += "<"; + switch (current.namespaceURI) { + case "http://www.w3.org/2000/svg": + str += "svg "; + break; + case "http://www.w3.org/1998/Math/MathML": + str += "math "; + break; + } + if (current.localName && current.namespaceURI && current.namespaceURI != null) { + str += current.localName; + } else { + str += current.nodeName.toAsciiLowerCase(); + } + str += '>'; + if (parent != current.parentNode) { + return str += ' (misnested... aborting)'; + } else { + if (current.attributes) { + var attrNames = []; + var attrPos = {}; + for (var j = 0; j < current.attributes.length; j += 1) { + if (current.attributes[j].specified) { + var name = ""; + switch (current.attributes[j].namespaceURI) { + case "http://www.w3.org/XML/1998/namespace": + name += "xml "; + break; + case "http://www.w3.org/2000/xmlns/": + name += "xmlns "; + break; + case "http://www.w3.org/1999/xlink": + name += "xlink "; + break; + } + if (current.attributes[j].localName) { + name += current.attributes[j].localName; + } else { + name += current.attributes[j].nodeName; + } + attrNames.push(name); + attrPos[name] = j; + } + } + if (attrNames.length > 0) { + attrNames.sort(); + for (var j = 0; j < attrNames.length; j += 1) { + str += "\n| " + indent(1 + ancestors) + attrNames[j]; + str += '="' + current.attributes[attrPos[attrNames[j]]].nodeValue + '"'; + } + } + } + if (next = current.firstChild) { + parent = current; + current = next; + ancestors++; + continue; + } + } + break; + } + for (;;) { + if (next = current.nextSibling) { + current = next; + break; + } + current = current.parentNode; + parent = parent.parentNode; + ancestors--; + if (current == node) { + return str.substring(1); + } + } + } +} -- cgit v1.2.3