From f9cab004186edb425a9b88ad649726605080a17c Mon Sep 17 00:00:00 2001 From: Thomas Groman Date: Mon, 20 Apr 2020 20:49:37 -0700 Subject: move browser to webbrowser/ --- components/sessionstore/DocumentUtils.jsm | 230 ------------------------------ 1 file changed, 230 deletions(-) delete mode 100644 components/sessionstore/DocumentUtils.jsm (limited to 'components/sessionstore/DocumentUtils.jsm') diff --git a/components/sessionstore/DocumentUtils.jsm b/components/sessionstore/DocumentUtils.jsm deleted file mode 100644 index 6b3f729..0000000 --- a/components/sessionstore/DocumentUtils.jsm +++ /dev/null @@ -1,230 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this file, - * You can obtain one at http://mozilla.org/MPL/2.0/. */ - -this.EXPORTED_SYMBOLS = [ "DocumentUtils" ]; - -const Cu = Components.utils; -const Ci = Components.interfaces; - -Cu.import("resource://gre/modules/XPCOMUtils.jsm"); -Cu.import("resource:///modules/sessionstore/XPathGenerator.jsm"); - -this.DocumentUtils = { - /** - * Obtain form data for a DOMDocument instance. - * - * The returned object has 2 keys, "id" and "xpath". Each key holds an object - * which further defines form data. - * - * The "id" object maps element IDs to values. The "xpath" object maps the - * XPath of an element to its value. - * - * @param aDocument - * DOMDocument instance to obtain form data for. - * @return object - * Form data encoded in an object. - */ - getFormData: function DocumentUtils_getFormData(aDocument) { - let formNodes = aDocument.evaluate( - XPathGenerator.restorableFormNodes, - aDocument, - XPathGenerator.resolveNS, - Ci.nsIDOMXPathResult.UNORDERED_NODE_ITERATOR_TYPE, null - ); - - let node; - let ret = {id: {}, xpath: {}}; - - // Limit the number of XPath expressions for performance reasons. See - // bug 477564. - const MAX_TRAVERSED_XPATHS = 100; - let generatedCount = 0; - - while (node = formNodes.iterateNext()) { - let nId = node.id; - let hasDefaultValue = true; - let value; - - // Only generate a limited number of XPath expressions for perf reasons - // (cf. bug 477564) - if (!nId && generatedCount > MAX_TRAVERSED_XPATHS) { - continue; - } - - if (node instanceof Ci.nsIDOMHTMLInputElement || - node instanceof Ci.nsIDOMHTMLTextAreaElement) { - switch (node.type) { - case "checkbox": - case "radio": - value = node.checked; - hasDefaultValue = value == node.defaultChecked; - break; - case "file": - value = { type: "file", fileList: node.mozGetFileNameArray() }; - hasDefaultValue = !value.fileList.length; - break; - default: // text, textarea - value = node.value; - hasDefaultValue = value == node.defaultValue; - break; - } - } else if (!node.multiple) { - // s with the multiple attribute are easier to determine the - // default value since each