2012-06-21 01:07:51 +04:00
|
|
|
/* 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/. */
|
|
|
|
|
2017-08-01 19:13:27 +03:00
|
|
|
"use strict";
|
2012-06-21 01:07:51 +04:00
|
|
|
|
2018-01-30 02:20:18 +03:00
|
|
|
ChromeUtils.defineModuleGetter(this, "Services", // jshint ignore:line
|
2017-08-01 19:13:27 +03:00
|
|
|
"resource://gre/modules/Services.jsm");
|
2018-01-30 02:20:18 +03:00
|
|
|
ChromeUtils.defineModuleGetter(this, "Rect", // jshint ignore:line
|
2017-08-01 19:13:27 +03:00
|
|
|
"resource://gre/modules/Geometry.jsm");
|
2018-01-30 02:20:18 +03:00
|
|
|
ChromeUtils.defineModuleGetter(this, "Roles", // jshint ignore:line
|
2017-08-01 19:13:27 +03:00
|
|
|
"resource://gre/modules/accessibility/Constants.jsm");
|
2018-01-30 02:20:18 +03:00
|
|
|
ChromeUtils.defineModuleGetter(this, "Events", // jshint ignore:line
|
2017-08-01 19:13:27 +03:00
|
|
|
"resource://gre/modules/accessibility/Constants.jsm");
|
2018-01-30 02:20:18 +03:00
|
|
|
ChromeUtils.defineModuleGetter(this, "Relations", // jshint ignore:line
|
2017-08-01 19:13:27 +03:00
|
|
|
"resource://gre/modules/accessibility/Constants.jsm");
|
2018-01-30 02:20:18 +03:00
|
|
|
ChromeUtils.defineModuleGetter(this, "States", // jshint ignore:line
|
2017-08-01 19:13:27 +03:00
|
|
|
"resource://gre/modules/accessibility/Constants.jsm");
|
2018-01-30 02:20:18 +03:00
|
|
|
ChromeUtils.defineModuleGetter(this, "PluralForm", // jshint ignore:line
|
2017-08-01 19:13:27 +03:00
|
|
|
"resource://gre/modules/PluralForm.jsm");
|
|
|
|
|
2018-02-23 22:50:01 +03:00
|
|
|
var EXPORTED_SYMBOLS = ["Utils", "Logger", "PivotContext", "PrefCache"]; // jshint ignore:line
|
2012-06-21 01:07:51 +04:00
|
|
|
|
2018-02-23 22:50:01 +03:00
|
|
|
var Utils = { // jshint ignore:line
|
2012-07-20 20:46:54 +04:00
|
|
|
_buildAppMap: {
|
2018-03-21 12:17:38 +03:00
|
|
|
"{3c2e2abc-06d4-11e1-ac3b-374f68613e61}": "b2g",
|
|
|
|
"{d1bfe7d9-c01e-4237-998b-7b5f960a4314}": "graphene",
|
2017-08-01 19:13:27 +03:00
|
|
|
"{ec8030f7-c20a-464f-9b0e-13a3a9e97384}": "browser",
|
2018-10-19 15:55:39 +03:00
|
|
|
"{aa3c5121-dab2-40e2-81ca-7ea25febc110}": "mobile/android",
|
2012-07-20 20:46:54 +04:00
|
|
|
},
|
|
|
|
|
2016-08-08 18:47:48 +03:00
|
|
|
get AccService() {
|
|
|
|
if (!this._AccService) {
|
2017-08-01 19:13:27 +03:00
|
|
|
this._AccService = Cc["@mozilla.org/accessibilityService;1"].
|
2016-08-08 18:47:48 +03:00
|
|
|
getService(Ci.nsIAccessibilityService);
|
2012-08-27 07:14:42 +04:00
|
|
|
}
|
|
|
|
|
2016-08-08 18:47:48 +03:00
|
|
|
return this._AccService;
|
2012-08-27 07:14:42 +04:00
|
|
|
},
|
|
|
|
|
2012-10-02 00:33:26 +04:00
|
|
|
set MozBuildApp(value) {
|
|
|
|
this._buildApp = value;
|
|
|
|
},
|
|
|
|
|
2012-07-20 20:46:54 +04:00
|
|
|
get MozBuildApp() {
|
2014-08-06 17:38:56 +04:00
|
|
|
if (!this._buildApp) {
|
2012-07-20 20:46:54 +04:00
|
|
|
this._buildApp = this._buildAppMap[Services.appinfo.ID];
|
2014-08-06 17:38:56 +04:00
|
|
|
}
|
2012-07-20 20:46:54 +04:00
|
|
|
return this._buildApp;
|
|
|
|
},
|
|
|
|
|
2012-10-02 00:33:26 +04:00
|
|
|
get ScriptName() {
|
2014-08-06 17:38:56 +04:00
|
|
|
if (!this._ScriptName) {
|
2012-10-02 00:33:26 +04:00
|
|
|
this._ScriptName =
|
2017-08-01 19:13:27 +03:00
|
|
|
(Services.appinfo.processType == 2) ? "AccessFuContent" : "AccessFu";
|
2014-08-06 17:38:56 +04:00
|
|
|
}
|
2012-10-02 00:33:26 +04:00
|
|
|
return this._ScriptName;
|
|
|
|
},
|
|
|
|
|
2012-06-21 01:07:51 +04:00
|
|
|
get AndroidSdkVersion() {
|
|
|
|
if (!this._AndroidSdkVersion) {
|
2017-08-01 19:13:27 +03:00
|
|
|
if (Services.appinfo.OS == "Android") {
|
2014-08-06 17:38:56 +04:00
|
|
|
this._AndroidSdkVersion = Services.sysinfo.getPropertyAsInt32(
|
2017-08-01 19:13:27 +03:00
|
|
|
"version");
|
2012-10-10 19:10:39 +04:00
|
|
|
} else {
|
|
|
|
// Most useful in desktop debugging.
|
2014-03-19 11:38:25 +04:00
|
|
|
this._AndroidSdkVersion = 16;
|
2012-10-10 19:10:39 +04:00
|
|
|
}
|
2012-06-21 01:07:51 +04:00
|
|
|
}
|
|
|
|
return this._AndroidSdkVersion;
|
|
|
|
},
|
|
|
|
|
|
|
|
set AndroidSdkVersion(value) {
|
|
|
|
// When we want to mimic another version.
|
|
|
|
this._AndroidSdkVersion = value;
|
|
|
|
},
|
|
|
|
|
2018-05-30 19:43:00 +03:00
|
|
|
getCurrentBrowser: function getCurrentBrowser(aWindow) {
|
|
|
|
let win = aWindow ||
|
|
|
|
Services.wm.getMostRecentWindow("navigator:browser") ||
|
|
|
|
Services.wm.getMostRecentWindow("navigator:geckoview");
|
|
|
|
return win.document.querySelector("browser[type=content][primary=true]");
|
2012-10-02 00:33:26 +04:00
|
|
|
},
|
|
|
|
|
2013-05-21 22:16:50 +04:00
|
|
|
get isContentProcess() {
|
|
|
|
delete this.isContentProcess;
|
|
|
|
this.isContentProcess =
|
|
|
|
Services.appinfo.processType == Services.appinfo.PROCESS_TYPE_CONTENT;
|
|
|
|
return this.isContentProcess;
|
|
|
|
},
|
|
|
|
|
2014-08-06 17:38:50 +04:00
|
|
|
localize: function localize(aOutput) {
|
|
|
|
let outputArray = Array.isArray(aOutput) ? aOutput : [aOutput];
|
|
|
|
let localized =
|
2015-10-18 17:21:31 +03:00
|
|
|
outputArray.map(details => this.stringBundle.get(details));
|
2014-08-06 17:38:50 +04:00
|
|
|
// Clean up the white space.
|
2015-10-18 17:21:31 +03:00
|
|
|
return localized.filter(word => word).map(word => word.trim()).
|
|
|
|
filter(trimmed => trimmed);
|
2014-08-06 17:38:50 +04:00
|
|
|
},
|
|
|
|
|
2014-03-04 22:10:38 +04:00
|
|
|
get stringBundle() {
|
|
|
|
delete this.stringBundle;
|
2014-08-06 17:38:50 +04:00
|
|
|
let bundle = Services.strings.createBundle(
|
2017-08-01 19:13:27 +03:00
|
|
|
"chrome://global/locale/AccessFu.properties");
|
2014-08-06 17:38:50 +04:00
|
|
|
this.stringBundle = {
|
|
|
|
get: function stringBundle_get(aDetails = {}) {
|
2017-08-01 19:13:27 +03:00
|
|
|
if (!aDetails || typeof aDetails === "string") {
|
2014-08-06 17:38:50 +04:00
|
|
|
return aDetails;
|
|
|
|
}
|
2017-08-01 19:13:27 +03:00
|
|
|
let str = "";
|
2014-08-06 17:38:50 +04:00
|
|
|
let string = aDetails.string;
|
|
|
|
if (!string) {
|
|
|
|
return str;
|
|
|
|
}
|
|
|
|
try {
|
|
|
|
let args = aDetails.args;
|
|
|
|
let count = aDetails.count;
|
|
|
|
if (args) {
|
|
|
|
str = bundle.formatStringFromName(string, args, args.length);
|
|
|
|
} else {
|
|
|
|
str = bundle.GetStringFromName(string);
|
|
|
|
}
|
|
|
|
if (count) {
|
|
|
|
str = PluralForm.get(count, str);
|
2017-08-01 19:13:27 +03:00
|
|
|
str = str.replace("#1", count);
|
2014-08-06 17:38:50 +04:00
|
|
|
}
|
|
|
|
} catch (e) {
|
2017-08-01 19:13:27 +03:00
|
|
|
Logger.debug("Failed to get a string from a bundle for", string);
|
2014-08-06 17:38:50 +04:00
|
|
|
} finally {
|
|
|
|
return str;
|
|
|
|
}
|
2018-10-19 15:55:39 +03:00
|
|
|
},
|
2014-08-06 17:38:50 +04:00
|
|
|
};
|
2014-03-04 22:10:38 +04:00
|
|
|
return this.stringBundle;
|
|
|
|
},
|
|
|
|
|
2013-03-15 17:50:55 +04:00
|
|
|
getMessageManager: function getMessageManager(aBrowser) {
|
2018-05-30 19:43:00 +03:00
|
|
|
let browser = aBrowser || this.getCurrentBrowser();
|
2013-03-15 17:50:55 +04:00
|
|
|
try {
|
2018-05-30 19:43:00 +03:00
|
|
|
return browser.frameLoader.messageManager;
|
2013-03-15 17:50:55 +04:00
|
|
|
} catch (x) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2014-01-28 04:35:13 +04:00
|
|
|
getState: function getState(aAccessibleOrEvent) {
|
|
|
|
if (aAccessibleOrEvent instanceof Ci.nsIAccessibleStateChangeEvent) {
|
|
|
|
return new State(
|
|
|
|
aAccessibleOrEvent.isExtraState ? 0 : aAccessibleOrEvent.state,
|
|
|
|
aAccessibleOrEvent.isExtraState ? aAccessibleOrEvent.state : 0);
|
2017-08-01 21:08:02 +03:00
|
|
|
}
|
2014-01-28 04:35:13 +04:00
|
|
|
let state = {};
|
|
|
|
let extState = {};
|
|
|
|
aAccessibleOrEvent.getState(state, extState);
|
|
|
|
return new State(state.value, extState.value);
|
2012-07-20 20:46:54 +04:00
|
|
|
},
|
|
|
|
|
2013-05-28 21:51:44 +04:00
|
|
|
getAttributes: function getAttributes(aAccessible) {
|
|
|
|
let attributes = {};
|
|
|
|
|
2013-06-28 01:15:36 +04:00
|
|
|
if (aAccessible && aAccessible.attributes) {
|
|
|
|
// Populate |attributes| object with |aAccessible|'s attribute key-value
|
|
|
|
// pairs.
|
2018-08-19 04:13:14 +03:00
|
|
|
for (let attribute of aAccessible.attributes.enumerate()) {
|
2013-06-28 01:15:36 +04:00
|
|
|
attributes[attribute.key] = attribute.value;
|
|
|
|
}
|
2013-05-28 21:51:44 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return attributes;
|
|
|
|
},
|
|
|
|
|
2012-07-20 20:46:54 +04:00
|
|
|
getVirtualCursor: function getVirtualCursor(aDocument) {
|
|
|
|
let doc = (aDocument instanceof Ci.nsIAccessible) ? aDocument :
|
2016-08-08 18:47:48 +03:00
|
|
|
this.AccService.getAccessibleFor(aDocument);
|
2012-07-20 20:46:54 +04:00
|
|
|
|
2013-05-21 22:16:50 +04:00
|
|
|
return doc.QueryInterface(Ci.nsIAccessibleDocument).virtualCursor;
|
|
|
|
},
|
2012-07-20 20:46:54 +04:00
|
|
|
|
2014-08-19 23:26:02 +04:00
|
|
|
getContentResolution: function _getContentResolution(aAccessible) {
|
2018-12-30 04:15:27 +03:00
|
|
|
return aAccessible.document.window.windowUtils.getResolution();
|
2013-07-04 02:02:44 +04:00
|
|
|
},
|
|
|
|
|
2018-04-19 12:31:00 +03:00
|
|
|
getBounds: function getBounds(aAccessible) {
|
2014-08-19 23:26:02 +04:00
|
|
|
let objX = {}, objY = {}, objW = {}, objH = {};
|
|
|
|
aAccessible.getBounds(objX, objY, objW, objH);
|
|
|
|
|
2018-04-19 12:31:00 +03:00
|
|
|
return new Rect(objX.value, objY.value, objW.value, objH.value);
|
2014-08-19 23:26:02 +04:00
|
|
|
},
|
|
|
|
|
2018-07-12 18:33:13 +03:00
|
|
|
getTextSelection: function getTextSelection(aAccessible) {
|
|
|
|
const accText = aAccessible.QueryInterface(Ci.nsIAccessibleText);
|
|
|
|
const start = {}, end = {};
|
|
|
|
if (accText.selectionCount) {
|
|
|
|
accText.getSelectionBounds(0, start, end);
|
|
|
|
} else {
|
|
|
|
start.value = end.value = accText.caretOffset;
|
|
|
|
}
|
|
|
|
|
|
|
|
return [start.value, end.value];
|
|
|
|
},
|
|
|
|
|
2014-08-19 23:26:02 +04:00
|
|
|
getTextBounds: function getTextBounds(aAccessible, aStart, aEnd,
|
|
|
|
aPreserveContentScale) {
|
|
|
|
let accText = aAccessible.QueryInterface(Ci.nsIAccessibleText);
|
|
|
|
let objX = {}, objY = {}, objW = {}, objH = {};
|
|
|
|
accText.getRangeExtents(aStart, aEnd, objX, objY, objW, objH,
|
|
|
|
Ci.nsIAccessibleCoordinateType.COORDTYPE_SCREEN_RELATIVE);
|
|
|
|
|
2018-04-19 12:31:00 +03:00
|
|
|
return new Rect(objX.value, objY.value, objW.value, objH.value);
|
2013-07-25 01:52:57 +04:00
|
|
|
},
|
|
|
|
|
2014-03-05 05:49:27 +04:00
|
|
|
isInSubtree: function isInSubtree(aAccessible, aSubTreeRoot) {
|
|
|
|
let acc = aAccessible;
|
2015-10-15 17:06:36 +03:00
|
|
|
|
|
|
|
// If aSubTreeRoot is an accessible document, we will only walk up the
|
|
|
|
// ancestry of documents and skip everything else.
|
|
|
|
if (aSubTreeRoot instanceof Ci.nsIAccessibleDocument) {
|
|
|
|
while (acc) {
|
|
|
|
let parentDoc = acc instanceof Ci.nsIAccessibleDocument ?
|
|
|
|
acc.parentDocument : acc.document;
|
|
|
|
if (parentDoc === aSubTreeRoot) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
acc = parentDoc;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2014-03-05 05:49:27 +04:00
|
|
|
while (acc) {
|
|
|
|
if (acc == aSubTreeRoot) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
try {
|
|
|
|
acc = acc.parent;
|
|
|
|
} catch (x) {
|
2017-08-01 19:13:27 +03:00
|
|
|
Logger.debug("Failed to get parent:", x);
|
2014-03-05 05:49:27 +04:00
|
|
|
acc = null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
},
|
|
|
|
|
2014-09-25 17:57:22 +04:00
|
|
|
visibleChildCount: function visibleChildCount(aAccessible) {
|
|
|
|
let count = 0;
|
|
|
|
for (let child = aAccessible.firstChild; child; child = child.nextSibling) {
|
2018-07-04 17:18:43 +03:00
|
|
|
++count;
|
2014-09-25 17:57:22 +04:00
|
|
|
}
|
|
|
|
return count;
|
|
|
|
},
|
|
|
|
|
2014-01-30 03:08:53 +04:00
|
|
|
isAliveAndVisible: function isAliveAndVisible(aAccessible, aIsOnScreen) {
|
2013-07-04 02:02:44 +04:00
|
|
|
if (!aAccessible) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
try {
|
2014-01-28 04:35:13 +04:00
|
|
|
let state = this.getState(aAccessible);
|
|
|
|
if (state.contains(States.DEFUNCT) || state.contains(States.INVISIBLE) ||
|
2018-07-04 17:18:43 +03:00
|
|
|
(aIsOnScreen && state.contains(States.OFFSCREEN))) {
|
2013-07-04 02:02:44 +04:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
} catch (x) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
2013-07-12 00:42:11 +04:00
|
|
|
},
|
|
|
|
|
2013-08-21 20:40:06 +04:00
|
|
|
matchAttributeValue: function matchAttributeValue(aAttributeValue, values) {
|
2017-08-01 19:13:27 +03:00
|
|
|
let attrSet = new Set(aAttributeValue.split(" "));
|
2013-08-21 20:40:06 +04:00
|
|
|
for (let value of values) {
|
|
|
|
if (attrSet.has(value)) {
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2013-07-12 00:42:11 +04:00
|
|
|
getLandmarkName: function getLandmarkName(aAccessible) {
|
2015-07-13 12:53:00 +03:00
|
|
|
return this.matchRoles(aAccessible, [
|
2017-08-01 19:13:27 +03:00
|
|
|
"banner",
|
|
|
|
"complementary",
|
|
|
|
"contentinfo",
|
|
|
|
"main",
|
|
|
|
"navigation",
|
2018-10-19 15:55:39 +03:00
|
|
|
"search",
|
2015-07-13 12:53:00 +03:00
|
|
|
]);
|
|
|
|
},
|
|
|
|
|
|
|
|
getMathRole: function getMathRole(aAccessible) {
|
|
|
|
return this.matchRoles(aAccessible, [
|
2017-08-01 19:13:27 +03:00
|
|
|
"base",
|
|
|
|
"close-fence",
|
|
|
|
"denominator",
|
|
|
|
"numerator",
|
|
|
|
"open-fence",
|
|
|
|
"overscript",
|
|
|
|
"presubscript",
|
|
|
|
"presuperscript",
|
|
|
|
"root-index",
|
|
|
|
"subscript",
|
|
|
|
"superscript",
|
2018-10-19 15:55:39 +03:00
|
|
|
"underscript",
|
2015-07-13 12:53:00 +03:00
|
|
|
]);
|
|
|
|
},
|
|
|
|
|
|
|
|
matchRoles: function matchRoles(aAccessible, aRoles) {
|
2017-08-01 19:13:27 +03:00
|
|
|
let roles = this.getAttributes(aAccessible)["xml-roles"];
|
2013-07-12 00:42:11 +04:00
|
|
|
if (!roles) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-07-13 12:53:00 +03:00
|
|
|
// Looking up a role that would match any in the provided roles.
|
|
|
|
return this.matchAttributeValue(roles, aRoles);
|
2013-10-14 23:56:19 +04:00
|
|
|
},
|
|
|
|
|
|
|
|
getEmbeddedControl: function getEmbeddedControl(aLabel) {
|
|
|
|
if (aLabel) {
|
2013-11-19 22:17:43 +04:00
|
|
|
let relation = aLabel.getRelationByType(Relations.LABEL_FOR);
|
2013-10-14 23:56:19 +04:00
|
|
|
for (let i = 0; i < relation.targetsCount; i++) {
|
|
|
|
let target = relation.getTarget(i);
|
|
|
|
if (target.parent === aLabel) {
|
|
|
|
return target;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
2014-05-01 08:33:37 +04:00
|
|
|
},
|
|
|
|
|
|
|
|
isListItemDecorator: function isListItemDecorator(aStaticText,
|
|
|
|
aExcludeOrdered) {
|
|
|
|
let parent = aStaticText.parent;
|
2017-08-01 19:13:27 +03:00
|
|
|
if (aExcludeOrdered && parent.parent.DOMNode.nodeName === "OL") {
|
2014-05-01 08:33:37 +04:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return parent.role === Roles.LISTITEM && parent.childCount > 1 &&
|
|
|
|
aStaticText.indexInParent === 0;
|
2018-10-19 15:55:39 +03:00
|
|
|
},
|
2012-06-21 01:07:51 +04:00
|
|
|
};
|
|
|
|
|
2014-02-04 23:56:20 +04:00
|
|
|
/**
|
|
|
|
* State object used internally to process accessible's states.
|
|
|
|
* @param {Number} aBase Base state.
|
|
|
|
* @param {Number} aExtended Extended state.
|
|
|
|
*/
|
|
|
|
function State(aBase, aExtended) {
|
|
|
|
this.base = aBase;
|
|
|
|
this.extended = aExtended;
|
|
|
|
}
|
|
|
|
|
|
|
|
State.prototype = {
|
|
|
|
contains: function State_contains(other) {
|
|
|
|
return !!(this.base & other.base || this.extended & other.extended);
|
|
|
|
},
|
|
|
|
toString: function State_toString() {
|
2016-08-08 18:47:48 +03:00
|
|
|
let stateStrings = Utils.AccService.
|
2014-02-04 23:56:20 +04:00
|
|
|
getStringStates(this.base, this.extended);
|
|
|
|
let statesArray = new Array(stateStrings.length);
|
|
|
|
for (let i = 0; i < statesArray.length; i++) {
|
|
|
|
statesArray[i] = stateStrings.item(i);
|
|
|
|
}
|
2017-08-01 19:13:27 +03:00
|
|
|
return "[" + statesArray.join(", ") + "]";
|
2018-10-19 15:55:39 +03:00
|
|
|
},
|
2014-02-04 23:56:20 +04:00
|
|
|
};
|
|
|
|
|
2018-02-23 22:50:01 +03:00
|
|
|
var Logger = { // jshint ignore:line
|
2014-08-14 17:24:08 +04:00
|
|
|
GESTURE: -1,
|
2012-06-21 01:07:51 +04:00
|
|
|
DEBUG: 0,
|
|
|
|
INFO: 1,
|
|
|
|
WARNING: 2,
|
|
|
|
ERROR: 3,
|
2017-08-01 19:13:27 +03:00
|
|
|
_LEVEL_NAMES: ["GESTURE", "DEBUG", "INFO", "WARNING", "ERROR"],
|
2012-06-21 01:07:51 +04:00
|
|
|
|
|
|
|
logLevel: 1, // INFO;
|
|
|
|
|
2018-07-27 15:19:00 +03:00
|
|
|
// Note: used for testing purposes. If true, also log to the console service.
|
|
|
|
useConsoleService: false,
|
2013-04-23 21:39:15 +04:00
|
|
|
|
2012-06-21 01:07:51 +04:00
|
|
|
log: function log(aLogLevel) {
|
2014-08-06 17:38:56 +04:00
|
|
|
if (aLogLevel < this.logLevel) {
|
2012-06-21 01:07:51 +04:00
|
|
|
return;
|
2014-08-06 17:38:56 +04:00
|
|
|
}
|
2012-06-21 01:07:51 +04:00
|
|
|
|
2014-02-27 19:42:45 +04:00
|
|
|
let args = Array.prototype.slice.call(arguments, 1);
|
2017-08-01 19:13:27 +03:00
|
|
|
let message = (typeof(args[0]) === "function" ? args[0]() : args).join(" ");
|
|
|
|
message = "[" + Utils.ScriptName + "] " + this._LEVEL_NAMES[aLogLevel + 1] +
|
|
|
|
" " + message + "\n";
|
2013-04-23 21:39:15 +04:00
|
|
|
dump(message);
|
2018-07-27 15:19:00 +03:00
|
|
|
if (this.useConsoleService) {
|
2013-04-23 21:39:15 +04:00
|
|
|
try {
|
|
|
|
Services.console.logStringMessage(message);
|
|
|
|
} catch (ex) {
|
|
|
|
// There was an exception logging to the console service.
|
|
|
|
}
|
|
|
|
}
|
2012-06-21 01:07:51 +04:00
|
|
|
},
|
|
|
|
|
|
|
|
info: function info() {
|
|
|
|
this.log.apply(
|
|
|
|
this, [this.INFO].concat(Array.prototype.slice.call(arguments)));
|
|
|
|
},
|
|
|
|
|
2014-08-14 17:24:08 +04:00
|
|
|
gesture: function gesture() {
|
|
|
|
this.log.apply(
|
|
|
|
this, [this.GESTURE].concat(Array.prototype.slice.call(arguments)));
|
|
|
|
},
|
|
|
|
|
2012-06-21 01:07:51 +04:00
|
|
|
debug: function debug() {
|
|
|
|
this.log.apply(
|
|
|
|
this, [this.DEBUG].concat(Array.prototype.slice.call(arguments)));
|
|
|
|
},
|
|
|
|
|
|
|
|
warning: function warning() {
|
|
|
|
this.log.apply(
|
|
|
|
this, [this.WARNING].concat(Array.prototype.slice.call(arguments)));
|
|
|
|
},
|
|
|
|
|
|
|
|
error: function error() {
|
|
|
|
this.log.apply(
|
|
|
|
this, [this.ERROR].concat(Array.prototype.slice.call(arguments)));
|
|
|
|
},
|
|
|
|
|
2013-06-28 01:15:36 +04:00
|
|
|
logException: function logException(
|
2017-08-01 19:13:27 +03:00
|
|
|
aException, aErrorMessage = "An exception has occured") {
|
2012-10-20 00:39:36 +04:00
|
|
|
try {
|
2017-08-01 19:13:27 +03:00
|
|
|
let stackMessage = "";
|
2013-06-28 01:15:36 +04:00
|
|
|
if (aException.stack) {
|
2017-08-01 19:13:27 +03:00
|
|
|
stackMessage = " " + aException.stack.replace(/\n/g, "\n ");
|
2013-06-28 01:15:36 +04:00
|
|
|
} else if (aException.location) {
|
|
|
|
let frame = aException.location;
|
|
|
|
let stackLines = [];
|
|
|
|
while (frame && frame.lineNumber) {
|
|
|
|
stackLines.push(
|
2017-08-01 19:13:27 +03:00
|
|
|
" " + frame.name + "@" + frame.filename + ":" + frame.lineNumber);
|
2013-06-28 01:15:36 +04:00
|
|
|
frame = frame.caller;
|
|
|
|
}
|
2017-08-01 19:13:27 +03:00
|
|
|
stackMessage = stackLines.join("\n");
|
2013-06-28 01:15:36 +04:00
|
|
|
} else {
|
2014-08-06 17:38:56 +04:00
|
|
|
stackMessage =
|
2017-08-01 19:13:27 +03:00
|
|
|
"(" + aException.fileName + ":" + aException.lineNumber + ")";
|
2013-06-28 01:15:36 +04:00
|
|
|
}
|
2017-08-01 19:13:27 +03:00
|
|
|
this.error(aErrorMessage + ":\n " +
|
|
|
|
aException.message + "\n" +
|
2013-06-28 01:15:36 +04:00
|
|
|
stackMessage);
|
2012-10-20 00:39:36 +04:00
|
|
|
} catch (x) {
|
|
|
|
this.error(x);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2012-06-21 01:07:51 +04:00
|
|
|
accessibleToString: function accessibleToString(aAccessible) {
|
2014-08-14 17:24:08 +04:00
|
|
|
if (!aAccessible) {
|
2017-08-01 19:13:27 +03:00
|
|
|
return "[ null ]";
|
2014-08-14 17:24:08 +04:00
|
|
|
}
|
|
|
|
|
2012-06-21 01:07:51 +04:00
|
|
|
try {
|
2017-08-01 19:13:27 +03:00
|
|
|
return "[ " + Utils.AccService.getStringRole(aAccessible.role) +
|
|
|
|
" | " + aAccessible.name + " ]";
|
2012-06-21 01:07:51 +04:00
|
|
|
} catch (x) {
|
2017-08-01 19:13:27 +03:00
|
|
|
return "[ defunct ]";
|
2012-06-21 01:07:51 +04:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
eventToString: function eventToString(aEvent) {
|
2016-08-08 18:47:48 +03:00
|
|
|
let str = Utils.AccService.getStringEventType(aEvent.eventType);
|
2013-11-19 22:17:43 +04:00
|
|
|
if (aEvent.eventType == Events.STATE_CHANGE) {
|
2012-06-21 01:07:51 +04:00
|
|
|
let event = aEvent.QueryInterface(Ci.nsIAccessibleStateChangeEvent);
|
2013-01-19 19:38:01 +04:00
|
|
|
let stateStrings = event.isExtraState ?
|
2016-08-08 18:47:48 +03:00
|
|
|
Utils.AccService.getStringStates(0, event.state) :
|
|
|
|
Utils.AccService.getStringStates(event.state, 0);
|
2017-08-01 19:13:27 +03:00
|
|
|
str += " (" + stateStrings.item(0) + ")";
|
2012-06-21 01:07:51 +04:00
|
|
|
}
|
|
|
|
|
2014-02-27 01:31:09 +04:00
|
|
|
if (aEvent.eventType == Events.VIRTUALCURSOR_CHANGED) {
|
|
|
|
let event = aEvent.QueryInterface(
|
|
|
|
Ci.nsIAccessibleVirtualCursorChangeEvent);
|
|
|
|
let pivot = aEvent.accessible.QueryInterface(
|
|
|
|
Ci.nsIAccessibleDocument).virtualCursor;
|
2017-08-01 19:13:27 +03:00
|
|
|
str += " (" + this.accessibleToString(event.oldAccessible) + " -> " +
|
|
|
|
this.accessibleToString(pivot.position) + ")";
|
2014-02-27 01:31:09 +04:00
|
|
|
}
|
|
|
|
|
2012-06-21 01:07:51 +04:00
|
|
|
return str;
|
2012-07-20 20:46:54 +04:00
|
|
|
},
|
|
|
|
|
|
|
|
statesToString: function statesToString(aAccessible) {
|
2014-01-28 04:35:13 +04:00
|
|
|
return Utils.getState(aAccessible).toString();
|
2012-07-20 20:46:54 +04:00
|
|
|
},
|
|
|
|
|
|
|
|
dumpTree: function dumpTree(aLogLevel, aRootAccessible) {
|
2014-08-06 17:38:56 +04:00
|
|
|
if (aLogLevel < this.logLevel) {
|
2012-07-20 20:46:54 +04:00
|
|
|
return;
|
2014-08-06 17:38:56 +04:00
|
|
|
}
|
2012-07-20 20:46:54 +04:00
|
|
|
|
|
|
|
this._dumpTreeInternal(aLogLevel, aRootAccessible, 0);
|
|
|
|
},
|
|
|
|
|
2014-08-06 17:38:56 +04:00
|
|
|
_dumpTreeInternal:
|
|
|
|
function _dumpTreeInternal(aLogLevel, aAccessible, aIndent) {
|
2017-08-01 19:13:27 +03:00
|
|
|
let indentStr = "";
|
2014-08-06 17:38:56 +04:00
|
|
|
for (let i = 0; i < aIndent; i++) {
|
2017-08-01 19:13:27 +03:00
|
|
|
indentStr += " ";
|
2014-08-06 17:38:56 +04:00
|
|
|
}
|
|
|
|
this.log(aLogLevel, indentStr,
|
|
|
|
this.accessibleToString(aAccessible),
|
2017-08-01 19:13:27 +03:00
|
|
|
"(" + this.statesToString(aAccessible) + ")");
|
2014-08-06 17:38:56 +04:00
|
|
|
for (let i = 0; i < aAccessible.childCount; i++) {
|
|
|
|
this._dumpTreeInternal(aLogLevel, aAccessible.getChildAt(i),
|
|
|
|
aIndent + 1);
|
|
|
|
}
|
2018-10-19 15:55:39 +03:00
|
|
|
},
|
2012-06-21 01:07:51 +04:00
|
|
|
};
|
2013-04-05 02:16:37 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* PivotContext: An object that generates and caches context information
|
|
|
|
* for a given accessible and its relationship with another accessible.
|
2013-10-14 23:56:19 +04:00
|
|
|
*
|
|
|
|
* If the given accessible is a label for a nested control, then this
|
|
|
|
* context will represent the nested control instead of the label.
|
|
|
|
* With the exception of bounds calculation, which will use the containing
|
|
|
|
* label. In this case the |accessible| field would be the embedded control,
|
|
|
|
* and the |accessibleForBounds| field would be the label.
|
2013-04-05 02:16:37 +04:00
|
|
|
*/
|
2018-02-23 22:50:01 +03:00
|
|
|
function PivotContext(aAccessible, aOldAccessible, // jshint ignore:line
|
2013-08-21 20:40:06 +04:00
|
|
|
aStartOffset, aEndOffset, aIgnoreAncestry = false,
|
|
|
|
aIncludeInvisible = false) {
|
2013-04-05 02:16:37 +04:00
|
|
|
this._accessible = aAccessible;
|
2013-10-14 23:56:19 +04:00
|
|
|
this._nestedControl = Utils.getEmbeddedControl(aAccessible);
|
2013-04-05 02:16:37 +04:00
|
|
|
this._oldAccessible =
|
|
|
|
this._isDefunct(aOldAccessible) ? null : aOldAccessible;
|
2013-07-25 01:52:57 +04:00
|
|
|
this.startOffset = aStartOffset;
|
|
|
|
this.endOffset = aEndOffset;
|
2013-08-21 20:40:06 +04:00
|
|
|
this._ignoreAncestry = aIgnoreAncestry;
|
|
|
|
this._includeInvisible = aIncludeInvisible;
|
2018-02-23 22:50:01 +03:00
|
|
|
}
|
2013-04-05 02:16:37 +04:00
|
|
|
|
|
|
|
PivotContext.prototype = {
|
|
|
|
get accessible() {
|
2013-10-14 23:56:19 +04:00
|
|
|
// If the current pivot accessible has a nested control,
|
|
|
|
// make this context use it publicly.
|
|
|
|
return this._nestedControl || this._accessible;
|
2013-04-05 02:16:37 +04:00
|
|
|
},
|
|
|
|
|
|
|
|
get oldAccessible() {
|
|
|
|
return this._oldAccessible;
|
|
|
|
},
|
|
|
|
|
2013-10-14 23:56:19 +04:00
|
|
|
get isNestedControl() {
|
|
|
|
return !!this._nestedControl;
|
|
|
|
},
|
|
|
|
|
|
|
|
get accessibleForBounds() {
|
|
|
|
return this._accessible;
|
|
|
|
},
|
|
|
|
|
2013-07-25 01:52:57 +04:00
|
|
|
get textAndAdjustedOffsets() {
|
|
|
|
if (this.startOffset === -1 && this.endOffset === -1) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!this._textAndAdjustedOffsets) {
|
|
|
|
let result = {startOffset: this.startOffset,
|
|
|
|
endOffset: this.endOffset,
|
|
|
|
text: this._accessible.QueryInterface(Ci.nsIAccessibleText).
|
2014-08-06 17:38:56 +04:00
|
|
|
getText(0,
|
|
|
|
Ci.nsIAccessibleText.TEXT_OFFSET_END_OF_TEXT)};
|
|
|
|
let hypertextAcc = this._accessible.QueryInterface(
|
|
|
|
Ci.nsIAccessibleHyperText);
|
2013-07-25 01:52:57 +04:00
|
|
|
|
|
|
|
// Iterate through the links in backwards order so text replacements don't
|
|
|
|
// affect the offsets of links yet to be processed.
|
|
|
|
for (let i = hypertextAcc.linkCount - 1; i >= 0; i--) {
|
|
|
|
let link = hypertextAcc.getLinkAt(i);
|
2017-08-01 19:13:27 +03:00
|
|
|
let linkText = "";
|
2013-07-25 01:52:57 +04:00
|
|
|
if (link instanceof Ci.nsIAccessibleText) {
|
|
|
|
linkText = link.QueryInterface(Ci.nsIAccessibleText).
|
2014-08-06 17:38:56 +04:00
|
|
|
getText(0,
|
|
|
|
Ci.nsIAccessibleText.TEXT_OFFSET_END_OF_TEXT);
|
2013-07-25 01:52:57 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
let start = link.startIndex;
|
|
|
|
let end = link.endIndex;
|
2017-08-01 19:13:27 +03:00
|
|
|
for (let offset of ["startOffset", "endOffset"]) {
|
2013-07-25 01:52:57 +04:00
|
|
|
if (this[offset] >= end) {
|
|
|
|
result[offset] += linkText.length - (end - start);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
result.text = result.text.substring(0, start) + linkText +
|
|
|
|
result.text.substring(end);
|
|
|
|
}
|
|
|
|
|
|
|
|
this._textAndAdjustedOffsets = result;
|
|
|
|
}
|
|
|
|
|
|
|
|
return this._textAndAdjustedOffsets;
|
|
|
|
},
|
|
|
|
|
2013-06-28 01:15:36 +04:00
|
|
|
/**
|
|
|
|
* Get a list of |aAccessible|'s ancestry up to the root.
|
|
|
|
* @param {nsIAccessible} aAccessible.
|
|
|
|
* @return {Array} Ancestry list.
|
|
|
|
*/
|
|
|
|
_getAncestry: function _getAncestry(aAccessible) {
|
|
|
|
let ancestry = [];
|
|
|
|
let parent = aAccessible;
|
2014-03-05 05:49:27 +04:00
|
|
|
try {
|
|
|
|
while (parent && (parent = parent.parent)) {
|
|
|
|
ancestry.push(parent);
|
|
|
|
}
|
2014-04-15 22:24:57 +04:00
|
|
|
} catch (x) {
|
2014-03-05 05:49:27 +04:00
|
|
|
// A defunct accessible will raise an exception geting parent.
|
2017-08-01 19:13:27 +03:00
|
|
|
Logger.debug("Failed to get parent:", x);
|
2013-06-28 01:15:36 +04:00
|
|
|
}
|
|
|
|
return ancestry.reverse();
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A list of the old accessible's ancestry.
|
|
|
|
*/
|
|
|
|
get oldAncestry() {
|
|
|
|
if (!this._oldAncestry) {
|
2013-08-21 20:40:06 +04:00
|
|
|
if (!this._oldAccessible || this._ignoreAncestry) {
|
2013-06-28 01:15:36 +04:00
|
|
|
this._oldAncestry = [];
|
|
|
|
} else {
|
|
|
|
this._oldAncestry = this._getAncestry(this._oldAccessible);
|
|
|
|
this._oldAncestry.push(this._oldAccessible);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return this._oldAncestry;
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A list of the current accessible's ancestry.
|
|
|
|
*/
|
|
|
|
get currentAncestry() {
|
|
|
|
if (!this._currentAncestry) {
|
2013-08-21 20:40:06 +04:00
|
|
|
this._currentAncestry = this._ignoreAncestry ? [] :
|
2013-10-14 23:56:19 +04:00
|
|
|
this._getAncestry(this.accessible);
|
2013-06-28 01:15:36 +04:00
|
|
|
}
|
|
|
|
return this._currentAncestry;
|
|
|
|
},
|
|
|
|
|
2013-04-05 02:16:37 +04:00
|
|
|
/*
|
|
|
|
* This is a list of the accessible's ancestry up to the common ancestor
|
|
|
|
* of the accessible and the old accessible. It is useful for giving the
|
|
|
|
* user context as to where they are in the heirarchy.
|
|
|
|
*/
|
|
|
|
get newAncestry() {
|
|
|
|
if (!this._newAncestry) {
|
2015-10-18 17:21:31 +03:00
|
|
|
this._newAncestry = this._ignoreAncestry ? [] :
|
|
|
|
this.currentAncestry.filter(
|
|
|
|
(currentAncestor, i) => currentAncestor !== this.oldAncestry[i]);
|
2013-04-05 02:16:37 +04:00
|
|
|
}
|
|
|
|
return this._newAncestry;
|
|
|
|
},
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Traverse the accessible's subtree in pre or post order.
|
|
|
|
* It only includes the accessible's visible chidren.
|
2013-06-11 00:31:17 +04:00
|
|
|
* Note: needSubtree is a function argument that can be used to determine
|
|
|
|
* whether aAccessible's subtree is required.
|
2013-04-05 02:16:37 +04:00
|
|
|
*/
|
2014-08-06 17:38:56 +04:00
|
|
|
_traverse: function* _traverse(aAccessible, aPreorder, aStop) {
|
2013-06-11 00:31:17 +04:00
|
|
|
if (aStop && aStop(aAccessible)) {
|
|
|
|
return;
|
|
|
|
}
|
2013-04-05 02:16:37 +04:00
|
|
|
let child = aAccessible.firstChild;
|
|
|
|
while (child) {
|
2018-07-04 17:18:43 +03:00
|
|
|
let include = true;
|
2013-08-21 20:40:06 +04:00
|
|
|
if (include) {
|
2013-06-11 00:31:17 +04:00
|
|
|
if (aPreorder) {
|
|
|
|
yield child;
|
2015-10-18 17:21:31 +03:00
|
|
|
for (let node of this._traverse(child, aPreorder, aStop)) {
|
|
|
|
yield node;
|
|
|
|
}
|
2013-06-11 00:31:17 +04:00
|
|
|
} else {
|
2015-10-18 17:21:31 +03:00
|
|
|
for (let node of this._traverse(child, aPreorder, aStop)) {
|
|
|
|
yield node;
|
|
|
|
}
|
2013-06-11 00:31:17 +04:00
|
|
|
yield child;
|
|
|
|
}
|
2013-04-05 02:16:37 +04:00
|
|
|
}
|
|
|
|
child = child.nextSibling;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2014-11-20 18:00:05 +03:00
|
|
|
/**
|
|
|
|
* Get interaction hints for the context ancestry.
|
|
|
|
* @return {Array} Array of interaction hints.
|
|
|
|
*/
|
|
|
|
get interactionHints() {
|
|
|
|
let hints = [];
|
|
|
|
this.newAncestry.concat(this.accessible).reverse().forEach(aAccessible => {
|
2017-08-01 19:13:27 +03:00
|
|
|
let hint = Utils.getAttributes(aAccessible)["moz-hint"];
|
2014-11-20 18:00:05 +03:00
|
|
|
if (hint) {
|
|
|
|
hints.push(hint);
|
|
|
|
} else if (aAccessible.actionCount > 0) {
|
|
|
|
hints.push({
|
2016-08-08 18:47:48 +03:00
|
|
|
string: Utils.AccService.getStringRole(
|
2018-10-19 15:55:39 +03:00
|
|
|
aAccessible.role).replace(/\s/g, "") + "-hint",
|
2014-11-20 18:00:05 +03:00
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
return hints;
|
|
|
|
},
|
|
|
|
|
2013-04-05 02:16:37 +04:00
|
|
|
/*
|
2013-06-11 00:31:17 +04:00
|
|
|
* A subtree generator function, used to generate a flattened
|
|
|
|
* list of the accessible's subtree in pre or post order.
|
2013-04-05 02:16:37 +04:00
|
|
|
* It only includes the accessible's visible chidren.
|
2013-06-11 00:31:17 +04:00
|
|
|
* @param {boolean} aPreorder A flag for traversal order. If true, traverse
|
|
|
|
* in preorder; if false, traverse in postorder.
|
|
|
|
* @param {function} aStop An optional function, indicating whether subtree
|
|
|
|
* traversal should stop.
|
2013-04-05 02:16:37 +04:00
|
|
|
*/
|
2013-06-11 00:31:17 +04:00
|
|
|
subtreeGenerator: function subtreeGenerator(aPreorder, aStop) {
|
2013-10-14 23:56:19 +04:00
|
|
|
return this._traverse(this.accessible, aPreorder, aStop);
|
2013-04-05 02:16:37 +04:00
|
|
|
},
|
|
|
|
|
2013-06-28 01:15:36 +04:00
|
|
|
getCellInfo: function getCellInfo(aAccessible) {
|
|
|
|
if (!this._cells) {
|
|
|
|
this._cells = new WeakMap();
|
|
|
|
}
|
|
|
|
|
|
|
|
let domNode = aAccessible.DOMNode;
|
|
|
|
if (this._cells.has(domNode)) {
|
|
|
|
return this._cells.get(domNode);
|
|
|
|
}
|
|
|
|
|
|
|
|
let cellInfo = {};
|
|
|
|
let getAccessibleCell = function getAccessibleCell(aAccessible) {
|
|
|
|
if (!aAccessible) {
|
|
|
|
return null;
|
|
|
|
}
|
2018-02-01 22:45:22 +03:00
|
|
|
if (![
|
2015-07-13 12:53:00 +03:00
|
|
|
Roles.CELL,
|
|
|
|
Roles.COLUMNHEADER,
|
|
|
|
Roles.ROWHEADER,
|
2018-10-19 15:55:39 +03:00
|
|
|
Roles.MATHML_CELL,
|
2018-02-01 22:45:22 +03:00
|
|
|
].includes(aAccessible.role)) {
|
2013-07-02 07:50:39 +04:00
|
|
|
return null;
|
2013-06-28 01:15:36 +04:00
|
|
|
}
|
|
|
|
try {
|
|
|
|
return aAccessible.QueryInterface(Ci.nsIAccessibleTableCell);
|
|
|
|
} catch (x) {
|
|
|
|
Logger.logException(x);
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
};
|
2014-08-06 17:38:56 +04:00
|
|
|
let getHeaders = function* getHeaders(aHeaderCells) {
|
2018-08-19 04:13:14 +03:00
|
|
|
for (let {name} of aHeaderCells.enumerate(Ci.nsIAccessible)) {
|
|
|
|
yield name;
|
2013-06-28 01:15:36 +04:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
cellInfo.current = getAccessibleCell(aAccessible);
|
|
|
|
|
|
|
|
if (!cellInfo.current) {
|
|
|
|
Logger.warning(aAccessible,
|
2017-08-01 19:13:27 +03:00
|
|
|
"does not support nsIAccessibleTableCell interface.");
|
2013-06-28 01:15:36 +04:00
|
|
|
this._cells.set(domNode, null);
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
let table = cellInfo.current.table;
|
|
|
|
if (table.isProbablyForLayout()) {
|
|
|
|
this._cells.set(domNode, null);
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
cellInfo.previous = null;
|
|
|
|
let oldAncestry = this.oldAncestry.reverse();
|
|
|
|
let ancestor = oldAncestry.shift();
|
|
|
|
while (!cellInfo.previous && ancestor) {
|
|
|
|
let cell = getAccessibleCell(ancestor);
|
|
|
|
if (cell && cell.table === table) {
|
|
|
|
cellInfo.previous = cell;
|
|
|
|
}
|
|
|
|
ancestor = oldAncestry.shift();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (cellInfo.previous) {
|
|
|
|
cellInfo.rowChanged = cellInfo.current.rowIndex !==
|
|
|
|
cellInfo.previous.rowIndex;
|
|
|
|
cellInfo.columnChanged = cellInfo.current.columnIndex !==
|
|
|
|
cellInfo.previous.columnIndex;
|
|
|
|
} else {
|
|
|
|
cellInfo.rowChanged = true;
|
|
|
|
cellInfo.columnChanged = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
cellInfo.rowExtent = cellInfo.current.rowExtent;
|
|
|
|
cellInfo.columnExtent = cellInfo.current.columnExtent;
|
|
|
|
cellInfo.columnIndex = cellInfo.current.columnIndex;
|
|
|
|
cellInfo.rowIndex = cellInfo.current.rowIndex;
|
|
|
|
|
|
|
|
cellInfo.columnHeaders = [];
|
|
|
|
if (cellInfo.columnChanged && cellInfo.current.role !==
|
2013-11-19 22:17:43 +04:00
|
|
|
Roles.COLUMNHEADER) {
|
2015-10-18 17:21:31 +03:00
|
|
|
cellInfo.columnHeaders = [...getHeaders(cellInfo.current.columnHeaderCells)];
|
2013-06-28 01:15:36 +04:00
|
|
|
}
|
|
|
|
cellInfo.rowHeaders = [];
|
2015-07-13 12:53:00 +03:00
|
|
|
if (cellInfo.rowChanged &&
|
|
|
|
(cellInfo.current.role === Roles.CELL ||
|
|
|
|
cellInfo.current.role === Roles.MATHML_CELL)) {
|
2015-10-18 17:21:31 +03:00
|
|
|
cellInfo.rowHeaders = [...getHeaders(cellInfo.current.rowHeaderCells)];
|
2013-06-28 01:15:36 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
this._cells.set(domNode, cellInfo);
|
|
|
|
return cellInfo;
|
|
|
|
},
|
|
|
|
|
2013-04-05 02:16:37 +04:00
|
|
|
get bounds() {
|
|
|
|
if (!this._bounds) {
|
2013-10-14 23:56:19 +04:00
|
|
|
this._bounds = Utils.getBounds(this.accessibleForBounds);
|
2013-04-05 02:16:37 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return this._bounds.clone();
|
|
|
|
},
|
|
|
|
|
|
|
|
_isDefunct: function _isDefunct(aAccessible) {
|
|
|
|
try {
|
2014-01-28 04:35:13 +04:00
|
|
|
return Utils.getState(aAccessible).contains(States.DEFUNCT);
|
2013-04-05 02:16:37 +04:00
|
|
|
} catch (x) {
|
|
|
|
return true;
|
|
|
|
}
|
2018-10-19 15:55:39 +03:00
|
|
|
},
|
2013-05-24 22:57:28 +04:00
|
|
|
};
|
|
|
|
|
2018-02-23 22:50:01 +03:00
|
|
|
function PrefCache(aName, aCallback, aRunCallbackNow) { // jshint ignore:line
|
2013-05-24 22:57:28 +04:00
|
|
|
this.name = aName;
|
|
|
|
this.callback = aCallback;
|
|
|
|
|
|
|
|
let branch = Services.prefs;
|
|
|
|
this.value = this._getValue(branch);
|
|
|
|
|
|
|
|
if (this.callback && aRunCallbackNow) {
|
|
|
|
try {
|
2014-10-15 01:42:50 +04:00
|
|
|
this.callback(this.name, this.value, true);
|
2013-05-24 22:57:28 +04:00
|
|
|
} catch (x) {
|
|
|
|
Logger.logException(x);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
branch.addObserver(aName, this, true);
|
2018-02-23 22:50:01 +03:00
|
|
|
}
|
2013-05-24 22:57:28 +04:00
|
|
|
|
|
|
|
PrefCache.prototype = {
|
|
|
|
_getValue: function _getValue(aBranch) {
|
2014-03-04 22:10:38 +04:00
|
|
|
try {
|
|
|
|
if (!this.type) {
|
|
|
|
this.type = aBranch.getPrefType(this.name);
|
|
|
|
}
|
|
|
|
switch (this.type) {
|
|
|
|
case Ci.nsIPrefBranch.PREF_STRING:
|
|
|
|
return aBranch.getCharPref(this.name);
|
|
|
|
case Ci.nsIPrefBranch.PREF_INT:
|
|
|
|
return aBranch.getIntPref(this.name);
|
|
|
|
case Ci.nsIPrefBranch.PREF_BOOL:
|
|
|
|
return aBranch.getBoolPref(this.name);
|
|
|
|
default:
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
} catch (x) {
|
|
|
|
// Pref does not exist.
|
|
|
|
return null;
|
2013-05-24 22:57:28 +04:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2014-08-06 17:38:56 +04:00
|
|
|
observe: function observe(aSubject) {
|
2013-05-24 22:57:28 +04:00
|
|
|
this.value = this._getValue(aSubject.QueryInterface(Ci.nsIPrefBranch));
|
2017-08-01 19:13:27 +03:00
|
|
|
Logger.info("pref changed", this.name, this.value);
|
2013-05-24 22:57:28 +04:00
|
|
|
if (this.callback) {
|
|
|
|
try {
|
2014-10-15 01:42:50 +04:00
|
|
|
this.callback(this.name, this.value, false);
|
2013-05-24 22:57:28 +04:00
|
|
|
} catch (x) {
|
|
|
|
Logger.logException(x);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2018-04-23 06:55:06 +03:00
|
|
|
QueryInterface: ChromeUtils.generateQI([Ci.nsIObserver,
|
2018-10-19 15:55:39 +03:00
|
|
|
Ci.nsISupportsWeakReference]),
|
2013-07-18 00:41:29 +04:00
|
|
|
};
|