Bug 413605 - allow to use JS for the selected accessible in the accessibleTree view, r=sdwilsh, sr=neil, a=mconnor

This commit is contained in:
surkov.alexander@gmail.com 2008-02-05 22:49:43 -08:00
Родитель 5533ef53f6
Коммит 24f6ea8503
9 изменённых файлов: 270 добавлений и 28 удалений

Просмотреть файл

@ -76,6 +76,8 @@ inspector.jar:
content/inspector/viewers/accessibleRelations/accessibleRelations.xul (resources/content/viewers/accessibleRelations/accessibleRelations.xul)
content/inspector/viewers/accessibleTree/accessibleTree.js (resources/content/viewers/accessibleTree/accessibleTree.js)
content/inspector/viewers/accessibleTree/accessibleTree.xul (resources/content/viewers/accessibleTree/accessibleTree.xul)
content/inspector/viewers/accessibleTree/evalJSDialog.js (resources/content/viewers/accessibleTree/evalJSDialog.js)
content/inspector/viewers/accessibleTree/evalJSDialog.xul (resources/content/viewers/accessibleTree/evalJSDialog.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)

Просмотреть файл

@ -45,14 +45,7 @@ VPATH=@srcdir@
include $(DEPTH)/config/autoconf.mk
ALL_LOCALES = \
cs \
de \
en-US \
fr \
pl \
ru \
sk \
sv-SE \
$(NULL)
include $(topsrcdir)/config/config.mk

Просмотреть файл

@ -136,6 +136,23 @@ AccessibleTreeViewer.prototype =
this.mObsMan.removeObserver(aEvent, aObserver);
},
// UI commands
cmdEvalJS: function cmdEvalJS()
{
var sel = this.getSelectedAccessible();
if (sel) {
var win = openDialog("chrome://inspector/content/viewers/accessibleTree/evalJSDialog.xul",
"_blank", "chrome,resizable=yes", sel);
}
},
cmdInspectInNewView: function cmdInspectInNewView()
{
var sel = this.getSelectedAccessible();
if (sel)
inspectObject(sel);
},
// stuff
onItemSelected: function onItemSelected()
@ -144,7 +161,13 @@ AccessibleTreeViewer.prototype =
this.mSelection = this.mView.getDOMNode(idx);
this.mObsMan.dispatchEvent("selectionChange",
{ selection: this.mSelection } );
}
},
getSelectedAccessible: function getSelectedAccessible()
{
var idx = this.mTree.currentIndex;
return this.mView.getAccessible(idx);
}
};
///////////////////////////////////////////////////////////////////////////////
@ -410,6 +433,23 @@ function getDOMNode(aRow)
return this.getDOMNodeFor(node.accessible);
}
/**
* Return accessible of the tree node pointed by the given
* row index.
*
* @param aRow The row index to get the accessible from.
* @returns The accessible for the given index.
*/
inAccTreeView.prototype.getAccessible =
function getAccessible(aRow)
{
var node = this.mNodes[aRow];
if (!node)
return null;
return node.accessible;
}
///////////////////////////////////////////////////////////////////////////////
//// inAccTreeViewNode

Просмотреть файл

@ -57,8 +57,21 @@
<script type="application/javascript"
src="chrome://inspector/content/viewers/accessibleTree/accessibleTree.js"/>
<commandset id="cmdsAccTreeViewer">
<command id="cmdEvalJS" oncommand="viewer.cmdEvalJS();"/>
<command id="cmdInspectInNewView"
oncommand="viewer.cmdInspectInNewView();"/>
</commandset>
<popup id="popupContext">
<menuitem label="&inspectNewWindow.label;" observes="cmdInspectInNewView"/>
<menuseparator/>
<menuitem label="&evaluateJS.label;" observes="cmdEvalJS"/>
</popup>
<tree id="olAccessibleTree" class="plain" flex="1"
onselect="viewer.onItemSelected()">
onselect="viewer.onItemSelected()"
context="popupContext">
<treecols>
<treecol id="olcRole"
label="&role.label;"

Просмотреть файл

@ -0,0 +1,68 @@
/* ***** 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 mozilla.org code.
*
* The Initial Developer of the Original Code is
* Mozilla Foundation.
* Portions created by the Initial Developer are Copyright (C) 2008
* 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 ***** */
var gAcc = window.arguments[0];
var gInputArea = null;
var gOutputArea = null;
function load()
{
gInputArea = document.getElementById("JSInputArea");
gOutputArea = document.getElementById("JSOutputArea");
}
function execute()
{
if (!gAcc)
return;
gOutputArea.value = "";
var expr = gInputArea.value;
try {
var f = Function("accessible", expr);
var result = f(gAcc);
} catch (ex) {
output(ex);
}
}
function output(aValue)
{
gOutputArea.value += aValue;
}

Просмотреть файл

@ -0,0 +1,75 @@
<?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) 2008
- 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 ***** -->
<!DOCTYPE dialog [
<!ENTITY % dtd1 SYSTEM "chrome://inspector/locale/viewers/accessibleTreeEvalJSDialog.dtd"> %dtd1;
]>
<?xml-stylesheet href="chrome://communicator/skin"?>
<dialog id="winEvalJS"
title="&evaluateDialog.title;"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
buttons="accept, extra1"
buttonlabelextra1="&btnEvaluateJS.label;"
buttonaccesskeyextra1="&btnEvaluateJS.accesskey;"
ondialogextra1="return execute();"
style="width: 30em;"
onload="load();">
<script type="application/x-javascript"
src="chrome://inspector/content/viewers/accessibleTree/evalJSDialog.js"/>
<label control="JSInputArea"
accesskey="&txtInputArea.accesskey;">&txtInputArea.label;</label>
<textbox id="JSInputArea"
flex="1"
multiline="true"
rows="10"/>
<label control="JSOutputArea"
value="&txtOutputArea.label;"
accesskey="&txtOutputArea.accesskey;"/>
<textbox id="JSOutputArea"
flex="1"
multiline="true"
readonly="true"
rows="8"/>
</dialog>

Просмотреть файл

@ -41,3 +41,5 @@
<!ENTITY name.label "Name">
<!ENTITY nodeName.label "Node Name">
<!ENTITY evaluateJS.label "Evaluate JavaScript">

Просмотреть файл

@ -0,0 +1,48 @@
<!-- ***** 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
- Mozilla Foundation.
- Portions created by the Initial Developer are Copyright (C) 2008
- 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 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 evaluateDialog.title "Evaluate JavaScript Dialog">
<!ENTITY btnEvaluateJS.label "Evaluate">
<!ENTITY btnEvaluateJS.accesskey "E">
<!ENTITY txtInputArea.label "Input Area (use 'accessible' variable to operate with the selected accessible and 'output' function to write into 'Output Area' window): ">
<!ENTITY txtInputArea.accesskey "I">
<!ENTITY txtOutputArea.label "Output Area: ">
<!ENTITY txtOutputArea.accesskey "O">

Просмотреть файл

@ -2,22 +2,23 @@
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/accessibleEvent.dtd (@AB_CD@/viewers/accessibleEvent.dtd)
* locale/@AB_CD@/inspector/viewers/accessibleEvents.dtd (@AB_CD@/viewers/accessibleEvents.dtd)
* locale/@AB_CD@/inspector/viewers/accessibleProps.dtd (@AB_CD@/viewers/accessibleProps.dtd)
* locale/@AB_CD@/inspector/viewers/accessibleRelations.dtd (@AB_CD@/viewers/accessibleRelations.dtd)
* locale/@AB_CD@/inspector/viewers/accessibleTree.dtd (@AB_CD@/viewers/accessibleTree.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/accessibleEvent.dtd (@AB_CD@/viewers/accessibleEvent.dtd)
* locale/@AB_CD@/inspector/viewers/accessibleEvents.dtd (@AB_CD@/viewers/accessibleEvents.dtd)
* locale/@AB_CD@/inspector/viewers/accessibleProps.dtd (@AB_CD@/viewers/accessibleProps.dtd)
* locale/@AB_CD@/inspector/viewers/accessibleRelations.dtd (@AB_CD@/viewers/accessibleRelations.dtd)
* locale/@AB_CD@/inspector/viewers/accessibleTree.dtd (@AB_CD@/viewers/accessibleTree.dtd)
* locale/@AB_CD@/inspector/viewers/accessibleTreeEvalJSDialog.dtd (@AB_CD@/viewers/accessibleTreeEvalJSDialog.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)