(NOT PART OF BUILD) Document Inspector

git-svn-id: svn://10.0.0.236/trunk@87088 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
hewitt%netscape.com 2001-02-15 09:14:18 +00:00
parent 6d4f091694
commit 831720e707
134 changed files with 8252 additions and 5 deletions

View File

@ -0,0 +1,6 @@
@import url("chrome://inspector/skin/titledSplitter.css");
.titled-splitter {
-moz-binding: url("titledSplitter.xml#titledSplitter") !important;
}

View File

@ -0,0 +1,86 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://inspector/skin/titledSplitter.css"?>
<bindings id="bdsTitledSplitter"
xmlns="http://www.mozilla.org/xbl"
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<binding id="titledSplitter" extends="xul:splitter">
<content>
<xul:box class="titledsplitter-container" orient="vertical" flex="1">
<xul:spring class="titledsplitter-dragbar"/>
<xul:box class="titledsplitter-titlebox" flex="1" onmousedown="event.stopPropagation()">
<xul:box autostretch="never">
<xul:text class="titledsplitter-text" inherits="value"/>
</xul:box>
<xul:spring flex="1"/>
<xul:box class="titledsplitter-closebutton" onclick="this.parentNode.parentNode.parentNode.close();"/>
</xul:box>
</xul:box>
</content>
<implementation>
<property name="isOpened">
<getter><![CDATA[
return this.mOpened;
]]></getter>
</property>
<property name="collapsee">
<getter><![CDATA[
var collapse = this.getAttribute("collapse");
return collapse == "before" ? this.previousSibling : this.nextSibling;
]]></getter>
</property>
<method name="open">
<body><![CDATA[
var collapsee = this.collapsee;
if (collapsee) {
this.setAttribute("closed", "false");
this.setAttribute("collapsed", "false");
collapsee.setAttribute("collapsed", "false");
this.mOpened = true;
this.onopen();
}
]]></body>
</method>
<method name="close">
<body><![CDATA[
var collapsee = this.collapsee;
if (collapsee) {
this.setAttribute("closed", "true");
this.setAttribute("collapsed", "true");
collapsee.setAttribute("collapsed", "true");
this.mOpened = false;
this.onopen();
}
]]></body>
</method>
<method name="onopen">
<body><![CDATA[
if (!this.mOnOpen) {
var js = this.getAttribute("onopen");
if (js)
this.mOnOpen = new Function(js);
}
if (this.mOnOpen) {
return this.mOnOpen();
}
]]></body>
</method>
</implementation>
<handlers>
<handler event="bindingattached"><![CDATA[
this.mOpened = false;
]]></handler>
</handlers>
</binding>
</bindings>

View File

@ -0,0 +1,11 @@
@import url("chrome://inspector/skin/treeEditable.css");
.tree-editable {
-moz-binding: url("treeEditable.xml#treeEditable");
}
.treecell-editable {
-moz-binding: url("treeEditable.xml#treecellEditable");
}

View File

@ -0,0 +1,161 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://inspector/skin/treeEditable.css"?>
<bindings id="bnsEditableTree"
xmlns="http://www.mozilla.org/xbl"
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<binding id="treeEditable" extends="chrome://global/content/treeBindings.xml#tree">
<content>
<children/>
<xul:treerows class="tree-container-treerows" inherits="dragover,dragdroptree">
<children includes="treehead|treechildren"/>
</xul:treerows>
</content>
<implementation>
<property name="onStartEdit" readonly="true">
new Function("event", this.getAttribute("onstartedit"));
</property>
<property name="onAfterEdit" readonly="true">
new Function("event", this.getAttribute("onafteredit"));
</property>
<method name="getEditorElement">
<parameter name="aTreecell"/>
<body><![CDATA[
var eclass = aTreecell.getAttributeNS("http://www.mozilla.org", "editorclass");
var cached = this.mEditorCache[eclass];
var event = {
editingNode: aTreecell,
editorCached: cached,
editorClass: eclass
};
var userEl = this.onStartEdit(event);
var el = userEl ? userEl : ( cached ? cached : this.createDefaultEditor() );
if (userEl || !cached) {
el.setAttribute("class", el.getAttribute("class") + " treecell-editor");
this.mEditorCache[eclass] = el;
}
return el;
]]></body>
</method>
<method name="startEdit">
<parameter name="aTreecell"/>
<body><![CDATA[
// walk up to the treeitem containing the editing cell
var item = aTreecell
while (item && item.localName.toLowerCase() != "treeitem")
item = item.parentNode;
var editor = this.getEditorElement(aTreecell);
editor.setAttribute("value", aTreecell.getAttribute("value"));
aTreecell.parentNode.replaceChild(editor, aTreecell);
this.mEditing = true;
this.mEditingCell = aTreecell;
this.mEditingEditor = editor;
this.mEditingItem = item;
editor.focus();
// if it proves to be a textfield... select it's text
if (editor.select) editor.select();
]]></body>
</method>
<method name="stopEdit">
<parameter name="aCancel"/>
<body><![CDATA[
if (this.mEditing) {
var cell = this.mEditingCell;
var ed = this.mEditingEditor;
var ev = ed.value;
var cancel = this.onAfterEdit({ newValue: ev, editingNode: cell, editingItem: this.mEditingItem });
if (!aCancel && !cancel) cell.setAttribute("value", ev);
ed.parentNode.replaceChild(cell, ed);
this.mEditing = false;
this.focus();
}
]]></body>
</method>
<method name="createDefaultEditor">
<body><![CDATA[
var el = document.createElement("textfield");
return el;
]]></body>
</method>
</implementation>
<handlers>
<handler event="bindingattached"><![CDATA[
this.mEditorCache = {};
this.mEditing = false;
this.mEditingCell = null;
this.mEditingEditor = null;
]]></handler>
<handler event="mousedown"><![CDATA[
if (this.mEditing && event.target != this.mEditingEditor)
this.stopEdit();
]]></handler>
<handler event="keypress"><![CDATA[
// using ifs here because the "keycode" attribute isn't working on handler
if (this.mEditing && event.keyCode == 13)
this.stopEdit();
if (this.mEditing && event.keyCode == 27)
this.stopEdit(true);
if (this.mEditing && event.keyCode == 9) {
event.stopPropagation();
event.preventDefault();
}
]]></handler>
</handlers>
</binding>
<!-- ==================================================================================== -->
<!-- ==================================================================================== -->
<binding id="treecellEditable" extends="chrome://global/content/treeBindings.xml#treecell">
<implementation>
<property name="parentItem" readonly="true"><![CDATA[
var parent = this.parentNode;
while (parent.localName != "treeitem" && parent) {
parent = parent.parentNode;
}
this.mParentItem = parent;
this.mParentItem;
]]></property>
<property name="parentTree" readonly="true"><![CDATA[
var parent = this.parentNode;
while (parent.localName != "tree" && parent) {
parent = parent.parentNode;
}
this.mParentTree = parent;
this.mParentTree;
]]></property>
<method name="startEdit">
<body><![CDATA[
this.parentTree.startEdit(this);
]]></body>
</method>
</implementation>
<handlers>
<handler event="mousedown"><![CDATA[
if (this.parentItem.getAttribute("selected") == "true" && event.button == 1)
this.startEdit();
]]></handler>
</handlers>
</binding>
</bindings>

View File

@ -0,0 +1,47 @@
/***************************************************************
* wsm-colorpicker ----------------------------------------------
* Quick script which adds support for the color picker widget
* to nsWidgetStateManager in the pref winodw.
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
* REQUIRED IMPORTS:
****************************************************************/
function AddColorPicker(aCallback)
{
window.addEventListener("load", AddColorPicker_delayCheck, false);
window.AddColorPicker_callback = aCallback;
}
function AddColorPicker_delayCheck()
{
if (parent.hPrefWindow)
AddColorPicker_addColorHandlers()
else
setTimeout("AddColorPicker_delayCheck()", 1);
}
function AddColorPicker_addColorHandlers()
{
parent.hPrefWindow.wsm.handlers.colorpicker = {
set: function (aElementID, aDataObject)
{
var wsm = parent.hPrefWindow.wsm;
var element = wsm.contentArea.document.getElementById( aElementID );
element.color = aDataObject.color;
},
get: function (aElementID)
{
var wsm = parent.hPrefWindow.wsm;
var element = wsm.contentArea.document.getElementById( aElementID );
var dataObject = wsm.generic_Get(element);
if(dataObject) {
dataObject.color = element.color;
return dataObject;
}
return null;
}
}
window.AddColorPicker_callback();
}

View File

@ -52,12 +52,7 @@ inspector.jar:
content/inspector/search/modules/junkImgs/dialog.js (search/modules/junkImgs/dialog.js)
content/inspector/sidebar/sidebar.xul (sidebar/sidebar.xul)
content/inspector/sidebar/InspectorSidebar.js (sidebar/InspectorSidebar.js)
content/inspector/tests/test1.html (tests/test1.html)
content/inspector/tests/test2.xul (tests/test2.xul)
content/inspector/tests/selectors.xul (tests/selectors.xul)
content/inspector/tests/selectors.css (tests/selectors.css)
content/inspector/tests/allskin.xul (tests/allskin.xul)
content/inspector/tests/allskin-ns.xul (tests/allskin-ns.xul)
content/inspector/viewers/computedStyle/computedStyle.xul (viewers/computedStyle/computedStyle.xul)
content/inspector/viewers/computedStyle/computedStyle.js (viewers/computedStyle/computedStyle.js)
content/inspector/viewers/dom/dom.xul (viewers/dom/dom.xul)

View File

@ -0,0 +1,159 @@
/***************************************************************
* RDFArray -----------------------------------------------
* A convenience routine for creating an RDF-based 2d array
* indexed by number and hashkey.
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
* REQUIRED IMPORTS:
* chrome://inspector/content/utils.js
* chrome://inspector/content/jsutil/xpcom/XPCU.js
* chrome://inspector/content/jsutil/rdf/RDFU.js
****************************************************************/
//////////// global constants ////////////////////
RDFArray.URI = "http://www.joehewitt.com/mozilla/util/RDFArray#";
RDFArray.RDF_URI = "http://www.w3.org/1999/02/22-rdf-syntax-ns#";
///// class RDFArray /////////////////////////
function RDFArray(aNSURI, aRootURN, aArcName)
{
this.mNSURI = aNSURI;
this.mRootURN = aRootURN;
this.mArcName = aArcName ? aArcName : "list";
}
RDFArray.prototype = {
get datasource() { return this.mDS; },
get length() { return this.mLength } ,
initialize: function()
{
this.mLength = 0;
this.mDS = XPCU.createInstance("@mozilla.org/rdf/datasource;1?name=in-memory-datasource", "nsIRDFDataSource");
var root = gRDF.GetResource(this.mRootURN);
var res = gRDF.GetAnonymousResource();
this.mDS.Assert(root, gRDF.GetResource(this.mNSURI+this.mArcName), res, true);
this.mSeq = gRDFCU.MakeSeq(this.mDS, res);
},
add: function(aObject)
{
var res = this.createResourceFrom(aObject);
this.addResource(res);
},
addResource: function(aResource)
{
this.mSeq.AppendElement(aResource);
this.mLength++;
},
insertAt: function(aIndex, aObject)
{
var res = this.createResourceFrom(aObject);
this.insertResourceAt(aIndex, res);
},
insertResourceAt: function(aIndex, aResource)
{
},
removeAt: function(aIndex)
{
this.mSeq.RemoveElementAt(aIndex+1, true);
this.mLength--;
},
removeById: function(aId)
{
var proj = gRDF.GetResource(aId);
proj = XPCU.QI(proj, "nsIRDFNode");
this.mSeq.RemoveElement(proj, true);
this.mLength--;
},
get: function(aIndex, aKey)
{
var res = RDFU.getSeqElementAt(this.mSeq, aIndex);
return RDFU.readAttribute(this.mDS, res, this.mNSURI+aKey);
},
set: function(aIndex, aKey, aValue)
{
var res = RDFU.getSeqElementAt(this.mSeq, aIndex);
RDFU.writeAttribute(this.mDS, res, this.mNSURI+aKey, aValue);
},
getResource: function(aIndex)
{
return RDFU.getSeqElementAt(this.mSeq, aIndex);
},
getResourceId: function(aIndex)
{
var el = RDFU.getSeqElementAt(this.mSeq, aIndex);
return el.Value;
},
save: function()
{
RDFU.saveDataSource(this.mDS);
},
clear: function()
{
while (this.mLength) {
this.mSeq.RemoveElementAt(1, true);
this.mLength--;
}
},
createResourceFrom: function(aObject)
{
var el = gRDF.GetAnonymousResource();
// add a literal node for each property being added
for (var name in aObject) {
this.mDS.Assert(el, gRDF.GetResource(this.mNSURI+name), gRDF.GetLiteral(aObject[name]), true);
}
return el;
}
};
/////////// static factory methods /////////////////////////
RDFArray.fromContainer = function(aDS, aResourceID, aNSURI)
{
var list = new RDFArray(aNSURI);
list.mDS = aDS;
var seq = RDFU.findSeq(aDS, aResourceID);
list.mSeq = seq;
list.mLength = seq.GetCount();
return list;
}
RDFArray.fromContainerArc = function(aDS, aSourceId, aTargetId, aNSURI)
{
var list = new RDFArray(aNSURI);
list.mDS = aDS;
var source = gRDF.GetResource(aSourceId);
var target = gRDF.GetResource(aTargetId);
var seqRes = aDS.GetTarget(source, target, true);
var seq = RDFU.makeSeq(aDS, seqRes);
list.mSeq = seq;
list.mLength = seq.GetCount();
return list;
}

View File

@ -0,0 +1,114 @@
/***************************************************************
* RDFU -----------------------------------------------
* Convenience routines for common RDF commands.
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
* REQUIRED IMPORTS:
* chrome://inspector/content/jsutil/xpcom/XPCU.js
****************************************************************/
//////////// global constants ////////////////////
try {
var gRDF = Components.classes['@mozilla.org/rdf/rdf-service;1'].getService();
gRDF = gRDF.QueryInterface(Components.interfaces.nsIRDFService);
var gRDFCU = Components.classes['@mozilla.org/rdf/container-utils;1'].getService();
gRDFCU = gRDFCU.QueryInterface(Components.interfaces.nsIRDFContainerUtils);
} catch (ex) { alert("RDFU: " + ex); }
///////////////////////////////////////////////////
var RDFU = {
getSeqElementAt: function(aSeq, aIndex)
{
var ordinal = gRDFCU.IndexToOrdinalResource(aIndex+1);
return aSeq.DataSource.GetTarget(aSeq.Resource, ordinal, true);
},
readAttribute: function(aDS, aRes, aName)
{
var attr = aDS.GetTarget(aRes, gRDF.GetResource(aName), true);
if (attr)
attr = XPCU.QI(attr, "nsIRDFLiteral");
return attr ? attr.Value : null;
},
writeAttribute: function(aDS, aRes, aName, aValue)
{
var attr = aDS.GetTarget(aRes, gRDF.GetResource(aName), true);
if (attr)
aDS.Change(aRes, gRDF.GetResource(aName), attr, gRDF.GetLiteral(aValue));
},
findSeq: function(aDS, aResName)
{
try {
var res = gRDF.GetResource(aResName);
seq = this.makeSeq(aDS, res);
} catch (ex) {
alert("Unable to find sequence:" + ex);
}
return seq;
},
makeSeq: function(aDS, aRes)
{
var seq = XPCU.createInstance("@mozilla.org/rdf/container;1", "nsIRDFContainer");
seq.Init(aDS, aRes);
return seq;
},
createSeq: function(aDS, aBaseRes, aArcRes)
{
var res = gRDF.GetAnonymousResource();
aDS.Assert(aBaseRes, aArcRes, res, true);
var seq = gRDFCU.MakeSeq(aDS, res);
return seq;
},
loadDataSource: function(aURL, aListener)
{
var ds = gRDF.GetDataSource(aURL);
var rds = XPCU.QI(ds, "nsIRDFRemoteDataSource");
var observer = new DSLoadObserver(aListener);
if (rds.loaded) {
observer.onEndLoad(ds);
} else {
var sink = XPCU.QI(ds, "nsIRDFXMLSink");
sink.addXMLSinkObserver(observer);
}
},
saveDataSource: function(aDS)
{
var ds = XPCU.QI(aDS, "nsIRDFRemoteDataSource");
ds.Flush();
}
};
///////////
function DSLoadObserver(aListener) { this.mListener = aListener; }
DSLoadObserver.prototype =
{
onBeginLoad: function(aSink) { },
onInterrupt: function(aSink) {},
onResume: function(aSink) {},
onError: function(aSink, aStatus, aErrorMsg)
{
this.mListener.onError(aErrorMsg);
},
onEndLoad: function(aSink)
{
var ds = XPCU.QI(aSink, "nsIRDFDataSource");
this.mListener.onDataSourceReady(ds);
}
};

View File

@ -0,0 +1,35 @@
/***************************************************************
* ClipboardUtils -------------------------------------------------
* Utility functions for painless clipboard interaction.
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
* REQUIRED IMPORTS:
****************************************************************/
//////////// global variables /////////////////////
//////////// global constants ////////////////////
////////////////////////////////////////////////////////////////////////////
//// class ClipboardUtils
var ClipboardUtils = {
writeString: function(aString)
{
var clipboard = XPCU.getService("@mozilla.org/widget/clipboard;1", "nsIClipboard");
var transferable = XPCU.createInstance("@mozilla.org/widget/transferable;1", "nsITransferable");
if (clipboard && transferable) {
transferable.addDataFlavor("text/unicode");
var data = XPCU.createInstance("@mozilla.org/supports-wstring;1", "nsISupportsWString");
if (data) {
data.data = aString;
transferable.setTransferData("text/unicode", data, aString.length * 2);
clipboard.setData(transferable, null, Components.interfaces.nsIClipboard.kGlobalClipboard);
}
}
}
};

View File

@ -0,0 +1,59 @@
/***************************************************************
* DiskSearch -------------------------------------------------
* A utility for handily searching the disk for files matching
* a certain criteria.
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
* REQUIRED IMPORTS:
****************************************************************/
//////////// global variables /////////////////////
//////////// global constants ////////////////////
////////////////////////////////////////////////////////////////////////////
//// class DiskSearch
var DiskSearch =
{
findFiles: function(aRootDir, aExtList, aRecurse)
{
// has the file extensions so we don't have to
// linear search the array every time through
var extHash = {};
for (var i = 0; i < aExtList.length; i++) {
extHash[aExtList[i]] = true;
}
// recursively build the list of results
var results = [];
this.recurseDir(aRootDir, extHash, aRecurse, results);
return results;
},
recurseDir: function(aDir, aExtHash, aRecurse, aResults)
{
debug("("+aResults.length+") entering " + aDir.path + "\n");
var entries = aDir.directoryEntries;
var entry, ext;
while (entries.hasMoreElements()) {
entry = XPCU.QI(entries.getNext(), "nsIFile");
if (aRecurse && entry.isDirectory())
this.recurseDir(entry, aExtHash, aRecurse, aResults);
ext = this.getExtension(entry.leafName);
if (ext) {
if (aExtHash[ext])
aResults.push(entry.URL);
}
}
},
getExtension: function(aFileName)
{
var dotpt = aFileName.lastIndexOf(".");
if (dotpt)
return aFileName.substr(dotpt+1).toLowerCase();
return null;
}
};

View File

@ -0,0 +1,86 @@
/***************************************************************
* FilePickerUtils -------------------------------------------------
* A utility for easily dealing with the file picker dialog.
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
* REQUIRED IMPORTS:
****************************************************************/
//////////// global constants ////////////////////
const kFilePickerCID = "@mozilla.org/filepicker;1";
const kLFileCID = "@mozilla.org/file/local;1";
const nsIFilePicker = Components.interfaces.nsIFilePicker;
////////////////////////////////////////////////////////////////////////////
//// class FilePickerUtils
var FilePickerUtils =
{
pickFile: function(aTitle, aInitPath, aFilters, aMode)
{
try {
var modeStr = aMode ? "mode" + aMode : "modeOpen";
var mode;
try {
mode = nsIFilePicker[modeStr];
} catch (ex) {
dump("WARNING: Invalid FilePicker mode '"+aMode+"'. Defaulting to 'Open'.\n");
mode = nsIFilePicker.modeOpen;
}
var fp = XPCU.createInstance(kFilePickerCID, "nsIFilePicker");
fp.init(window, aTitle, mode);
// join array of filter names into bit string
var filters = this.prepareFilters(aFilters);
if (aInitPath) {
var dir = XPCU.createInstance(kLFileCID, "nsILocalFile");
dir.initWithPath(aInitPath);
fp.displayDirectory = dir;
}
if (fp.show() == nsIFilePicker.returnOK) {
return fp.file;
}
} catch (ex) {
dump("ERROR: Unable to open file picker.\n" + ex + "\n");
}
return null;
},
pickDir: function(aTitle, aInitPath)
{
try {
var fp = XPCU.createInstance(kFilePickerCID, "nsIFilePicker");
fp.init(window, aTitle, nsIFilePicker.modeGetFolder);
if (aInitPath) {
var dir = XPCU.createInstance(kLFileCID, "nsILocalFile");
dir.initWithPath(aInitPath);
fp.displayDirectory = dir;
}
if (fp.show() == nsIFilePicker.returnOK) {
return fp.file;
}
} catch (ex) {
dump("ERROR: Unable to open directory picker.\n" + ex + "\n");
}
return null;
},
prepareFilters: function(aFilters)
{
// join array of filter names into bit string
var filters = 0;
for (var i = 0; i < aFilters.length; ++i)
filters = filters | nsIFilePicker[aFilters[i]];
return filters;
}
};

View File

@ -0,0 +1,78 @@
/***************************************************************
* PrefUtils -------------------------------------------------
* Utility for easily using the Mozilla preferences system.
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
* REQUIRED IMPORTS:
****************************************************************/
//////////// global variables /////////////////////
//////////// global constants ////////////////////
const nsIPref = Components.interfaces.nsIPref;
////////////////////////////////////////////////////////////////////////////
//// class PrefUtils
var PrefUtils =
{
mPrefs: null,
init: function()
{
this.mPrefs = XPCU.getService("@mozilla.org/preferences;1", "nsIPref");
},
addObserver: function(aDomain, aFunction)
{
if (!this.mPrefs) this.init();
this.mPrefs.addObserver(aDomain, aFunction);
},
removeObserver: function(aDomain, aFunction)
{
if (!this.mPrefs) this.init();
this.mPrefs.removeObserver(aDomain, aFunction);
},
setPref: function(aName, aValue)
{
if (!this.mPrefs) this.init();
var type = this.mPrefs.GetPrefType(aName);
try {
if (type == nsIPref.ePrefString) {
this.mPrefs.SetUnicharPref(aName, aValue);
} else if (type == nsIPref.ePrefBool) {
this.mPrefs.SetBoolPref(aName, aValue);
} else if (type == nsIPref.ePrefInt) {
this.mPrefs.SetIntPref(aName, aValue);
}
} catch(ex) {
debug("ERROR: Unable to write pref \"" + aName + "\".\n");
}
},
getPref: function(aName)
{
if (!this.mPrefs) this.init();
var type = this.mPrefs.GetPrefType(aName);
try {
if (type == nsIPref.ePrefString) {
return this.mPrefs.CopyUnicharPref(aName);
} else if (type == nsIPref.ePrefBool) {
return this.mPrefs.GetBoolPref(aName);
} else if (type == nsIPref.ePrefInt) {
return this.mPrefs.GetIntPref(aName);
}
} catch(ex) {
debug("ERROR: Unable to read pref \"" + aName + "\".\n");
}
return null;
}
};

View File

@ -0,0 +1,701 @@
/*** -*- Mode: Javascript; tab-width: 2;
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 Collabnet code.
The Initial Developer of the Original Code is Collabnet.
Portions created by Collabnet are
Copyright (C) 2000 Collabnet. All
Rights Reserved.
Contributor(s): Pete Collins, Doug Turner, Brendan Eich, Warren Harris, Eric Plaster
File API (The purpose of this file is to make it a little easier to do file IO from js)
file.js
Function List
// Constructor
File(aPath) // creates the File object and sets the file path
open(aMode); // open a file handle for reading, writing or appending
close(); // closes a file handle
exists(); // check to see if a file exists
read(); // returns the contents of a file
readline(aDone); // returns the next line in the file. aDone == true at EOF
write(aContents, aPermissions); // permissions are optional
eof(); // check 'end of file' status
// file attributes
permissions(); // returns the files permissions
dateModified(); // returns the last modified date in locale string
size(); // returns the file size
// file string manipulation
path(); // returns the path
leaf(); // leaf is the endmost file string ex: foo.html in /myDir/foo.html
extension(); // returns a file extension if there is one
dirPath() // returns the dir part of a path
// direct manipulation
nsIFIle() // returns an nsIFile obj
// help!
help(); // currently dumps a list of available functions
Instructions:
First include this js file in your xul file. Next, create an File object:
var file = new File("/path/file.ext");
To see if the file exists, call the exists() member. This is a good check before going into some
deep code to try and extract information from a non-existant file.
To open a file for reading<"r">, writing<"w"> or appending<"a">,
just call:
file.open("w");
where in this case you will be creating a new file called '/path/file.ext', with a mode of "w"
which means you want to write a new file.
If you want to read from a file, just call:
file.open("r");
var theFilesContents = file.read();
The file contents will be returned to the caller so you can do something usefull with it.
file.close();
Calling 'close()' destroys any created objects. If you forget to use file.close() no probs
all objects are discarded anyway.
Warning: these API's are not for religious types
************/
/****************** Globals **********************/
const JSLIB_FILE = "file.js";
const JSFILE_LOCAL_CID = "@mozilla.org/file/local;1";
const JSFILE_F_CHANNEL_CID = "@mozilla.org/network/local-file-channel;1";
const JSFILE_I_STREAM_CID = "@mozilla.org/scriptableinputstream;1";
const JSFILE_I_LOCAL_FILE = "nsILocalFile";
const JSFILE_I_FILE_CHANNEL = "nsIFileChannel";
const JSFILE_I_SCRIPTABLE_IN_STREAM = "nsIScriptableInputStream";
const JSFILE_INIT_W_PATH = "initWithPath";
const JSFILE_READ = 0x01; // 1
const JSFILE_WRITE = 0x08; // 8
const JSFILE_APPEND = 0x10; // 16
const JSFILE_READ_MODE = "r";
const JSFILE_WRITE_MODE = "w";
const JSFILE_APPEND_MODE = "a";
const JSFILE_DELETE = "delete";
const JSFILE_FILETYPE = 0x00; // 0
const JSFILE_CHUNK = 1024; // buffer for readline => set to 1k
const JSFILE_OK = true;
const JSFILE_FilePath = new Components.Constructor( JSFILE_LOCAL_CID, JSFILE_I_LOCAL_FILE, JSFILE_INIT_W_PATH);
const JSFILE_FileChannel = new Components.Constructor( JSFILE_F_CHANNEL_CID, JSFILE_I_FILE_CHANNEL );
const JSFILE_InputStream = new Components.Constructor( JSFILE_I_STREAM_CID, JSFILE_I_SCRIPTABLE_IN_STREAM );
/****************** Globals **********************/
/****************** File Object Class *********************/
function File(aPath) {
if(aPath)
this.mPath= aPath;
} // constructor
File.prototype = {
mPath : null,
mode : null,
fileInst : null,
fileChannel : null,
inputStream : null,
lineBuffer : null,
/********************* OPEN *****************************/
open : function(aSetMode)
{
if(!this.mPath)
{
dump(JSLIB_FILE+":open:ERROR: Missing member path argument\nNS_ERROR_NUMBER: ");
return Components.results.NS_ERROR_NOT_INITIALIZED;
}
this.close();
if(!aSetMode)
aSetMode=JSFILE_READ_MODE;
try { this.fileInst = new JSFILE_FilePath(this.mPath); }
catch (e)
{
dump(JSLIB_FILE+":open:ERROR: UNEXPECTED"+e.name+" "+e.message+"\nNS_ERROR_NUMBER: ");
return Components.results.NS_ERROR_UNEXPECTED;
}
var fileExists = this.exists();
if(fileExists) {
if(this.fileInst.isDirectory())
{
dump(JSLIB_FILE+":open:ERROR: Can't open directory "+this.mPath+" as a file!\nNS_ERROR_NUMBER: ");
return Components.results.NS_ERROR_FAILURE;
}
}
var retval;
switch(aSetMode)
{
case JSFILE_WRITE_MODE:
{
if(fileExists)
{
try
{
this.fileInst[JSFILE_DELETE](false);
fileExists=false;
}
catch(e)
{
dump(JSLIB_FILE+":open:ERROR: Failed to delete file "+this.mPath+"\nNS_ERROR_NUMBER: ");
this.close();
return Components.results.NS_ERROR_FAILURE;
}
}
if (!fileExists)
{
try
{
this.fileInst.create(JSFILE_FILETYPE, 0644);
fileExists=true;
}
catch(e)
{
dump(JSLIB_FILE+":open:ERROR: Failed to create file "+this.mPath+"\nNS_ERROR_NUMBER: ");
this.close();
return Components.results.NS_ERROR_FAILURE;
}
}
this.mode=JSFILE_WRITE;
retval=JSFILE_OK;
break;
}
case JSFILE_APPEND_MODE:
{
if(!fileExists)
{
try
{
this.fileInst.create(JSFILE_FILETYPE, 0644);
fileExists=true;
}
catch(e)
{
dump(JSLIB_FILE+":open:ERROR: Failed to create file "+this.mPath+"\nNS_ERROR_NUMBER: ");
this.close();
return Components.results.NS_ERROR_FAILURE;
}
}
this.mode=JSFILE_APPEND;
retval=JSFILE_OK;
break;
}
case JSFILE_READ_MODE:
{
if(!fileExists)
{
dump(JSLIB_FILE+"open:ERROR: "+this.mPath+" doesn't exist!\nNS_ERROR_NUMBER: ");
return Components.results.NS_ERROR_FAILURE
}
try {
this.lineBuffer = new Array();
this.fileChannel = new JSFILE_FileChannel();
this.inputStream = new JSFILE_InputStream();
try { var perm = this.fileInst.permissions; }
catch(e){ perm=null; }
this.fileChannel.init(this.fileInst, JSFILE_READ, perm);
this.inputStream.init(this.fileChannel.openInputStream());
retval=JSFILE_OK;
}
catch (e)
{
dump(JSLIB_FILE+":open:ERROR: reading... "+e.name+" "+e.message+"\nNS_ERROR_NUMBER: ");
return Components.results.NS_ERROR_FAILURE;
}
break;
}
default:
dump(JSLIB_FILE+":open:WARNING: \""+setMode+"\" is an Invalid file mode\nNS_ERROR_NUMBER: ");
return Components.results.NS_ERROR_INVALID_ARG;
}
return retval;
},
/********************* EXISTS ***************************/
exists : function ()
{
var retval = null;
try
{
var file = new JSFILE_FilePath(this.mPath);
retval=file.exists();
}
catch(e)
{
dump(JSLIB_FILE+":exists:ERROR: "+e.name+"\n"+e.message+"\nNS_ERROR_NUMBER: ");
return Components.results.NS_ERROR_UNEXPECTED;
}
return retval;
},
/********************* WRITE ****************************/
write : function(aBuffer, aPerms)
{
if(!this.fileInst)
{
dump(JSLIB_FILE+":write:ERROR: Please open a file handle first\n NS_ERROR_NUMBER:");
return Components.results.NS_ERROR_NOT_INITIALIZED;
}
if(!aBuffer)
throw(JSLIB_FILE+":write:ERROR: must have a buffer to write!\n");
if(this.mode == JSFILE_READ)
throw(JSLIB_FILE+":write:ERROR: not in write or append mode!\n");
var buffSize = aBuffer.length;
try
{
if(!this.fileChannel)
this.fileChannel = new JSFILE_FileChannel();
if(aPerms)
{
var checkPerms = this.validatePermissions(aPerms);
if(!checkPerms)
{
dump(JSLIB_FILE+":write:ERROR: invalid permissions set: "+aPerms+"\nNS_ERROR_NUMBER: ");
return Components.results.NS_ERROR_INVALID_ARG
}
}
if(!aPerms)
aPerms=0644;
this.fileChannel.init(this.fileInst, this.mode, aPerms);
try
{
this.fileInst.permissions=aPerms;
}
catch(e){ }
var outStream = this.fileChannel.openOutputStream();
outStream.write(aBuffer, buffSize);
outStream.flush();
outStream.close();
}
catch (e)
{
dump(JSLIB_FILE+":write:ERROR: "+e.name+"\n"+e.message+"\nNS_ERROR_NUMBER: ");
return Components.results.NS_ERROR_UNEXPECTED;
}
return JSFILE_OK;
},
/********************* READ *****************************/
read : function()
{
var retval = null;
try
{
if(!this.fileInst || !this.inputStream)
{
dump(JSLIB_FILE+":read:ERROR: Please open a valid file handle for reading\nNS_ERROR_NUMBER: ");
return Components.results.NS_ERROR_NOT_INITIALIZED;
}
retval = this.inputStream.read(this.fileInst.fileSize);
this.inputStream.close();
}
catch (e)
{
dump(JSLIB_FILE+":read:ERROR: "+e.name+"\n"+e.message+"\nNS_ERROR_NUMBER: ");
return Components.results.NS_ERROR_FAILURE;
}
return retval;
},
eof : function()
{
if(!this.fileInst || !this.inputStream)
{
dump(JSLIB_FILE+":readline:ERROR: Please open a valid file handle for reading\nNS_ERROR_NUMBER: ");
return Components.results.NS_ERROR_NOT_INITIALIZED;
}
if((this.lineBuffer.length > 0) || (this.inputStream.available() > 0))
return false;
else
return JSFILE_OK;
},
/********************* READLINE *****************************/
readline : function()
{
var retval = null;
var buf = null;
try
{
if(!this.fileInst || !this.inputStream)
{
dump(JSLIB_FILE+":readline:ERROR: Please open a valid file handle for reading\nNS_ERROR_NUMBER: ");
return Components.results.NS_ERROR_NOT_INITIALIZED;
}
if(this.lineBuffer.length < 2) {
buf = this.inputStream.read(JSFILE_CHUNK);
if(buf) {
var tmp = null;
if(this.lineBuffer.length == 1) {
tmp = this.lineBuffer.shift();
buf = tmp+buf;
}
this.lineBuffer = buf.split(/[\n\r]/);
}
}
retval = this.lineBuffer.shift();
}
catch (e)
{
dump(JSLIB_FILE+":readline:ERROR: "+e.name+" "+e.message+"\nNS_ERROR_NUMBER: ");
throw(e);
}
return retval;
},
/********************* PATH *****************************/
path : function () { return this.mPath; },
/********************* PATH *****************************/
/********************* LEAF *****************************/
leaf : function ()
{
if(!this.mPath)
{
dump(JSLIB_FILE+":leaf:ERROR: Missing path argument\nNS_ERROR_NUMBER: ");
return Components.results.NS_ERROR_INVALID_ARG;
}
if(!this.exists())
{
dump(JSLIB_FILE+":leaf:ERROR: File doesn't exist\nNS_ERROR_NUMBER: ");
return Components.results.NS_ERROR_FAILURE;
}
var retval;
try
{
var fileInst = new JSFILE_FilePath(this.mPath);
retval=fileInst.leafName;
}
catch(e)
{
dump(JSLIB_FILE+":leaf:ERROR: "+e.name+"\n"+e.message+"\nNS_ERROR_NUMBER: ");
return Components.results.NS_ERROR_FAILURE;
}
return retval;
},
/********************* VALIDATE PERMISSIONS *************/
validatePermissions : function(aNum)
{
if ( parseInt(aNum.toString(10).length) < 3 )
return false;
return JSFILE_OK;
},
/********************* PERMISSIONS **********************/
permissions : function ()
{
if(!this.mPath)
{
dump(JSLIB_FILE+":permissions:ERROR: Missing path argument\nNS_ERROR_NUMBER: ");
return Components.results.NS_ERROR_XPC_NOT_ENOUGH_ARGS;
}
if(!this.exists())
{
dump(JSLIB_FILE+":permissions:ERROR: File doesn't exist\nNS_ERROR_NUMBER: ");
return Components.results.NS_ERROR_FAILURE;
}
var retval;
try
{
var fileInst = new JSFILE_FilePath(this.mPath);
retval=fileInst.permissions.toString(8);
}
catch(e)
{
dump(JSLIB_FILE+":permissions:ERROR: "+e.name+"\n"+e.message+"\nNS_ERROR_NUMBER: ");
return Components.results.NS_ERROR_UNEXPECTED;
}
return retval;
},
/********************* MODIFIED *************************/
dateModified : function ()
{
if(!this.mPath)
{
dump(JSLIB_FILE+":dateModified:ERROR: Missing path argument\nNS_ERROR_NUMBER: ");
return Components.results.NS_ERROR_XPC_NOT_ENOUGH_ARGS;
}
if(!this.exists())
{
dump(JSLIB_FILE+":dateModified:ERROR: File doesn't exist\nNS_ERROR_NUMBER: ");
return Components.results.NS_ERROR_FAILURE;
}
var retval;
try
{
var fileInst = new JSFILE_FilePath(this.mPath);
var date = new Date(fileInst.lastModificationDate).toLocaleString();
retval=date;
}
catch(e)
{
dump(JSLIB_FILE+":dateModified:ERROR: "+e.name+"\n"+e.message+"\nNS_ERROR_NUMBER: ");
return Components.results.NS_ERROR_UNEXPECTED;
}
return retval;
},
/********************* SIZE *****************************/
size : function ()
{
if(!this.mPath)
{
dump(JSLIB_FILE+":size:ERROR: Missing member path argument\nNS_ERROR_NUMBER: ");
return Components.results.NS_ERROR_NOT_INITIALIZED;
}
if(!this.exists())
{
dump(JSLIB_FILE+":size:ERROR: File doesn't exist\nNS_ERROR_NUMBER: ");
return Components.results.NS_ERROR_FAILURE;
}
var retval;
try
{
var fileInst = new JSFILE_FilePath(this.mPath);
retval = fileInst.fileSize;
}
catch(e)
{
dump(JSLIB_FILE+":size:ERROR: "+e.name+"\n"+e.message+"\nNS_ERROR_NUMBER: ");
return Components.results.NS_ERROR_UNEXPECTED;
}
return retval;
},
/********************* EXTENSION ************************/
extension : function ()
{
if(!this.mPath)
{
dump(JSLIB_FILE+":extension:ERROR: Missing member path argument\nNS_ERROR_NUMBER: ");
return Components.results.NS_ERROR_NOT_INITIALIZED;
}
if(!this.exists())
{
dump(JSLIB_FILE+":extension:ERROR: File doesn't exist\nNS_ERROR_NUMBER: ");
return Components.results.NS_ERROR_FAILURE;
}
var retval;
try
{
var fileInst = new JSFILE_FilePath(this.mPath);
var leafName = fileInst.leafName;
var dotIndex = leafName.lastIndexOf('.');
retval=(dotIndex >= 0) ? leafName.substring(dotIndex+1) : "";
}
catch(e)
{
dump(JSLIB_FILE+":extension:ERROR: "+e.name+"\n"+e.message+"\nNS_ERROR_NUMBER: ");
return Components.results.NS_ERROR_UNEXPECTED;
}
return retval;
},
/********************* DIRPATH **************************/
dirPath : function ()
{
if(!this.mPath)
{
dump(JSLIB_FILE+":dirPath:ERROR: Missing member path argument\nNS_ERROR_NUMBER: ");
return Components.results.NS_ERROR_NOT_INITIALIZED;
}
var retval;
try
{
var fileInst = new JSFILE_FilePath(this.mPath);
if(fileInst.isFile())
retval=fileInst.path.replace(this.leaf(), "");
if(fileInst.isDirectory())
retval=fileInst.path;
}
catch (e)
{
dump(JSLIB_FILE+":dirPath:ERROR: "+e.name+"\n"+e.message+"\nNS_ERROR_NUMBER: ");
return Components.results.NS_ERROR_UNEXPECTED;
}
return retval;
},
/********************* nsIFILE **************************/
nsIFile : function ()
{
if(!this.mPath)
{
dump(JSLIB_FILE+":nsIFile:ERROR: Missing member path argument\nNS_ERROR_NUMBER: ");
return Components.results.NS_ERROR_NOT_INITIALIZED;
}
var retval;
try
{
retval = new JSFILE_FilePath(this.mPath);
}
catch (e)
{
dump(JSLIB_FILE+":nsIFile:ERROR: "+e.name+"\n"+e.message+"\nNS_ERROR_NUMBER: ");
return Components.results.NS_ERROR_UNEXPECTED;
}
return retval;
},
/********************* HELP *****************************/
help : function()
{
var help =
"\n\nFunction List:\n" +
"\n" +
" open(aMode);\n" +
" exists();\n" +
" read();\n" +
" readline(aDone);\n" +
" write(aContents, aPermissions);\n" +
" leaf();\n" +
" permissions();\n" +
" dateModified();\n" +
" size();\n" +
" extension();\n" +
" dirPath();\n" +
" nsIFile();\n" +
" help();\n";
dump(help+"\n");
return "";
},
/********************* CLOSE ****************************/
close : function()
{
/***************** Destroy Instances *********************/
if(this.fileInst) delete this.fileInst;
if(this.fileChannel) delete this.fileChannel;
if(this.inputStream) delete this.inputStream;
if(this.mode) this.mode=null;
/***************** Destroy Instances *********************/
return JSFILE_OK;
}
};

View File

@ -0,0 +1,31 @@
var XPCU =
{
getService: function(aURL, aInterface)
{
try {
return Components.classes[aURL].getService(Components.interfaces[aInterface]);
} catch (ex) {
dump("Error getting service: " + aURL + ", " + aInterface + "\n" + ex);
}
},
createInstance: function (aURL, aInterface)
{
try {
return Components.classes[aURL].createInstance(Components.interfaces[aInterface]);
} catch (ex) {
dump("Error creating instance: " + aURL + ", " + aInterface + "\n" + ex);
}
},
QI: function(aEl, aIName)
{
try {
return aEl.QueryInterface(Components.interfaces[aIName]);
} catch (ex) {
dump("Error in QI: " + aIName + "\n" + ex);
}
}
};

View File

@ -0,0 +1,79 @@
/***************************************************************
* DNDUtils -------------------------------------------------
* Utility functions for common drag and drop tasks.
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
* REQUIRED IMPORTS:
****************************************************************/
//////////// global variables /////////////////////
var app;
//////////// global constants ////////////////////
////////////////////////////////////////////////////////////////////////////
//// class DNDUtils
var DNDUtils =
{
invokeSession: function(aTarget, aTypes, aValues)
{
var transData, trans, supports;
var transArray = XPCU.createInstance("@mozilla.org/supports-array;1", "nsISupportsArray");
for (var i = 0; i < aTypes.length; ++i) {
transData = this.createTransferableData(aValues[i]);
trans = XPCU.createInstance("@mozilla.org/widget/transferable;1", "nsITransferable");
trans.addDataFlavor(aTypes[i]);
trans.setTransferData (aTypes[i], transData.data, transData.size);
supports = trans.QueryInterface(Components.interfaces.nsISupports);
transArray.AppendElement(supports);
}
var nsIDragService = Components.interfaces.nsIDragService;
var dragService = XPCU.getService("@mozilla.org/widget/dragservice;1", "nsIDragService");
dragService.invokeDragSession(aTarget, transArray, null, nsIDragService.DRAGDROP_ACTION_MOVE);
},
createTransferableData: function(aValue)
{
var obj = {};
if (typeof(aValue) == "string") {
obj.data = XPCU.createInstance("@mozilla.org/supports-wstring;1", "nsISupportsWString");
obj.data.data = aValue;
obj.size = aValue.length*2;
} else if (false) {
// TODO: create data for other primitive types
}
return obj;
},
checkCanDrop: function(aType)
{
var dragService = XPCU.getService("@mozilla.org/widget/dragservice;1", "nsIDragService");
var dragSession = dragService.getCurrentSession();
var gotFlavor = false;
for (var i = 0; i < arguments.length; ++i)
gotFlavor |= dragSession.isDataFlavorSupported(arguments[i]);
dragSession.canDrop = gotFlavor;
return gotFlavor;
},
getData: function(aType, aIndex)
{
var dragService = XPCU.getService("@mozilla.org/widget/dragservice;1", "nsIDragService");
var dragSession = dragService.getCurrentSession();
var trans = XPCU.createInstance("@mozilla.org/widget/transferable;1", "nsITransferable");
trans.addDataFlavor(aType);
dragSession.getData(trans, aIndex);
var data = new Object();
trans.getAnyTransferData ({}, data, {});
return data.value;
}
};

View File

@ -0,0 +1,36 @@
/***************************************************************
* FrameExchange ----------------------------------------------
* Utility for passing specific data to a document loaded
* through an iframe
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
* REQUIRED IMPORTS:
****************************************************************/
//////////// implementation ////////////////////
var FrameExchange = {
mData: {},
mCount: 0,
loadURL: function(aFrame, aURL, aData)
{
var id = "entry-"+this.mCount;
this.mCount++;
this.mData[id] = aData;
var url = aURL + "?" + id;
aFrame.setAttribute("src", url);
},
receiveData: function(aWindow)
{
var id = aWindow.location.search.substr(1);
var data = this.mData[id];
this.mData[id] = null;
return data;
}
};

View File

@ -0,0 +1,107 @@
/***************************************************************
* inFormManager -------------------------------------------------
* Manages the reading and writing of forms via simple maps of
* attribute/value pairs. A "form" is simply a XUL window which
* contains "form widgets" such as textfields and menulists.
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
* REQUIRED IMPORTS:
****************************************************************/
////////////////////////////////////////////////////////////////////////////
//// class inFormManager
var inFormManager =
{
// Object
readWindow: function(aWindow, aIds)
{
var el, fn;
var doc = aWindow.document;
var map = {};
for (var i = 0; i < aIds.length; i++) {
el = doc.getElementById(aIds[i]);
if (el) {
this.persistIf(doc, el);
fn = this["read_"+el.localName];
if (fn)
map[aIds[i]] = fn(el);
}
}
return map;
},
// void
writeWindow: function(aWindow, aMap)
{
var el, fn;
var doc = aWindow.document;
for (var i = 0; i < aIds.length; i++) {
el = doc.getElementById(aIds[i]);
if (el) {
fn = this["write_"+el.localName];
if (fn)
fn(el, aMap[aIds[i]]);
}
}
},
persistIf: function(aDoc, aEl)
{
if (aEl.getAttribute("persist") == "true" && aEl.hasAttribute("id")) {
aEl.setAttribute("value", aEl.value);
aDoc.persist(aEl.getAttribute("id"), "value");
}
},
read_textfield: function(aEl)
{
return aEl.value;
},
read_menulist: function(aEl)
{
return aEl.getAttribute("data");
},
read_checkbox: function(aEl)
{
return aEl.getAttribute("checked") == "true";
},
read_radiogroup: function(aEl)
{
return aEl.getAttribute("data");
},
read_colorpicker: function(aEl)
{
return aEl.getAttribute("color");
},
write_textfield: function(aEl, aValue)
{
aEl.setAttribute("value", aValue);
},
write_menulist: function(aEl, aValue)
{
aEl.setAttribute("data", aValue);
},
write_checkbox: function(aEl, aValue)
{
aEl.setAttribute("checked", aValue);
},
write_radiogroup: function(aEl, aValue)
{
aEl.setAttribute("data", aValue);
},
write_colorpicker: function(aEl, aValue)
{
aEl.color = aValue;
}
};

View File

@ -0,0 +1,659 @@
/***************************************************************
* inTreeTableBuilder -------------------------------------------------
* Automatically builds up a tree so that it will display a tabular
* set of data with titled columns and optionally an icon for each row.
* The tree that is supplied must begin with no children other than
* a single template element. The template is required.
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
* REQUIRED IMPORTS:
* chrome://inspector/content/jsutil/xul/DNDUtils.js
****************************************************************/
//////////// global variables /////////////////////
var inTreeTableBuilderPartCount = 0;
//////////// global constants ////////////////////
////////////////////////////////////////////////////////////////////////////
//// class inTreeTableBuilder
function inTreeTableBuilder(aTree, aNameSpace, aArcName)
{
this.tree = aTree;
this.nameSpace = aNameSpace;
this.arcName = aArcName;
this.mColumns = [];
this.mExtras = [];
}
inTreeTableBuilder.prototype =
{
mTree: null,
// datasource stuff
mNameSpace: null,
mArcName: null,
mIsRefContainer: true,
mIsContainer: false,
// table structure stuff
mIsIconic: false,
mColumns: null,
mSplitters: true,
mItemFields: null,
mItemAttrs: null,
mAllowDND: false,
mLastDragCol: null,
mLastDragColWhere: null,
////////////////////////////////////////////////////////////////////////////
//// properties
// the xul tree node we will construct
get tree() { return this.mTree },
set tree(aVal) { this.mTree = aVal; aVal._treeBuilder = this },
// the namespace to use for all fields
get nameSpace() { return this.mNameSpace },
set nameSpace(aVal) { this.mNameSpace = aVal },
// the name of the arc to the container
get arcName() { return this.mArcName },
set arcName(aVal) { this.mArcName = aVal },
// is the datasource ref an arc to a container, or a container itself
get isRefContainer() { return this.mIsRefContainer },
set isRefContainer(aVal) { this.mIsRefContainer = aVal },
// is each row a potential container?
get isContainer() { return this.mIsContainer },
set isContainer(aVal) { this.mIsContainer = aVal },
// place an icon before the first column of each row
get isIconic() { return this.mIsIconic },
set isIconic(aVal) { this.mIsIconic = aVal },
// put splitters between the columns?
get useSplitters() { return this.mSplitters },
set useSplitters(aVal) { this.mSplitters = aVal },
// extra attributes to set on the treeitem
get itemAttributes() { return this.mItemAttrs },
set itemAttributes(aVal) { this.mItemAttrs = aVal },
// extra data fields to set on the treeitem
get itemFields() { return this.mItemFields },
set itemFields(aVal) { this.mItemFields = aVal },
// extra data fields to set on the treeitem
get allowDragColumns() { return this.mAllowDND },
set allowDragColumns(aVal) { this.mAllowDND = aVal },
////////////////////////////////////////////////////////////////////////////
//// event handlers
get onColumnAdd() { return this.mOnColumnAdd },
set onColumnAdd(aFn) { this.mOnColumnAdd = aFn },
get onColumnRemove() { return this.mOnColumnRemove },
set onColumnRemove(aFn) { this.mOnColumnRemove = aFn },
////////////////////////////////////////////////////////////////////////////
//// initialization
initialize: function()
{
this.initColumns();
this.initTemplate();
},
initColumns: function()
{
// initialize the treehead
var treehead = document.createElementNS(kXULNSURI, "treehead");
var treerow = document.createElementNS(kXULNSURI, "treerow");
this.mTreeHeadRow = treerow;
treehead.appendChild(treerow);
this.mTree.appendChild(treehead);
// initialize the treecolgroup
var colgroup = document.createElementNS(kXULNSURI, "treecolgroup");
this.mColGroup = colgroup;
this.mTree.appendChild(colgroup);
this.initDND();
},
initTemplate: function()
{
var template = this.mTree.getElementsByTagNameNS(kXULNSURI, "template")[0];
this.mTemplate = template;
this.clearChildren(template);
var rule = document.createElementNS(kXULNSURI, "rule");
template.appendChild(rule);
this.mRule = rule;
this.createDefaultConditions();
var bindings = document.createElementNS(kXULNSURI, "bindings");
rule.appendChild(bindings);
this.mBindings = bindings;
this.createDefaultAction();
},
createDefaultConditions: function()
{
var conditions = document.createElementNS(kXULNSURI, "conditions");
this.mRule.appendChild(conditions);
var content = document.createElementNS(kXULNSURI, "content");
content.setAttribute("uri", "?uri");
conditions.appendChild(content);
var triple = this.createTriple("?uri", this.mNameSpace+this.mArcName,
this.mIsRefContainer ? "?table" : "?item");
conditions.appendChild(triple);
if (this.mIsRefContainer) {
var member = this.createMember("?table", "?item");
conditions.appendChild(member);
}
},
createDefaultAction: function()
{
var action = document.createElementNS(kXULNSURI, "action");
this.mRule.appendChild(action);
var treechildren = this.createTemplatePart("treechildren");
action.appendChild(treechildren);
treechildren.setAttribute("flex", "1");
var treeitem = this.createTemplatePart("treeitem");
treechildren.appendChild(treeitem);
treeitem.setAttribute("uri", "?item");
this.mTreeItem = treeitem;
var treerow = this.createTemplatePart("treerow");
treeitem.appendChild(treerow);
this.mTreeRow = treerow;
// assign the item attributes
if (this.mItemAttrs)
for (key in this.mItemAttrs)
treeitem.setAttribute(key, this.mItemAttrs[key]);
},
createDefaultBindings: function()
{
// assign the item fields
var binding;
if (this.mItemFields) {
for (key in this.mItemFields) {
binding = this.createBinding(this.mItemFields[key]);
this.mBindings.appendChild(binding);
this.mTreeItem.setAttribute(key, "?" + this.mItemFields[key]);
}
}
},
createTriple: function(aSubject, aPredicate, aObject)
{
var triple = document.createElementNS(kXULNSURI, "triple");
triple.setAttribute("subject", aSubject);
triple.setAttribute("predicate", aPredicate);
triple.setAttribute("object", aObject);
return triple;
},
createMember: function(aContainer, aChild)
{
var member = document.createElementNS(kXULNSURI, "member");
member.setAttribute("container", aContainer);
member.setAttribute("child", aChild);
return member;
},
reset: function()
{
this.mColumns = [];
this.mIsIconic = false;
this.resetTree();
},
resetTree: function()
{
this.clearChildren(this.mColGroup);
this.clearChildren(this.mTreeHeadRow);
this.clearChildren(this.mBindings);
this.clearChildren(this.mTreeRow);
this.createDefaultBindings();
},
clearChildren: function(aEl)
{
while (aEl.childNodes.length)
aEl.removeChild(aEl.lastChild);
},
////////////////////////////////////////////////////////////////////////////
//// column drag and drop
initDND: function()
{
if (this.mAllowDND) {
// addEventListener doesn't work for dnd events, apparently... so we use the attributes
this.addDNDListener(this.mTree, "ondragenter");
this.addDNDListener(this.mTree, "ondragover");
this.addDNDListener(this.mTree, "ondragexit");
this.addDNDListener(this.mTree, "ondraggesture");
this.addDNDListener(this.mTree, "ondragdrop");
}
},
onDragEnter: function(aEvent)
{
},
onDragOver: function(aEvent)
{
if (!DNDUtils.checkCanDrop("TreeTableBuilder/column-add"))
return;
var idx = this.getColumnIndexFromX(aEvent.clientX, 50);
this.mColumnInsertIndex = idx;
var kids = this.mColGroup.childNodes;
var col = this.getColumnAt(idx);
if (idx == -1)
this.markColumnInsert(col, "after", idx);
else
this.markColumnInsert(col, "before", idx);
},
onDragExit: function(aEvent)
{
},
onDragDrop: function(aEvent)
{
this.markColumnInsert(null);
var dragService = XPCU.getService("@mozilla.org/widget/dragservice;1", "nsIDragService");
var dragSession = dragService.getCurrentSession();
if (!dragSession.isDataFlavorSupported("TreeTableBuilder/column-add"))
return false;
var trans = XPCU.createInstance("@mozilla.org/widget/transferable;1", "nsITransferable");
trans.addDataFlavor("TreeTableBuilder/column-add");
dragSession.getData(trans, 0);
var data = new Object();
trans.getAnyTransferData ({}, data, {});
var string = XPCU.QI(data.value, "nsISupportsWString");
this.insertColumn(this.mColumnInsertIndex,
{
name: string.data,
title: string.data,
flex: 1
});
this.build();
// if we rebuildContent during this thread, it will crash in the dnd service
setTimeout(function(aTreeBuilder) { aTreeBuilder.buildContent() }, 1, this);
// bug 56270 - dragSession.sourceDocument is null --
// causes me to code this very temporary, very nasty hack
// to tell columnsDialog.js about the drop
if (this.mTree.onClientDrop) {
this.mTree.onClientDrop();
}
},
markColumnInsert: function (aColumn, aWhere, aIdx)
{
var col = this.mLastDragCol;
var lastWhere = this.mLastDragColWhere;
if (col)
col.setAttribute("dnd-insert-"+lastWhere, "false");
if (aWhere != "before" && aWhere != "after") {
this.mLastDragCol = null;
this.mLastDragColWhere = null;
return;
}
col = aColumn;
if (col) {
this.mLastDragCol = col;
this.mLastDragColWhere = aWhere;
col.setAttribute("dnd-insert-"+aWhere, "true");
}
},
getColumnIndexFromX: function(aX, aThresh)
{
var colgroup = this.mColGroup;
var width = 0, cw;
var col;
var pct = aThresh/100;
for (var i = 0; i < this.columnCount; ++i) {
col = this.getColumnAt(i);
cw = col.boxObject.width;
width += cw;
if (width-(cw*pct) > aX)
return i;
}
return -1;
},
getColumnIndexFromHeader: function(aHeader)
{
var headers = this.mTreeHeadRow.childNodes;
for (var i = 0; i < headers.length; ++i) {
if (headers[i] == aHeader)
return i;
}
return -1;
},
//// for drag-n-drop removal/arrangement of columns
onDragGesture: function(aEvent)
{
var target = aEvent.target;
if (target.parentNode == this.mTreeHeadRow) {
var column = target.getAttribute("value");
var idx = this.getColumnIndexFromHeader(target);
if (idx == -1) return;
this.mColumnDragging = idx;
DNDUtils.invokeSession(target, ["TreeTableBuilder/column-remove"], [column]);
}
},
addColumnDropTarget: function(aBox)
{
aBox._treeBuilderDropTarget = this;
this.addDNDListener(aBox, "ondragover", "Target");
this.addDNDListener(aBox, "ondragdrop", "Target");
},
removeColumnDropTarget: function(aBox)
{
aBox._treeBuilderDropTarget = this;
this.removeDNDListener(aBox, "ondragover", "Target");
this.removeDNDListener(aBox, "ondragdrop", "Target");
},
onDragOverTarget: function(aBox, aEvent)
{
DNDUtils.checkCanDrop("TreeTableBuilder/column-remove");
},
onDragDropTarget: function(aBox, aEvent)
{
this.removeColumn(this.mColumnDragging);
this.build();
// if we rebuildContent during this thread, it will crash in the dnd service
setTimeout(function(aTreeBuilder) { aTreeBuilder.buildContent() }, 1, this);
},
// these are horrible hacks to compensate for the lack of true multiple
// listener support for the DND events
addDNDListener: function(aBox, aType, aModifier)
{
var js = "inTreeTableBuilder_"+aType+(aModifier?"_"+aModifier:"")+"(this, event);";
var attr = aBox.getAttribute(aType);
attr = attr ? attr : "";
aBox.setAttribute(aType, attr + js);
},
removeDNDListener: function(aBox, aType, aModifier)
{
var js = "inTreeTableBuilder_"+aType+(aModifier?"_"+aModifier:"")+"(this, event);";
var attr = aBox.getAttribute(aType);
var idx = attr.indexOf(js);
if (idx != -1)
attr = attr.substr(0,idx) + attr.substr(idx+1);
aBox.setAttribute(aType, attr);
},
////////////////////////////////////////////////////////////////////////////
//// column properties
addColumn: function(aData)
{
this.mColumns.push(aData);
if (this.mOnColumnAdd)
this.mOnColumnAdd(this.mColumns.length-1)
},
insertColumn: function(aIndex, aData)
{
var idx;
if (aIndex == -1) {
this.mColumns.push(aData);
idx = this.mColumns.length-1;
} else {
this.mColumns.splice(aIndex, 0, aData);
idx = aIndex;
}
if (this.mOnColumnAdd)
this.mOnColumnAdd(idx);
},
removeColumn: function(aIndex)
{
this.mColumns.splice(aIndex, 1);
if (this.mOnColumnRemove)
this.mOnColumnRemove(aIndex);
},
getColumnAt: function(aIndex)
{
var idx;
var kids = this.mColGroup.childNodes;
if (aIndex == -1)
idx = kids.length-1;
else {
// step by 2 to skip over splitters, if they are used
var step = this.mSplitters ? 2 : 1;
idx = aIndex*step;
}
return kids[idx]
},
get columnCount() { return this.mColumns.length },
getColumnName: function(aIndex) { return this.mColumns[aIndex].name },
setColumnName: function(aIndex, aValue) { this.mColumns[aIndex].name = aValue },
getColumnTitle: function(aIndex) { return this.mColumns[aIndex].title },
setColumnTitle: function(aIndex, aValue) { this.mColumns[aIndex].title = aValue },
getColumnClassName: function(aIndex) { return this.mColumns[aIndex].className },
setColumnClassName: function(aIndex, aValue) { this.mColumns[aIndex].className = aValue },
getColumnFlex: function(aIndex) { return this.mColumns[aIndex].flex },
setColumnFlex: function(aIndex, aValue) { this.mColumns[aIndex].flex = aValue },
getExtras: function(aIndex) { return this.mColumns[aIndex].extras },
setExtras: function(aIndex, aValue) { this.mColumns[aIndex].extras = aExtras },
getAttrs: function(aIndex) { return this.mColumns[aIndex].attrs },
setAttrs: function(aIndex, aValue) { this.mColumns[aIndex].attrs = aExtras },
////////////////////////////////////////////////////////////////////////////
//// template building
build: function(aBuildContent)
{
try {
this.resetTree();
this.buildColGroup();
this.buildTreeHead();
this.buildTemplate();
if (aBuildContent)
this.buildContent();
} catch (ex) {
debug("### ERROR - inTreeTableBuilder::build failed.\n" + ex);
}
//if ("dumpDOM" in window)
//dumpDOM(this.mTemplate);
},
buildContent: function()
{
this.mTree.builder.rebuild();
},
buildColGroup: function()
{
var cols = this.mColumns;
var colgroup = this.mColGroup;
var col, val, split;
for (var i = 0; i < cols.length; i++) {
col = document.createElementNS(kXULNSURI, "treecol");
col.setAttribute("id", "treecol-"+cols[i].name);
col.setAttribute("persist", "width");
val = cols[i].className;
if (val)
col.setAttribute("class", val);
val = cols[i].flex;
if (val)
col.setAttribute("flex", val);
colgroup.appendChild(col);
if (this.mSplitters && i < cols.length-1) {
split = document.createElementNS(kXULNSURI, "splitter");
split.setAttribute("class", "tree-splitter");
colgroup.appendChild(split);
}
}
},
buildTreeHead: function()
{
var cols = this.mColumns;
var row = this.mTreeHeadRow;
var cell, val;
for (var i = 0; i < cols.length; i++) {
cell = document.createElementNS(kXULNSURI, "treecell");
cell.setAttribute("class", "treecell-header");
val = cols[i].title;
if (val)
cell.setAttribute("value", val);
row.appendChild(cell);
}
},
buildTemplate: function()
{
var cols = this.mColumns;
var bindings = this.mBindings;
var row = this.mTreeRow;
var cell, binding, val, extras, attrs, key, className;
if (this.mIsIconic) {
binding = this.createBinding("_icon");
bindings.appendChild(binding);
}
for (var i = 0; i < cols.length; ++i) {
val = cols[i].name;
if (!val)
throw "Column data is incomplete - missing name at index " + i + ".";
cell = this.createTemplatePart("treecell");
className = "";
// build the icon data field
if (i == 0 && this.mIsIconic) {
className += "treecell-iconic ";
cell.setAttribute("src", "?_icon");
}
// mark first node as a container, if necessary
if (i == 0 && this.mIsContainer)
className += "treecell-indent";
// build the default value data field
binding = this.createBinding(val);
bindings.appendChild(binding);
cell.setAttribute("value", "?" + val);
cell.setAttribute("class", className);
row.appendChild(cell);
}
},
createBinding: function(aName)
{
var binding = document.createElementNS(kXULNSURI, "binding");
binding.setAttribute("subject", "?item");
binding.setAttribute("predicate", this.mNameSpace+aName);
binding.setAttribute("object", "?" + aName);
return binding;
},
createTemplatePart: function(aTagName)
{
var el = document.createElementNS(kXULNSURI, aTagName);
el.setAttribute("id", "templatePart"+inTreeTableBuilderPartCount);
inTreeTableBuilderPartCount++;
return el;
}
};
function inTreeTableBuilder_ondraggesture(aTree, aEvent)
{
return aTree._treeBuilder.onDragGesture(aEvent);
}
function inTreeTableBuilder_ondragenter(aTree, aEvent)
{
return aTree._treeBuilder.onDragEnter(aEvent);
}
function inTreeTableBuilder_ondragover(aTree, aEvent)
{
return aTree._treeBuilder.onDragOver(aEvent);
}
function inTreeTableBuilder_ondragexit(aTree, aEvent)
{
return aTree._treeBuilder.onDragExit(aEvent);
}
function inTreeTableBuilder_ondragdrop(aTree, aEvent)
{
return aTree._treeBuilder.onDragDrop(aEvent);
}
function inTreeTableBuilder_ondragover_Target(aBox, aEvent)
{
return aBox._treeBuilderDropTarget.onDragOverTarget(aBox, aEvent);
}
function inTreeTableBuilder_ondragdrop_Target(aBox, aEvent)
{
return aBox._treeBuilderDropTarget.onDragDropTarget(aBox, aEvent);
}

View File

@ -0,0 +1,32 @@
#!nmake
#
# The contents of this file are subject to the Netscape 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/NPL/
#
# 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 Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s):
DEPTH=..\..\..\..
include <$(DEPTH)/config/config.mak>
install::
$(MAKE_INSTALL) inspector-history.rdf $(DIST)\bin\chrome\inspector
$(MAKE_INSTALL) inspector-prefs.rdf $(DIST)\bin\chrome\inspector
$(MAKE_INSTALL) viewer-registry.rdf $(DIST)\bin\chrome\inspector
$(MAKE_INSTALL) search-registry.rdf $(DIST)\bin\chrome\inspector
$(MAKE_INSTALL) prefs\inspector.js $(DIST)\bin\defaults\pref
include <$(DEPTH)\config\rules.mak>

View File

@ -0,0 +1,67 @@
<?xml version="1.0"?>
<!DOCTYPE overlay [
<!ENTITY % dtd1 SYSTEM "chrome://inspector/locale/inspector.dtd"> %dtd1;
<!ENTITY % dtd2 SYSTEM "chrome://inspector/content/util.dtd"> %dtd2;
]>
<overlay id="ovPopupsMain"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<popupset id="ppsGlobalPopupset">
<popup id="ppSearchResults">
<!--
<menuitem id="ppSearchResults-view" value="&cmdViewSearchItem.label;" observes="cmdViewSearchItem"/>
<menuitem id="ppSearchResults-edit" value="&cmdEditSearchItem.label;" observes="cmdEditSearchItem"/>
-->
<menuseparator id="ppSearchResults-insertion"/>
<menuitem id="ppSearchResults-copyLine" value="&cmdCopySearchItemLine.label;" observes="cmdCopySearchItemLine"/>
<menuitem id="ppSearchResults-copyAll" value="&cmdCopySearchItemAll.label;" observes="cmdCopySearchItemAll"/>
<menuitem id="ppSearchResults-save" value="&cmdSaveSearchItemText.label;" observes="cmdSaveSearchItemText"/>
<menuseparator/>
<menuitem id="ppSearchResults-clear" value="&cmdClearSearch.label;" observes="cmdClearSearch"/>
<menuitem id="ppSearchResults-hide" value="&cmdHideSearchItems.label;" observes="cmdToggleSearch"/>
</popup>
</popupset>
<menupopup id="mppFile">
<menuitem value="&cmdShowOpenURLDialog.label;..." accesskey="&cmdShowOpenURLDialog.accesskey;" observes="cmdShowOpenURLDialog"/>
<menuseparator/>
<menuitem value="&cmdExit.label;" accesskey="&cmdExit.accesskey;" observes="cmdExit"/>
</menupopup>
<menupopup id="mppEdit">
<menuitem value="&cmdUndo.label;" accesskey="&cmdUndo.accesskey;" observes="cmdUndo"/>
<menuitem value="&cmdRedo.label;" accesskey="&cmdRedo.accesskey;" observes="cmdRedo"/>
<menuseparator/>
<menuitem value="&cmdCut.label;" accesskey="&cmdCut.accesskey;" observes="cmdCut"/>
<menuitem value="&cmdCopy.label;" accesskey="&cmdCopy.accesskey;" observes="cmdCopy"/>
<menuitem value="&cmdPaste.label;" accesskey="&cmdPaste.accesskey;" observes="cmdPaste"/>
<menuitem value="&cmdDelete.label;" accesskey="&cmdDelete.accesskey;" observes="cmdDelete"/>
<menuseparator/>
<menuitem value="&cmdPrefs.label;..." accesskey="&cmdPrefs.accesskey;" observes="cmdShowPrefsDialog"/>
</menupopup>
<menupopup id="mppSearch" oncreate="inspector.initPopup(this)">
<menuseparator/>
<menu value="&mnSearchPlugins.label;" accesskey="&mnSearchPlugins.accesskey;">
<menupopup id="mppSearchPlugins">
<menuitem value="&cmdRunSearch.label;" accesskey="&cmdRunSearch.accesskey;" observes="cmdRunSearch"/>
</menupopup>
</menu>
</menupopup>
<menupopup id="mppView" >
<menuitem class="menuitem-iconic" type="checkbox" value="&cmdToggleBrowser.label;" observes="cmdToggleBrowser"/>
<menuitem class="menuitem-iconic" type="checkbox" value="&cmdToggleSearch.label;" observes="cmdToggleSearch"/>
<menuseparator/>
<menuitem class="menuitem-iconic" type="checkbox" value="&cmdFlashSelected.label;" observes="cmdFlashSelected"/>
</menupopup>
<menupopup id="mppHelp">
<menuitem value="&cmdNotes.label;" accesskey="&cmdNotes.accesskey;" observes="cmdShowNotes"/>
<menuseparator/>
<menuitem value="&cmdAbout.label;" accesskey="&cmdAbout.accesskey;" observes="cmdShowAbout"/>
</menupopup>
</overlay>

View File

@ -0,0 +1,6 @@
pref("inspector.blink.border-color", "#CC0000");
pref("inspector.blink.border-width", 2);
pref("inspector.blink.duration", 2);
pref("inspector.blink.on", true);
pref("inspector.blink.speed", 100);
pref("inspector.dom.columns", "localName,@id");

View File

@ -0,0 +1,86 @@
<?xml version="1.0"?>
<!DOCTYPE overlay SYSTEM "chrome://inspector/locale/prefs.dtd">
<?xml-stylesheet href="chrome://communicator/skin/"?>
<?xul-overlay href="chrome://global/content/dialogOverlay.xul"?>
<window id="winPref" orient="vertical"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script language="Javascript" src="chrome://inspector/content/extensions/wsm-colorpicker.js"/>
<script language="Javascript"><![CDATA[
var _elementIDs = [
"cprElBorderColor",
"txfElBorderWidth",
"txfElDuration",
"txfElSpeed",
"cbElOn"
];
function initFunction()
{
parent.initPanel("chrome://inspector/content/prefs/pref-inspector.xul");
}
AddColorPicker(initFunction);
]]></script>
<box class="box-smallheader" title="&Inspector.label;"/>
<box id="bxGeneralPrefs">
<titledbox>
<title><text value="Element Blinking"/></title>
<box orient="vertical">
<grid>
<columns>
<column/>
<column flex="1"/>
</columns>
<rows>
<row autostretch="never">
<text value="Border Color"/>
<box autostretch="never">
<colorpicker id="cprElBorderColor" type="button"
pref="true" preftype="color" prefstring="inspector.blink.border-color" prefattribute="color"/>
</box>
</row>
<row autostretch="never">
<text value="Border Width"/>
<box autostretch="never">
<textfield id="txfElBorderWidth" style="width: 4em"
pref="true" preftype="int" prefstring="inspector.blink.border-width" prefattribute="value"/>
<text value="(px)"/>
</box>
</row>
<row autostretch="never">
<text value="Blink Duration"/>
<box autostretch="never">
<textfield id="txfElDuration" style="width: 4em"
pref="true" preftype="int" prefstring="inspector.blink.duration" prefattribute="value"/>
<text value="(s)"/>
</box>
</row>
<row autostretch="never">
<text value="Blink Speed"/>
<box autostretch="never">
<textfield id="txfElSpeed" style="width: 4em"
pref="true" preftype="int" prefstring="inspector.blink.speed" prefattribute="value"/>
<text value="(ms)"/>
</box>
</row>
</rows>
</grid>
<box autostretch="never">
<checkbox id="cbElOn" value="Blink Selected Element"
pref="true" preftype="bool" prefstring="inspector.blink.on" prefattribute="checked"/>
</box>
</box>
</titledbox>
</box>
</window>

View File

@ -0,0 +1,127 @@
/***************************************************************
* SidebarPrefs -------------------------------------------------
* The controller for the lovely sidebar prefs panel.
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
* REQUIRED IMPORTS:
* chrome://inspector/content/jsutil/xpcom/XPCU.js
* chrome://inspector/content/jsutil/rdf/RDFU.js
****************************************************************/
//////////// global variables /////////////////////
var pref;
//////////// global constants ////////////////////
const kDirServiceCID = "@mozilla.org/file/directory_service;1"
const kStandardURLCID = "@mozilla.org/network/standard-url;1"
const kNCURI = "http://home.netscape.com/NC-rdf#";
const kSidebarPanelId = "UPnls"; // directory services property to find panels.rdf
const kSidebarURNPanelList = "urn:sidebar:current-panel-list";
const kSidebarURN3rdParty = "urn:sidebar:3rdparty-panel";
const kSidebarURL = "chrome://inspector/content/sidebar/sidebar.xul";
const kSidebarTitle = "Document Inspector";
//////////////////////////////////////////////////
window.addEventListener("load", SidebarPrefs_initialize, false);
function SidebarPrefs_initialize()
{
pref = new SidebarPrefs();
pref.initSidebarData();
}
///// class SidebarPrefs /////////////////////////
function SidebarPrefs()
{
}
SidebarPrefs.prototype =
{
init: function()
{
var not = this.isSidebarInstalled() ? "" : "Not";
var el = document.getElementById("bxSidebar"+not+"Installed");
el.setAttribute("collapsed", "false");
},
///////////////////////////////////////////////////////////////////////////
// Because nsSidebar has been so mean to me, I'm going to re-write it's
// addPanel code right here so I don't have to fight with it. Pbbbbt!
///////////////////////////////////////////////////////////////////////////
initSidebarData: function()
{
var file = this.getDirectoryFile(kSidebarPanelId);
if (file)
RDFU.loadDataSource(file, gSidebarLoadListener);
},
initSidebarData2: function(aDS)
{
var res = aDS.GetTarget(gRDF.GetResource(kSidebarURNPanelList), gRDF.GetResource(kNCURI + "panel-list"), true);
this.mDS = aDS;
this.mPanelSeq = RDFU.makeSeq(aDS, res);
this.mPanelRes = gRDF.GetResource(kSidebarURN3rdParty + ":" + kSidebarURL);
this.init();
},
isSidebarInstalled: function()
{
return this.mPanelSeq.IndexOf(this.mPanelRes) != -1;
},
installSidebar: function()
{
if (!this.isSidebarInstalled()) {
this.mDS.Assert(this.mPanelRes, gRDF.GetResource(kNCURI + "title"), gRDF.GetLiteral(kSidebarTitle), true);
this.mDS.Assert(this.mPanelRes, gRDF.GetResource(kNCURI + "content"), gRDF.GetLiteral(kSidebarURL), true);
this.mPanelSeq.AppendElement(this.mPanelRes);
this.forceSidebarRefresh();
return true;
} else
return false;
},
forceSidebarRefresh: function()
{
var listRes = gRDF.GetResource(kSidebarURNPanelList);
var refreshRes = gRDF.GetResource(kNCURI + "refresh");
var trueRes = gRDF.GetLiteral("true");
this.mDS.Assert(listRes, refreshRes, trueRes, true);
this.mDS.Unassert(listRes, refreshRes, trueRes);
},
getDirectoryFile: function(aFileId)
{
try {
var dirService = XPCU.getService(kDirServiceCID, "nsIProperties");
var file = dirService.get(aFileId, Components.interfaces.nsIFile);
if (!file.exists())
return null;
var fileURL = XPCU.createInstance(kStandardURLCID, "nsIFileURL");
fileURL.file = file;
return fileURL.spec;
} catch (ex) {
return null;
}
}
};
var gSidebarLoadListener = {
onDataSourceReady: function(aDS)
{
pref.initSidebarData2(aDS);
},
onError: function()
{
}
};

View File

@ -0,0 +1,29 @@
<?xml version="1.0"?>
<!DOCTYPE overlay SYSTEM "chrome://inspector/locale/prefs.dtd">
<?xml-stylesheet href="chrome://communicator/skin/"?>
<?xul-overlay href="chrome://global/content/dialogOverlay.xul"?>
<window id="winPrefSidebar" orient="vertical"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script language="Javascript" src="chrome://inspector/content/jsutil/xpcom/XPCU.js"/>
<script language="Javascript" src="chrome://inspector/content/jsutil/rdf/RDFU.js"/>
<script language="Javascript" src="chrome://inspector/content/prefs/pref-sidebar.js"/>
<box class="box-smallheader" title="&Sidebar.label;"/>
<box id="bxSidebarPrefs">
<box id="bxSidebarInstalled" collapsed="true" flex="1">
<text value="The sidebar panel is currently installed."/>
</box>
<box id="bxSidebarNotInstalled" collapsed="true" flex="1" orient="vertical">
<text value="The sidebar panel is not currently installed. Click the 'Install' button to add it to your sidebar."/>
<button value="Install" onclick="gSidebarPrefs.installSidebar()"/>
</box>
</box>
</window>

View File

@ -0,0 +1,25 @@
<?xml version="1.0"?>
<?xul-overlay href="chrome://global/content/dialogOverlay.xul"?>
<?xul-overlay href="chrome://inspector/content/prefs/prefOverlay.xul"?>
<?xml-stylesheet href="chrome://communicator/skin/"?>
<?xml-stylesheet href="chrome://inspector/skin/"?>
<?xml-stylesheet href="chrome://inspector/skin/prefs.css"?>
<window id="winInspectorPrefs" title="Preferences"
width="550" height="400" orient="vertical"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script language="Javascript" src="chrome://inspector/content/prefs/InspectorPrefs.js"/>
<tabcontrol flex="1">
<tabbox id="tbxPrefs"/>
<tabpanel id="tbpPrefs" flex="1"/>
</tabcontrol>
<box id="okCancelButtonsRight"/>
</window>

View File

@ -0,0 +1,25 @@
<?xml version="1.0"?>
<!DOCTYPE overlay SYSTEM "chrome://inspector/locale/prefs.dtd">
<overlay id="ovPrefs"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<treechildren id="panelChildren">
<treeitem id="inspector" container="true" open="true">
<treerow>
<treecell class="treecell-indent" url="chrome://inspector/content/prefs/pref-inspector.xul" value="&Inspector.label;"/>
</treerow>
<treechildren id="inspectorChildren">
<treeitem>
<treerow>
<treecell class="treecell-indent" url="chrome://inspector/content/prefs/pref-sidebar.xul" value="&Sidebar.label;"/>
</treerow>
</treeitem>
</treechildren>
</treeitem>
</treechildren>
</overlay>

View File

@ -0,0 +1,14 @@
<?xml version="1.0"?>
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:ins="http://www.mozilla.org/inspector#">
<rdf:Seq about="inspector:search">
<rdf:li><rdf:Description
ins:uid="findOrphanImages"
ins:description="Find Orphan Images"
ins:factory="SearchModule_findOrphanImages"/></rdf:li>
</rdf:Seq>
</rdf:RDF>

View File

@ -0,0 +1,487 @@
/***************************************************************
* inSearchModule -----------------------------------------------
* Encapsulates an ISML module and exposes it to inSearchService.
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
* REQUIRED IMPORTS:
* chrome://inspector/content/jsutil/xpcom/XPCU.js
* chrome://inspector/content/jsutil/rdf/RDFU.js
* chrome://inspector/content/jsutil/rdf/RDFArray.js
* chrome://inspector/content/jsutil/xul/inFormManager.js
* chrome://inspector/content/search/xul/inSearchUtils.js
****************************************************************/
//////////// global variables /////////////////////
//////////// global constants ////////////////////
////////////////////////////////////////////////////////////////////////////
//// class inSearchModule
function inSearchModule(aBaseURL)
{
this.mObservers = [];
this.mBaseURL = aBaseURL;
}
inSearchModule.prototype =
{
mTitle: null,
mBaseURL: null,
mImpl: null,
mDialogElementIds: null,
mDialogURL: null,
mContextMenuItems: null,
mColumns: null,
mColDelimiter: null,
mNameSpace: null,
mRDFArray: null,
mResult: null,
mObservers: null,
mStartTime: null,
mElapsed: 0,
//////////////////////////////////////////////////////////////////////////
//// Properties
get searchService() { return this.mSearchService},
set searchService(aVal) { this.mSearchService = aVal },
get title() { return this.mTitle },
get baseURL() { return this.mBaseURL },
get defaultIconURL() { return this.mDefaultIconURL },
get datasource() { return this.mRDFArray.datasource },
get resultCount() { return this.mRDFArray.length },
get progressPercent() { return this.mImpl.progressPercent },
get progressText() { return this.mImp.progressText },
get isPastMilestone() { return this.mImpl.isPastMilestone },
get elapsed() { return this.mElapsed },
//////////////////////////////////////////////////////////////////////////
//// Initialization
initFromElement: function(aSearchEl)
{
this.parseSearch(aSearchEl);
if (this.mImpl.constructor)
this.mImpl.constructor();
},
//////////////////////////////////////////////////////////////////////////
//// Parser
parseSearch: function(aSearchEl)
{
// get the title
this.mTitle = aSearchEl.getAttribute("title");
// get the default icon url
this.mDefaultIconURL = aSearchEl.getAttribute("defaultIcon");
// get the namespace
var ns = aSearchEl.getAttribute("namespace")
this.mNameSpace = ns ? ns : kInspectorNSURI;
this.parseDialog(aSearchEl);
this.parseContextMenu(aSearchEl);
this.parseColumns(aSearchEl);
this.parseImplementation(aSearchEl);
},
parseDialog: function(aSearchEl)
{
var els = aSearchEl.getElementsByTagNameNS(kISMLNSURI, "dialog");
if (els.length > 0) {
var dialogEl = els[0];
// get the array of dialog element ids
var ids = dialogEl.getAttribute("elements");
if (ids)
this.mDialogElementIds = ids.split(",");
// get the dialog url
this.setDialogURL(dialogEl.getAttribute("href"));
// get the dialog parameters
this.mDialogResizable = (dialogEl.getAttribute("resizable") == "true") ? true : false;
}
},
parseContextMenu: function(aSearchEl)
{
var els = aSearchEl.getElementsByTagNameNS(kISMLNSURI, "contextmenu");
if (els.length > 0) {
var kids = els[0].childNodes;
this.mContextMenu = [];
for (var i = 0; i < kids.length; ++i) {
this.mContextMenu[i] = kids[i].cloneNode(true);
}
}
},
parseColumns: function(aSearchEl)
{
// get the result columns
var els = aSearchEl.getElementsByTagNameNS(kISMLNSURI, "columns");
if (els.length > 0) {
this.mColumns = [];
var cols = els[0];
this.mColDelimiter = cols.getAttribute("delimiter");
var kids = cols.childNodes;
var col, data;
for (var i= 0; i < kids.length; ++i) {
col = kids[i];
if (col.nodeType == 1) { // ignore non-element nodes
data = {
name: col.getAttribute("name"),
title: col.getAttribute("title"),
flex: col.getAttribute("flex"),
className: col.getAttribute("class"),
copy: col.getAttribute("copy") == "true"
};
this.mColumns.push(data);
}
}
}
},
parseImplementation: function(aSearchEl)
{
this.mImpl = this.getDefaultImplementation();
// get the implementation object
var els = aSearchEl.getElementsByTagNameNS(kISMLNSURI, "implementation");
if (els.length > 0) {
var kids = aSearchEl.getElementsByTagNameNS(kISMLNSURI, "*");
for (var i = 0; i < kids.length; i++) {
if (kids[i].localName == "property")
this.parseProperty(kids[i]);
if (kids[i].localName == "method")
this.parseMethod(kids[i]);
}
}
},
parseProperty: function(aPropEl)
{
var name = aPropEl.getAttribute("name");
// look for a getter
try {
var fn = this.getCodeTagFunction(aPropEl, "getter", null);
if (fn)
this.mImpl.__defineGetter__(name, fn);
} catch (ex) {
throw "### SYNTAX ERROR IN ISML GETTER \"" + name + "\" ###\n" + ex;
}
// look for a setter
try {
var fn = this.getCodeTagFunction(aPropEl, "setter", ["val"]);
if (fn)
this.mImpl.__defineSetter__(name, fn);
} catch (ex) {
throw "### SYNTAX ERROR IN ISML SETTER \"" + name + "\" ###\n" + ex;
}
},
parseMethod: function(aMethodEl)
{
var name = aMethodEl.getAttribute("name");
var def = aMethodEl.getAttribute("defaultCommand") == "true";
// get all the parameters
var els = aMethodEl.getElementsByTagNameNS(kISMLNSURI, "parameter");
var params = [];
for (var i = 0; i < els.length; i++) {
params[i] = els[i].getAttribute("name");
}
// get the body javascript and create the function
try {
var fn = this.getCodeTagFunction(aMethodEl, "body", params);
this.mImpl[name] = fn;
if (def)
this.mImpl.__DefaultCmd__ = fn;
} catch (ex) {
throw "### SYNTAX ERROR IN ISML METHOD \"" + name + "\" ###\n" + ex;
}
},
getCodeTagFunction: function(aParent, aLocalName, aParams)
{
var els = aParent.getElementsByTagNameNS(kISMLNSURI, aLocalName);
if (els.length) {
var body = els[0];
// try to determine where the code is located
var node = body.childNodes.length > 0 ? body.firstChild : body;
return this.getJSFunction(aParams, node.nodeValue);
}
return null;
},
getJSFunction: function(aParams, aCode)
{
var params = "";
if (aParams) {
for (var i = 0; i < aParams.length; i++) {
params += aParams[i];
if (i < aParams.length-1) params += ",";
}
}
var js = "function(" + params + ") " +
"{" +
(aCode ? aCode : "") +
"}";
var fn;
eval("fn = " + js);
return fn;
},
getDefaultImplementation: function()
{
return { module: this };
},
//////////////////////////////////////////////////////////////////////////
//// Dialog box
openDialog: function()
{
window.openDialog(this.mDialogURL, "inSearchModule_dialog",
"chrome,modal,resizable="+this.mDialogResizable, this);
},
processDialog: function(aWindow)
{
var map = inFormManager.readWindow(aWindow, this.mDialogElementIds);
this.implStartSearch(map);
},
//////////////////////////////////////////////////////////////////////////
//// Searching
startSearch: function()
{
if (this.mDialogURL) {
this.openDialog();
} else
this.implStartSearch(null);
},
implStartSearch: function(aMap)
{
this.mStartTime = new Date();
this.mElapsed = 0;
this.notifySearchStart();
this.initDataSource();
this.prepareForResult();
this.mImpl.searchStart(aMap);
},
stopSearch: function()
{
this.searchEnd();
},
//////////////////////////////////////////////////////////////////////////
//// Result Returns
setResultProperty: function(aAttr, aValue)
{
this.mResult[aAttr] = aValue;
},
searchResultReady: function()
{
this.mRDFArray.add(this.mResult);
this.notifySearchResult();
this.prepareForResult();
},
searchError: function(aMsg)
{
},
searchEnd: function()
{
this.mElapsed = new Date() - this.mStartTime;
this.notifySearchEnd();
},
//////////////////////////////////////////////////////////////////////////
//// Columns
get columnCount() { return this.mColumns.length },
getColumn: function(aIndex) { return this.mColumns[aIndex] },
getColumnName: function(aIndex) { return this.mColumns[aIndex].name },
getColumnTitle: function(aIndex) { return this.mColumns[aIndex].title },
getColumnClassName: function(aIndex) { return this.mColumns[aIndex].className },
getColumnFlex: function(aIndex) { return this.mColumns[aIndex].flex },
//////////////////////////////////////////////////////////////////////////
//// RDF Datasource
initDataSource: function()
{
this.mRDFArray = new RDFArray(this.mNameSpace, "inspector:searchResults", "results");
this.mRDFArray.initialize();
},
getResultPropertyAt: function(aIndex, aProp)
{
return this.mRDFArray.get(aIndex, aProp);
},
getItemText: function(aIndex)
{
var cols = this.mColumns;
var text = [];
for (var i = 0; i < cols.length; ++i) {
if (cols[i].copy) {
text.push(this.getResultPropertyAt(aIndex, cols[i].name));
}
}
return text.join(this.mColDelimiter);
},
//////////////////////////////////////////////////////////////////////////
//// Context Menu
installContextMenu: function(aMenu, aInsertionPoint, aDir)
{
if (this.mContextMenu) {
aMenu._searchModule = this;
var item;
this.mMenuItems = [];
if (this.mContextMenu.length == 0)
aInsertionPoint.setAttribute("hide", "true");
for (var i = 0; i < this.mContextMenu.length; ++i) {
item = this.mContextMenu[i];
this.mMenuItems.push(item);
this.installSearchReference(item);
if (aDir == inSearchService.INSERT_BEFORE)
aMenu.insertBefore(item, aInsertionPoint);
else {
// NOT YET IMPLEMENTED
}
}
}
},
uninstallContextMenu: function(aMenu, aInsertionPoint, aDir)
{
if (this.mContextMenu) {
if (this.mContextMenu.length == 0)
aInsertionPoint.setAttribute("hide", "false");
// remove the menu items
for (var i = 0; i < this.mContextMenu.length; ++i)
aMenu.removeChild(this.mMenuItems[i]);
}
},
installSearchReference: function(aItem)
{
if (aItem.nodeType == 1) {
if (aItem.localName == "menuitem") {
aItem.search = this.mImpl;
for (var i = 0; i < aItem.childNodes.length; ++i)
this.installSearchReference(aItem.childNodes[i]);
}
}
},
//////////////////////////////////////////////////////////////////////////
//// Event Notification
// NOTE TO SELF - this code could be cut down to nothing if you write a module
// called "ObserverManager" to do the work for you
addSearchObserver: function(aObserver)
{
this.mObservers.push(aObserver);
},
removeSearchObserver: function(aObserver)
{
var o;
var obs = this.mObservers;
for (var i = 0; i < obs.length; i++) {
o = obs[i];
if (o == aObserver) {
obs.splice(i, 1);
return;
}
}
},
notifySearchStart: function()
{
var o = this.mObservers;
for (var i = 0; i < o.length; i++)
o[i].onSearchStart(this);
},
notifySearchResult: function()
{
var o = this.mObservers;
for (var i = 0; i < o.length; i++)
o[i].onSearchResult(this);
},
notifySearchEnd: function(aResult)
{
var o = this.mObservers;
for (var i = 0; i < o.length; i++)
o[i].onSearchEnd(this, aResult);
},
notifySearchError: function(aMsg)
{
var o = this.mObservers;
for (var i = 0; i < o.length; i++)
o[i].onSearchError(this, aMsg);
},
//////////////////////////////////////////////////////////////////////////
//// Uncategorized
callDefaultCommand: function()
{
if (this.mImpl.__DefaultCmd__)
this.mImpl.__DefaultCmd__();
},
prepareForResult: function()
{
this.mResult = { _icon: this.mDefaultIconURL };
},
setDialogURL: function(aURL)
{
this.mDialogURL = aURL;
// This block below doesn't work for now because none of the local file implementations
// implement SetURL. So, for now, the url in the search file MUST be absolute :(
/* this.mDialogURL = aURL;
var baseFile = inSearchUtils.createLocalFile(this.mBaseURL);
try {
baseFile.append(aURL);
} catch (ex) {
basefile = inSearchUtils.createLocalFile(aURL);
}
var file = XPCU.QI(file, "nsIFile");
this.mDialogURL = basefile.URL;
*/
}
};
//////////////////////////////////////////////////////////////////////////
//// Event Listeners

View File

@ -0,0 +1,381 @@
/***************************************************************
* inSearchService -----------------------------------------------
* The centry registry where information about all installed
* search modules is kept.
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
* Until Bug 54237 is fixed, there be some ugly hacks in this
* file. We'll need to load search modules via a XUL document
* within an iframe, instead of using the xml loader for now.
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
* REQUIRED IMPORTS:
* chrome://inspector/content/jsutil/xpcom/XPCU.js
* chrome://inspector/content/search/inSearchTreeBuilder.js
* chrome://inspector/content/search/inSearchModule.js
****************************************************************/
//////////// global variables /////////////////////
//////////// global constants ////////////////////
var kSearchURLPrefix = "chrome://inspector/content/search/";
////////////////////////////////////////////////////////////////////////////
//// class inSearchService
function inSearchService()
{
this.mInstances = {};
this.mObservers = [];
// the browser and webnav are a hack. We should be able to use
// the xmlextras facility for loading xml, but it's broken, so
// we use a browser for onw
var browser = document.getElementById("inSearchServiceLoader");
browser.addEventListener("load", inSearchService_LoadListener, true);
this.mWebNav = browser.webNavigation;
}
// constants
inSearchService.INSERT_BEFORE = 1;
inSearchService.INSERT_AFTER = 2;
inSearchService.prototype =
{
mInstances: null,
mObservers: null,
mCurrentModule: null,
mTree: null,
mContextMenu: null,
mCMInsertPt: null,
mCMInsert: inSearchService.INSERT_BEFORE,
////////////////////////////////////////////////////////////////////////////
//// Properties
get currentModule() { return this.mCurrentModule },
get resultsTree() { return this.mTree },
set resultsTree(aTree) {
// XX this condition could be fixed with a little bit of effort
if (this.mTree) throw "inSearchService.tree should only be set once"
this.mTree = aTree;
aTree._searchService = this;
this.mTreeBuilder = new inSearchTreeBuilder(aTree, kInspectorNSURI, "results");
this.mTreeBuilder.isIconic = true;
// XX HACKERY AT IT'S FINEST - the click event won't fire when I add it to the tree -- go figure
// in the mean time I'll add it to the parentNode, which seems to work. FIX ME!
var parent = aTree.parentNode;
parent._tempTreeYuckyHack = aTree;
parent.addEventListener("click", inSearchService_TreeClickListener, false);
},
get contextMenu() { return this.mContextMenu },
set contextMenu(aVal)
{
this.mContextMenu = aVal;
aVal._searchService = this;
},
get contextMenuInsertPt() { return this.mCMInsertPt },
set contextMenuInsertPt(aVal) { this.mCMInsertPt = aVal },
get contextMenuInsert() { return this.mCMInsert },
set contextMenuInsert(aVal) { this.mCMInsert = aVal },
////////////////////////////////////////////////////////////////////////////
//// Running Modules
startModule: function(aURL)
{
var instance = this.mInstances[aURL];
if (instance)
this.doStartModule(instance);
else
this.loadModule(aURL);
},
doStartModule: function(aModule)
{
aModule.startSearch();
},
startSearch: function(aModule)
{
this.mCurrentModule = aModule;
// build up the context menu
this.installContextMenu();
// build up the search results tree
this.mTreeBuilder.module = aModule;
},
clearSearch: function()
{
var mod = this.mCurrentModule;
if (mod) {
// clear datasource from search tree
this.mTreeBuilder.module = null;
this.mTreeBuilder.buildContent();
// clear context menu
this.uninstallContextMenu();
}
this.mCurrentModule = null;
},
////////////////////////////////////////////////////////////////////////////
//// Loading Modules
loadModule: function(aURL)
{
this.mWebNav.loadURI(aURL, nsIWebNavigation.LOAD_FLAGS_NONE);
this.mLoadingURL = aURL;
/*
// This method of loading the xml doesn't work, but it should. See bug 54237...
var doc = document.implementation.createDocument("", "", null);
doc.addEventListener("load", SearchFileLoadListener, false);
doc.load(aURL, "text/xml");
*/
},
searchFileLoaded: function()
{
var mod = this.createModule(this.mWebNav.document);
mod.addSearchObserver(this);
this.mInstances[this.mLoadingURL] = mod;
this.doStartModule(mod);
},
createModule: function(aDocument)
{
var mod = new inSearchModule(aDocument.location);
mod.searchService = this;
mod.initFromElement(aDocument.documentElement);
return mod;
},
////////////////////////////////////////////////////////////////////////////
//// interface inISearchObserver
onSearchStart: function(aModule)
{
this.startSearch(aModule);
this.notifySearchStart();
},
onSearchResult: function(aModule)
{
this.notifySearchResult();
},
onSearchEnd: function(aModule, aResult)
{
this.notifySearchEnd(aResult);
},
onSearchError: function(aModule, aMessage)
{
this.notifySearchError(aMessage);
this.clearSearch();
},
////////////////////////////////////////////////////////////////////////////
//// Results Tree
get selectedItemCount()
{
return this.mTree ? this.mTree.selectedItems.length : null;
},
getSelectedIndex: function(aIdx)
{
if (this.mTree) {
var items = this.mTree.selectedItems;
return this.mTree.getIndexOfItem(items[aIdx]);
}
return null;
},
onTreeDblClick: function()
{
this.mCurrentModule.callDefaultCommand();
},
//////////////////////////////////////////////////////////////////////////
//// ContextMenu
installContextMenu: function()
{
var mod = this.mCurrentModule;
if (mod) {
var menu = this.mContextMenu;
menu.addEventListener("create", inSearchService_onCreatePopup, true);
mod.installContextMenu(menu, this.mCMInsertPt, this.mCMInsert);
}
},
uninstallContextMenu: function()
{
var mod = this.mCurrentModule;
if (mod) {
// remove the createion listener
var menu = this.mContextMenu;
menu.removeEventListener("create", inSearchService_onCreatePopup, true);
mod.uninstallContextMenu(menu, this.mCMInsertPt, this.mCMInsert);
}
},
onCreatePopup: function(aMenu)
{
},
//////////////////////////////////////////////////////////////////////////
//// Event Notification
// NOTE TO SELF - this code could be cut down to nothing if you write a module
// called "ObserverManager" to do the work for you
addSearchObserver: function(aObserver)
{
this.mObservers.push(aObserver);
},
removeSearchObserver: function(aObserver)
{
var o;
var obs = this.mObservers;
for (var i = 0; i < obs.length; i++) {
o = obs[i];
if (o == aObserver) {
obs.splice(i, 1);
return;
}
}
},
notifySearchStart: function()
{
var o = this.mObservers;
for (var i = 0; i < o.length; i++)
o[i].onSearchStart(this.mCurrentModule);
},
notifySearchResult: function()
{
var o = this.mObservers;
for (var i = 0; i < o.length; i++)
o[i].onSearchResult(this.mCurrentModule);
},
notifySearchEnd: function(aResult)
{
var o = this.mObservers;
for (var i = 0; i < o.length; i++)
o[i].onSearchEnd(this.mCurrentModule, aResult);
},
notifySearchError: function(aMsg)
{
var o = this.mObservers;
for (var i = 0; i < o.length; i++)
o[i].onSearchError(this.mCurrentModule, aMsg);
}
};
////////////////////////////////////////////////////////////////////////////
//// Event Listeners
function inSearchService_LoadListener(aEvent)
{
inspector.searchRegistry.searchFileLoaded();
}
function inSearchService_TreeClickListener(aEvent)
{
if (aEvent.detail == 2) {
var tree = this._tempTreeYuckyHack;
tree._searchService.onTreeDblClick();
}
}
function inSearchService_onCreatePopup(aEvent)
{
// event.target is returning null for this event - I should file a bug
// in the mean time I'll just back off this feature for now...
/* var menu = aEvent.target;
var svc = menu._searchService;
svc.onCreatePopup(menu);
*/
}
// This code is from when there was an RDF "search registry"... I might want to bring that back,
// so I'll keep this code sitting here for a little while...
/*
function inSearchServiceLoadObserver(aTarget)
{
this.mTarget = aTarget;
}
inSearchServiceLoadObserver.prototype = {
mTarget: null,
onError: function(aErrorMsg)
{
this.mTarget.onLoadError(aErrorMsg);
},
onDataSourceReady: function(aDS)
{
this.mTarget.onLoad(aDS);
}
};
load: function(aURL, aObserver)
{
this.mURL = aURL;
this.mObserver = aObserver;
RDFU.loadDataSource(aURL, new inSearchServiceLoadObserver(this));
},
onLoad: function(aDS)
{
this.mDS = aDS;
this.prepareRegistry();
this.mObserver.oninSearchServiceLoad();
},
onLoadError: function(aErrorMsg)
{
this.mObserver.oninSearchServiceLoadError(aErrorMsg);
},
prepareRegistry: function()
{
this.mModuleSeq = RDFU.findSeq(this.mDS, "inspector:search");
var el, uid, fnName, factory;
var els = this.mModuleSeq.GetElements();
while (els.hasMoreElements()) {
el = els.getNext();
uid = RDFU.readAttribute(this.mDS, el, kInspectorNSURI+"uid");
fnName = RDFU.readAttribute(this.mDS, el, kInspectorNSURI+"factory");
factory = eval(fnName);
if (factory)
this.mFactories[uid] = factory;
}
},
*/

View File

@ -0,0 +1,104 @@
/***************************************************************
* inSearchTreeBuilder ------------------------------------------
* Utility for automatically building an rdf template and xul
* tree structure from a tabular data set.
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
* REQUIRED IMPORTS:
* chrome://inspector/content/jsutil/inTreeBuilder.js
****************************************************************/
//////////// global variables /////////////////////
//////////// global constants ////////////////////
////////////////////////////////////////////////////////////////////////////
//// class inSearchTreeBuilder
function inSearchTreeBuilder(aTree, aNameSpace, aArcName)
{
this.mBuilder = new inTreeTableBuilder(aTree, aNameSpace, aArcName);
aTree.setAttribute("ref", "inspector:searchResults");
this.mBuilder.initialize();
}
inSearchTreeBuilder.prototype =
{
mCommited: false,
mBuilder: null,
mModule: null,
mCommitted: false,
get tree() { return this.mBuilder.tree },
set tree(aVal) { this.mBuilder.tree = aVal },
get isIconic() { return this.mBuilder.isIconic },
set isIconic(aVal) { this.mBuilder.isIconic = aVal },
get module() { return this.mModule },
set module(aModule)
{
if (aModule != this.mModule) {
if (this.mModule) {
if (this.mCommitted)
this.mBuilder.tree.database.RemoveDataSource(this.mModule.datasource);
this.mCommitted = false;
this.mModule.removeSearchObserver(this);
this.mBuilder.reset();
}
this.mModule = aModule;
if (aModule) {
aModule.addSearchObserver(this);
this.isIconic = aModule.defaultIconURL ? true : false;
for (var i = 0; i < aModule.columnCount; i++)
this.mBuilder.addColumn(aModule.getColumn(i));
this.mBuilder.build();
}
}
},
getSelectedSearchIndex: function()
{
var tItem = this.mSearchTree.selectedItems[0];
return this.mSearchTree.getIndexOfItem(tItem);
},
onSearchStart: function(aProcess)
{
if (this.mCommitted)
this.mBuilder.tree.database.RemoveDataSource(this.mModule.datasource);
},
onSearchResult: function(aProcess)
{
},
onSearchEnd: function(aProcess, aResult)
{
this.mBuilder.tree.database.AddDataSource(this.mModule.datasource);
this.mBuilder.buildContent();
this.mCommitted = true;
},
onSearchError: function(aProcess, aMessage)
{
},
reset: function()
{
this.mBuilder.reset();
},
buildContent: function()
{
this.mBuilder.buildContent();
}
};

View File

@ -0,0 +1,69 @@
/***************************************************************
* inSearchUtils -------------------------------------------------
* Utilities for helping search modules accomplish common tasks.
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
* REQUIRED IMPORTS:
****************************************************************/
//////////// global variables /////////////////////
var kSearchLookup = {
file: "inIFileSearch",
cssvalue: "inICSSValueSearch"
};
//////////// global constants ////////////////////
const kISMLNSURI = "http://www.mozilla.org/inspector/isml";
const kSearchHelperCIDPrefix = "@mozilla.org/inspector/search;1?type=";
const kFileSearchCID = "@mozilla.org/inspector/search;1?type=file";
const kCSSValueSearchCID = "@mozilla.org/inspector/search;1?type=cssvalue";
const kLocalFileCID = "@mozilla.org/file/local;1";
const kInMemoryDataSourceCID = "@mozilla.org/rdf/datasource;1?name=in-memory-datasource";
////////////////////////////////////////////////////////////////////////////
//// class inSearchUtils
var inSearchUtils =
{
// nsISupports
createSearchHelper: function(aName)
{
var cid = kSearchHelperCIDPrefix + aName;
var iid = kSearchLookup[aName];
return XPCU.createInstance(cid, iid);
},
// nsIFile
createLocalFile: function(aPath)
{
var file = XPCU.createInstance(kLocalFileCID, "nsILocalFile");
if (aPath) {
try {
file.initWithPath(aPath);
} catch (ex) {
debug("Invalid path in nsILocalFile::initWithPath\n" + ex);
}
}
return XPCU.QI(file, "nsIFile");
},
// inISearchObserver
createSearchObserver: function(aTarget, aLabel)
{
var observer = {
mTarget: aTarget,
onSearchStart: new Function("aModule", "this.mTarget.on"+aLabel+"SearchStart(aModule)"),
onSearchEnd: new Function("aModule", "aResult", "this.mTarget.on"+aLabel+"SearchEnd(aModule, aResult)"),
onSearchError: new Function("aModule", "aMsg", "this.mTarget.on"+aLabel+"SearchError(aModule, aMsg)"),
onSearchResult: new Function("aModule", "this.mTarget.on"+aLabel+"SearchResult(aModule)")
};
return observer;
}
};

View File

@ -0,0 +1,23 @@
<?xml version="1.0"?>
<!DOCTYPE overlay [
<!ENTITY % dtd1 SYSTEM "chrome://inspector/locale/search/junkImgs.dtd"> %dtd1;
<!ENTITY % dtd2 SYSTEM "chrome://inspector/locale/search/findFiles.dtd"> %dtd2;
]>
<overlay id="ovUnusedImagesCommands"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<broadcasterset id="brsGlobalCommands">
<broadcaster id="cmd:startJunkImgs"
oncommand="inspector.startSearchModule('chrome://inspector/content/search/modules/junkImgs/junkImgs.xml')"/>
<broadcaster id="cmd:startFindFiles"
oncommand="inspector.startSearchModule('chrome://inspector/content/search/modules/findFiles/findFiles.xml')"/>
</broadcasterset>
</overlay>

View File

@ -0,0 +1,51 @@
/***************************************************************
* FindFilesDialog ---------------------------------------
* Controller for dialog.
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
* REQUIRED IMPORTS:
****************************************************************/
//////////// global variables /////////////////////
var dialog;
//////////////////////////////////////////////////
window.addEventListener("load", FindFilesDialog_initialize, false);
function FindFilesDialog_initialize()
{
dialog = new FindFilesDialog();
doSetOKCancel(gDoOKFunc);
}
////////////////////////////////////////////////////////////////////////////
//// class FindFilesDialog
function FindFilesDialog()
{
}
FindFilesDialog.prototype =
{
browse: function()
{
var txf = document.getElementById("txfSearchPath");
var defaultPath = txf.getAttribute("value");
var file = FilePickerUtils.pickDir("Select Search Path", defaultPath);
if (file) {
txf.setAttribute("value", file.path);
}
}
};
////////////////////////////////////////////////////////////////////////////
//// dialogOverlay stuff
function gDoOKFunc() {
window.close();
window.arguments[0].processDialog(window);
return true;
}

View File

@ -0,0 +1,38 @@
<?xml version="1.0"?>
<!DOCTYPE overlay SYSTEM "chrome://inspector/locale/search/findFiles.dtd">
<?xul-overlay href="chrome://global/content/dialogOverlay.xul"?>
<?xml-stylesheet href="chrome://communicator/skin/"?>
<?xml-stylesheet href="chrome://inspector/skin/"?>
<window id="winJunkImgs" class="dialog"
title="&findFiles.title;"
persist="screenX screenY"
orient="vertical"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script language="Javascript" src="chrome://inspector/content/search/modules/findFiles/dialog.js"/>
<script language="Javascript" src="chrome://inspector/content/jsutil/xpcom/XPCU.js"/>
<script language="javascript" src="chrome://inspector/content/jsutil/system/FilePickerUtils.js"/>
<box orient="vertical">
<box autostretch="never">
<text id="txSearchFor" value="&txSearchFor.label;"/>
<textfield id="txfSearchFor" style="width: 25em;" persist="true"/>
</box>
<box autostretch="never">
<text id="txSearchPath" value="&txSearchPath.label;"/>
<textfield id="txfSearchPath" style="width: 25em;" persist="true"/>
<button id="btnSearchPathBrowser" value="Browse" onclick="dialog.browse()" persist="true"/>
</box>
<box autostretch="never">
<checkbox id="cbRecurse" value="&cbRecurse.label;"/>
</box>
</box>
<box id="okCancelButtonsRight"/>
</window>

View File

@ -0,0 +1,112 @@
<?xml version="1.0"?>
<search
title="Find Files"
xmlns="http://www.mozilla.org/inspector/isml"
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<dialog elements="txfSearchPath,txfSearchFor,cbRecurse"
href="chrome://inspector/content/search/modules/findFiles/dialog.xul"/>
<columns delimiter="">
<column title="File" name="path" flex="1" copy="true"/>
</columns>
<implementation>
<property name="progressPercent">
<getter><![CDATA[
return (100 * (this.mFileSearch.directoriesSearched+1)) / this.mDirDepth;
]]></getter>
</property>
<property name="progressText">
<getter><![CDATA[
return "blah";
]]></getter>
</property>
<property name="isPastMilestone">
<getter><![CDATA[
if (this.mDirDepth = 1) return true; // always update on a single dir search
var search = this.mFileSearch.directoriesSearched;
var is = search > this.mDirsSearched;
if (is)
this.mDirsSearched = search;
return is;
]]></getter>
</property>
<method name="searchStart">
<parameter name="aMap"/>
<body><![CDATA[
if (!aMap.txfSearchPath) return false;
var fsearch = inSearchUtils.createSearchHelper("file");
this.mFileSearch = fsearch;
var root = inSearchUtils.createLocalFile(aMap.txfSearchPath);
fsearch.searchPath = root;
fsearch.filenameCriteria = aMap.txfSearchFor ? aMap.txfSearchFor : "*";
fsearch.holdResults = false;
fsearch.basePath = aMap.txfSearchPath;
fsearch.returnRelativePaths = true;
fsearch.searchRecursive = aMap.cbRecurse;
this.mDirDepth = fsearch.getDirectoryDepth(root);
var observer = inSearchUtils.createSearchObserver(this, "File");
fsearch.searchAsync(observer);
]]></body>
</method>
<method name="searchStop">
<body><![CDATA[
if (this.mFileSearch)
this.mFileSearch.searchStop();
]]></body>
</method>
<method name="returnSearchResult">
<parameter name="aPath"/>
<body><![CDATA[
this.module.setResultProperty("path", aPath);
this.module.searchResultReady();
]]></body>
</method>
<!-- FileSearch observer -->
<method name="onFileSearchStart">
<parameter name="aProcess"/>
<body/>
</method>
<method name="onFileSearchResult">
<parameter name="aProcess"/>
<body><![CDATA[
var idx = aProcess.resultCount-1;
this.returnSearchResult(aProcess.getStringResultAt(idx));
]]></body>
</method>
<method name="onFileSearchEnd">
<parameter name="aProcess"/>
<parameter name="aResult"/>
<body><![CDATA[
this.module.searchEnd();
]]></body>
</method>
<method name="onFileSearchError">
<parameter name="aProcess"/>
<parameter name="aMsg"/>
<body/>
</method>
</implementation>
</search>

View File

@ -0,0 +1,50 @@
/***************************************************************
* JunkImgsDialog -------------------------------------------------
* Controller for dialog.
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
* REQUIRED IMPORTS:
****************************************************************/
//////////// global variables /////////////////////
var dialog;
//////////////////////////////////////////////////
window.addEventListener("load", JunkImgsDialog_initialize, false);
function JunkImgsDialog_initialize()
{
dialog = new JunkImgsDialog();
doSetOKCancel(gDoOKFunc);
}
////////////////////////////////////////////////////////////////////////////
//// class JunkImgsDialog
function JunkImgsDialog()
{
}
JunkImgsDialog.prototype =
{
browse: function()
{
var txf = document.getElementById("txfSearchPath");
var defaultPath = txf.getAttribute("value");
var file = FilePickerUtils.pickDir("Select Search Path", defaultPath);
if (file)
txf.setAttribute("value", file.path);
}
};
////////////////////////////////////////////////////////////////////////////
//// dialogOverlay stuff
function gDoOKFunc() {
window.close();
window.arguments[0].processDialog(window);
return true;
}

View File

@ -0,0 +1,42 @@
<?xml version="1.0"?>
<!DOCTYPE overlay SYSTEM "chrome://inspector/locale/search/junkImgs.dtd">
<?xul-overlay href="chrome://global/content/dialogOverlay.xul"?>
<?xml-stylesheet href="chrome://communicator/skin/"?>
<?xml-stylesheet href="chrome://inspector/skin/"?>
<window id="winJunkImgs" class="dialog"
title="&junkImgs.title;"
persist="screenX screenY"
orient="vertical"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script language="Javascript" src="chrome://inspector/content/search/modules/junkImgs/dialog.js"/>
<script language="Javascript" src="chrome://inspector/content/jsutil/xpcom/XPCU.js"/>
<script language="javascript" src="chrome://inspector/content/jsutil/system/FilePickerUtils.js"/>
<box orient="vertical">
<html style="width: 400px">&junkImgsDescription;</html>
<box autostretch="never">
<text id="txSearchPath" value="Search Path:"/>
<textfield id="txfSearchPath" flex="1" style="width: 25em;" persist="true"/>
<button id="btnSearchPathBrowser" value="Browse" onclick="dialog.browse()"/>
</box>
<!--
<box autostretch="never">
<text id="txRemotePath" value="Target URL:"/>
<textfield id="txfRemotePath" flex="1" persist="true"/>
</box>
<box autostretch="never">
<checkbox id="cbIsSkin" value="Target is a Skin" checked="true" persist="true"/>
</box>
-->
</box>
<box id="okCancelButtonsRight"/>
</window>

View File

@ -0,0 +1,176 @@
<?xml version="1.0"?>
<search
title="Find Unused Images in Current Theme"
defaultIcon="chrome://inspector/skin/ImageSearchItem.gif"
xmlns="http://www.mozilla.org/inspector/isml"
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<dialog elements="txfSearchPath" resizable="true"
href="chrome://inspector/content/search/modules/junkImgs/dialog.xul"/>
<columns delimiter="">
<column title="Path" name="path" flex="1" copy="true"/>
</columns>
<contextmenu>
<xul:menuitem value="View..." oncommand="this.search.cmdViewItem()" isEnabled="return true"/>
<xul:menuitem value="Delete File" oncommand="this.search.cmdDeleteItems()" isEnabled="return true"/>
</contextmenu>
<implementation>
<method name="constructor">
<body><![CDATA[
mHashTable = null;
]]></body>
</method>
<property name="progressPercent">
<getter><![CDATA[
return (100 * (this.mFileSearch.directoriesSearched+1)) / this.mDirDepth
]]></getter>
</property>
<property name="progressText">
<getter><![CDATA[
return "blah"
]]></getter>
</property>
<property name="isPastMilestone">
<getter><![CDATA[
var search = this.mFileSearch.directoriesSearched;
var is = search > this.mDirsSearched;
if (is)
this.mDirsSearched = search;
return is;
]]></getter>
</property>
<method name="searchStart">
<parameter name="aMap"/>
<body><![CDATA[
this.mParams = aMap;
this.mDirsSearched = 0;
// hash every image url in the css tree
this.buildCSSImageURLHash();
var fsearch = inSearchUtils.createSearchHelper("file");
this.mFileSearch = fsearch;
var root = inSearchUtils.createLocalFile(aMap.txfSearchPath);
fsearch.searchPath = root;
fsearch.filenameCriteria = "*.gif,*.png,*.jpg";
fsearch.holdResults = false;
fsearch.basePath = aMap.txfSearchPath;
fsearch.returnRelativePaths = true;
this.mDirDepth = fsearch.getDirectoryDepth(root);
var observer = inSearchUtils.createSearchObserver(this, "File");
fsearch.searchAsync(observer);
]]></body>
</method>
<method name="searchStop">
<body><![CDATA[
if (this.mFileSearch)
this.mFileSearch.searchStop();
]]></body>
</method>
<method name="buildCSSImageURLHash">
<body><![CDATA[
var cssSearch = inSearchUtils.createSearchHelper("cssvalue");
cssSearch.returnRelativeURLs = true;
cssSearch.normalizeChromeURLs = true; //this.mParams.cbIsSkin;
cssSearch.addPropertyCriteria("background-image");
cssSearch.addPropertyCriteria("list-style-image");
cssSearch.document = inspector.document;
cssSearch.searchSync(this);
var count = cssSearch.resultCount;
var hash = {};
for (var i = 0; i < count; i++) {
//debug(cssSearch.getStringResultAt(i)+"\n");
hash[cssSearch.getStringResultAt(i)] = 1;
}
this.mHashTable = hash;
]]></body>
</method>
<method name="returnSearchResult">
<parameter name="aFile"/>
<body><![CDATA[
this.module.setResultProperty("path", aFile.path);
this.module.searchResultReady();
]]></body>
</method>
<!-- context menu commands -->
<method name="cmdDeleteItems">
<body><![CDATA[
var mod = this.module;
var svc = mod.searchService;
var count = svc.selectedItemCount;
var idx, path, file;
for (var i = 0; i < count; ++i) {
idx = svc.getSelectedIndex(i);
path = mod.getResultPropertyAt(idx, "path");
file = inSearchUtils.createLocalFile(path);
if (file) {
file["delete"](false);
}
}
]]></body>
</method>
<method name="cmdViewItem" defaultCommand="true">
<body><![CDATA[
alert("view");
]]></body>
</method>
<!-- FileSearch observer -->
<method name="onFileSearchStart">
<parameter name="aProcess"/>
<body/>
</method>
<method name="onFileSearchResult">
<parameter name="aProcess"/>
<body><![CDATA[
var fs = this.mFileSearch;
var idx = fs.resultCount-1;
// get the relative-ized path for the file
var path = fs.getStringResultAt(idx);
// check if this path is in the css value hash
if (!this.mHashTable[path])
this.returnSearchResult(fs.getFileResultAt(idx));
]]></body>
</method>
<method name="onFileSearchEnd">
<parameter name="aProcess"/>
<parameter name="aResult"/>
<body><![CDATA[
this.module.searchEnd();
]]></body>
</method>
<method name="onFileSearchError">
<parameter name="aProcess"/>
<parameter name="aMsg"/>
<body/>
</method>
</implementation>
</search>

View File

@ -0,0 +1,28 @@
<?xml version="1.0"?>
<!DOCTYPE overlay [
<!ENTITY % dtd1 SYSTEM "chrome://inspector/locale/search/junkImgs.dtd"> %dtd1;
<!ENTITY % dtd2 SYSTEM "chrome://inspector/locale/search/findFiles.dtd"> %dtd2;
]>
<overlay id="ovJunkImgsPopup"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<menupopup id="mppSearchPlugins">
<menuitem id="item:startFindFiles" position="1"
value="&findFiles.title;..."
observes="cmd:startFindFiles"/>
<menuitem id="item:startJunkImgs" position="2"
value="&junkImgs.title;..."
isDisabled="return !inspector.isViewingContent"
observes="cmd:startJunkImgs"/>
<menuseparator position="3"/>
</menupopup>
</overlay>

View File

@ -0,0 +1,408 @@
/***************************************************************
* InspectorSidebar -------------------------------------------------
* The primary object that controls the Inspector sidebar.
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
* REQUIRED IMPORTS:
* chrome://inspector/content/ViewerRegistry.js
* chrome://inspector/content/jsutil/xpcom/XPCU.js
* chrome://inspector/content/jsutil/rdf/RDFArray.js
* chrome://inspector/content/jsutil/rdf/RDFU.js
* chrome://inspector/content/jsutil/xul/FrameExchange.js
* chrome://inspector/content/jsutil/Flasher.js
****************************************************************/
//////////// global variables /////////////////////
var inspector;
var kViewerRegURL = "chrome/inspector/viewer-registry.rdf";
//////////// global constants ////////////////////
const kXULNSURI = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
const kInstallDirId = "CurProcD";
const kFlasherCID = "@mozilla.org/inspector/flasher;1"
const kWindowMediatorIID = "@mozilla.org/rdf/datasource;1?name=window-mediator";
const kObserverServiceIID = "@mozilla.org/observer-service;1";
const kDirServiceCID = "@mozilla.org/file/directory_service;1"
var gNavigator = window._content;
const nsIPref = Components.interfaces.nsIPref;
//////////////////////////////////////////////////
window.addEventListener("load", InspectorSidebar_initialize, false);
function InspectorSidebar_initialize()
{
inspector = new InspectorSidebar();
inspector.initialize();
}
////////////////////////////////////////////////////////////////////////////
//// class InspectorSidebar
function InspectorSidebar() // implements inIViewerPaneContainer
{
try {
this.mInstallURL = this.getSpecialDirectory(kInstallDirId).URL;
} catch (ex) { alert(ex); }
kViewerRegURL = this.prependBaseURL(kViewerRegURL);
this.mUFlasher = XPCU.createInstance(kFlasherCID, "inIFlasher");
}
InspectorSidebar.prototype =
{
////////////////////////////////////////////////////////////////////////////
//// Initialization
mShell: null,
mViewerReg: null,
mPaneCount: 2,
mCurrentViewer: null,
mCurrentWindow: null,
mLoadChecks: 0,
mInstallURL: null,
mFlashSelected: null,
mFlashes: 0,
get document() { return this.mDocViewerPane.viewer.viewee; },
initialize: function()
{
this.loadViewerRegistry();
this.installNavObserver();
this.initPrefs();
this.setFlashSelected(PrefUtils.getPref("inspector.blink.on"));
},
initViewerPanes: function()
{
var elPane = document.getElementById("bxDocPane");
this.mDocViewerPane = new ViewerPane();
this.mDocViewerPane.initialize("Document", this, elPane, this.mViewerReg);
elPane = document.getElementById("bxObjectPane");
this.mObjViewerPane = new ViewerPane();
this.mObjViewerPane.initialize("Object", this, elPane, this.mViewerReg);
this.setAllViewerCmdAttributes("disabled", "true");
},
////////////////////////////////////////////////////////////////////////////
//// interface inIViewerPaneContainer
get viewerPaneCount() { return this.mPaneCount; },
onViewerChanged: function(aPane, aOldViewer, aOldEntry, aNewViewer, aNewEntry)
{
var ids, el, i;
this.mViewerReg.cacheViewer(aNewViewer, aNewEntry);
// disable all commands for for the old viewer
if (aOldViewer)
this.setViewerCmdAttribute(aOldEntry, "disabled", "true");
// enable all commands for for the new viewer
if (aNewViewer)
this.setViewerCmdAttribute(aNewEntry, "disabled", "false");
},
onVieweeChanged: function(aPane, aNewObject)
{
if (aPane == this.mDocViewerPane) {
this.mObjViewerPane.viewee = aNewObject;
if (this.mFlashSelected)
this.flashElement(aNewObject, this.mCurrentWindow);
}
},
getViewerPaneAt: function(aIndex)
{
if (aIndex == 0) {
return this.mDocViewerPane;
} else if (aIndex == 1) {
return this.mObjViewerPane;
} else {
return null;
}
},
setCommandAttribute: function(aCmdId, aAttribute, aValue)
{
var cmd = document.getElementById(aCmdId);
if (cmd)
cmd.setAttribute(aAttribute, aValue);
},
getCommandAttribute: function(aCmdId, aAttribute)
{
var cmd = document.getElementById(aCmdId);
if (cmd)
return cmd.getAttribute(aAttribute);
},
////////////////////////////////////////////////////////////////////////////
//// UI Commands
toggleFlashSelected: function(aExplicit, aValue)
{
var val = aExplicit ? aValue : !this.mFlashSelected;
PrefUtils.setPref("inspector.blink.on", val);
this.setFlashSelected(val);
},
setFlashSelected: function(aValue)
{
this.mFlashSelected = aValue;
var cmd = document.getElementById("cmdFlashSelected");
cmd.setAttribute("checked", aValue);
},
exit: function()
{
window.close()
},
////////////////////////////////////////////////////////////////////////////
//// Viewer Registry Interaction
loadViewerRegistry: function()
{
this.mViewerReg = new ViewerRegistry();
this.mViewerReg.load(kViewerRegURL, this);
},
onViewerRegistryLoad: function()
{
this.initViewerPanes();
},
onViewerRegistryLoadError: function(aStatus, aErrorMsg)
{
},
getViewer: function(aUID)
{
return this.mViewerReg.getViewerByUID(aUID);
},
////////////////////////////////////////////////////////////////////////////
//// History Commands
prepareHistory: function(aDS)
{
this.mHistory = RDFArray.fromContainer(aDS, "inspector:history", kInspectorNSURI);
var mppHistory = document.getElementById("mppHistory");
mppHistory.database.AddDataSource(aDS);
mppHistory.builder.rebuild();
},
addToHistory: function(aURL)
{
this.mHistory.add({ URL: aURL});
this.mHistory.save();
},
////////////////////////////////////////////////////////////////////////////
//// Navigation
setTargetWindow: function(aWindow)
{
if (aWindow) {
this.mCurrentWindow = aWindow;
this.setTargetDocument(aWindow.document);
} else
alert("Unable to switch to window");
},
setTargetDocument: function(aDoc)
{
this.mDocViewerPane.viewee = aDoc;
},
////////////////////////////////////////////////////////////////////////////
//// Preferences
initPrefs: function()
{
this.mPrefs = XPCU.getService("@mozilla.org/preferences;1", "nsIPref");
this.mPrefs.addObserver("inspector", PrefChangeObserver);
},
setPref: function(aName, aValue)
{
var type = this.mPrefs.GetPrefType(aName);
try {
if (type == nsIPref.ePrefString) {
this.mPrefs.SetUnicharPref(aName, aValue);
} else if (type == nsIPref.ePrefBool) {
this.mPrefs.SetBoolPref(aName, aValue);
} else if (type == nsIPref.ePrefInt) {
this.mPrefs.SetIntPref(aName, aValue);
}
} catch(ex) {
debug("ERROR: Unable to write pref \"" + aName + "\".\n");
}
},
getPref: function(aName)
{
var type = this.mPrefs.GetPrefType(aName);
try {
if (type == nsIPref.ePrefString) {
return this.mPrefs.CopyUnicharPref(aName);
} else if (type == nsIPref.ePrefBool) {
return this.mPrefs.GetBoolPref(aName);
} else if (type == nsIPref.ePrefInt) {
return this.mPrefs.GetIntPref(aName);
}
} catch(ex) {
debug("ERROR: Unable to read pref \"" + aName + "\".\n");
}
},
onPrefChanged: function(aName)
{
if (aName == "inspector.blink.on")
this.setFlashSelected(PrefUtils.getPref("inspector.blink.on"));
if (this.mFlasher) {
if (aName == "inspector.blink.border-color") {
this.mFlasher.color = PrefUtils.getPref("inspector.blink.border-color");
} else if (aName == "inspector.blink.border-width") {
this.mFlasher.thickness = PrefUtils.getPref("inspector.blink.border-width");
} else if (aName == "inspector.blink.duration") {
this.mFlasher.duration = PrefUtils.getPref("inspector.blink.duration");
} else if (aName == "inspector.blink.speed") {
this.mFlasher.speed = PrefUtils.getPref("inspector.blink.speed");
}
}
},
////////////////////////////////////////////////////////////////////////////
//// Uncategorized
fillInTooltip: function(tipElement)
{
var retVal = false;
var textNode = document.getElementById("txTooltip");
if (textNode) {
try {
var tipText = tipElement.getAttribute("tooltiptext");
if (tipText != "") {
textNode.setAttribute("value", tipText);
retVal = true;
}
}
catch (e) { }
}
return retVal;
},
onTreeItemSelected: function()
{
var tree = this.mDOMTree;
var items = tree.selectedItems;
if (items.length > 0) {
var node = this.getNodeFromTreeItem(items[0]);
this.startViewingNode(node, items[0].id);
}
},
///////////////////////////////////////////////////////////////////////////
// The string we get back from shell.getInstallationURL starts with
// "file://" and so we need to add an extra slash, or the load fails.
//
// @param wstring aURL - the url to repair
///////////////////////////////////////////////////////////////////////////
prependBaseURL: function(aURL)
{
return "file:///" + this.mInstallURL.substr(7) + aURL;
},
flashElement: function(aElement, aWindow)
{
// make sure we only try to flash element nodes
if (aElement.nodeType == 1) {
if (!this.mFlasher)
this.mFlasher = new Flasher(this.mUFlasher,
PrefUtils.getPref("inspector.blink.border-color"),
PrefUtils.getPref("inspector.blink.border-width"),
PrefUtils.getPref("inspector.blink.duration"),
PrefUtils.getPref("inspector.blink.speed"));
if (this.mFlasher.flashing)
this.mFlasher.stop();
try {
this.mFlasher.element = aElement;
this.mFlasher.window = aWindow;
this.mFlasher.start();
} catch (ex) {
}
}
},
setViewerCmdAttribute: function(aEntry, aAttr, aValue)
{
var uid = this.mViewerReg.getEntryProperty(aEntry, "uid");
var cmds = document.getElementById("brsGlobalCommands");
var els = cmds.getElementsByAttribute("viewer", uid);
for (var i = 0; i < els.length; i++) {
if (els[i].getAttribute("exclusive") != "false")
els[i].setAttribute(aAttr, aValue);
}
},
setAllViewerCmdAttributes: function(aAttr, aValue)
{
var count = this.mViewerReg.getEntryCount();
for (var i = 0; i < count; i++) {
this.setViewerCmdAttribute(this.mViewerReg.getEntryAt(i), aAttr, aValue);
}
},
getSpecialDirectory: function(aName)
{
var dirService = XPCU.getService(kDirServiceCID, "nsIProperties");
return dirService.get(aName, Components.interfaces.nsIFile);
},
installNavObserver: function()
{
var observerService = XPCU.getService(kObserverServiceIID, "nsIObserverService");
observerService.AddObserver(NavLoadObserver, "EndDocumentLoad");
}
};
var gHistoryLoadListener = {
onDataSourceReady: function(aDS)
{
inspector.prepareHistory(aDS);
},
onError: function()
{
}
};
var NavLoadObserver = {
Observe: function(aWindow)
{
inspector.setTargetWindow(aWindow);
}
};
var PrefChangeObserver = {
Observe: function(aSubject, aTopic, aData)
{
inspector.onPrefChanged(aData);
}
};

View File

@ -0,0 +1,67 @@
<?xml version="1.0"?>
<!DOCTYPE overlay [
<!ENTITY % dtd1 SYSTEM "chrome://inspector/locale/inspector.dtd"> %dtd1;
<!ENTITY % dtd2 SYSTEM "chrome://inspector/content/util.dtd"> %dtd2;
]>
<?xul-overlay href="chrome://inspector/content/commandOverlay.xul"?>
<?xul-overlay href="chrome://inspector/content/keysetOverlay.xul"?>
<?xul-overlay href="chrome://inspector/content/popupOverlay.xul"?>
<?xul-overlay href="chrome://inspector/content/statusbarOverlay.xul"?>
<?xml-stylesheet href="chrome://communicator/skin/"?>
<?xml-stylesheet href="chrome://inspector/skin/"?>
<window id="winInspectorSidebar" class="color-dialog"
title="Document Inspector" orient="vertical"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script language="Javascript" src="chrome://inspector/content/sidebar/InspectorSidebar.js"/>
<script language="javascript" src="chrome://inspector/content/ViewerRegistry.js"/>
<script language="javascript" src="chrome://inspector/content/ViewerPane.js"/>
<script language="javascript" src="chrome://inspector/content/utils.js"/>
<script language="javascript" src="chrome://inspector/content/jsutil/xpcom/XPCU.js"/>
<script language="javascript" src="chrome://inspector/content/jsutil/rdf/RDFU.js"/>
<script language="javascript" src="chrome://inspector/content/jsutil/rdf/RDFArray.js"/>
<script language="javascript" src="chrome://inspector/content/jsutil/xul/FrameExchange.js"/>
<script language="javascript" src="chrome://inspector/content/Flasher.js"/>
<popupset id="psTooltipSet">
<popup id="ppTooltip" class="tooltip" oncreate="return inspector.fillInTooltip(document.tooltipNode);">
<text id="txTooltip"/>
</popup>
</popupset>
<popupset id="ppsGlobalPopupset" collapsed="true"/>
<broadcasterset id="brsGlobalCommands"/>
<tabcontrol id="tbcInspectorSidebar" flex="1">
<tabbox>
<tab value="Document"/>
<tab value="Node"/>
</tabbox>
<tabpanel flex="1">
<box id="bxDocPane" flex="1" orient="vertical">
<box id="bxDocHeader" autostretch="never">
<menubutton class="viewer-list" ins-role="viewer-list" disabled="true"/>
<text class="viewer-title" ins-role="viewer-title" flex="1"/>
<menubutton class="viewer-menu" ins-role="viewer-menu" disabled="true"/>
</box>
<iframe id="ifDocViewer" class="viewer-iframe" flex="1" ins-role="viewer-iframe"/>
</box>
<box id="bxObjectPane" flex="1" orient="vertical">
<box id="bxObjHeader" autostretch="never">
<menubutton class="viewer-list" ins-role="viewer-list" disabled="true"/>
<text class="viewer-title" ins-role="viewer-title" flex="1"/>
<menubutton class="viewer-menu" ins-role="viewer-menu" disabled="true"/>
</box>
<iframe id="ifObjViewer" class="viewer-iframe" flex="1" ins-role="viewer-iframe"/>
</box>
</tabpanel>
</tabcontrol>
</window>

View File

@ -0,0 +1,11 @@
<?xml version="1.0"?>
<overlay id="ovStatusbar"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<box id="bxStatus">
<progressmeter id="pmStatus" mode="normal" value="0"/>
<text id="txStatus" value="Ready"/>
</box>
</overlay>

View File

@ -0,0 +1,30 @@
<?xml version="1.0"?>
<!DOCTYPE window SYSTEM "chrome://inspector/locale/tasksOverlay.dtd" >
<overlay id="eInspectorTasksOverlay"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script language="javascript">
function launchInspector()
{
toOpenWindowByType("inspector", "chrome://inspector/content");
}
</script>
<broadcasterset id="broadcasterset">
<broadcaster id="Tasks:Inspector" value="&inspectorTaskCmd.label;" oncommand="launchInspector();"/>
</broadcasterset>
<!--
<keyset id="keyset">
<key id="kInspectorTask" key="&inspectorTaskCmd.commandkey;" observes="Tasks:Inspector" modifiers="accel"/>
</keyset>
-->
<menupopup id="toolsPopup">
<menuitem accesskey="&inspectorTaskCmd.accesskey;" observes="Tasks:Inspector"/>
</menupopup>
</overlay>

View File

@ -0,0 +1,82 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://communicator/skin/box.css"?>
<?xml-stylesheet href="chrome://communicator/skin/brand.css"?>
<?xml-stylesheet href="chrome://communicator/skin/button.css"?>
<?xml-stylesheet href="chrome://communicator/skin/communicator.css"?>
<?xml-stylesheet href="chrome://communicator/skin/dialogOverlay.css"?>
<?xml-stylesheet href="chrome://communicator/skin/formatting.css"?>
<?xml-stylesheet href="chrome://communicator/skin/menubutton.css"?>
<?xml-stylesheet href="chrome://communicator/skin/prefpanels.css"?>
<?xml-stylesheet href="chrome://communicator/skin/securityOverlay.css"?>
<?xml-stylesheet href="chrome://communicator/skin/splitter.css"?>
<?xml-stylesheet href="chrome://communicator/skin/tasksOverlay.css"?>
<?xml-stylesheet href="chrome://communicator/skin/toolbar.css"?>
<?xml-stylesheet href="chrome://communicator/skin/bookmarks/bookmarks.css"?>
<?xml-stylesheet href="chrome://communicator/skin/directory/directory.css"?>
<?xml-stylesheet href="chrome://communicator/skin/profile/newProfile1_2.css"?>
<?xml-stylesheet href="chrome://communicator/skin/profile/profile.css"?>
<?xml-stylesheet href="chrome://communicator/skin/profile/profileManager.css"?>
<?xml-stylesheet href="chrome://communicator/skin/regviewer/regviewer.css"?>
<?xml-stylesheet href="chrome://communicator/skin/related/related.css"?>
<?xml-stylesheet href="chrome://communicator/skin/search/findresults.css"?>
<?xml-stylesheet href="chrome://communicator/skin/search/icons.css"?>
<?xml-stylesheet href="chrome://communicator/skin/search/internet.css"?>
<?xml-stylesheet href="chrome://communicator/skin/search/internetresults.css"?>
<?xml-stylesheet href="chrome://communicator/skin/search/search-editor.css"?>
<?xml-stylesheet href="chrome://communicator/skin/search/search.css"?>
<?xml-stylesheet href="chrome://communicator/skin/sidebar/customize.css"?>
<?xml-stylesheet href="chrome://communicator/skin/sidebar/preview.css"?>
<?xml-stylesheet href="chrome://communicator/skin/sidebar/sidebar.css"?>
<?xml-stylesheet href="chrome://communicator/skin/xpinstall/xpinstall.css"?>
<?xml-stylesheet href="chrome://editor/skin/EdImageMap.css"?>
<?xml-stylesheet href="chrome://editor/skin/EdImageMapPage.css"?>
<?xml-stylesheet href="chrome://editor/skin/editor.css"?>
<?xml-stylesheet href="chrome://editor/skin/EditorDialog.css"?>
<?xml-stylesheet href="chrome://editor/skin/EditorToolbars.css"?>
<?xml-stylesheet href="chrome://global/skin/box.css"?>
<?xml-stylesheet href="chrome://global/skin/button.css"?>
<?xml-stylesheet href="chrome://global/skin/checkbox.css"?>
<?xml-stylesheet href="chrome://global/skin/colorpicker.css"?>
<?xml-stylesheet href="chrome://global/skin/commonDialog.css"?>
<?xml-stylesheet href="chrome://global/skin/console.css"?>
<?xml-stylesheet href="chrome://global/skin/dialogOverlay.css"?>
<?xml-stylesheet href="chrome://global/skin/filepicker.css"?>
<?xml-stylesheet href="chrome://global/skin/formatting.css"?>
<?xml-stylesheet href="chrome://global/skin/global.css"?>
<?xml-stylesheet href="chrome://global/skin/menu.css"?>
<?xml-stylesheet href="chrome://global/skin/menubutton.css"?>
<?xml-stylesheet href="chrome://global/skin/menulist.css"?>
<?xml-stylesheet href="chrome://global/skin/radio.css"?>
<?xml-stylesheet href="chrome://global/skin/scrollbars.css"?>
<?xml-stylesheet href="chrome://global/skin/splitter.css"?>
<?xml-stylesheet href="chrome://global/skin/tabcontrol.css"?>
<?xml-stylesheet href="chrome://global/skin/tasksOverlay.css"?>
<?xml-stylesheet href="chrome://global/skin/textfield.css"?>
<?xml-stylesheet href="chrome://global/skin/toolbar.css"?>
<?xml-stylesheet href="chrome://global/skin/tree.css"?>
<?xml-stylesheet href="chrome://global/skin/wizardOverlay.css"?>
<?xml-stylesheet href="chrome://messenger/skin/AccountManager.css"?>
<?xml-stylesheet href="chrome://messenger/skin/fieldMapImport.css"?>
<?xml-stylesheet href="chrome://messenger/skin/folderPane.css"?>
<?xml-stylesheet href="chrome://messenger/skin/importDialog.css"?>
<?xml-stylesheet href="chrome://messenger/skin/mailheader.css"?>
<?xml-stylesheet href="chrome://messenger/skin/messenger.css"?>
<?xml-stylesheet href="chrome://messenger/skin/msgHdrViewOverlay.css"?>
<?xml-stylesheet href="chrome://messenger/skin/pref-mailnews.css"?>
<?xml-stylesheet href="chrome://messenger/skin/subscribe.css"?>
<?xml-stylesheet href="chrome://messenger/skin/threadPane.css"?>
<?xml-stylesheet href="chrome://messenger/skin/wizard.css"?>
<?xml-stylesheet href="chrome://messenger/skin/addressbook/addressbook.css"?>
<?xml-stylesheet href="chrome://messenger/skin/messengercompose/messengercompose.css"?>
<?xml-stylesheet href="chrome://navigator/skin/navigator.css"?>
<?xml-stylesheet href="chrome://navigator/skin/NavSecurityOverlay.css"?>
<window orient="vertical"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<text value="All skin css files are now loaded."/>
</window>

View File

@ -0,0 +1,97 @@
<?xml version="1.0"?>
<!DOCTYPE overlay [
<!ENTITY % dtd1 SYSTEM "chrome://inspector/locale/inspector.dtd"> %dtd1;
<!ENTITY % dtd2 SYSTEM "chrome://inspector/content/util.dtd"> %dtd2;
]>
<?xul-overlay href="chrome://inspector/content/popupOverlay.xul"?>
<overlay id="ovToolbox"
xmlns:ins="http://www.mozilla.org/inspector#"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<popupset id="ppsGlobalPopupset"/>
<menubar id="mbrInspectorMain">
<menu id="mnFile" value="&mnFile.label;" accesskey="&mnFile.accesskey;">
<menupopup id="mppFile">
<menu
id="mnWindowsFile" value="&mnWindows.label;" accesskey="&mnWindows.accesskey;"
datasources="rdf:window-mediator" ref="NC:WindowMediatorRoot">
<template>
<rule>
<menupopup>
<menuitem uri="rdf:*" value="&NC-rdf;Name" oncommand="inspector.goToWindow(this)"/>
</menupopup>
</rule>
</template>
</menu>
</menupopup>
</menu>
<menu id="mnEdit" value="&mnEdit.label;" accesskey="&mnEdit.accesskey;">
<menupopup id="mppEdit"/>
</menu>
<menu id="mnSearch" value="&mnSearch.label;" accesskey="&mnSearch.accesskey;">
<menupopup id="mppSearch"/>
</menu>
<menu id="mnView" value="&mnView.label;" accesskey="&mnView.accesskey;">
<menupopup id="mppView"/>
</menu>
<menu id="mnHelp" value="&mnHelp.label;" accesskey="&mnHelp.accesskey;">
<menupopup id="mppHelp"/>
</menu>
</menubar>
<toolbar id="tbInspectorPrimary">
<box id="bxURLBar" flex="1" autostretch="never" valign="middle">
<text id="txDocument" class="toolbar-header1" value="&txDocument.label;"/>
<box id="bxURLBarContainer" flex="1">
<box autostretch="never" valign="middle" flex="1">
<image id="imgURLBarIcon"/>
<textfield
id="tfURLBar" class="plain" flex="1"
observes="cmdGotoURL"
tooltip="PPTooltip" tooltiptext="Enter a URL to inspect"/>
</box>
<menubutton id="mbHistory" class="menubutton-icon">
<menupopup
id="mppHistory"
popupalign="topright" popupanchor="bottomright"
datasources="rdf:null" ref="inspector:history">
<template>
<rule>
<conditions>
<content uri="?uri"/>
<member container="?uri" child="?item"/>
<triple subject="?item" predicate="&INS-rdf;URL" object="?url"/>
</conditions>
<action>
<menuitem uri="?item" value="?url" oncommand="inspector.goToHistoryItem(this)"/>
</action>
</rule>
</template>
</menupopup>
</menubutton>
</box>
<button class="button-toolbar-3" value="&btnInspect.label;" observes="cmdGotoURL"/>
</box>
</toolbar>
</overlay>

View File

@ -0,0 +1,2 @@
<!ENTITY INS-rdf "http://www.mozilla.org/inspector#">
<!ENTITY NC-rdf "rdf:http://home.netscape.com/NC-rdf#">

View File

@ -0,0 +1,20 @@
<?xml version="1.0"?>
<window id="inspectorUtilWindow"
width="200" height="200"
persist="screenX screenY width height sizemode"
onload="opener.UtilWindowOpenListener(window)"
orient="vertical"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<spring flex="1"/>
<box id="bxOuter" orient="horizontal" flex="1">
<spring flex="1"/>
<box id="bxCenter" autostretch="never"/>
<spring flex="1"/>
</box>
<spring flex="1"/>
</window>

View File

@ -0,0 +1,74 @@
/***************************************************************
* Inspector Utils ----------------------------------------------
* Common functions and constants used across the app.
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
* REQUIRED IMPORTS:
* chrome://inspector/content/jsutil/xpcom/XPCU.js
* chrome://inspector/content/jsutil/rdf/RDFU.js
****************************************************************/
//////////// global constants ////////////////////
const kInspectorNSURI = "http://www.mozilla.org/inspector#";
const kXULNSURI = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
var InsUtil = {
/******************************************************************************
* Convenience function for calling nsIChromeRegistry::convertChromeURL
*******************************************************************************/
convertChromeURL: function(aURL)
{
var uri = XPCU.getService("@mozilla.org/network/simple-uri;1", "nsIURI");
uri.spec = aURL;
var reg = XPCU.getService("@mozilla.org/chrome/chrome-registry;1", "nsIChromeRegistry");
return reg.convertChromeURL(uri);
},
/******************************************************************************
* Convenience function for getting a literal value from nsIRDFDataSource::GetTarget
*******************************************************************************/
getDSProperty: function(/*nsISupports*/ aDS, /*String*/ aId, /*String*/ aPropName)
{
var ruleRes = gRDF.GetResource(aId);
var ds = XPCU.QI(aDS, "nsIRDFDataSource"); // just to be sure
var propRes = ds.GetTarget(ruleRes, gRDF.GetResource(kInspectorNSURI+aPropName), true);
propRes = XPCU.QI(propRes, "nsIRDFLiteral");
return propRes.Value;
}
};
// ::::::: debugging utilities ::::::
function debug(aText)
{
// XX comment out to reduce noise
//consoleDump(aText);
dump(aText);
}
function consoleDump(aText)
{
var csClass = Components.classes['@mozilla.org/consoleservice;1'];
var cs = csClass.getService(Components.interfaces.nsIConsoleService);
cs.logStringMessage(aText);
}
function dumpDOM(aNode, aIndent)
{
if (!aIndent) aIndent = "";
debug(aIndent + "<" + aNode.localName + "\n");
var attrs = aNode.attributes;
var attr;
for (var a = 0; a < attrs.length; ++a) {
attr = attrs[a];
debug(aIndent + " " + attr.nodeName + "=\"" + attr.nodeValue + "\"\n");
}
debug(aIndent + ">\n");
aIndent += " ";
for (var i = 0; i < aNode.childNodes.length; ++i)
dumpDOM(aNode.childNodes[i], aIndent);
}

View File

@ -0,0 +1,50 @@
<?xml version="1.0"?>
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:ins="http://www.mozilla.org/inspector#">
<rdf:Seq about="inspector:viewers">
<rdf:li><rdf:Description
ins:uid="dom"
ins:description="DOM Viewer"
ins:icon="chrome://inspector/content/viewers/dom/dom-icon.gif"
ins:filter="return object.nodeType == 9"/></rdf:li>
<rdf:li><rdf:Description
ins:uid="nodeElement"
ins:description="Element Node"
ins:filter="return object.nodeType == 1"/></rdf:li>
<rdf:li><rdf:Description
ins:uid="nodeText"
ins:description="Text Node"
ins:filter="return object.nodeType == 3"/></rdf:li>
<rdf:li><rdf:Description
ins:uid="stylesheets"
ins:description="Stylesheets"
ins:filter="return object.nodeType == 9"/></rdf:li>
<rdf:li><rdf:Description
ins:uid="styleRules"
ins:description="CSS Style Rules"
ins:filter="return object.nodeType == 1"/></rdf:li>
<rdf:li><rdf:Description
ins:uid="computedStyle"
ins:description="Computed Style"
ins:filter="return object.nodeType == 1"/></rdf:li>
<rdf:li><rdf:Description
ins:uid="xblBindings"
ins:description="XBL Bindings"
ins:filter="return object.nodeType == 1"/></rdf:li>
<rdf:li><rdf:Description
ins:uid="jsObject"
ins:description="Javascript Object"
ins:filter="return object.nodeType == 1"/></rdf:li>
</rdf:Seq>
</rdf:RDF>

View File

@ -0,0 +1,12 @@
<?xml version="1.0"?>
<!DOCTYPE overlay [
<!ENTITY % dtd1 SYSTEM "chrome://inspector/locale/inspector.dtd"> %dtd1;
<!ENTITY % dtd2 SYSTEM "chrome://inspector/content/util.dtd"> %dtd2;
]>
<overlay id="ovViewer"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
</overlay>

View File

@ -0,0 +1,63 @@
/***************************************************************
* ComputedStyleViewer --------------------------------------------
* The viewer for the computed css styles on a DOM element.
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
* REQUIRED IMPORTS:
* chrome://inspector/content/jsutil/xpcom/XPCU.js
****************************************************************/
//////////// global variables /////////////////////
var viewer;
//////////// global constants ////////////////////
//////////////////////////////////////////////////
window.addEventListener("load", ComputedStyleViewer_initialize, false);
function ComputedStyleViewer_initialize()
{
viewer = new ComputedStyleViewer();
viewer.initialize(parent.FrameExchange.receiveData(window));
}
////////////////////////////////////////////////////////////////////////////
//// class ComputedStyleViewer
function ComputedStyleViewer()
{
this.mURL = window.location;
}
ComputedStyleViewer.prototype =
{
////////////////////////////////////////////////////////////////////////////
//// Initialization
mViewee: null,
mPane: null,
////////////////////////////////////////////////////////////////////////////
//// interface inIViewer
get uid() { return "computedStyle" },
get pane() { return this.mPane },
get viewee() { return this.mViewee },
set viewee(aObject)
{
},
initialize: function(aPane)
{
this.mPane = aPane;
aPane.onViewerConstructed(this);
},
destroy: function()
{
}
};

View File

@ -0,0 +1,22 @@
<?xml version="1.0"?>
<!DOCTYPE overlay [
<!ENTITY % dtd1 SYSTEM "chrome://inspector/locale/inspector.dtd"> %dtd1;
<!ENTITY % dtd2 SYSTEM "chrome://inspector/content/util.dtd"> %dtd2;
]>
<?xml-stylesheet href="chrome://communicator/skin"?>
<window id="winComputedStyle" class="color-dialog"
orient="vertical"
xmlns:html="http://www.w3.org/1999/xhtml"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script language="javascript" src="chrome://inspector/content/viewers/computedStyle/computedStyle.js"/>
<script language="javascript" src="chrome://inspector/content/jsutil/xpcom/XPCU.js"/>
<text value="Not Yet Implemented"/>
</window>

View File

@ -0,0 +1,126 @@
/***************************************************************
* FindDialog ---------------------------------------------------
* Controls the dialog box used for searching the DOM.
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
* REQUIRED IMPORTS:
* chrome://inspector/content/jsutil/xpcom/XPCU.js
* chrome://inspector/content/jsutil/rdf/RDFU.js
****************************************************************/
//////////// global variables /////////////////////
var dialog;
//////////// global constants ////////////////////
//////////////////////////////////////////////////
window.addEventListener("load", FindDialog_initialize, false);
function FindDialog_initialize()
{
dialog = new FindDialog();
}
////////////////////////////////////////////////////////////////////////////
//// class FindDialog
function FindDialog()
{
this.toggleType(window.arguments[0]);
this.mOpener = window.arguments[1];
document.getElementById("tfText1").focus();
}
FindDialog.prototype =
{
mType: null,
////////// Properties
////////// Methods
doFind: function()
{
var el = document.getElementById("tfText1");
if (this.mType == "id") {
this.mOpener.doFindElementById(el.value);
} else if (this.mType == "tag") {
this.mOpener.doFindElementsByTagName(el.value);
} else if (this.mType == "attr") {
var el2 = document.getElementById("tfText2");
this.mOpener.doFindElementsByAttr(el.value, el2.value);
}
this.close();
},
close: function()
{
window.close();
},
toggleType: function(aType)
{
this.mType = aType;
if (aType == "id") {
this.showDirection(false);
this.setLabel1("Find Id");
this.setLabel2(null);
} else if (aType == "tag") {
this.showDirection(true);
this.setLabel1("Find Tag");
this.setLabel2(null);
} else if (aType == "attr") {
this.showDirection(true);
this.setLabel1("Attribute");
this.setLabel2("Value");
}
var rd = document.getElementById("rdType_"+aType.toLowerCase());
if (rd) {
var rg = document.getElementById("rgType");
rg.selectedItem = rd;
}
},
setLabel1: function(aVal)
{
this.setLabel(1, aVal);
},
setLabel2: function(aVal)
{
this.setLabel(2, aVal);
},
setLabel: function(aIdx, aVal)
{
var el = document.getElementById("txText"+aIdx);
var row = document.getElementById("rwRow"+aIdx);
if (aVal) {
el.setAttribute("value", aVal + ":");
row.setAttribute("hide", "false");
} else {
row.setAttribute("hide", "true");
}
},
setDirection: function(aMode)
{
var rd = document.getElementById("rdDir_"+aMode.toLowerCase());
if (rd) {
var rg = document.getElementById("rgDirection");
rg.selectedItem = rd;
}
},
showDirection: function(aTruth)
{
//document.getElementById("tbxDirection").setAttribute("hide", !aTruth);
}
};

View File

@ -0,0 +1,214 @@
/***************************************************************
* ColumnsDialog --------------------------------------------
* Dialog box for editing the columns in the DOM Viewer tree.
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
* REQUIRED IMPORTS:
****************************************************************/
//////////// global variables /////////////////////
var dialog;
var gColumnTitles = [
"nodeName",
"nodeType",
"prefix",
"localName",
"namespaceURI"
];
//////////// global constants ////////////////////
//////////////////////////////////////////////////
window.addEventListener("load", ColumnsDialog_initialize, false);
window.addEventListener("unload", ColumnsDialog_destroy, false);
function ColumnsDialog_initialize()
{
dialog = new ColumnsDialog();
dialog.initialize();
}
function ColumnsDialog_destroy()
{
dialog.destroy();
}
////////////////////////////////////////////////////////////////////////////
//// class ColumnsDialog
function ColumnsDialog()
{
this.mViewer = window.arguments[0];
this.mColBoxHash = {};
}
ColumnsDialog.prototype =
{
mBox: null,
mDraggingBox: null,
get box() { return this.mBox },
initialize: function()
{
// bug 56270 - dragSession.sourceDocument is null --
// causes me to code this very temporary, very nasty hack
// to make sure I get notified when a column is dropped
opener.viewer.mDOMTree.onClientDrop = ColumnsDialogDragDropOut;
this.buildContents();
// notify the dom viewer that we've opened
this.mViewer.onColumnsDialogReady(this);
},
destroy: function()
{
// notify the dom viewer that we're going away
this.mViewer.onColumnsDialogClose(this);
},
buildContents: function()
{
var box = document.getElementById("bxColumns");
this.mBox = box;
// create the special attribute box
var item = this.createAttrItem();
box.appendChild(item);
// add all boxes except those that are already
// in the viewer
for (var i = 0; i < gColumnTitles.length; ++i)
if (!this.mViewer.hasColumn(gColumnTitles[i])) {
this.addItem(gColumnTitles[i]);
}
},
addItem: function(aValue)
{
if (!aValue || aValue.charAt(0) == "@")
return null;
item = this.createItem(aValue);
this.mColBoxHash[aValue] = item;
if (item) {
this.mBox.appendChild(item);
window.sizeToContent();
}
},
removeItem: function(aValue)
{
if (!aValue || aValue.charAt(0) == "@")
return null;
var colBox = this.mColBoxHash[aValue];
if (!colBox._isAttrCol) {
this.mBox.removeChild(colBox);
window.sizeToContent();
}
},
createItem: function(aValue)
{
var text = document.createElementNS(kXULNSURI, "text");
text._ColValue = aValue;
text._isColBox = true;
text._isAttrCol = false;
text.setAttribute("class", "column-selector");
text.setAttribute("value", aValue);
return text;
},
createAttrItem: function(aValue)
{
var box = document.createElementNS(kXULNSURI, "box");
box._isColBox = true;
box._isAttrCol = true;
box.setAttribute("class", "column-selector");
box.setAttribute("autostretch", "never");
var text = document.createElementNS(kXULNSURI, "text");
text.setAttribute("value", "Attr");
box.appendChild(text);
var txf = document.createElementNS(kXULNSURI, "textfield");
txf.setAttribute("class", "attr-column-selector");
txf.setAttribute("flex", 1);
box.appendChild(txf);
return box;
},
////////////////////////////////////////////////////////////////////////////
//// Drag and Drop
onDragGesture: function(aEvent)
{
var box = this.getBoxTarget(aEvent.target);
this.setDraggingBox(box);
if (!box) return false;
var column = this.getColumnValue(box);
if (!column) return false;
DNDUtils.invokeSession(aEvent.target, ["TreeTableBuilder/column-add"], [column]);
return false;
},
onDragDropOut: function()
{
var box = document.getElementById("bxColumns");
var value = this.mDraggingBox._ColValue;
this.setDraggingBox(null);
this.removeItem(value);
},
onDragDropIn: function(aEvent)
{
var data = DNDUtils.getData("TreeTableBuilder/column-remove", 0);
var string = XPCU.QI(data, "nsISupportsWString");
this.addItem(string.data);
},
setDraggingBox: function(aBox)
{
if (this.mDraggingBox) {
this.mDraggingBox.setAttribute("col-dragging", "false");
}
this.mDraggingBox = aBox;
if (aBox)
aBox.setAttribute("col-dragging", "true");
},
getBoxTarget: function(aNode)
{
var node = aNode;
while (node && !node._isColBox)
node = node.parentNode;
return node;
},
getColumnValue: function(aColBox)
{
if (aColBox._isAttrCol) {
var txf = aColBox.getElementsByTagName("textfield")[0];
return "@" + txf.value;
} else {
return aColBox._ColValue;
}
}
};
function ColumnsDialogDragDropOut()
{
dialog.onDragDropOut();
}

View File

@ -0,0 +1,24 @@
<?xml version="1.0"?>
<!DOCTYPE overlay SYSTEM "chrome://inspector/locale/viewers/dom.dtd">
<?xml-stylesheet href="chrome://inspector/skin/viewers/dom/columnsDialog.css"?>
<window id="winEditCols" class="color-dialog"
title="&ColumnsDialog.title;"
persist="screenX screenY"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script language="javascript" src="chrome://inspector/content/viewers/dom/columnsDialog.js"/>
<script language="javascript" src="chrome://inspector/content/utils.js"/>
<script language="javascript" src="chrome://inspector/content/jsutil/xpcom/XPCU.js"/>
<script language="javascript" src="chrome://inspector/content/jsutil/rdf/RDFU.js"/>
<script language="javascript" src="chrome://inspector/content/jsutil/xul/inTreeTableBuilder.js"/>
<script language="javascript" src="chrome://inspector/content/jsutil/xul/DNDUtils.js"/>
<box id="bxColumns" flex="1" orient="vertical"
ondragdrop="dialog.onDragDropIn(event);"
ondraggesture="dialog.onDragGesture(event);"/>
</window>

View File

@ -0,0 +1,30 @@
<?xml version="1.0"?>
<!DOCTYPE rdf [
<!ENTITY % dtd1 SYSTEM "chrome://inspector/locale/viewers/dom.dtd"> %dtd1;
]>
<overlay id="ovDOMViewerCommands"
xmlns:ins="http://www.mozilla.org/inspector#"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<broadcasterset id="brsGlobalCommands">
<broadcaster id="cmd:selectByClick" viewer="dom"
oncommand="inspector.getViewer('dom').selectByClick()"/>
<broadcaster id="cmd:find" viewer="dom"
oncommand="inspector.getViewer('dom').showFindDialog()"/>
<broadcaster id="cmd:findNext" viewer="dom"
oncommand="inspector.getViewer('dom').findNext()"/>
<broadcaster id="cmd:toggleAnon" viewer="dom"
oncommand="inspector.getViewer('dom').toggleAnonContent()"/>
<broadcaster id="cmd:showColumns" viewer="dom"
oncommand="inspector.getViewer('dom').showColumnsDialog()"/>
</broadcasterset>
</overlay>

View File

@ -0,0 +1,355 @@
/***************************************************************
* DOMViewer --------------------------------------------
* Views all nodes within a document.
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
* REQUIRED IMPORTS:
* chrome://inspector/content/util.js
* chrome://inspector/content/jsutil/xpcom/XPCU.js
* chrome://inspector/content/jsutil/rdf/RDFU.js
****************************************************************/
//////////// global variables /////////////////////
var viewer;
var gColumnExtras = {
"Anonymous": "Anonymous",
"NodeType": "NodeType"
};
var gColumnAttrs = {
"class": "triDOMView"
};
//////////// global constants ////////////////////
var kDOMDataSourceIID = "@mozilla.org/rdf/datasource;1?name=Inspector_DOM";
//////////////////////////////////////////////////
window.addEventListener("load", DOMViewer_initialize, false);
function DOMViewer_initialize()
{
viewer = new DOMViewer();
viewer.initialize(parent.FrameExchange.receiveData(window));
}
////////////////////////////////////////////////////////////////////////////
//// class DOMViewer
function DOMViewer() // implements inIViewer
{
this.mDialogs = [];
this.mDOMTree = document.getElementById("trDOMTree");
// prepare and attach the DOM DataSource
this.mDOMDS = XPCU.createInstance(kDOMDataSourceIID, "nsIInsDOMDataSource");
this.mDOMDS.removeFilterByType(2); // hide attribute nodes
this.mDOMTree.database.AddDataSource(this.mDOMDS);
}
DOMViewer.prototype =
{
mViewee: null,
mDOMDS: null,
// searching stuff
mSearchResults: null,
mSearchCurrentIdx: null,
mSearchDirection: null,
mColumns: null,
mDialogs: null,
////////////////////////////////////////////////////////////////////////////
//// interface inIViewer
//// attributes
get uid() { return "dom" },
get pane() { return this.mPane },
get viewee() { return this.mViewee },
set viewee(aObject) {
this.mViewee = aObject;
this.mDOMDS.document = aObject;
try {
this.mTreeBuilder.buildContent();
} catch (ex) {
debug("ERROR: While rebuilding dom tree\n" + ex);
}
},
//// methods
initialize: function(aPane)
{
this.initColumns();
this.mPane = aPane;
aPane.onViewerConstructed(this);
this.toggleAnonContent(true, false);
},
destroy: function()
{
for (var i = 0; i < this.mDialogs.length; ++i) {
this.mDialogs[i].close();
this.mDialogs[i] = null;
}
},
////////////////////////////////////////////////////////////////////////////
//// UI Commands
showFindDialog: function()
{
var win = openDialog("chrome://inspector/content/viewers/dom/findDialog.xul", "_blank", "chrome", "id", this);
this.mDialogs.push(win);
},
findNext: function()
{
if (this.mSearchResults) {
this.mSearchCurrentIdx++;
if (this.mSearchCurrentIdx >= this.mSearchResults.length)
this.mSearchCurrentIdx = 0;
this.selectElementInTree(this.mSearchResults[this.mSearchCurrentIdx]);
}
},
toggleAnonContent: function(aExplicit, aValue)
{
var val = aExplicit ? aValue : !this.mDOMDS.showAnonymousContent;
this.mDOMDS.showAnonymousContent = val;
this.mPane.setCommandAttribute("cmd:toggleAnon", "checked", val ? "true" : "false");
},
showColumnsDialog: function()
{
var win = openDialog("chrome://inspector/content/viewers/dom/columnsDialog.xul",
"_blank", "chrome,dependent", this);
this.mDialogs.push(win);
},
selectByClick: function()
{
// wait until after user releases the mouse after selecting this command from a UI element
window.setTimeout("viewer.startSelectByClick()", 10);
},
startSelectByClick: function()
{
var doc = this.mDOMDS.document;
doc.addEventListener("mousedown", gClickListener, true);
},
doSelectByClick: function(aTarget)
{
var doc = this.mDOMDS.document;
doc.removeEventListener("mousedown", gClickListener, true);
this.selectElementInTree(aTarget);
},
onTreeItemSelected: function()
{
var item = this.mDOMTree.selectedItems[0];
this.mPane.onVieweeChanged(this.getNodeFromTreeItem(item));
},
////////////////////////////////////////////////////////////////////////////
//// Searching Methods
doFindElementById: function(aValue)
{
var el = this.mDOMDS.document.getElementById(aValue);
if (el) {
this.selectElementInTree(el);
} else {
alert("No elements were found.");
}
},
doFindElementsByTagName: function(aValue)
{
var els = this.mDOMDS.document.getElementsByTagName(aValue);
if (els.length == 0) {
alert("No elements were found.");
} else {
this.mSearchResults = els;
this.mSearchCurrentIdx = 0;
this.selectElementInTree(els[0]);
}
},
doFindElementsByAttr: function(aAttr, aValue)
{
var els = this.mDOMDS.document.getElementsByAttribute(aAttr, aValue);
if (els.length == 0) {
alert("No elements were found.");
} else {
this.mSearchResults = els;
this.mSearchCurrentIdx = 0;
this.selectElementInTree(els[0]);
}
},
///////////////////////////////////////////////////////////////////////////
// Takes an element from the document being inspected, finds the treeitem
// which represents it in the DOM tree and selects that treeitem.
//
// @param aEl - element from the document being inspected
///////////////////////////////////////////////////////////////////////////
selectElementInTree: function(aEl)
{
var searching = true;
var parent = aEl;
var line = [];
var res, item;
// Keep searching until a pre-created ancestor is
// found, and then open each ancestor until
// the found element is created
while (searching && parent) {
res = this.mDOMDS.getResourceForObject(parent);
item = document.getElementById(res.Value);
line.push(parent);
if (!item) {
parent = parent.parentNode;
} else {
// we've got all the ancestors, now open them
// one-by-one from the top on down
for (var i = line.length-1; i >= 0; i--) {
res = this.mDOMDS.getResourceForObject(line[i]);
item = document.getElementById(res.Value);
if (!item) return false; // can't find item, so stop trying to descend
item.setAttribute("open", "true");
}
searching = false;
this.mDOMTree.selectItem(item);
}
}
},
////////////////////////////////////////////////////////////////////////////
//// Columns
initColumns: function()
{
var colPref = PrefUtils.getPref("inspector.dom.columns");
var cols = colPref.split(",")
this.mColumns = cols;
this.mColumnHash = {};
var tb = new inTreeTableBuilder(this.mDOMTree, kInspectorNSURI, "Child");
tb.allowDragColumns = true;
tb.isRefContainer = false;
tb.isContainer = true;
tb.itemAttributes = gColumnAttrs;
tb.itemFields = gColumnExtras;
this.mTreeBuilder = tb;
tb.initialize();
for (var i = 0; i < cols.length; i++) {
this.mColumnHash[cols[i]] = true;
tb.addColumn({
name: cols[i],
title: cols[i],
flex: i == 0 ? 2 : 1,
className: "triDOMView"});
}
// start listening for modifications to columns
// from drag and drop operations
tb.onColumnAdd = gColumnAddListener;
tb.onColumnRemove = gColumnRemoveListener;
tb.build();
},
hasColumn: function(aName)
{
return this.mColumnHash[aName] == true;
},
//// these add/remove methods depend on names that have already
//// been added to the tree builder
doAddColumn: function(aIndex)
{
var name = this.mTreeBuilder.getColumnName(aIndex);
this.mColumnHash[name] = true;
this.mColumns.splice(aIndex, 0, name);
this.saveColumns();
},
doRemoveColumn: function(aIndex)
{
var name = this.mColumns[aIndex];
this.mColumnHash[name] = null;
this.mColumns.splice(aIndex, 1);
this.saveColumns();
},
onColumnAdd: function(aIndex)
{
this.doAddColumn(aIndex);
},
onColumnRemove: function(aIndex)
{
this.doRemoveColumn(aIndex);
},
saveColumns: function()
{
var cols = this.mColumns.join(",");
PrefUtils.setPref("inspector.dom.columns", cols);
},
onColumnsDialogReady: function (aDialog)
{
this.mColumnsDialog = aDialog;
this.mTreeBuilder.addColumnDropTarget(aDialog.box);
},
onColumnsDialogClose: function (aDialog)
{
this.mColumnsDialog = null;
},
////////////////////////////////////////////////////////////////////////////
//// Uncategorized
getNodeFromTreeItem: function(aItem)
{
var res = gRDF.GetResource(aItem.id);
res = res.QueryInterface(Components.interfaces.nsIDOMDSResource);
return res ? res.object : null;
}
};
////////////////////////////////////////////////////////////////////////////
//// Listener Objects
function gClickListener(aEvent)
{
viewer.doSelectByClick(aEvent.target);
}
function gColumnAddListener(aIndex)
{
viewer.onColumnAdd(aIndex);
}
function gColumnRemoveListener(aIndex)
{
viewer.onColumnRemove(aIndex);
}

View File

@ -0,0 +1,37 @@
<?xml version="1.0"?>
<!DOCTYPE overlay [
<!ENTITY % dtd1 SYSTEM "chrome://inspector/locale/inspector.dtd"> %dtd1;
<!ENTITY % dtd2 SYSTEM "chrome://inspector/content/util.dtd"> %dtd2;
]>
<?xml-stylesheet href="chrome://inspector/skin/viewers/dom/dom.css"?>
<window id="winDOMViewer" class="color-dialog"
orient="vertical"
xmlns:html="http://www.w3.org/1999/xhtml"
xmlns:ins="http://www.mozilla.org/inspector#"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script language="javascript" src="chrome://inspector/content/viewers/dom/dom.js"/>
<script language="javascript" src="chrome://inspector/content/jsutil/xpcom/XPCU.js"/>
<script language="javascript" src="chrome://inspector/content/utils.js"/>
<script language="javascript" src="chrome://inspector/content/jsutil/rdf/RDFU.js"/>
<script language="javascript" src="chrome://inspector/content/jsutil/system/PrefUtils.js"/>
<script language="javascript" src="chrome://inspector/content/jsutil/xul/inTreeTableBuilder.js"/>
<script language="javascript" src="chrome://inspector/content/jsutil/xul/DNDUtils.js"/>
<!-- ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
The template for this tree will be filled in by inTreeTableBuilder
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -->
<tree id="trDOMTree"
flex="1" onselect="viewer.onTreeItemSelected()"
datasources="rdf:null" ref="inspector:DOMRoot"
containment="&INS-rdf;HasChildren" flags="dont-test-empty">
<template/>
</tree>
</window>

View File

@ -0,0 +1,69 @@
<?xml version="1.0"?>
<!DOCTYPE overlay SYSTEM "chrome://inspector/content/inspector.dtd">
<?xml-stylesheet href="chrome://inspector/skin/viewers/dom/findDialog.css"?>
<window id="winFind" class="dialog"
title="Find"
persist="screenX screenY"
orient="horizontal"
xmlns:html="http://www.w3.org/1999/xhtml"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script language="javascript" src="chrome://inspector/content/viewers/dom/FindDialog.js"/>
<script language="javascript" src="chrome://inspector/content/jsutil/xpcom/XPCU.js"/>
<script language="javascript" src="chrome://inspector/content/jsutil/rdf/RDFU.js"/>
<broadcasterset id="brsBroadcasters">
<broadcaster id="cmdFind" oncommand="dialog.doFind()" onkeypress="if (event.keyCode == 13) dialog.doFind()"/>
<broadcaster id="cmdClose" oncommand="dialog.close()"/>
</broadcasterset>
<keyset id="ksKeys">
<key id="kClose" keycode="VK_ESCAPE" observes="cmdClose"/>
</keyset>
<box orient="vertical" autostretch="never">
<grid>
<columns>
<column/>
<column flex="1"/>
</columns>
<rows>
<row id="rwRow1">
<text id="txText1" value=""/>
<textfield id="tfText1" observes="cmdFind"/>
</row>
<row id="rwRow2">
<text id="txText2" value=""/>
<textfield id="tfText2" observes="cmdFind"/>
</row>
</rows>
</grid>
<box orient="horizontal" autostretch="never" style="vertical-align: top">
<titledbox id="tbxType">
<title value="Search By"/>
<radiogroup id="rgType" orient="vertical">
<radio id="rdType_id" value="ID" oncommand="dialog.toggleType('id')"/>
<radio id="rdType_tag" value="Tag" oncommand="dialog.toggleType('tag')"/>
<radio id="rdType_attr" value="Attribute" oncommand="dialog.toggleType('attr')"/>
</radiogroup>
</titledbox>
<titledbox id="tbxDirection" hide="true">
<title value="Direction"/>
<radiogroup id="rgDirection" orient="horizontal">
<radio id="rdDir_up" value="Up"/>
<radio id="rdDir_down" value="Down"/>
</radiogroup>
</titledbox>
</box>
</box>
<box orient="vertical">
<button value="Find" observes="cmdFind" default="true"/>
<button value="Close" observes="cmdClose"/>
</box>
</window>

View File

@ -0,0 +1,15 @@
<?xml version="1.0"?>
<!DOCTYPE rdf SYSTEM "chrome://inspector/locale/viewers/dom.dtd">
<overlay id="ovDOMViewerKeyset"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<keyset id="ksGlobalKeyset">
<key id="key:find" xulkey="true" key="&cmdShowFindDialog.accelkey;" observes="cmd:find" modifiers="accel"/>
<key id="key:findNext" keycode="VK_F3" observes="cmd:findNext"/>
</keyset>
</overlay>

View File

@ -0,0 +1,72 @@
<?xml version="1.0"?>
<!DOCTYPE rdf SYSTEM "chrome://inspector/locale/viewers/dom.dtd">
<overlay id="ovDOMViewerPopup"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<popupset id="ppsGlobalPopupset">
<menupopup id="ppViewerContext-dom">
<menuitem id="item:find"
value="&cmdShowFindDialog.label;"
accesskey="&cmdShowFindDialog.accesskey;"
key="key:find"
observes="cmd:find"/>
<menuitem id="item:findNext"
value="&cmdFindNext.label;"
key="key:findNext"
observes="cmd:findNext"/>
<menuseparator/>
<menuitem id="item:toggleAnon"
class="menuitem-iconic"
type="checkbox"
value="&cmdToggleAnonContent.label;"
accesskey="&cmdToggleAnonContent.accesskey;"
observes="cmd:toggleAnon"/>
<menuseparator/>
<menuitem id="item:showColumns"
value="&cmdShowColumnsDialog.label;"
accesskey="&cmdShowColumnsDialog.accesskey;"
observes="cmd:showColumns"/>
</menupopup>
</popupset>
<menupopup id="mppSearch">
<menuitem id="item:find" position="1"
value="&cmdShowFindDialog.label;"
accesskey="&cmdShowFindDialog.accesskey;"
key="key:find"
observes="cmd:find"/>
<menuitem id="item:findNext" position="2"
value="&cmdFindNext.label;"
key="key:findNext"
observes="cmd:findNext"/>
<menuseparator position="3"/>
<menuitem id="item:selectByClick" position="4"
value="&cmdSelectByClick.label;"
accesskey="&cmdSelectByClick.accesskey;"
observes="cmd:selectByClick"/>
</menupopup>
<menupopup id="mppView">
<menuitem id="item:toggleAnon"
class="menuitem-iconic"
type="checkbox"
value="&cmdToggleAnonContent.label;"
accesskey="&cmdToggleAnonContent.accesskey;"
observes="cmd:toggleAnon"/>
</menupopup>
</overlay>

View File

@ -0,0 +1,63 @@
/***************************************************************
* JSObjectViewer --------------------------------------------
* The viewer for all facets of a javascript object.
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
* REQUIRED IMPORTS:
* chrome://inspector/content/jsutil/xpcom/XPCU.js
****************************************************************/
//////////// global variables /////////////////////
var viewer;
//////////// global constants ////////////////////
//////////////////////////////////////////////////
window.addEventListener("load", JSObjectViewer_initialize, false);
function JSObjectViewer_initialize()
{
viewer = new JSObjectViewer();
viewer.initialize(parent.FrameExchange.receiveData(window));
}
////////////////////////////////////////////////////////////////////////////
//// class JSObjectViewer
function JSObjectViewer()
{
this.mURL = window.location;
}
JSObjectViewer.prototype =
{
////////////////////////////////////////////////////////////////////////////
//// Initialization
mViewee: null,
mPane: null,
////////////////////////////////////////////////////////////////////////////
//// interface inIViewer
get uid() { return "computedStyle" },
get pane() { return this.mPane },
get viewee() { return this.mViewee },
set viewee(aObject)
{
},
initialize: function(aPane)
{
this.mPane = aPane;
aPane.onViewerConstructed(this);
},
destroy: function()
{
}
};

View File

@ -0,0 +1,22 @@
<?xml version="1.0"?>
<!DOCTYPE overlay [
<!ENTITY % dtd1 SYSTEM "chrome://inspector/locale/inspector.dtd"> %dtd1;
<!ENTITY % dtd2 SYSTEM "chrome://inspector/content/util.dtd"> %dtd2;
]>
<?xml-stylesheet href="chrome://communicator/skin"?>
<window id="winJSObject" class="color-dialog"
orient="vertical"
xmlns:html="http://www.w3.org/1999/xhtml"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script language="javascript" src="chrome://inspector/content/viewers/jsObject/jsObject.js"/>
<script language="javascript" src="chrome://inspector/content/jsutil/xpcom/XPCU.js"/>
<text value="Not Yet Implemented"/>
</window>

View File

@ -0,0 +1,151 @@
/***************************************************************
* NodeElementViewer --------------------------------------------
* The default viewer for DOM Nodes
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
* REQUIRED IMPORTS:
* chrome://inspector/content/util.js
* chrome://inspector/content/jsutil/xpcom/XPCU.js
* chrome://inspector/content/jsutil/rdf/RDFU.js
****************************************************************/
//////////// global variables /////////////////////
var viewer;
//////////// global constants ////////////////////
var kDOMDataSourceIID = "@mozilla.org/rdf/datasource;1?name=Inspector_DOM";
//////////////////////////////////////////////////
window.addEventListener("load", NodeElementViewer_initialize, false);
function NodeElementViewer_initialize()
{
viewer = new NodeElementViewer();
viewer.initialize(parent.FrameExchange.receiveData(window));
}
////////////////////////////////////////////////////////////////////////////
//// class NodeElementViewer
function NodeElementViewer() // implements inIViewer
{
this.mURL = window.location;
this.mAttrTree = document.getElementById("trAttributes");
var ds = XPCU.createInstance(kDOMDataSourceIID, "nsIInsDOMDataSource");
this.mDS = ds;
ds.addFilterByType(2, true);
this.mAttrTree.database.AddDataSource(ds);
}
NodeElementViewer.prototype =
{
////////////////////////////////////////////////////////////////////////////
//// Initialization
mDS: null,
mViewee: null,
mPane: null,
get selectedAttribute() { return this.mAttrTree.selectedItems[0] },
////////////////////////////////////////////////////////////////////////////
//// interface inIViewer
//// attributes
get uid() { return "nodeElement" },
get pane() { return this.mPane },
get viewee() { return this.mViewee },
set viewee(aObject)
{
if (aObject.ownerDocument != this.mDS.document)
this.mDS.document = aObject.ownerDocument;
this.mViewee = aObject;
this.setTextValue("nodeName", aObject.nodeName);
this.setTextValue("nodeType", aObject.nodeType);
this.setTextValue("nodeValue", aObject.nodeValue);
this.setTextValue("namespace", aObject.namespaceURI);
var res = this.mDS.getResourceForObject(aObject);
try {
this.mAttrTree.setAttribute("ref", res.Value);
} catch (ex) {
debug("ERROR: While rebuilding attribute tree\n" + ex);
}
},
// methods
initialize: function(aPane)
{
this.mPane = aPane;
aPane.onViewerConstructed(this);
},
destroy: function()
{
this.mAttrTree.database.RemoveDataSource(this.mDS);
},
////////////////////////////////////////////////////////////////////////////
//// UI Commands
cmdNewAttribute: function()
{
var name = prompt("Enter the attribute name:", "");
if (name) {
var attr = this.mViewee.getAttributeNode(name);
if (!attr)
this.mViewee.setAttribute(name, "");
var res = this.mDS.getResourceForObject(attr);
var kids = this.mAttrTree.getElementsByTagName("treechildren")[1];
var item = kids.childNodes[kids.childNodes.length-1];
if (item) {
var cell = item.getElementsByAttribute("ins-type", "value")[0];
this.mAttrTree.selectItem(item);
this.mAttrTree.startEdit(cell);
}
}
},
cmdEditSelectedAttribute: function()
{
var item = this.mAttrTree.selectedItems[0];
var cell = item.getElementsByAttribute("ins-type", "value")[0];
this.mAttrTree.startEdit(cell);
},
cmdDeleteSelectedAttribute: function()
{
var item = this.selectedAttribute;
if (item) {
var attrname = InsUtil.getDSProperty(this.mDS, item.id, "nodeName");
this.mViewee.removeAttribute(attrname);
}
},
cmdSetSelectedAttributeValue: function(aItem, aValue)
{
if (aItem) {
var attrname = InsUtil.getDSProperty(this.mDS, aItem.id, "nodeName");
this.mViewee.setAttribute(attrname, aValue);
}
},
////////////////////////////////////////////////////////////////////////////
//// Uncategorized
setTextValue: function(aName, aText)
{
var field = document.getElementById("tx_"+aName);
if (field) {
field.setAttribute("value", aText);
}
}
};

View File

@ -0,0 +1,110 @@
<?xml version="1.0"?>
<!DOCTYPE overlay [
<!ENTITY % dtd1 SYSTEM "chrome://inspector/locale/inspector.dtd"> %dtd1;
<!ENTITY % dtd2 SYSTEM "chrome://inspector/locale/viewers/nodeElement.dtd"> %dtd2;
<!ENTITY % dtd3 SYSTEM "chrome://inspector/content/util.dtd"> %dtd3;
]>
<?xml-stylesheet href="chrome://inspector/skin/viewers/nodeElement/nodeElement.css"?>
<window id="winNodeDefault" class="color-dialog"
orient="vertical" style="padding: 10px"
xmlns:html="http://www.w3.org/1999/xhtml"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<!--============================= SCRIPTS ============================= -->
<script language="javascript" src="chrome://inspector/content/viewers/nodeElement/nodeElement.js"/>
<script language="javascript" src="chrome://inspector/content/utils.js"/>
<script language="javascript" src="chrome://inspector/content/jsutil/xpcom/XPCU.js"/>
<script language="javascript" src="chrome://inspector/content/jsutil/rdf/RDFU.js"/>
<!--============================= POPUPS ============================== -->
<popupset id="psPopups">
<popup id="ppAttrContext">
<menuitem value="New Attribute" oncommand="viewer.cmdNewAttribute()"/>
<menuitem value="Edit" oncommand="viewer.cmdEditSelectedAttribute()"/>
<menuitem value="Delete" oncommand="viewer.cmdDeleteSelectedAttribute()"/>
</popup>
</popupset>
<!--============================= CONTENT ============================== -->
<grid>
<columns>
<column/>
<column flex="1"/>
</columns>
<rows>
<row>
<text value="Node Name:"/>
<textfield id="tx_nodeName" readonly="true"/>
</row>
<row>
<text value="Namespace URI:"/>
<textfield id="tx_namespace" readonly="true"/>
</row>
<row>
<text value="Node Type:"/>
<textfield id="tx_nodeType" readonly="true"/>
</row>
<row>
<text value="Node Value:"/>
<textfield id="tx_nodeValue" readonly="true" multiline="true"/>
</row>
</rows>
</grid>
<tree id="trAttributes" class="tree-editable"
flex="1" context="ppAttrContext"
datasources="rdf:null"
onafteredit="viewer.cmdSetSelectedAttributeValue(event.editingItem, event.newValue)">
<treecolgroup>
<treecol id="tcolNodeName" flex="1"/>
<splitter class="tree-splitter"/>
<treecol id="tcolNodeValue" flex="1"/>
</treecolgroup>
<treehead>
<treerow>
<treecell class="treecell-header" value="Name"/>
<treecell class="treecell-header" value="Value"/>
</treerow>
</treehead>
<treechildren flex="1"/>
<template>
<rule>
<conditions>
<content uri="?uri"/>
<triple subject="?uri" predicate="&INS-rdf;Child" object="?node"/>
</conditions>
<bindings>
<binding subject="?node" predicate="&INS-rdf;nodeName" object="?nodeName"/>
<binding subject="?node" predicate="&INS-rdf;nodeValue" object="?nodeValue"/>
</bindings>
<action>
<treechildren>
<treeitem uri="?node">
<treerow>
<treecell value="?nodeName" ins-type="name"/>
<treecell value="?nodeValue" class="treecell-editable" ins-type="value"/>
</treerow>
</treeitem>
</treechildren>
</action>
</rule>
</template>
</tree>
</window>

View File

@ -0,0 +1,75 @@
/***************************************************************
* NodeTextViewer --------------------------------------------
* The viewer for text nodes.
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
* REQUIRED IMPORTS:
* chrome://inspector/content/jsutil/xpcom/XPCU.js
****************************************************************/
//////////// global variables /////////////////////
var viewer;
//////////// global constants ////////////////////
//////////////////////////////////////////////////
window.addEventListener("load", NodeTextViewer_initialize, false);
function NodeTextViewer_initialize()
{
viewer = new NodeTextViewer();
viewer.initialize(parent.FrameExchange.receiveData(window));
}
////////////////////////////////////////////////////////////////////////////
//// class NodeTextViewer
function NodeTextViewer()
{
this.mURL = window.location;
}
NodeTextViewer.prototype =
{
////////////////////////////////////////////////////////////////////////////
//// Initialization
mViewee: null,
mPane: null,
////////////////////////////////////////////////////////////////////////////
//// interface inIViewer
get uid() { return "nodeText" },
get pane() { return this.mPane },
get viewee() { return this.mViewee },
set viewee(aObject)
{
this.mViewee = aObject;
this.setTextValue("NodeValue", aObject.nodeValue);
},
initialize: function(aPane)
{
this.mPane = aPane;
aPane.onViewerConstructed(this);
},
destroy: function()
{
},
////////////////////////////////////////////////////////////////////////////
//// Uncategorized
setTextValue: function(aName, aText)
{
var field = document.getElementById("tx"+aName);
if (field) {
field.setAttribute("value", aText);
}
}
};

View File

@ -0,0 +1,20 @@
<?xml version="1.0"?>
<!DOCTYPE overlay [
<!ENTITY % dtd1 SYSTEM "chrome://inspector/locale/inspector.dtd"> %dtd1;
<!ENTITY % dtd2 SYSTEM "chrome://inspector/content/util.dtd"> %dtd2;
]>
<?xml-stylesheet href="chrome://inspector/skin/viewers/nodeText/nodeText.css"?>
<window id="winNodeDefault" class="color-dialog"
orient="vertical" style="padding: 10px"
xmlns:html="http://www.w3.org/1999/xhtml"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script language="javascript" src="chrome://inspector/content/viewers/nodeText/nodeText.js"/>
<textfield id="txNodeValue" readonly="true" multiline="true" flex="1"/>
</window>

View File

@ -0,0 +1,13 @@
<?xml version="1.0"?>
<!DOCTYPE rdf SYSTEM "chrome://inspector/locale/viewers/styleRules.dtd">
<overlay id="ovStyleRulesViewerCommands"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<broadcasterset id="brsGlobalCommands">
</broadcasterset>
</overlay>

View File

@ -0,0 +1,15 @@
<?xml version="1.0"?>
<!DOCTYPE rdf SYSTEM "chrome://inspector/locale/viewers/dom.dtd">
<overlay id="ovDOMViewerKeyset"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<keyset id="ksGlobalKeyset">
<key id="key:find" xulkey="true" key="&cmdShowFindDialog.accelkey;" observes="cmd:find" modifiers="accel"/>
<key id="key:findNext" keycode="VK_F3" observes="cmd:findNext"/>
</keyset>
</overlay>

View File

@ -0,0 +1,16 @@
<?xml version="1.0"?>
<!DOCTYPE rdf SYSTEM "chrome://inspector/locale/viewers/styleRules.dtd">
<overlay id="ovStyleRulesViewerPopup"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<popupset id="ppsGlobalPopupset">
</popupset>
<menupopup id="mppSearch">
</menupopup>
</overlay>

View File

@ -0,0 +1,212 @@
/***************************************************************
* StyleRulesViewer --------------------------------------------
* The viewer for CSS style rules that apply to a DOM element.
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
* REQUIRED IMPORTS:
* chrome://inspector/content/util.js
* chrome://inspector/content/jsutil/xpcom/XPCU.js
* chrome://inspector/content/jsutil/rdf/RDFU.js
****************************************************************/
//////////// global variables /////////////////////
var viewer;
//////////// global constants ////////////////////
var kCSSRuleDataSourceIID = "@mozilla.org/rdf/datasource;1?name=Inspector_CSSRules";
var kCSSDecDataSourceIID = "@mozilla.org/rdf/datasource;1?name=Inspector_CSSDec";
//////////////////////////////////////////////////
window.addEventListener("load", StyleRulesViewer_initialize, false);
function StyleRulesViewer_initialize()
{
viewer = new StyleRulesViewer();
viewer.initialize(parent.FrameExchange.receiveData(window));
}
////////////////////////////////////////////////////////////////////////////
//// class StyleRulesViewer
function StyleRulesViewer() // implements inIViewer
{
this.mURL = window.location;
this.mRuleTree = document.getElementById("trStyleRules");
this.mDecTree = document.getElementById("trStyleDec");
// create the rules datasource
var ds = XPCU.createInstance(kCSSRuleDataSourceIID, "nsICSSRuleDataSource");
this.mRuleDS = ds;
this.mRuleTree.database.AddDataSource(ds);
// create the declaration datasource
var ds = XPCU.createInstance(kCSSDecDataSourceIID, "nsICSSDecDataSource");
this.mDecDS = ds;
this.mDecTree.database.AddDataSource(ds);
}
StyleRulesViewer.prototype =
{
////////////////////////////////////////////////////////////////////////////
//// Initialization
mRuleDS: null,
mDecDS: null,
mViewee: null,
////////////////////////////////////////////////////////////////////////////
//// interface inIViewer
get uid() { return "styleRules" },
get pane() { return this.mPane },
get viewee() { return this.mViewee },
set viewee(aObject)
{
this.mViewee = aObject;
this.mRuleDS.element = aObject;
this.mRuleTree.builder.rebuild();
},
initialize: function(aPane)
{
this.mPane = aPane;
aPane.onViewerConstructed(this);
},
destroy: function()
{
this.mRuleTree.database.RemoveDataSource(this.mRuleDS);
this.mRuleDS = null;
this.mDecTree.database.RemoveDataSource(this.mDecDS);
this.mDecDS = null;
},
////////////////////////////////////////////////////////////////////////////
//// UI Commands
//////// rule contextual commands
cmdNewRule: function()
{
},
cmdToggleSelectedRule: function()
{
},
cmdDeleteSelectedRule: function()
{
},
cmdOpenSelectedFileInEditor: function()
{
var item = this.mRuleTree.selectedItems[0];
if (item)
{
var path = null;
var url = InsUtil.getDSProperty(this.mRuleDS, item.id, "FileURL");
if (url.substr(0, 6) == "chrome") {
// This is a tricky situation. Finding the source of a chrome file means knowing where
// your build tree is located, and where in the tree the file came from. Since files
// from the build tree get copied into chrome:// from unpredictable places, the best way
// to find them is manually.
//
// Solution to implement: Have the user pick the file location the first time it is opened.
// After that, keep the result in some sort of registry to look up next time it is opened.
// Allow this registry to be edited via preferences.
} else if (url.substr(0, 4) == "file") {
path = url;
}
if (path) {
try {
var exe = XPCU.createInstance("@mozilla.org/file/local;1", "nsILocalFile");
exe.initWithPath("c:\\windows\\notepad.exe");
exe = exe.nsIFile;
exe.spawn([url], 1);
} catch (ex) {
alert("Unable to open editor.");
}
}
}
},
//////// property contextual commands
cmdNewProperty: function()
{
var propname = prompt("Enter the property name:", "");
var propval = prompt("Enter the property value:", "");
if (propname && propval){
this.mDecDS.setCSSProperty(propname, propval, "");
this.mDecTree.builder.rebuild();
}
},
cmdEditSelectedProperty: function()
{
var item = this.mDecTree.selectedItems[0];
var cell = item.getElementsByAttribute("ins-type", "value")[0];
this.mDecTree.startEdit(cell);
},
cmdDeleteSelectedProperty: function()
{
var propname = this.getSelectedPropertyValue("PropertyName");
this.mDecDS.removeCSSProperty(propname);
this.mDecTree.builder.rebuild();
},
cmdSetSelectedPropertyValue: function(aItem, aNewValue)
{
// XXX can't depend on selection, use the item object passed into function instead
var propname = this.getSelectedPropertyValue("PropertyName");
var priority = this.getSelectedPropertyValue("PropertyPriority");
this.mDecDS.setCSSProperty(propname, aNewValue, priority);
},
cmdToggleSelectedImportant: function()
{
var priority = this.getSelectedPropertyValue("PropertyPriority");
priority = priority == "!important" ? "!blah" : "!important";
var propname = this.getSelectedPropertyValue("PropertyName");
var propval = this.getSelectedPropertyValue("PropertyValue");
// sadly, we must remove it first or it don't work
this.mDecDS.removeCSSProperty(propname);
this.mDecDS.setCSSProperty(propname, propval, priority);
this.mDecTree.builder.rebuild();
},
////////////////////////////////////////////////////////////////////////////
//// Uncategorized
getSelectedPropertyValue: function(aProperty)
{
var item = this.mDecTree.selectedItems[0];
return InsUtil.getDSProperty(this.mDecDS, item.id, aProperty);
},
onCreateRulePopup: function()
{
},
onRuleSelect: function()
{
var tree = this.mRuleTree;
var item = tree.selectedItems[0];
var res = gRDF.GetResource(item.id);
this.mDecDS.refResource = res;
tree = this.mDecTree;
tree.builder.rebuild();
}
};

View File

@ -0,0 +1,160 @@
<?xml version="1.0"?>
<!DOCTYPE overlay [
<!ENTITY % dtd1 SYSTEM "chrome://inspector/locale/inspector.dtd"> %dtd1;
<!ENTITY % dtd2 SYSTEM "chrome://inspector/content/util.dtd"> %dtd2;
]>
<?xml-stylesheet href="chrome://inspector/skin/viewers/styleRules/styleRules.css"?>
<window id="winNodeDefault" class="color-dialog"
orient="vertical"
xmlns:ins="&INS-rdf;"
xmlns:html="http://www.w3.org/1999/xhtml"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<!--============================= SCRIPTS ============================= -->
<script language="javascript" src="chrome://inspector/content/viewers/styleRules/styleRules.js"/>
<script language="javascript" src="chrome://inspector/content/utils.js"/>
<script language="javascript" src="chrome://inspector/content/jsutil/xpcom/XPCU.js"/>
<script language="javascript" src="chrome://inspector/content/jsutil/rdf/RDFU.js"/>
<!--============================= POPUPS ============================== -->
<popupset id="psPopups">
<popup id="ppStyleRuleContext" oncreate="return viewer.onCreateRulePopup()">
<menuitem value="New" oncommand="viewer.cmdNewRule()"/>
<menuitem value="Delete" oncommand="viewer.cmdDeleteSelectedRule()"/>
<menuitem value="Disable" oncommand="viewer.cmdToggleSelectedRule()"/>
<menuseparator/>
<menuitem value="Open File in Editor" oncommand="viewer.cmdOpenSelectedFileInEditor()"/>
</popup>
<popup id="ppStyleDecContext">
<menuitem value="New Property" oncommand="viewer.cmdNewProperty()"/>
<menuitem value="Edit" oncommand="viewer.cmdEditSelectedProperty()"/>
<menuitem value="Delete" oncommand="viewer.cmdDeleteSelectedProperty()"/>
<menuseparator/>
<menuitem value="Toggle !important" oncommand="viewer.cmdToggleSelectedImportant()"/>
</popup>
</popupset>
<!--============================= CONTENT ============================== -->
<box orient="vertical">
<tree id="trStyleRules"
flex="1" context="ppStyleRuleContext"
onselect="viewer.onRuleSelect()"
datasources="rdf:null" ref="inspector:RuleRoot">
<template>
<rule>
<conditions>
<content uri="?uri"/>
<triple subject="?uri" predicate="&INS-rdf;Rule" object="?rule"/>
</conditions>
<bindings>
<binding subject="?rule" predicate="&INS-rdf;Selector" object="?selector"/>
<binding subject="?rule" predicate="&INS-rdf;FileURL" object="?fileURL"/>
<binding subject="?rule" predicate="&INS-rdf;Weight" object="?weight"/>
<binding subject="?rule" predicate="&INS-rdf;LineNum" object="?lineNum"/>
</bindings>
<action>
<treechildren>
<treeitem uri="?rule">
<treerow>
<treecell value="?selector"/>
<treecell value="?fileURL"/>
<treecell value="?weight"/>
<treecell value="?lineNum"/>
</treerow>
</treeitem>
</treechildren>
</action>
</rule>
</template>
<treecolgroup>
<treecol id="tcolNodeName" flex="1"/>
<splitter class="tree-splitter"/>
<treecol id="tcolNodeValue" flex="1"/>
<splitter class="tree-splitter"/>
<treecol id="tcolNodeValue" flex="1"/>
<splitter class="tree-splitter"/>
<treecol id="tcolNodeValue" flex="1"/>
</treecolgroup>
<treehead>
<treerow>
<treecell class="treecell-header" value="Selector"/>
<treecell class="treecell-header" value="File"/>
<treecell class="treecell-header" value="Weight"/>
<treecell class="treecell-header" value="Line"/>
</treerow>
</treehead>
<treechildren flex="1"/>
</tree>
</box>
<splitter orient="horizontal" collapse="after">
<grippy/>
</splitter>
<tree id="trStyleDec" class="tree-editable"
onafteredit="viewer.cmdSetSelectedPropertyValue(event.editingItem, event.newValue)"
flex="1" context="ppStyleDecContext"
datasources="rdf:null" ref="inspector:DecRoot">
<template>
<rule>
<conditions>
<content uri="?uri"/>
<triple subject="?uri" predicate="&INS-rdf;Property" object="?prop"/>
</conditions>
<bindings>
<binding subject="?prop" predicate="&INS-rdf;PropertyPriority" object="?priority"/>
<binding subject="?prop" predicate="&INS-rdf;PropertyName" object="?name"/>
<binding subject="?prop" predicate="&INS-rdf;PropertyValue" object="?value"/>
</bindings>
<action>
<treechildren>
<treeitem uri="?prop">
<treerow>
<treecell class="treecell-priority treecell-iconic" ins-type="priority" ins:priority="?priority"/>
<treecell value="?name" ins-type="name"/>
<treecell class="treecell-editable" value="?value" ins-type="value"/>
</treerow>
</treeitem>
</treechildren>
</action>
</rule>
</template>
<treecolgroup>
<treecol id="tcolPropPriority"/>
<treecol id="tcolPropName" flex="1"/>
<splitter class="tree-splitter"/>
<treecol id="tcolPropValue" flex="1"/>
</treecolgroup>
<treehead>
<treerow>
<treecell class="treecell-header" value="!"/>
<treecell class="treecell-header" value="Name"/>
<treecell class="treecell-header" value="Value"/>
</treerow>
</treehead>
<treechildren flex="1"/>
</tree>
</window>

View File

@ -0,0 +1,63 @@
/***************************************************************
* StylesheetsViewer --------------------------------------------
* The viewer for the stylesheets loaded by a document.
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
* REQUIRED IMPORTS:
* chrome://inspector/content/jsutil/xpcom/XPCU.js
****************************************************************/
//////////// global variables /////////////////////
var viewer;
//////////// global constants ////////////////////
//////////////////////////////////////////////////
window.addEventListener("load", StylesheetsViewer_initialize, false);
function StylesheetsViewer_initialize()
{
viewer = new StylesheetsViewer();
viewer.initialize(parent.FrameExchange.receiveData(window));
}
////////////////////////////////////////////////////////////////////////////
//// class StylesheetsViewer
function StylesheetsViewer()
{
this.mURL = window.location;
}
StylesheetsViewer.prototype =
{
////////////////////////////////////////////////////////////////////////////
//// Initialization
mViewee: null,
mPane: null,
////////////////////////////////////////////////////////////////////////////
//// interface inIViewer
get uid() { return "stylesheets" },
get pane() { return this.mPane },
get viewee() { return this.mViewee },
set viewee(aObject)
{
},
initialize: function(aPane)
{
this.mPane = aPane;
aPane.onViewerConstructed(this);
},
destroy: function()
{
}
};

View File

@ -0,0 +1,22 @@
<?xml version="1.0"?>
<!DOCTYPE overlay [
<!ENTITY % dtd1 SYSTEM "chrome://inspector/locale/inspector.dtd"> %dtd1;
<!ENTITY % dtd2 SYSTEM "chrome://inspector/content/util.dtd"> %dtd2;
]>
<?xml-stylesheet href="chrome://communicator/skin"?>
<window id="winStylesheets" class="color-dialog"
orient="vertical"
xmlns:html="http://www.w3.org/1999/xhtml"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script language="javascript" src="chrome://inspector/content/viewers/stylesheets/stylesheets.js"/>
<script language="javascript" src="chrome://inspector/content/jsutil/xpcom/XPCU.js"/>
<text value="Not Yet Implemented"/>
</window>

View File

@ -0,0 +1,63 @@
/***************************************************************
* XBLBindings --------------------------------------------
* The viewer for the computed css styles on a DOM element.
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
* REQUIRED IMPORTS:
* chrome://inspector/content/jsutil/xpcom/XPCU.js
****************************************************************/
//////////// global variables /////////////////////
var viewer;
//////////// global constants ////////////////////
//////////////////////////////////////////////////
window.addEventListener("load", XBLBindings_initialize, false);
function XBLBindings_initialize()
{
viewer = new XBLBindings();
viewer.initialize(parent.FrameExchange.receiveData(window));
}
////////////////////////////////////////////////////////////////////////////
//// class XBLBindings
function XBLBindings()
{
this.mURL = window.location;
}
XBLBindings.prototype =
{
////////////////////////////////////////////////////////////////////////////
//// Initialization
mViewee: null,
mPane: null,
////////////////////////////////////////////////////////////////////////////
//// interface inIViewer
get uid() { return "computedStyle" },
get pane() { return this.mPane },
get viewee() { return this.mViewee },
set viewee(aObject)
{
},
initialize: function(aPane)
{
this.mPane = aPane;
aPane.onViewerConstructed(this);
},
destroy: function()
{
}
};

View File

@ -0,0 +1,22 @@
<?xml version="1.0"?>
<!DOCTYPE overlay [
<!ENTITY % dtd1 SYSTEM "chrome://inspector/locale/inspector.dtd"> %dtd1;
<!ENTITY % dtd2 SYSTEM "chrome://inspector/content/util.dtd"> %dtd2;
]>
<?xml-stylesheet href="chrome://communicator/skin"?>
<window id="winXBLBindings" class="color-dialog"
orient="vertical"
xmlns:html="http://www.w3.org/1999/xhtml"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script language="javascript" src="chrome://inspector/content/viewers/xblBindings/xblBindings.js"/>
<script language="javascript" src="chrome://inspector/content/jsutil/xpcom/XPCU.js"/>
<text value="Not Yet Implemented"/>
</window>

View File

@ -0,0 +1,32 @@
#
# The contents of this file are subject to the Netscape 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/NPL/
#
# 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 Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s):
#
DEPTH=../../../..
topsrcdir=@top_srcdir@
srcdir=@srcdir@
VPATH=@srcdir@
include $(DEPTH)/config/autoconf.mk
DIRS= en-US
include $(topsrcdir)/config/rules.mk

View File

@ -0,0 +1,29 @@
#
# The contents of this file are subject to the Netscape 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/NPL/
#
# 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 Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s):
#
DEPTH=../../../../..
topsrcdir=@top_srcdir@
srcdir=@srcdir@
VPATH=@srcdir@
include $(DEPTH)/config/autoconf.mk
include $(topsrcdir)/config/rules.mk

View File

@ -0,0 +1,18 @@
<?xml version="1.0"?>
<RDF:RDF xmlns:RDF="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:chrome="http://www.mozilla.org/rdf/chrome#">
<!-- list all the skins being supplied by this package -->
<RDF:Seq about="urn:mozilla:locale:root">
<RDF:li resource="urn:mozilla:locale:en-US"/>
</RDF:Seq>
<!-- locale information -->
<RDF:Description about="urn:mozilla:locale:en-US">
<chrome:packages>
<RDF:Seq about="urn:mozilla:locale:en-US:packages">
<RDF:li resource="urn:mozilla:locale:en-US:inspector"/>
</RDF:Seq>
</chrome:packages>
</RDF:Description>
</RDF:RDF>

View File

@ -0,0 +1,60 @@
<!ENTITY thDOMNodes.label "DOM Nodes">
<!ENTITY txDocument.label "Document">
<!ENTITY btnInspect.label "Inspect">
<!-- MAIN MENU ITEMS -->
<!ENTITY mnFile.label "File">
<!ENTITY mnWindows.label "Inspect a Window">
<!ENTITY mnWindows.accesskey "w">
<!ENTITY mnFile.accesskey "f">
<!ENTITY cmdShowOpenURLDialog.label "Inspect a URL">
<!ENTITY cmdShowOpenURLDialog.accesskey "u">
<!ENTITY cmdExit.label "Exit">
<!ENTITY cmdExit.accesskey "x">
<!ENTITY mnEdit.label "Edit">
<!ENTITY mnEdit.accesskey "e">
<!ENTITY cmdUndo.label "Undo">
<!ENTITY cmdUndo.accesskey "u">
<!ENTITY cmdRedo.label "Redo">
<!ENTITY cmdRedo.accesskey "r">
<!ENTITY cmdCut.label "Cut">
<!ENTITY cmdCut.accesskey "t">
<!ENTITY cmdCopy.label "Copy">
<!ENTITY cmdCopy.accesskey "c">
<!ENTITY cmdPaste.label "Paste">
<!ENTITY cmdPaste.accesskey "p">
<!ENTITY cmdDelete.label "Delete">
<!ENTITY cmdDelete.accesskey "d">
<!ENTITY cmdPrefs.label "Preferences">
<!ENTITY cmdPrefs.accesskey "f">
<!ENTITY mnSearch.label "Search">
<!ENTITY mnSearch.accesskey "s">
<!ENTITY mnSearchPlugins.label "Extensions">
<!ENTITY mnSearchPlugins.accesskey "e">
<!ENTITY cmdRunSearch.label "Run...">
<!ENTITY cmdRunSearch.accesskey "r">
<!ENTITY mnView.label "View">
<!ENTITY mnView.accesskey "v">
<!ENTITY cmdToggleBrowser.label "Browser">
<!ENTITY cmdToggleSearch.label "Search Results">
<!ENTITY cmdFlashSelected.label "Blink Selected Element">
<!ENTITY mnHelp.label "Help">
<!ENTITY mnHelp.accesskey "h">
<!ENTITY cmdNotes.label "Release Notes...">
<!ENTITY cmdNotes.accesskey "n">
<!ENTITY cmdAbout.label "About Document Inspector">
<!ENTITY cmdAbout.accesskey "a">
<!ENTITY cmdViewSearchItem.label "View...">
<!ENTITY cmdEditSearchItem.label "Edit...">
<!ENTITY cmdCopySearchItemLine.label "Copy Line">
<!ENTITY cmdCopySearchItemAll.label "Copy All">
<!ENTITY cmdSaveSearchItemText.label "Save...">
<!ENTITY cmdClearSearch.label "Clear">
<!ENTITY cmdHideSearchItems.label "Hide">

View File

@ -0,0 +1,11 @@
inspector.jar:
locale/en-US/inspector/contents.rdf
locale/en-US/inspector/inspector.dtd
locale/en-US/inspector/tasksOverlay.dtd
locale/en-US/inspector/prefs.dtd
locale/en-US/inspector/search/findFiles.dtd (search/findFiles.dtd)
locale/en-US/inspector/search/junkImgs.dtd (search/junkImgs.dtd)
locale/en-US/inspector/viewers/dom.dtd (viewers/dom.dtd)
locale/en-US/inspector/viewers/nodeElement.dtd (viewers/nodeElement.dtd)
locale/en-US/inspector/viewers/styleRules.dtd (viewers/styleRules.dtd)

View File

@ -0,0 +1,24 @@
#!nmake
#
# The contents of this file are subject to the Netscape 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/NPL/
#
# 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 Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s):
DEPTH=..\..\..\..\..
include <$(DEPTH)/config/config.mak>
include <$(DEPTH)\config\rules.mak>

View File

@ -0,0 +1,2 @@
<!ENTITY Inspector.label "Inspector">
<!ENTITY Sidebar.label "Sidebar">

View File

@ -0,0 +1,4 @@
<!ENTITY findFiles.title "Find Files">
<!ENTITY txSearchFor.label "Search For:">
<!ENTITY txSearchPath.label "Search In:">
<!ENTITY cbRecurse.label "Search Subfolders">

View File

@ -0,0 +1,2 @@
<!ENTITY junkImgs.title "Find Unused Images in Current Theme">
<!ENTITY junkImgsDescription "In order for this search to work effectively, you must be inspecting a document which loads EVERY CSS file in the current theme. Then, point to a location on disk where the root of the current theme can be found.">

View File

@ -0,0 +1,5 @@
<!ENTITY inspectorTaskCmd.label "Document Inspector">
<!ENTITY inspectorTaskCmd.commandkey "i">
<!ENTITY inspectorTaskCmd.accesskey "I">

View File

@ -0,0 +1,18 @@
<!ENTITY cmdShowFindDialog.label "Find Nodes...">
<!ENTITY cmdShowFindDialog.accesskey "f">
<!ENTITY cmdShowFindDialog.accelkey "f">
<!ENTITY cmdFindNext.label "Find Next">
<!ENTITY cmdFindNext.accesskey "n">
<!ENTITY cmdToggleAnonContent.label "Show Anonymous Content">
<!ENTITY cmdToggleAnonContent.accesskey "a">
<!ENTITY cmdSelectByClick.label "Select Element By Click">
<!ENTITY cmdSelectByClick.accesskey "s">
<!ENTITY ColumnsDialog.title "Columns">
<!ENTITY cmdShowColumnsDialog.label "Columns...">
<!ENTITY cmdShowColumnsDialog.accesskey "c">

View File

@ -0,0 +1,3 @@
<!ENTITY miFindCSSRules.label "Find CSS Rules...">
<!ENTITY miFindCSSRules.accesskey "Find CSS Rules...">

View File

@ -0,0 +1,27 @@
#!nmake
#
# The contents of this file are subject to the Netscape 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/NPL/
#
# 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 Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s):
DEPTH=..\..\..\..
include <$(DEPTH)/config/config.mak>
DIRS = en-US
include <$(DEPTH)\config\rules.mak>

View File

@ -0,0 +1,32 @@
#
# The contents of this file are subject to the Netscape 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/NPL/
#
# 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 Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s):
#
DEPTH=../../../..
topsrcdir=@top_srcdir@
srcdir=@srcdir@
VPATH=@srcdir@
include $(DEPTH)/config/autoconf.mk
DIRS=classic modern
include $(topsrcdir)/config/rules.mk

Binary file not shown.

After

Width:  |  Height:  |  Size: 122 B

View File

@ -0,0 +1,30 @@
#
# The contents of this file are subject to the Netscape 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/NPL/
#
# 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 Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s):
#
DEPTH=../../../../..
topsrcdir=@top_srcdir@
srcdir=@srcdir@
VPATH=@srcdir@
include $(DEPTH)/config/autoconf.mk
include $(topsrcdir)/config/rules.mk

View File

@ -0,0 +1,18 @@
<?xml version="1.0"?>
<RDF:RDF xmlns:RDF="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:chrome="http://www.mozilla.org/rdf/chrome#">
<!-- List all the skins being supplied by this theme -->
<RDF:Seq about="urn:mozilla:skin:root">
<RDF:li resource="urn:mozilla:skin:classic/1.0" />
</RDF:Seq>
<!-- Classic Information -->
<RDF:Description about="urn:mozilla:skin:classic/1.0">
<chrome:packages>
<RDF:Seq about="urn:mozilla:skin:classic/1.0:packages">
<RDF:li resource="urn:mozilla:skin:classic/1.0:inspector"/>
</RDF:Seq>
</chrome:packages>
</RDF:Description>
</RDF:RDF>

Binary file not shown.

After

Width:  |  Height:  |  Size: 65 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 172 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 59 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 53 B

View File

@ -0,0 +1,12 @@
@import url("chrome://communicator/skin");
@import url("chrome://inspector/skin/viewerPane.css");
@import url("chrome://inspector/content/inspector.css");
@import url("chrome://inspector/content/extensions/titledSplitter.css");
@namespace ins url("http://www.mozilla.org/inspector#");
treecol {
width: 16px;
}

View File

@ -0,0 +1,56 @@
@import url("chrome://inspector/skin");
#mlViewers {
min-width: 10em;
max-width: 10em;
}
.toolbar-header1 {
margin: 2px;
color: #000000;
font-size: 14px;
font-weight: bold;
}
#bxURLBar {
padding: 3px;
}
#bxURLBarContainer {
margin: 0px 3px 0px 3px;
border: 1px inset ThreeDFace;
padding: 0px 1px 0px 1px;
background-color: -moz-field;
}
#mbHistory.menubutton-icon {
border: 1px outset ThreeDFace;
background-color: ThreeDFace;
list-style-image: url("chrome://global/skin/scroll-down.gif");
}
.button-toolbar-3 {
margin: 0px !important;
border: 0px !important;
}
#imgURLBarIcon {
margin: 1px 1px 0px 1px;
list-style-image: url("chrome://communicator/skin/bookmarks/location.gif");
}
#bxSearch {
height: 150px;
}
#bxStatus {
border-top: 1px outset ThreeDFace;
padding: 2px;
min-width: 1px;
background-color: ThreeDFace;
font-size: smaller;
}
#txStatus {
margin-left: 5px;
}

Some files were not shown because too many files have changed in this diff Show More