mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-26 14:22:01 +00:00
Bug 337674. Make it possible to inspect accessibles (nsIAccessible) objects. Patch thanks to Alexander Surkov. r=timeless, sr=neil
This commit is contained in:
parent
76317a1b0e
commit
083e28aa17
@ -76,6 +76,8 @@ inspector.jar:
|
||||
content/inspector/search/modules/junkImgs/dialog.xul (resources/content/search/modules/junkImgs/dialog.xul)
|
||||
content/inspector/search/modules/junkImgs/junkImgs.xml (resources/content/search/modules/junkImgs/junkImgs.xml)
|
||||
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/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)
|
||||
@ -93,6 +95,8 @@ inspector.jar:
|
||||
content/inspector/viewers/boxModel/boxModel.xul (resources/content/viewers/boxModel/boxModel.xul)
|
||||
content/inspector/viewers/jsObject/jsObject.js (resources/content/viewers/jsObject/jsObject.js)
|
||||
content/inspector/viewers/jsObject/jsObject.xul (resources/content/viewers/jsObject/jsObject.xul)
|
||||
content/inspector/viewers/jsObject/jsObjectViewer.js (resources/content/viewers/jsObject/jsObjectViewer.js)
|
||||
content/inspector/viewers/jsObject/jsObjectViewer.xul (resources/content/viewers/jsObject/jsObjectViewer.xul)
|
||||
content/inspector/viewers/jsObject/evalExprDialog.js (resources/content/viewers/jsObject/evalExprDialog.js)
|
||||
content/inspector/viewers/jsObject/evalExprDialog.xul (resources/content/viewers/jsObject/evalExprDialog.xul)
|
||||
content/inspector/viewers/domNode/domNode.js (resources/content/viewers/domNode/domNode.js)
|
||||
|
@ -99,17 +99,17 @@ ViewerRegistry.prototype =
|
||||
this.mObserver.onViewerRegistryLoad();
|
||||
},
|
||||
|
||||
prepareRegistry: function()
|
||||
prepareRegistry: function prepareRegistry()
|
||||
{
|
||||
this.mViewerDS = RDFArray.fromContainer(this.mDS, "inspector:viewers", kInspectorNSURI);
|
||||
|
||||
|
||||
// create and cache the filter functions
|
||||
var js, fn;
|
||||
this.mFilters = [];
|
||||
for (var i = 0; i < this.mViewerDS.length; ++i) {
|
||||
js = this.getEntryProperty(i, "filter");
|
||||
try {
|
||||
fn = new Function("object", js);
|
||||
fn = new Function("object", "linkedViewer", js);
|
||||
} catch (ex) {
|
||||
fn = new Function("return false");
|
||||
debug("### ERROR - Syntax error in filter for viewer \"" + this.getEntryProperty(i, "description") + "\"\n");
|
||||
@ -132,15 +132,18 @@ ViewerRegistry.prototype =
|
||||
|
||||
//// Lookup Methods
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// Searches the viewer registry for all viewers that can view a particular
|
||||
// object.
|
||||
//
|
||||
// @param Object aObject - the object being searched against
|
||||
// @param String aPanelId - the id of the panel requesting viewers
|
||||
// @return nsIRDFResource[] - array of entries in the viewer registry
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
findViewersForObject: function(aObject, aPanelId)
|
||||
/**
|
||||
* Searches the viewer registry for all viewers that can view a particular
|
||||
* object.
|
||||
*
|
||||
* @param Object aObject - the object being searched against
|
||||
* @param String aPanelId - the id of the panel requesting viewers
|
||||
* @param Object aLinkedViewer - the view object of linked panel
|
||||
*
|
||||
* @return nsIRDFResource[] - array of entries in the viewer registry
|
||||
*/
|
||||
findViewersForObject: function findViewersForObject(aObject, aPanelId,
|
||||
aLinkedViewer)
|
||||
{
|
||||
// check each entry in the registry
|
||||
var len = this.mViewerDS.length;
|
||||
@ -150,9 +153,9 @@ ViewerRegistry.prototype =
|
||||
if (this.getEntryProperty(i, "panels").indexOf(aPanelId) == -1) {
|
||||
continue;
|
||||
}
|
||||
if (this.objectMatchesEntry(aObject, i)) {
|
||||
if (this.objectMatchesEntry(aObject, aLinkedViewer, i)) {
|
||||
if (this.getEntryProperty(i, "important")) {
|
||||
urls.unshift(i);
|
||||
urls.unshift(i);
|
||||
} else {
|
||||
urls.push(i);
|
||||
}
|
||||
@ -162,16 +165,19 @@ ViewerRegistry.prototype =
|
||||
return urls;
|
||||
},
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// Determines if an object is eligible to be viewed by a particular viewer.
|
||||
//
|
||||
// @param Object aObject - the object being checked for eligibility
|
||||
// @param long aIndex - the index of the entry
|
||||
// @return boolean - true if object can be viewed
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
objectMatchesEntry: function(aObject, aIndex)
|
||||
/**
|
||||
* Determines if an object is eligible to be viewed by a particular viewer.
|
||||
*
|
||||
* @param Object aObject - the object being checked for eligibility
|
||||
* @param Object aLinkedViewer - the view object of linked panel
|
||||
* @param long aIndex - the index of the entry
|
||||
*
|
||||
* @return boolean - true if object can be viewed
|
||||
*/
|
||||
objectMatchesEntry: function objectMatchesEntry(aObject, aLinkedViewer,
|
||||
aIndex)
|
||||
{
|
||||
return this.mFilters[aIndex](aObject);
|
||||
return this.mFilters[aIndex](aObject, aLinkedViewer);
|
||||
},
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
@ -129,6 +129,13 @@ InspectorApp.prototype =
|
||||
document.getElementById("cmdToggleChrome").setAttribute("checked",
|
||||
PrefUtils.getPref("inspector.showChrome"));
|
||||
|
||||
// check if accessibility service is available
|
||||
var cmd = document.getElementById("cmd:toggleAccessibleNodes");
|
||||
if (cmd) {
|
||||
if (!("@mozilla.org/accessibilityService;1" in Components.classes))
|
||||
cmd.setAttribute("disabled", "true");
|
||||
}
|
||||
|
||||
if (aURI) {
|
||||
this.gotoURL(aURI);
|
||||
}
|
||||
|
@ -572,6 +572,7 @@
|
||||
</property>
|
||||
|
||||
<field name="mLinkedPanel">null</field>
|
||||
<field name="mLinkedViewer">null</field>
|
||||
<field name="mCurrentViewer">null</field>
|
||||
<field name="mCurrentEntry">null</field>
|
||||
|
||||
@ -661,7 +662,8 @@
|
||||
this.mParams = null;
|
||||
|
||||
// get the list of viewers which match the node
|
||||
var entries = this.registry.findViewersForObject(aObject, this.id);
|
||||
var entries = this.registry.findViewersForObject(aObject, this.id,
|
||||
this.mLinkedViewer);
|
||||
this.rebuildViewerList(entries);
|
||||
|
||||
if (entries.length == 0) {
|
||||
|
@ -43,4 +43,5 @@ pref("inspector.blink.speed", 100);
|
||||
pref("inspector.blink.invert", false);
|
||||
pref("inspector.dom.showAnon", true);
|
||||
pref("inspector.dom.showWhitespaceNodes", true);
|
||||
pref("inspector.dom.showAccessibleNodes", false);
|
||||
pref("inspector.showChrome", false);
|
||||
|
@ -20,10 +20,17 @@
|
||||
ins:icon This sets an icon for the viewer. Currently unused.
|
||||
|
||||
ins:filter This determines which nodes (or in the case of JavaScript Object
|
||||
viewer, values), the viewer referenced is valid for. For example,
|
||||
ins:filter="return object instanceof Components.interfaces.nsIDOMDocument;"
|
||||
is a JavaScript fragment ViewerRegistry.js uses to define a filter
|
||||
function if the panel's subject node is an instance of nsIDOMDocument.
|
||||
viewer, values), the viewer referenced is valid for.
|
||||
|
||||
@param object - nsIDOMNode object (or in the case of JavaScript
|
||||
Object viewer, JavaScript object).
|
||||
@param linkedViewer - linked viewer object.
|
||||
|
||||
For example, ins:filter=
|
||||
"return object instanceof Components.interfaces.nsIDOMDocument;"
|
||||
is a JavaScript fragment ViewerRegistry.js uses to define a
|
||||
filter function if the panel's subject node is an instance of
|
||||
nsIDOMDocument.
|
||||
-->
|
||||
|
||||
<rdf:Seq about="inspector:viewers">
|
||||
@ -84,6 +91,27 @@
|
||||
ins:filter="return true;"/>
|
||||
</rdf:li>
|
||||
|
||||
<rdf:li>
|
||||
<rdf:Description ins:uid="accessibleObject"
|
||||
ins:panels="bxObjectPanel bxObjPanel"
|
||||
ins:description="Accessible Object">
|
||||
<ins:filter><![CDATA[
|
||||
if (!linkedViewer || linkedViewer.uid != "dom" ||
|
||||
!linkedViewer.getAccessibleNodes() ||
|
||||
!(object instanceof Components.interfaces.nsIDOMNode))
|
||||
return false;
|
||||
|
||||
try {
|
||||
var accService =
|
||||
Components.classes['@mozilla.org/accessibilityService;1']
|
||||
.getService(Components.interfaces.nsIAccessibilityService);
|
||||
return accService.getAccessibleFor(object);
|
||||
} catch(e) {
|
||||
return false;
|
||||
}
|
||||
]]></ins:filter>
|
||||
</rdf:Description>
|
||||
</rdf:li>
|
||||
</rdf:Seq>
|
||||
|
||||
</rdf:RDF>
|
||||
|
@ -0,0 +1,97 @@
|
||||
/* ***** 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
|
||||
* Mozilla Foundation.
|
||||
* 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)
|
||||
*
|
||||
* 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 ***** */
|
||||
|
||||
/***************************************************************
|
||||
* AccessibleObjectViewer --------------------------------------------
|
||||
* The viewer for the accessible object.
|
||||
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
* REQUIRED IMPORTS:
|
||||
* chrome://inspector/content/jsutil/events/ObserverManager.js
|
||||
****************************************************************/
|
||||
|
||||
//////////// global variables /////////////////////
|
||||
|
||||
var viewer;
|
||||
var bundle;
|
||||
var accService;
|
||||
|
||||
//////////// global constants ////////////////////
|
||||
//////////////////////////////////////////////////
|
||||
|
||||
window.addEventListener("load", AccessibleObjectViewer_initialize, false);
|
||||
|
||||
function AccessibleObjectViewer_initialize()
|
||||
{
|
||||
bundle = document.getElementById("inspector-bundle");
|
||||
accService = Components.classes['@mozilla.org/accessibilityService;1']
|
||||
.getService(Components.interfaces.nsIAccessibilityService);
|
||||
|
||||
viewer = new JSObjectViewer();
|
||||
|
||||
viewer.__defineGetter__(
|
||||
"uid",
|
||||
function uidGetter()
|
||||
{
|
||||
return "accessibleObject";
|
||||
}
|
||||
);
|
||||
|
||||
viewer.__defineSetter__(
|
||||
"subject",
|
||||
function subjectSetter(aObject)
|
||||
{
|
||||
var accObject = null;
|
||||
try {
|
||||
accObject = accService.getAccessibleFor(aObject);
|
||||
} catch(e) {
|
||||
dump("Failed to get accessible object for node.");
|
||||
}
|
||||
|
||||
this.mSubject = accObject;
|
||||
this.emptyTree(this.mTreeKids);
|
||||
var ti = this.addTreeItem(this.mTreeKids,
|
||||
bundle.getString("root.title"),
|
||||
accObject,
|
||||
accObject);
|
||||
ti.setAttribute("open", "true");
|
||||
|
||||
this.mObsMan.dispatchEvent("subjectChange", { subject: accObject });
|
||||
}
|
||||
);
|
||||
|
||||
viewer.initialize(parent.FrameExchange.receiveData(window));
|
||||
}
|
@ -0,0 +1,53 @@
|
||||
<?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
|
||||
- Mozilla Foundation.
|
||||
- Portions created by the Initial Developer are Copyright (C) 2006
|
||||
- the Initial Developer. All Rights Reserved.
|
||||
-
|
||||
- Contributor(s):
|
||||
- Alexander Surkov <surkov.alexander@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 ***** -->
|
||||
|
||||
<?xul-overlay href="chrome://inspector/content/viewers/jsObject/jsObjectViewer.xul"?>
|
||||
|
||||
<page id="winAccessibleObject"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
||||
|
||||
<script type="application/javascript"
|
||||
src="chrome://inspector/content/viewers/accessibleObject/accessibleObject.js"/>
|
||||
|
||||
<stringbundle id="inspector-bundle"/>
|
||||
<commandset id="cmdsJSObjectViewer"/>
|
||||
|
||||
<popup id="popupContext"/>
|
||||
<tree id="treeJSObject"/>
|
||||
</page>
|
@ -23,6 +23,9 @@
|
||||
<command id="cmd:toggleSubDocs" viewer="dom"
|
||||
oncommand="inspector.getViewer('dom').toggleSubDocs()"/>
|
||||
|
||||
<command id="cmd:toggleAccessibleNodes" viewer="dom"
|
||||
oncommand="inspector.getViewer('dom').toggleAccessibleNodes(true);"/>
|
||||
|
||||
<command id="cmd:toggleWhitespaceNodes" viewer="dom"
|
||||
oncommand="inspector.getViewer('dom').toggleWhitespaceNodes()"/>
|
||||
|
||||
|
@ -134,6 +134,7 @@ DOMViewer.prototype =
|
||||
aPane.notifyViewerReady(this);
|
||||
|
||||
this.setAnonContent(PrefUtils.getPref("inspector.dom.showAnon"), false);
|
||||
this.setAccessibleNodes(PrefUtils.getPref("inspector.dom.showAccessibleNodes"), false);
|
||||
this.setWhitespaceNodes(PrefUtils.getPref("inspector.dom.showWhitespaceNodes"));
|
||||
this.setFlashSelected(PrefUtils.getPref("inspector.blink.on"));
|
||||
},
|
||||
@ -288,6 +289,46 @@ DOMViewer.prototype =
|
||||
this.mPanel.panelset.setCommandAttribute("cmd:toggleSubDocs", "checked", val);
|
||||
},
|
||||
|
||||
/**
|
||||
* Toggle state of 'Show Accessible Nodes' option.
|
||||
*
|
||||
* @param Boolean aRebuild - if true then DOM nodes tree will be rebuilded.
|
||||
*/
|
||||
toggleAccessibleNodes: function toggleAccessibleNodes(aRebuild)
|
||||
{
|
||||
this.setAccessibleNodes(!this.getAccessibleNodes(), aRebuild);
|
||||
},
|
||||
|
||||
/**
|
||||
* Set state of 'Show Accessible Nodes' option.
|
||||
*
|
||||
* @param Boolean aValue - if true then accessible nodes will be shown
|
||||
* @param Boolean aRebuild - if true then DOM nodes tree will be rebuilded.
|
||||
*/
|
||||
setAccessibleNodes: function setAccessibleNodes(aValue, aRebuild)
|
||||
{
|
||||
if (!("@mozilla.org/accessibilityService;1" in Components.classes))
|
||||
aValue = false;
|
||||
|
||||
this.mDOMView.showAccessibleNodes = aValue;
|
||||
this.mPanel.panelset.setCommandAttribute("cmd:toggleAccessibleNodes",
|
||||
"checked", aValue);
|
||||
PrefUtils.setPref("inspector.dom.showAccessibleNodes", aValue);
|
||||
|
||||
if (aRebuild) {
|
||||
this.rebuild();
|
||||
}
|
||||
this.onItemSelected();
|
||||
},
|
||||
|
||||
/**
|
||||
* Return state of 'Show Accessible Nodes' option.
|
||||
*/
|
||||
getAccessibleNodes: function getAccessibleNodes()
|
||||
{
|
||||
return this.mDOMView.showAccessibleNodes;
|
||||
},
|
||||
|
||||
setWhitespaceNodes: function(aValue)
|
||||
{
|
||||
// Do this first so we ensure the checkmark is set in the case
|
||||
|
@ -34,6 +34,13 @@
|
||||
accesskey="&cmdToggleAnonContent.accesskey;"
|
||||
observes="cmd:toggleAnon"/>
|
||||
|
||||
<menuitem id="item:toggleAccessibleNodes"
|
||||
class="menuitem-iconic"
|
||||
type="checkbox"
|
||||
label="&cmdToggleAccessibleNodes.label;"
|
||||
accesskey="&cmdToggleAccessibleNodes.accesskey;"
|
||||
observes="cmd:toggleAccessibleNodes"/>
|
||||
|
||||
<menuitem id="item:toggleWhitespaceNodes"
|
||||
class="menuitem-iconic"
|
||||
type="checkbox"
|
||||
@ -79,6 +86,13 @@
|
||||
accesskey="&cmdToggleAnonContent.accesskey;"
|
||||
observes="cmd:toggleAnon"/>
|
||||
|
||||
<menuitem id="item:toggleAccessibleNodes"
|
||||
class="menuitem-iconic"
|
||||
type="checkbox"
|
||||
label="&cmdToggleAccessibleNodes.label;"
|
||||
accesskey="&cmdToggleAccessibleNodes.accesskey;"
|
||||
observes="cmd:toggleAccessibleNodes"/>
|
||||
|
||||
<menuitem id="item:toggleWhitespaceNodes"
|
||||
class="menuitem-iconic"
|
||||
type="checkbox"
|
||||
|
@ -48,10 +48,6 @@
|
||||
var viewer;
|
||||
var bundle;
|
||||
|
||||
//////////// global constants ////////////////////
|
||||
|
||||
const kClipboardHelperCID = "@mozilla.org/widget/clipboardhelper;1";
|
||||
|
||||
//////////////////////////////////////////////////
|
||||
|
||||
window.addEventListener("load", JSObjectViewer_initialize, false);
|
||||
@ -62,231 +58,3 @@ function JSObjectViewer_initialize()
|
||||
viewer = new JSObjectViewer();
|
||||
viewer.initialize(parent.FrameExchange.receiveData(window));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//// class JSObjectViewer
|
||||
|
||||
function JSObjectViewer()
|
||||
{
|
||||
this.mObsMan = new ObserverManager(this);
|
||||
}
|
||||
|
||||
JSObjectViewer.prototype =
|
||||
{
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//// Initialization
|
||||
|
||||
mSubject: null,
|
||||
mPane: null,
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//// interface inIViewer
|
||||
|
||||
get uid() { return "jsObject" },
|
||||
get pane() { return this.mPane },
|
||||
|
||||
get selection() { return this.mSelection },
|
||||
|
||||
get subject() { return this.mSubject },
|
||||
set subject(aObject)
|
||||
{
|
||||
this.mSubject = aObject;
|
||||
this.emptyTree(this.mTreeKids);
|
||||
var ti = this.addTreeItem(this.mTreeKids, bundle.getString("root.title"), aObject, aObject);
|
||||
ti.setAttribute("open", "true");
|
||||
|
||||
this.mObsMan.dispatchEvent("subjectChange", { subject: aObject });
|
||||
},
|
||||
|
||||
initialize: function(aPane)
|
||||
{
|
||||
this.mPane = aPane;
|
||||
this.mTree = document.getElementById("treeJSObject");
|
||||
this.mTreeKids = document.getElementById("trchJSObject");
|
||||
|
||||
aPane.notifyViewerReady(this);
|
||||
},
|
||||
|
||||
destroy: function()
|
||||
{
|
||||
},
|
||||
|
||||
isCommandEnabled: function(aCommand)
|
||||
{
|
||||
return false;
|
||||
},
|
||||
|
||||
getCommand: function(aCommand)
|
||||
{
|
||||
return null;
|
||||
},
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//// event dispatching
|
||||
|
||||
addObserver: function(aEvent, aObserver) { this.mObsMan.addObserver(aEvent, aObserver); },
|
||||
removeObserver: function(aEvent, aObserver) { this.mObsMan.removeObserver(aEvent, aObserver); },
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//// UI Commands
|
||||
|
||||
cmdCopyValue: function()
|
||||
{
|
||||
var sel = getSelectedItem();
|
||||
if (sel) {
|
||||
var val = sel.__JSValue__;
|
||||
if (val) {
|
||||
var helper = XPCU.getService(kClipboardHelperCID, "nsIClipboardHelper");
|
||||
helper.copyString(val);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
cmdEvalExpr: function()
|
||||
{
|
||||
var sel = getSelectedItem();
|
||||
if (sel) {
|
||||
var win = openDialog("chrome://inspector/content/viewers/jsObject/evalExprDialog.xul",
|
||||
"_blank", "chrome", this, sel);
|
||||
}
|
||||
},
|
||||
|
||||
doEvalExpr: function(aExpr, aItem, aNewView)
|
||||
{
|
||||
// TODO: I should really write some C++ code to execute the
|
||||
// js code in the js context of the inspected window
|
||||
|
||||
try {
|
||||
var f = Function("target", aExpr);
|
||||
var result = f(aItem.__JSValue__);
|
||||
|
||||
if (result) {
|
||||
if (aNewView) {
|
||||
inspectObject(result);
|
||||
} else {
|
||||
this.subject = result;
|
||||
}
|
||||
}
|
||||
} catch (ex) {
|
||||
dump("Error in expression.\n");
|
||||
throw (ex);
|
||||
}
|
||||
},
|
||||
|
||||
cmdInspectInNewView: function()
|
||||
{
|
||||
var sel = getSelectedItem();
|
||||
if (sel)
|
||||
inspectObject(sel.__JSValue__);
|
||||
},
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//// tree construction
|
||||
|
||||
emptyTree: function(aTreeKids)
|
||||
{
|
||||
while (aTreeKids.hasChildNodes()) {
|
||||
aTreeKids.removeChild(aTreeKids.lastChild);
|
||||
}
|
||||
},
|
||||
|
||||
buildPropertyTree: function(aTreeChildren, aObject)
|
||||
{
|
||||
for (var prop in aObject) {
|
||||
try {
|
||||
this.addTreeItem(aTreeChildren, prop, aObject[prop], aObject);
|
||||
} catch (ex) {
|
||||
// hide unsightly NOT YET IMPLEMENTED errors when accessing certain properties
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
addTreeItem: function(aTreeChildren, aName, aValue, aObject)
|
||||
{
|
||||
var ti = document.createElement("treeitem");
|
||||
ti.__JSObject__ = aObject;
|
||||
ti.__JSValue__ = aValue;
|
||||
|
||||
var value;
|
||||
if (aValue === null) {
|
||||
value = "(null)";
|
||||
} else if (aValue === undefined) {
|
||||
value = "(undefined)";
|
||||
} else {
|
||||
try {
|
||||
value = aValue.toString();
|
||||
value = value.replace(/\n|\r|\t|\v/g, " ");
|
||||
} catch (ex) {
|
||||
value = "";
|
||||
}
|
||||
}
|
||||
|
||||
ti.setAttribute("typeOf", typeof(aValue));
|
||||
|
||||
if (typeof(aValue) == "object" && aValue !== null) {
|
||||
ti.setAttribute("container", "true");
|
||||
} else if (typeof(aValue) == "string")
|
||||
value = "\"" + value + "\"";
|
||||
|
||||
var tr = document.createElement("treerow");
|
||||
ti.appendChild(tr);
|
||||
|
||||
var tc = document.createElement("treecell");
|
||||
tc.setAttribute("label", aName);
|
||||
tr.appendChild(tc);
|
||||
tc = document.createElement("treecell");
|
||||
tc.setAttribute("label", value);
|
||||
if (aValue === null) {
|
||||
tc.setAttribute("class", "inspector-null-value-treecell");
|
||||
}
|
||||
if (aName == "nodeType")
|
||||
tc.setAttribute("tooltiptext", nodeTypeToText(aValue));
|
||||
tr.appendChild(tc);
|
||||
|
||||
aTreeChildren.appendChild(ti);
|
||||
|
||||
// listen for changes to open attribute
|
||||
this.mTreeKids.addEventListener("DOMAttrModified", onTreeItemAttrModified, false);
|
||||
|
||||
return ti;
|
||||
},
|
||||
|
||||
openTreeItem: function(aItem)
|
||||
{
|
||||
var treechildren = aItem.getElementsByTagName("treechildren").item(0);
|
||||
if (!treechildren) {
|
||||
treechildren = document.createElement("treechildren");
|
||||
this.buildPropertyTree(treechildren, aItem.__JSValue__);
|
||||
aItem.appendChild(treechildren);
|
||||
}
|
||||
},
|
||||
|
||||
onCreateContext: function(aPopup)
|
||||
{
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
function onTreeItemAttrModified(aEvent)
|
||||
{
|
||||
if (aEvent.attrName == "open")
|
||||
viewer.openTreeItem(aEvent.target);
|
||||
}
|
||||
|
||||
function getSelectedItem()
|
||||
{
|
||||
var tree = document.getElementById("treeJSObject");
|
||||
if (tree.view.selection.count)
|
||||
return tree.contentView.getItemAtIndex(tree.currentIndex);
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
function toggleItem(aItem)
|
||||
{
|
||||
var tree = document.getElementById("treeJSObject");
|
||||
var row = tree.currentView.getIndexOfItem(aItem);
|
||||
if (row >= 0) {
|
||||
tree.view.toggleOpenState(row);
|
||||
}
|
||||
}
|
||||
|
@ -1,47 +1,15 @@
|
||||
<?xml version="1.0"?>
|
||||
|
||||
<!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/jsObject.dtd"> %dtd3;
|
||||
]>
|
||||
|
||||
<?xml-stylesheet href="chrome://inspector/skin/"?>
|
||||
<?xul-overlay href="chrome://inspector/content/viewers/jsObject/jsObjectViewer.xul"?>
|
||||
|
||||
<page id="winJSObject"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
||||
|
||||
<script type="application/x-javascript" src="chrome://inspector/content/viewers/jsObject/jsObject.js"/>
|
||||
<script type="application/x-javascript" src="chrome://inspector/content/jsutil/xpcom/XPCU.js"/>
|
||||
<script type="application/x-javascript" src="chrome://inspector/content/jsutil/events/ObserverManager.js"/>
|
||||
<script type="application/x-javascript" src="chrome://inspector/content/hooks.js"/>
|
||||
<script type="application/x-javascript" src="chrome://inspector/content/utils.js"/>
|
||||
|
||||
<stringbundle id="inspector-bundle" src="chrome://inspector/locale/inspector.properties"/>
|
||||
|
||||
<commandset>
|
||||
<command id="cmdCopyValue" oncommand="viewer.cmdCopyValue()"/>
|
||||
<command id="cmdEvalExpr" oncommand="viewer.cmdEvalExpr()"/>
|
||||
<command id="cmdInspectInNewView" oncommand="viewer.cmdInspectInNewView()"/>
|
||||
</commandset>
|
||||
|
||||
<popupset>
|
||||
<popup id="popupContext">
|
||||
<menuitem label="&inspectNewWindow.label;" observes="cmdInspectInNewView"/>
|
||||
<menuseparator/>
|
||||
<menuitem label="&jsCopyValue.label;" observes="cmdCopyValue"/>
|
||||
<menuitem label="&jsEval.label;" observes="cmdEvalExpr"/>
|
||||
</popup>
|
||||
</popupset>
|
||||
|
||||
<tree id="treeJSObject" flex="1" context="popupContext">
|
||||
<treecols>
|
||||
<treecol id="colProp" flex="1" primary="true" label="&jsProperty.label;"/>
|
||||
<splitter class="tree-splitter"/>
|
||||
<treecol id="colVal" flex="1" label="&jsValue.label;"/>
|
||||
</treecols>
|
||||
|
||||
<treechildren id="trchJSObject"/>
|
||||
</tree>
|
||||
<stringbundle id="inspector-bundle"/>
|
||||
<commandset id="cmdsJSObjectViewer"/>
|
||||
|
||||
<popup id="popupContext"/>
|
||||
<tree id="treeJSObject"/>
|
||||
</page>
|
||||
|
@ -43,26 +43,10 @@
|
||||
* chrome://inspector/content/jsutil/xpcom/XPCU.js
|
||||
****************************************************************/
|
||||
|
||||
//////////// global variables /////////////////////
|
||||
|
||||
var viewer;
|
||||
var bundle;
|
||||
|
||||
//////////// global constants ////////////////////
|
||||
|
||||
const kClipboardHelperCID = "@mozilla.org/widget/clipboardhelper;1";
|
||||
|
||||
//////////////////////////////////////////////////
|
||||
|
||||
window.addEventListener("load", JSObjectViewer_initialize, false);
|
||||
|
||||
function JSObjectViewer_initialize()
|
||||
{
|
||||
bundle = document.getElementById("inspector-bundle");
|
||||
viewer = new JSObjectViewer();
|
||||
viewer.initialize(parent.FrameExchange.receiveData(window));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//// class JSObjectViewer
|
||||
|
||||
|
@ -0,0 +1,87 @@
|
||||
<?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
|
||||
- Netscape Communications Corporation.
|
||||
- Portions created by the Initial Developer are Copyright (C) 2001
|
||||
- the Initial Developer. All Rights Reserved.
|
||||
-
|
||||
- Contributor(s):
|
||||
- Joe Hewitt <hewitt@netscape.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/jsObject.dtd"> %dtd3;
|
||||
]>
|
||||
|
||||
<?xml-stylesheet href="chrome://inspector/skin/inspector.css"?>
|
||||
|
||||
<overlay xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
||||
|
||||
<script type="application/javascript"
|
||||
src="chrome://inspector/content/viewers/jsObject/jsObjectViewer.js"/>
|
||||
<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/hooks.js"/>
|
||||
<script type="application/javascript"
|
||||
src="chrome://inspector/content/utils.js"/>
|
||||
|
||||
<stringbundle id="inspector-bundle"
|
||||
src="chrome://inspector/locale/inspector.properties"/>
|
||||
|
||||
<commandset id="cmdsJSObjectViewer">
|
||||
<command id="cmdCopyValue" oncommand="viewer.cmdCopyValue();"/>
|
||||
<command id="cmdEvalExpr" oncommand="viewer.cmdEvalExpr();"/>
|
||||
<command id="cmdInspectInNewView"
|
||||
oncommand="viewer.cmdInspectInNewView();"/>
|
||||
</commandset>
|
||||
|
||||
<popup id="popupContext">
|
||||
<menuitem label="&inspectNewWindow.label;" observes="cmdInspectInNewView"/>
|
||||
<menuseparator/>
|
||||
<menuitem label="&jsCopyValue.label;" observes="cmdCopyValue"/>
|
||||
<menuitem label="&jsEval.label;" observes="cmdEvalExpr"/>
|
||||
</popup>
|
||||
|
||||
<tree id="treeJSObject" flex="1" context="popupContext">
|
||||
<treecols>
|
||||
<treecol id="colProp" flex="1" primary="true" label="&jsProperty.label;"/>
|
||||
<splitter class="tree-splitter"/>
|
||||
<treecol id="colVal" flex="1" label="&jsValue.label;"/>
|
||||
</treecols>
|
||||
|
||||
<treechildren id="trchJSObject"/>
|
||||
</tree>
|
||||
</overlay>
|
@ -52,6 +52,9 @@
|
||||
<!ENTITY cmdToggleWhitespaceNodes.label "Mostra els nodes d'espais blancs">
|
||||
<!ENTITY cmdToggleWhitespaceNodes.accesskey "b">
|
||||
|
||||
<!ENTITY cmdToggleAccessibleNodes.label "Show Accessible Nodes">
|
||||
<!ENTITY cmdToggleAccessibleNodes.accesskey "c">
|
||||
|
||||
<!ENTITY cmdFlashSelected.label "Marca l'element seleccionat">
|
||||
|
||||
<!ENTITY cmdToggleAttributes.label "Mostra els atributs">
|
||||
|
@ -44,6 +44,8 @@
|
||||
<!ENTITY cmdToggleAnonContent.accesskey "a">
|
||||
<!ENTITY cmdToggleWhitespaceNodes.label "Zobrazit prázdné uzly">
|
||||
<!ENTITY cmdToggleWhitespaceNodes.accesskey "p">
|
||||
<!ENTITY cmdToggleAccessibleNodes.label "Show Accessible Nodes">
|
||||
<!ENTITY cmdToggleAccessibleNodes.accesskey "c">
|
||||
<!ENTITY cmdFlashSelected.label "Zvýraznit vybraný prvek">
|
||||
<!ENTITY cmdToggleAttributes.label "Zobrazit atributy">
|
||||
<!ENTITY cmdToggleAttributes.accesskey "r">
|
||||
|
@ -49,6 +49,9 @@
|
||||
<!ENTITY cmdToggleWhitespaceNodes.label "Vis blanke noder">
|
||||
<!ENTITY cmdToggleWhitespaceNodes.accesskey "b">
|
||||
|
||||
<!ENTITY cmdToggleAccessibleNodes.label "Show Accessible Nodes">
|
||||
<!ENTITY cmdToggleAccessibleNodes.accesskey "c">
|
||||
|
||||
<!ENTITY cmdFlashSelected.label "Blink valgte element">
|
||||
|
||||
<!ENTITY cmdToggleAttributes.label "Vis attributer">
|
||||
|
@ -49,6 +49,9 @@
|
||||
<!ENTITY cmdToggleWhitespaceNodes.label "Leere Textknoten anzeigen">
|
||||
<!ENTITY cmdToggleWhitespaceNodes.accesskey "x">
|
||||
|
||||
<!ENTITY cmdToggleAccessibleNodes.label "Show Accessible Nodes">
|
||||
<!ENTITY cmdToggleAccessibleNodes.accesskey "c">
|
||||
|
||||
<!ENTITY cmdFlashSelected.label "Ausgewähltes Element blinken lassen">
|
||||
|
||||
<!ENTITY cmdToggleAttributes.label "Attribute anzeigen">
|
||||
|
@ -47,6 +47,9 @@
|
||||
<!ENTITY cmdToggleWhitespaceNodes.label "Προβολή Whitespace Nodes">
|
||||
<!ENTITY cmdToggleWhitespaceNodes.accesskey "W">
|
||||
|
||||
<!ENTITY cmdToggleAccessibleNodes.label "Show Accessible Nodes">
|
||||
<!ENTITY cmdToggleAccessibleNodes.accesskey "c">
|
||||
|
||||
<!ENTITY cmdFlashSelected.label "Αναβόσβημα επιλεγμένου στοιχείου">
|
||||
|
||||
<!ENTITY cmdToggleAttributes.label "Προβολή γνωρισμάτων">
|
||||
|
@ -49,6 +49,9 @@
|
||||
<!ENTITY cmdToggleWhitespaceNodes.label "Show Whitespace Nodes">
|
||||
<!ENTITY cmdToggleWhitespaceNodes.accesskey "W">
|
||||
|
||||
<!ENTITY cmdToggleAccessibleNodes.label "Show Accessible Nodes">
|
||||
<!ENTITY cmdToggleAccessibleNodes.accesskey "c">
|
||||
|
||||
<!ENTITY cmdFlashSelected.label "Blink Selected Element">
|
||||
|
||||
<!ENTITY cmdToggleAttributes.label "Show Attributes">
|
||||
|
@ -49,6 +49,9 @@
|
||||
<!ENTITY cmdToggleWhitespaceNodes.label "Voir les nœuds vides">
|
||||
<!ENTITY cmdToggleWhitespaceNodes.accesskey "V">
|
||||
|
||||
<!ENTITY cmdToggleAccessibleNodes.label "Show Accessible Nodes">
|
||||
<!ENTITY cmdToggleAccessibleNodes.accesskey "c">
|
||||
|
||||
<!ENTITY cmdFlashSelected.label "Faire clignoter l'élément sélectionné">
|
||||
|
||||
<!ENTITY cmdToggleAttributes.label "Afficher les attributs">
|
||||
|
@ -44,6 +44,8 @@
|
||||
<!ENTITY cmdToggleAnonContent.accesskey "A">
|
||||
<!ENTITY cmdToggleWhitespaceNodes.label "Taispeáin Nóid Spáis Bháin">
|
||||
<!ENTITY cmdToggleWhitespaceNodes.accesskey "B">
|
||||
<!ENTITY cmdToggleAccessibleNodes.label "Show Accessible Nodes">
|
||||
<!ENTITY cmdToggleAccessibleNodes.accesskey "c">
|
||||
<!ENTITY cmdFlashSelected.label "Cuir Eilimint Roghnaithe ag Caochadh">
|
||||
<!ENTITY cmdToggleAttributes.label "Taispeáin Aitreabúidí">
|
||||
<!ENTITY cmdToggleAttributes.accesskey "r">
|
||||
|
@ -49,6 +49,9 @@
|
||||
<!ENTITY cmdToggleWhitespaceNodes.label "Üres csomópontok megjelenítése">
|
||||
<!ENTITY cmdToggleWhitespaceNodes.accesskey "r">
|
||||
|
||||
<!ENTITY cmdToggleAccessibleNodes.label "Show Accessible Nodes">
|
||||
<!ENTITY cmdToggleAccessibleNodes.accesskey "c">
|
||||
|
||||
<!ENTITY cmdFlashSelected.label "Kijelölt elem villogtatása">
|
||||
|
||||
<!ENTITY cmdToggleAttributes.label "Attribútumok megjelenítése">
|
||||
|
@ -49,6 +49,9 @@
|
||||
<!ENTITY cmdToggleWhitespaceNodes.label "Vis blanke noder">
|
||||
<!ENTITY cmdToggleWhitespaceNodes.accesskey "b">
|
||||
|
||||
<!ENTITY cmdToggleAccessibleNodes.label "Show Accessible Nodes">
|
||||
<!ENTITY cmdToggleAccessibleNodes.accesskey "c">
|
||||
|
||||
<!ENTITY cmdFlashSelected.label "Blink valgt element">
|
||||
|
||||
<!ENTITY cmdToggleAttributes.label "Vis egenskaper">
|
||||
|
@ -49,6 +49,9 @@
|
||||
<!ENTITY cmdToggleWhitespaceNodes.label "Pokaż węzły zawierające niewidoczne znaki">
|
||||
<!ENTITY cmdToggleWhitespaceNodes.accesskey "W">
|
||||
|
||||
<!ENTITY cmdToggleAccessibleNodes.label "Show Accessible Nodes">
|
||||
<!ENTITY cmdToggleAccessibleNodes.accesskey "c">
|
||||
|
||||
<!ENTITY cmdFlashSelected.label "Wyróżnij wybrany element">
|
||||
|
||||
<!ENTITY cmdToggleAttributes.label "Pokaż atrybuty">
|
||||
|
@ -50,6 +50,9 @@
|
||||
<!ENTITY cmdToggleWhitespaceNodes.label "Exibir nós de espaços em branco">
|
||||
<!ENTITY cmdToggleWhitespaceNodes.accesskey "x">
|
||||
|
||||
<!ENTITY cmdToggleAccessibleNodes.label "Show Accessible Nodes">
|
||||
<!ENTITY cmdToggleAccessibleNodes.accesskey "c">
|
||||
|
||||
<!ENTITY cmdFlashSelected.label "Piscar elemento selecionado">
|
||||
|
||||
<!ENTITY cmdToggleAttributes.label "Exibir atributos">
|
||||
|
@ -23,6 +23,8 @@
|
||||
<!ENTITY cmdToggleAttributes.label "Показать атрибуты">
|
||||
<!ENTITY cmdToggleWhitespaceNodes.accesskey "П">
|
||||
<!ENTITY cmdToggleWhitespaceNodes.label "Показывать пробельные узлы">
|
||||
<!ENTITY cmdToggleAccessibleNodes.label "Show Accessible Nodes">
|
||||
<!ENTITY cmdToggleAccessibleNodes.accesskey "c">
|
||||
<!ENTITY findNodes.title "Найти узлы">
|
||||
<!ENTITY findNodesByAttr.label "Атрибут">
|
||||
<!ENTITY findNodesByAttrValue.label "Значение">
|
||||
|
@ -49,6 +49,9 @@
|
||||
<!ENTITY cmdToggleWhitespaceNodes.label "Zobraziť prázdne uzly">
|
||||
<!ENTITY cmdToggleWhitespaceNodes.accesskey "p">
|
||||
|
||||
<!ENTITY cmdToggleAccessibleNodes.label "Show Accessible Nodes">
|
||||
<!ENTITY cmdToggleAccessibleNodes.accesskey "c">
|
||||
|
||||
<!ENTITY cmdFlashSelected.label "Zvýrazniť vybratý prvok">
|
||||
|
||||
<!ENTITY cmdToggleAttributes.label "Zobraziť atribúty">
|
||||
|
@ -50,6 +50,9 @@
|
||||
<!ENTITY cmdToggleWhitespaceNodes.label "Visa tomma noder">
|
||||
<!ENTITY cmdToggleWhitespaceNodes.accesskey "t">
|
||||
|
||||
<!ENTITY cmdToggleAccessibleNodes.label "Show Accessible Nodes">
|
||||
<!ENTITY cmdToggleAccessibleNodes.accesskey "c">
|
||||
|
||||
<!ENTITY cmdFlashSelected.label "Blinka med det markerade elementet">
|
||||
|
||||
<!ENTITY cmdToggleAttributes.label "Visa attribut">
|
||||
|
@ -23,6 +23,8 @@
|
||||
<!ENTITY cmdToggleAttributes.label "显示属性">
|
||||
<!ENTITY cmdToggleWhitespaceNodes.accesskey "W">
|
||||
<!ENTITY cmdToggleWhitespaceNodes.label "显示空白节点">
|
||||
<!ENTITY cmdToggleAccessibleNodes.label "Show Accessible Nodes">
|
||||
<!ENTITY cmdToggleAccessibleNodes.accesskey "c">
|
||||
<!ENTITY findNodes.title "查找节点">
|
||||
<!ENTITY findNodesByAttr.label "属性">
|
||||
<!ENTITY findNodesByAttrValue.label "值">
|
||||
|
@ -8,6 +8,8 @@
|
||||
<!ENTITY cmdToggleAnonContent.accesskey "a">
|
||||
<!ENTITY cmdToggleWhitespaceNodes.label "顯示空白節點">
|
||||
<!ENTITY cmdToggleWhitespaceNodes.accesskey "W">
|
||||
<!ENTITY cmdToggleAccessibleNodes.label "Show Accessible Nodes">
|
||||
<!ENTITY cmdToggleAccessibleNodes.accesskey "c">
|
||||
<!ENTITY cmdFlashSelected.label "閃爍已選項目">
|
||||
<!ENTITY cmdToggleAttributes.label "顯示屬性">
|
||||
<!ENTITY cmdToggleAttributes.accesskey "r">
|
||||
|
@ -39,6 +39,10 @@
|
||||
|
||||
/* :::::::: node type color coding :::::::: */
|
||||
|
||||
treechildren::-moz-tree-cell-text(ACCESSIBLE_NODE) {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
treechildren::-moz-tree-cell-text(ELEMENT_NODE) {
|
||||
color: #000000;
|
||||
}
|
||||
|
@ -39,6 +39,10 @@
|
||||
|
||||
/* :::::::: node type color coding :::::::: */
|
||||
|
||||
treechildren::-moz-tree-cell-text(ACCESSIBLE_NODE) {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
treechildren::-moz-tree-cell-text(ELEMENT_NODE) {
|
||||
color: #000000;
|
||||
}
|
||||
|
@ -39,7 +39,7 @@
|
||||
|
||||
interface nsIDOMNode;
|
||||
|
||||
[scriptable, uuid(3EB4C760-DFFD-4983-94A8-18BCB99100E4)]
|
||||
[scriptable, uuid(FBB67442-27A3-483C-8EB2-29C3EED7514C)]
|
||||
interface inIDOMView : nsISupports
|
||||
{
|
||||
attribute nsIDOMNode rootNode;
|
||||
@ -47,6 +47,7 @@ interface inIDOMView : nsISupports
|
||||
attribute boolean showAnonymousContent;
|
||||
attribute boolean showSubDocuments;
|
||||
attribute boolean showWhitespaceNodes;
|
||||
attribute boolean showAccessibleNodes;
|
||||
attribute unsigned long whatToShow;
|
||||
|
||||
nsIDOMNode getNodeFromRowIndex(in long rowIndex);
|
||||
|
@ -61,6 +61,10 @@ REQUIRES = xpcom \
|
||||
webshell \
|
||||
$(NULL)
|
||||
|
||||
ifdef ACCESSIBILITY
|
||||
REQUIRES += accessibility
|
||||
endif
|
||||
|
||||
CPPSRCS= \
|
||||
inDOMView.cpp \
|
||||
inDeepTreeWalker.cpp \
|
||||
|
@ -57,6 +57,11 @@
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsITreeColumns.h"
|
||||
|
||||
#ifdef ACCESSIBILITY
|
||||
#include "nsIAccessible.h"
|
||||
#include "nsIAccessibilityService.h"
|
||||
#endif
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// inDOMViewNode
|
||||
|
||||
@ -113,11 +118,13 @@ nsIAtom* inDOMView::kDocumentNodeAtom = nsnull;
|
||||
nsIAtom* inDOMView::kDocumentTypeNodeAtom = nsnull;
|
||||
nsIAtom* inDOMView::kDocumentFragmentNodeAtom = nsnull;
|
||||
nsIAtom* inDOMView::kNotationNodeAtom = nsnull;
|
||||
nsIAtom* inDOMView::kAccessibleNodeAtom = nsnull;
|
||||
|
||||
inDOMView::inDOMView() :
|
||||
mShowAnonymous(PR_FALSE),
|
||||
mShowSubDocuments(PR_FALSE),
|
||||
mShowWhitespaceNodes(PR_TRUE),
|
||||
mShowAccessibleNodes(PR_FALSE),
|
||||
mWhatToShow(nsIDOMNodeFilter::SHOW_ALL)
|
||||
{
|
||||
}
|
||||
@ -140,7 +147,8 @@ inDOMView::~inDOMView()
|
||||
{"DOCUMENT_NODE", &inDOMView::kDocumentNodeAtom},
|
||||
{"DOCUMENT_TYPE_NODE", &inDOMView::kDocumentTypeNodeAtom},
|
||||
{"DOCUMENT_FRAGMENT_NODE", &inDOMView::kDocumentFragmentNodeAtom},
|
||||
{"NOTATION_NODE", &inDOMView::kNotationNodeAtom}
|
||||
{"NOTATION_NODE", &inDOMView::kNotationNodeAtom},
|
||||
{"ACCESSIBLE_NODE", &inDOMView::kAccessibleNodeAtom}
|
||||
};
|
||||
|
||||
/* static */ void
|
||||
@ -279,6 +287,20 @@ inDOMView::SetShowWhitespaceNodes(PRBool aShowWhitespaceNodes)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
inDOMView::GetShowAccessibleNodes(PRBool *aShowAccessibleNodes)
|
||||
{
|
||||
*aShowAccessibleNodes = mShowAccessibleNodes;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
inDOMView::SetShowAccessibleNodes(PRBool aShowAccessibleNodes)
|
||||
{
|
||||
mShowAccessibleNodes = aShowAccessibleNodes;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
inDOMView::GetWhatToShow(PRUint32 *aWhatToShow)
|
||||
{
|
||||
@ -370,6 +392,21 @@ inDOMView::GetCellProperties(PRInt32 row, nsITreeColumn* col, nsISupportsArray *
|
||||
properties->AppendElement(kNotationNodeAtom);
|
||||
break;
|
||||
}
|
||||
|
||||
#ifdef ACCESSIBILITY
|
||||
if (mShowAccessibleNodes) {
|
||||
nsCOMPtr<nsIAccessibilityService> accService(
|
||||
do_GetService("@mozilla.org/accessibilityService;1"));
|
||||
NS_ENSURE_TRUE(accService, NS_ERROR_FAILURE);
|
||||
|
||||
nsCOMPtr<nsIAccessible> accessible;
|
||||
nsresult rv = accService->GetAccessibleFor(node->node,
|
||||
getter_AddRefs(accessible));
|
||||
if (accessible)
|
||||
properties->AppendElement(kAccessibleNodeAtom);
|
||||
}
|
||||
#endif
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -83,6 +83,7 @@ protected:
|
||||
static nsIAtom* kDocumentTypeNodeAtom;
|
||||
static nsIAtom* kDocumentFragmentNodeAtom;
|
||||
static nsIAtom* kNotationNodeAtom;
|
||||
static nsIAtom* kAccessibleNodeAtom;
|
||||
|
||||
static const nsStaticAtom Atoms_info[];
|
||||
|
||||
@ -93,6 +94,7 @@ protected:
|
||||
PRPackedBool mShowAnonymous;
|
||||
PRPackedBool mShowSubDocuments;
|
||||
PRPackedBool mShowWhitespaceNodes;
|
||||
PRPackedBool mShowAccessibleNodes;
|
||||
PRUint32 mWhatToShow;
|
||||
|
||||
nsCOMPtr<nsIDOMNode> mRootNode;
|
||||
|
Loading…
Reference in New Issue
Block a user