Bug 347791 - expose accessible role and state as strings in Inspector, patch=vasiliy.potapenko, r=me,sdwilsh, sr=neil

This commit is contained in:
surkov.alexander@gmail.com 2007-07-11 00:51:07 -07:00
parent 70129c1bdc
commit 2fdd487028
9 changed files with 546 additions and 14 deletions

View File

@ -66,6 +66,8 @@ inspector.jar:
content/inspector/tests/allskin.xul (resources/content/tests/allskin.xul)
content/inspector/viewers/accessibleObject/accessibleObject.js (resources/content/viewers/accessibleObject/accessibleObject.js)
content/inspector/viewers/accessibleObject/accessibleObject.xul (resources/content/viewers/accessibleObject/accessibleObject.xul)
content/inspector/viewers/accessibleProps/accessibleProps.js (resources/content/viewers/accessibleProps/accessibleProps.js)
content/inspector/viewers/accessibleProps/accessibleProps.xul (resources/content/viewers/accessibleProps/accessibleProps.xul)
content/inspector/viewers/computedStyle/computedStyle.js (resources/content/viewers/computedStyle/computedStyle.js)
content/inspector/viewers/computedStyle/computedStyle.xul (resources/content/viewers/computedStyle/computedStyle.xul)
content/inspector/viewers/dom/FindDialog.js (resources/content/viewers/dom/FindDialog.js)

View File

@ -113,6 +113,29 @@
]]></ins:filter>
</rdf:Description>
</rdf:li>
<rdf:li>
<rdf:Description ins:uid="accessibleProps"
ins:panels="bxObjectPanel bxObjPanel"
ins:description="Accessible Properties">
<ins:filter><![CDATA[
if (!linkedViewer || linkedViewer.uid != "dom" ||
!linkedViewer.getAccessibleNodes() ||
!(object instanceof Components.interfaces.nsIDOMNode))
return false;
try {
var accService =
Components.classes["@mozilla.org/accessibleRetrieval;1"]
.getService(Components.interfaces.nsIAccessibleRetrieval);
return accService.getAttachedAccessibleFor(object);
} catch(e) {
return false;
}
]]></ins:filter>
</rdf:Description>
</rdf:li>
</rdf:Seq>
</rdf:RDF>

View File

@ -0,0 +1,231 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is DOM Inspector.
*
* The Initial Developer of the Original Code is
* Alexander Surkov.
* Portions created by the Initial Developer are Copyright (C) 2006
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Alexander Surkov <surkov.alexander@gmail.com> (original author)
* Vasiliy Potapenko <vasiliy.potapenko@gmail.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
///////////////////////////////////////////////////////////////////////////////
//// Global Variables
var viewer;
///////////////////////////////////////////////////////////////////////////////
//// Initialization/Destruction
window.addEventListener("load", AccessiblePropsViewer_initialize, false);
function AccessiblePropsViewer_initialize()
{
viewer = new AccessiblePropsViewer();
viewer.initialize(parent.FrameExchange.receiveData(window));
}
///////////////////////////////////////////////////////////////////////////////
//// class AccessiblePropsViewer
function AccessiblePropsViewer()
{
this.mURL = window.location;
this.mObsMan = new ObserverManager(this);
this.mAccService = Components.classes["@mozilla.org/accessibleRetrieval;1"]
.getService(Components.interfaces.nsIAccessibleRetrieval);
}
AccessiblePropsViewer.prototype =
{
mSubject: null,
mPane: null,
mAccSubject: null,
mAccService: null,
get uid() { return "accessibleProps" },
get pane() { return this.mPane },
get subject() { return this.mSubject },
set subject(aObject)
{
this.mSubject = aObject;
this.updateView();
this.mObsMan.dispatchEvent("subjectChange", { subject: aObject });
},
initialize: function initialize(aPane)
{
this.mPane = aPane;
aPane.notifyViewerReady(this);
},
isCommandEnabled: function isCommandEnabled(aCommand)
{
return false;
},
getCommand: function getCommand(aCommand)
{
return null;
},
destroy: function destroy() {},
// event dispatching
addObserver: function addObserver(aEvent, aObserver)
{
this.mObsMan.addObserver(aEvent, aObserver);
},
removeObserver: function removeObserver(aEvent, aObserver)
{
this.mObsMan.removeObserver(aEvent, aObserver);
},
// private
updateView: function updateView()
{
this.clearView();
try {
this.mAccSubject = this.mAccService.getAccessibleFor(this.mSubject);
} catch(e) {
dump("Failed to get accessible object for node.");
return;
}
var containers = document.getElementsByAttribute("prop", "*");
for (var i = 0; i < containers.length; ++i) {
var value = "";
try {
var prop = containers[i].getAttribute("prop");
value = this[prop];
} catch (e) {
dump("Accessibility " + prop + " property is not available.\n");
}
if (value instanceof Array)
containers[i].textContent = value.join(", ");
else
containers[i].textContent = value;
}
var attrs = this.mAccSubject.attributes;
if (attrs) {
var enumerate = attrs.enumerate();
while (enumerate.hasMoreElements())
this.addAccessibleAttribute(enumerate.getNext());
}
},
addAccessibleAttribute: function addAccessibleAttribute(aElement)
{
var prop = aElement.QueryInterface(Components.interfaces.nsIPropertyElement);
var trAttrBody = document.getElementById("trAttrBody");
var ti = document.createElement("treeitem");
var tr = document.createElement("treerow");
var tc = document.createElement("treecell");
tc.setAttribute("label", prop.key);
tr.appendChild(tc);
tc = document.createElement("treecell");
tc.setAttribute("label", prop.value);
tr.appendChild(tc);
ti.appendChild(tr);
trAttrBody.appendChild(ti);
},
removeAccessibleAttributes: function removeAccessibleAttributes()
{
var trAttrBody = document.getElementById("trAttrBody");
while (trAttrBody.hasChildNodes())
trAttrBody.removeChild(trAttrBody.lastChild)
},
clearView: function clearView()
{
var containers = document.getElementsByAttribute("prop", "*");
for (var i = 0; i < containers.length; ++i)
containers[i].textContent = "";
this.removeAccessibleAttributes();
},
get role()
{
return this.mAccService.getStringRole(this.mAccSubject.finalRole);
},
get name()
{
return this.mAccSubject.name;
},
get description()
{
return this.mAccSubject.description;
},
get value()
{
return this.mAccSubject.value;
},
get state()
{
var stateObj = {value: null};
var extStateObj = {value: null};
this.mAccSubject.getFinalState(stateObj, extStateObj);
var list = [];
states = this.mAccService.getStringStates(stateObj.value, extStateObj.value);
for (var i = 0; i < states.length; i++)
list.push(states.item(i));
return list;
},
get actionNames()
{
var list = [];
var count = this.mAccSubject.numActions;
for (var i = 0; i < count; i++)
list.push(this.mAccSubject.getActionName(i));
return list;
}
};

View File

@ -0,0 +1,99 @@
<?xml version="1.0"?>
<!-- ***** BEGIN LICENSE BLOCK *****
- Version: MPL 1.1/GPL 2.0/LGPL 2.1
-
- The contents of this file are subject to the Mozilla Public License Version
- 1.1 (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
- http://www.mozilla.org/MPL/
-
- Software distributed under the License is distributed on an "AS IS" basis,
- WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- for the specific language governing rights and limitations under the
- License.
-
- The Original Code is DOM Inspector.
-
- The Initial Developer of the Original Code is
- Alexander Surkov.
- Portions created by the Initial Developer are Copyright (C) 2006
- the Initial Developer. All Rights Reserved.
-
- Contributor(s):
- Alexander Surkov <surkov.alexander@gmail.com> (original author)
- Vasiliy Potapenko <vasiliy.potapenko@gmail.com>
-
- Alternatively, the contents of this file may be used under the terms of
- either the GNU General Public License Version 2 or later (the "GPL"), or
- the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- in which case the provisions of the GPL or the LGPL are applicable instead
- of those above. If you wish to allow use of your version of this file only
- under the terms of either the GPL or the LGPL, and not to allow others to
- use your version of this file under the terms of the MPL, indicate your
- decision by deleting the provisions above and replace them with the notice
- and other provisions required by the GPL or the LGPL. If you do not delete
- the provisions above, a recipient may use your version of this file under
- the terms of any one of the MPL, the GPL or the LGPL.
-
- ***** END LICENSE BLOCK ***** -->
<!DOCTYPE page [
<!ENTITY % dtd1 SYSTEM "chrome://inspector/locale/inspector.dtd"> %dtd1;
<!ENTITY % dtd2 SYSTEM "chrome://inspector/content/util.dtd"> %dtd2;
<!ENTITY % dtd3 SYSTEM "chrome://inspector/locale/viewers/accessibleProps.dtd"> %dtd3;
]>
<?xml-stylesheet href="chrome://inspector/skin"?>
<page id="winAccessibleProps"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script type="application/javascript"
src="chrome://inspector/content/jsutil/xpcom/XPCU.js"/>
<script type="application/javascript"
src="chrome://inspector/content/jsutil/events/ObserverManager.js"/>
<script type="application/javascript"
src="chrome://inspector/content/viewers/accessibleProps/accessibleProps.js"/>
<grid>
<columns>
<column/>
<column flex="1"/>
</columns>
<rows>
<row>
<description>&descRole.label;</description>
<description prop="role"/>
</row>
<row>
<description>&descName.label;</description>
<description prop="name"/>
</row>
<row>
<description>&descDescription.label;</description>
<description prop="description"/>
</row>
<row>
<description>&descValue.label;</description>
<description prop="value"/>
</row>
<row>
<description>&descState.label;</description>
<description prop="state"/>
</row>
<row>
<description>&descActionName.label;</description>
<description prop="actionNames"/>
</row>
</rows>
</grid>
<tree flex="1">
<treecols>
<treecol label="attrKey" flex="1"/>
<treecol label="attrValue" flex="2"/>
</treecols>
<treechildren id="trAttrBody"/>
</tree>
</page>

View File

@ -0,0 +1,44 @@
<!-- ***** BEGIN LICENSE BLOCK *****
#if 0
- Version: MPL 1.1/GPL 2.0/LGPL 2.1
-
- The contents of this file are subject to the Mozilla Public License Version
- 1.1 (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
- http://www.mozilla.org/MPL/
-
- Software distributed under the License is distributed on an "AS IS" basis,
- WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- for the specific language governing rights and limitations under the
- License.
-
- The Original Code is DOM Inspector.
-
- The Initial Developer of the Original Code is
- Vasiliy Potapenko
- Portions created by the Initial Developer are Copyright (C) 2007
- the Initial Developer. All Rights Reserved.
-
- Contributor(s):
- Vasiliy Potapenko <vasiliy.potapenko@gmail.com>
-
- Alternatively, the contents of this file may be used under the terms of
- either the GNU General Public License Version 2 or later (the "GPL"), or
- the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- in which case the provisions of the GPL or the LGPL are applicable instead
- of those above. If you wish to allow use of your version of this file only
- under the terms of either the GPL or the LGPL, and not to allow others to
- use your version of this file under the terms of the MPL, indicate your
- decision by deleting the provisions above and replace them with the notice
- and other provisions required by the LGPL or the GPL. If you do not delete
- the provisions above, a recipient may use your version of this file under
- the terms of any one of the MPL, the GPL or the LGPL.
-
#endif
- ***** END LICENSE BLOCK ***** -->
<!ENTITY descRole.label "Role:">
<!ENTITY descName.label "Name:">
<!ENTITY descDescription.label "Description:">
<!ENTITY descValue.label "Value:">
<!ENTITY descState.label "State:">
<!ENTITY descActionName.label "Action Name:">

View File

@ -0,0 +1,44 @@
<!-- ***** BEGIN LICENSE BLOCK *****
#if 0
- Version: MPL 1.1/GPL 2.0/LGPL 2.1
-
- The contents of this file are subject to the Mozilla Public License Version
- 1.1 (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
- http://www.mozilla.org/MPL/
-
- Software distributed under the License is distributed on an "AS IS" basis,
- WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- for the specific language governing rights and limitations under the
- License.
-
- The Original Code is DOM Inspector.
-
- The Initial Developer of the Original Code is
- Vasiliy Potapenko
- Portions created by the Initial Developer are Copyright (C) 2007
- the Initial Developer. All Rights Reserved.
-
- Contributor(s):
- Vasiliy Potapenko <vasiliy.potapenko@gmail.com>
-
- Alternatively, the contents of this file may be used under the terms of
- either the GNU General Public License Version 2 or later (the "GPL"), or
- the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- in which case the provisions of the GPL or the LGPL are applicable instead
- of those above. If you wish to allow use of your version of this file only
- under the terms of either the GPL or the LGPL, and not to allow others to
- use your version of this file under the terms of the MPL, indicate your
- decision by deleting the provisions above and replace them with the notice
- and other provisions required by the LGPL or the GPL. If you do not delete
- the provisions above, a recipient may use your version of this file under
- the terms of any one of the MPL, the GPL or the LGPL.
-
#endif
- ***** END LICENSE BLOCK ***** -->
<!ENTITY descRole.label "Role:">
<!ENTITY descName.label "Name:">
<!ENTITY descDescription.label "Description:">
<!ENTITY descValue.label "Value:">
<!ENTITY descState.label "State:">
<!ENTITY descActionName.label "Action Name:">

View File

@ -2,17 +2,18 @@
inspector.jar:
% locale inspector @AB_CD@ %locale/@AB_CD@/inspector/
* locale/@AB_CD@/inspector/contents.rdf (contents.rdf)
locale/@AB_CD@/inspector/inspector.dtd (@AB_CD@/inspector.dtd)
locale/@AB_CD@/inspector/prefs.dtd (@AB_CD@/prefs.dtd)
locale/@AB_CD@/inspector/editing.dtd (@AB_CD@/editing.dtd)
locale/@AB_CD@/inspector/tasksOverlay.dtd (@AB_CD@/tasksOverlay.dtd)
* locale/@AB_CD@/inspector/viewers/dom.dtd (@AB_CD@/viewers/dom.dtd)
* locale/@AB_CD@/inspector/viewers/domNode.dtd (@AB_CD@/viewers/domNode.dtd)
* locale/@AB_CD@/inspector/viewers/styleRules.dtd (@AB_CD@/viewers/styleRules.dtd)
* locale/@AB_CD@/inspector/viewers/stylesheets.dtd (@AB_CD@/viewers/stylesheets.dtd)
* locale/@AB_CD@/inspector/viewers/xblBindings.dtd (@AB_CD@/viewers/xblBindings.dtd)
* locale/@AB_CD@/inspector/viewers/boxModel.dtd (@AB_CD@/viewers/boxModel.dtd)
* locale/@AB_CD@/inspector/viewers/computedStyle.dtd (@AB_CD@/viewers/computedStyle.dtd)
* locale/@AB_CD@/inspector/viewers/jsObject.dtd (@AB_CD@/viewers/jsObject.dtd)
* locale/@AB_CD@/inspector/inspector.properties (@AB_CD@/inspector.properties)
* locale/@AB_CD@/inspector/contents.rdf (contents.rdf)
locale/@AB_CD@/inspector/inspector.dtd (@AB_CD@/inspector.dtd)
locale/@AB_CD@/inspector/prefs.dtd (@AB_CD@/prefs.dtd)
locale/@AB_CD@/inspector/editing.dtd (@AB_CD@/editing.dtd)
locale/@AB_CD@/inspector/tasksOverlay.dtd (@AB_CD@/tasksOverlay.dtd)
* locale/@AB_CD@/inspector/viewers/accessibleProps.dtd (@AB_CD@/viewers/accessibleProps.dtd)
* locale/@AB_CD@/inspector/viewers/dom.dtd (@AB_CD@/viewers/dom.dtd)
* locale/@AB_CD@/inspector/viewers/domNode.dtd (@AB_CD@/viewers/domNode.dtd)
* locale/@AB_CD@/inspector/viewers/styleRules.dtd (@AB_CD@/viewers/styleRules.dtd)
* locale/@AB_CD@/inspector/viewers/stylesheets.dtd (@AB_CD@/viewers/stylesheets.dtd)
* locale/@AB_CD@/inspector/viewers/xblBindings.dtd (@AB_CD@/viewers/xblBindings.dtd)
* locale/@AB_CD@/inspector/viewers/boxModel.dtd (@AB_CD@/viewers/boxModel.dtd)
* locale/@AB_CD@/inspector/viewers/computedStyle.dtd (@AB_CD@/viewers/computedStyle.dtd)
* locale/@AB_CD@/inspector/viewers/jsObject.dtd (@AB_CD@/viewers/jsObject.dtd)
* locale/@AB_CD@/inspector/inspector.properties (@AB_CD@/inspector.properties)

View File

@ -0,0 +1,44 @@
<!-- ***** BEGIN LICENSE BLOCK *****
#if 0
- Version: MPL 1.1/GPL 2.0/LGPL 2.1
-
- The contents of this file are subject to the Mozilla Public License Version
- 1.1 (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
- http://www.mozilla.org/MPL/
-
- Software distributed under the License is distributed on an "AS IS" basis,
- WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- for the specific language governing rights and limitations under the
- License.
-
- The Original Code is DOM Inspector.
-
- The Initial Developer of the Original Code is
- Vasiliy Potapenko
- Portions created by the Initial Developer are Copyright (C) 2007
- the Initial Developer. All Rights Reserved.
-
- Contributor(s):
- Vasiliy Potapenko <vasiliy.potapenko@gmail.com>
-
- Alternatively, the contents of this file may be used under the terms of
- either the GNU General Public License Version 2 or later (the "GPL"), or
- the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- in which case the provisions of the GPL or the LGPL are applicable instead
- of those above. If you wish to allow use of your version of this file only
- under the terms of either the GPL or the LGPL, and not to allow others to
- use your version of this file under the terms of the MPL, indicate your
- decision by deleting the provisions above and replace them with the notice
- and other provisions required by the LGPL or the GPL. If you do not delete
- the provisions above, a recipient may use your version of this file under
- the terms of any one of the MPL, the GPL or the LGPL.
-
#endif
- ***** END LICENSE BLOCK ***** -->
<!ENTITY descRole.label "Role:">
<!ENTITY descName.label "Name:">
<!ENTITY descDescription.label "Description:">
<!ENTITY descValue.label "Value:">
<!ENTITY descState.label "State:">
<!ENTITY descActionName.label "Action Name:">

View File

@ -0,0 +1,44 @@
<!-- ***** BEGIN LICENSE BLOCK *****
#if 0
- Version: MPL 1.1/GPL 2.0/LGPL 2.1
-
- The contents of this file are subject to the Mozilla Public License Version
- 1.1 (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
- http://www.mozilla.org/MPL/
-
- Software distributed under the License is distributed on an "AS IS" basis,
- WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- for the specific language governing rights and limitations under the
- License.
-
- The Original Code is DOM Inspector.
-
- The Initial Developer of the Original Code is
- Vasiliy Potapenko
- Portions created by the Initial Developer are Copyright (C) 2007
- the Initial Developer. All Rights Reserved.
-
- Contributor(s):
- Vasiliy Potapenko <vasiliy.potapenko@gmail.com>
-
- Alternatively, the contents of this file may be used under the terms of
- either the GNU General Public License Version 2 or later (the "GPL"), or
- the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- in which case the provisions of the GPL or the LGPL are applicable instead
- of those above. If you wish to allow use of your version of this file only
- under the terms of either the GPL or the LGPL, and not to allow others to
- use your version of this file under the terms of the MPL, indicate your
- decision by deleting the provisions above and replace them with the notice
- and other provisions required by the LGPL or the GPL. If you do not delete
- the provisions above, a recipient may use your version of this file under
- the terms of any one of the MPL, the GPL or the LGPL.
-
#endif
- ***** END LICENSE BLOCK ***** -->
<!ENTITY descRole.label "Role:">
<!ENTITY descName.label "Name:">
<!ENTITY descDescription.label "Description:">
<!ENTITY descValue.label "Value:">
<!ENTITY descState.label "State:">
<!ENTITY descActionName.label "Action Name:">