Use more efficient command structure, refactor commands, broadcasters and keys, remove unused attributes, do some other optimization (72923). Landing navigator part only; this should help new window opening and some other areas. r=ben sr=hyatt

This commit is contained in:
blakeross%telocity.com 2006-07-29 05:36:35 +00:00
parent 98b202bf59
commit 09bd7d7a23
9 changed files with 80 additions and 98 deletions

View File

@ -59,6 +59,6 @@
</box>
<box id="okCancelButtons"/>
<keyset id="keyset"/>
<keyset id="dialogKeys"/>
</window>

View File

@ -47,16 +47,13 @@
<!-- Open ==================================== -->
<menuitem id="context-openlink"
label="&openLinkCmd.label;"
accesskey=""
oncommand="contextMenu.openLink();"/>
<!-- XXX - DEPENDENT ON PRESENCE OF EDITOR!! - XXX -->
<menuitem id="context-editlink"
label="&editLinkCmd.label;"
accesskey=""
oncommand="contextMenu.editLink();"/>
<menuitem id="context-openframe"
label="&openFrameCmd.label;"
accesskey=""
oncommand="contextMenu.openFrame();"/>
<menuitem id="context-showonlythisframe"
label="&showOnlyThisFrameCmd.label;"
@ -82,29 +79,23 @@
oncommand="contextMenu.reloadFrame();"/>
<menuitem id="context-stop"
label="&stopCmd.label;"
accesskey=""
oncommand="BrowserStop();"/>
<menuseparator id="context-sep-navigation"/>
<!-- View ==================================== -->
<menuitem id="context-viewsource"
label="&viewPageSourceCmd.label;"
accesskey=""
oncommand="BrowserViewSource();"/>
<menuitem id="context-viewframesource"
label="&viewFrameSourceCmd.label;"
accesskey=""
oncommand="contextMenu.viewFrameSource();"/>
<menuitem id="context-viewinfo"
label="&viewPageInfoCmd.label;"
accesskey=""
oncommand="contextMenu.viewInfo();"/>
<menuitem id="context-viewframeinfo"
label="&viewFrameInfoCmd.label;"
accesskey=""
oncommand="contextMenu.viewFrameInfo();"/>
<menuitem id="context-viewimage"
label="&viewImageCmd.label;"
accesskey=""
oncommand="contextMenu.viewImage();"/>
<menuseparator id="context-sep-view"/>
<!-- Misc ==================================== -->
@ -143,19 +134,19 @@
<menuitem id="context-selectall"
label="&selectAllCmd.label;"
accesskey="&selectAllCmd.accesskey;"
observes="cmd_selectAll"/>
command="cmd_selectAll"/>
<menuitem id="context-cut"
label="&cutCmd.label;"
accesskey="&cutCmd.accesskey;"
observes="cmd_cut"/>
command="cmd_cut"/>
<menuitem id="context-copy"
label="&copyCmd.label;"
accesskey="&copyCmd.accesskey;"
observes="cmd_copy"/>
command="cmd_copy"/>
<menuitem id="context-paste"
label="&pasteCmd.label;"
accesskey="&pasteCmd.accesskey;"
observes="cmd_paste"/>
command="cmd_paste"/>
<menuitem id="context-copylink"
label="&copyLinkCmd.label;"
accesskey="&copyLinkCmd.accesskey;"

View File

@ -29,6 +29,7 @@
var contentAreaDNDObserver = {
onDragStart: function (aEvent, aXferData, aDragAction)
{
alert('hey');
// under the assumption that content areas won't contain
// draggable XBL, we'll ignore the drag if we're dragging XBL
// anonymous content nodes, like scrollbars, etc.
@ -54,14 +55,15 @@ var contentAreaDNDObserver = {
domselection.containsNode(draggedNode,false))
{
var anchors = domselection.anchorNode.getElementsByTagName("a");
if (anchors.length > 0) {
draggedNode = anchors[0];
urlstring = draggedNode.href;
if (anchors.length > 0) {
draggedNode = anchors[0];
urlstring = draggedNode.href;
}
var privateSelection = domselection.QueryInterface(Components.interfaces.nsISelectionPrivate);
if (privateSelection)
{
// the window has a selection so we should grab that rather
// than looking for specific elements
htmlstring = privateSelection.toStringWithFormat("text/html", 128+256, 0);

View File

@ -23,8 +23,7 @@
*/
var browser;
var dialog;
var bundle;
var dialog = {};
var pref = null;
try {
pref = Components.classes["@mozilla.org/preferences;1"]
@ -35,15 +34,12 @@ try {
function onLoad()
{
bundle = srGetStrBundle("chrome://communicator/locale/openLocation.properties");
dialog = new Object;
dialog.input = document.getElementById("dialog.input");
dialog.help = document.getElementById("dialog.help");
dialog.open = document.getElementById("ok");
dialog.openAppList = document.getElementById("openAppList");
dialog.openTopWindow = document.getElementById("currentWindow");
dialog.openEditWindow = document.getElementById("editWindow");
dialog.bundle = document.getElementById("openLocationBundle");
browser = window.arguments[0];
if (!browser) {
@ -56,7 +52,7 @@ function onLoad()
}
// change OK button text to 'open'
dialog.open.label = bundle.GetStringFromName("openButtonLabel");
dialog.open.label = dialog.bundle.getString("openButtonLabel");
doSetOKCancel(open, 0, 0, 0);
@ -123,6 +119,7 @@ function createInstance(contractid, iidName)
const nsIFilePicker = Components.interfaces.nsIFilePicker;
function onChooseFile()
{
alert('hey');
try {
var fp = Components.classes["@mozilla.org/filepicker;1"].createInstance(nsIFilePicker);
fp.init(window, bundle.GetStringFromName("chooseFileDialogTitle"), nsIFilePicker.modeOpen);

View File

@ -46,13 +46,12 @@
persist="screenX screenY"
screenX="24" screenY="24">
<script type="application/x-javascript" src="chrome://global/content/strres.js"/>
<script type="application/x-javascript" src="chrome://global/content/globalOverlay.js"/>
<script type="application/x-javascript" src="chrome://communicator/content/openLocation.js"/>
<script type="application/x-javascript" src="chrome://communicator/content/utilityOverlay.js"/>
<keyset id="keyset"/>
<stringbundle id="openLocationBundle" src="chrome://communicator/locale/openLocation.properties"/>
<keyset id="dialogKeys"/>
<box>
<box orient="vertical">
<image class="question-icon"/>
@ -65,7 +64,7 @@
<box autostretch="never">
<textbox id="dialog.input" flex="1" oninput="doEnabling();"/>
<button label="&chooseFile.label;" onclick="onChooseFile();"/>
<button label="&chooseFile.label;" oncommand="onChooseFile();"/>
</box>
<box autostretch="never" valign="center">
<text class="label" value="&openWhere.label;"/>

View File

@ -18,20 +18,19 @@
<keyset id="keyset">
<key id="key_navigator" key="&navigatorCmd.commandkey;" observes="Tasks:Navigator" modifiers="accel"/>
<key id="key_editor" key="&editorCmd.commandkey;" observes="Tasks:Editor" modifiers="accel"/>
<key id="key_addressbook" key="&addressBookCmd.commandkey;" observes="Tasks:AddressBook" modifiers="accel"/>
<keyset id="tasksKeys">
<key id="key_navigator" key="&navigatorCmd.commandkey;" command="Tasks:Navigator" modifiers="accel"/>
<key id="key_editor" key="&editorCmd.commandkey;" command="Tasks:Editor" modifiers="accel"/>
<key id="key_addressbook" key="&addressBookCmd.commandkey;" command="Tasks:AddressBook" modifiers="accel"/>
<!-- Tools Menu -->
<key id="key_gotoHistory" key="&history.commandKey;" oncommand="toHistory();" modifiers="accel"/>
</keyset>
<broadcasterset id="broadcasterset">
<broadcaster id="Tasks:Navigator" label="&navigatorCmd.label;" oncommand="toNavigator();"/>
<broadcaster id="Tasks:Editor" label="&editorCmd.label;" oncommand="toEditor();"/>
<broadcaster id="Tasks:AddressBook" label="&addressBookCmd.label;" oncommand="toAddressBook();"/>
</broadcasterset>
<commandset id="tasksCommands">
<command id="Tasks:Navigator" oncommand="toNavigator();"/>
<command id="Tasks:Editor" oncommand="toEditor();"/>
<command id="Tasks:AddressBook" oncommand="toAddressBook();"/>
</commandset>
<!-- Tasks Menu -->
@ -45,9 +44,9 @@
</template>
<menupopup id="taskPopup">
<menuitem accesskey="&navigatorCmd.accesskey;" key="key_navigator" observes="Tasks:Navigator"/>
<menuitem accesskey="&editorCmd.accesskey;" key="key_editor" observes="Tasks:Editor" />
<menuitem accesskey="&addressBookCmd.accesskey;" key="key_addressbook" observes="Tasks:AddressBook"/>
<menuitem label="&navigatorCmd.label;" accesskey="&navigatorCmd.accesskey;" key="key_navigator" command="Tasks:Navigator"/>
<menuitem label="&editorCmd.label;" accesskey="&editorCmd.accesskey;" key="key_editor" command="Tasks:Editor" />
<menuitem label="&addressBookCmd.label;" accesskey="&addressBookCmd.accesskey;" key="key_addressbook" command="Tasks:AddressBook"/>
<!-- Overlays get stuffed in here. -->

View File

@ -31,8 +31,8 @@
**/
function setOfflineStatus(aToggleFlag)
{
var ioService = nsJSComponentManager.getServiceByID("{9ac9e770-18bc-11d3-9337-00104ba0fd40}",
"nsIIOService");
var ioService = Components.classesByID["{9ac9e770-18bc-11d3-9337-00104ba0fd40}"]
.getService(Components.interfaces.nsIIOService);
var broadcaster = document.getElementById("Communicator:WorkMode");
if (aToggleFlag)
ioService.offline = !ioService.offline;

View File

@ -18,43 +18,43 @@
<script type="application/x-javascript" src="chrome://communicator/content/utilityOverlay.js"/>
<script type="application/x-javascript" src="chrome://communicator/content/builtinURLs.js"/>
<!-- online/offline status indicators -->
<broadcasterset id="broadcasterset">
<broadcaster id="Communicator:WorkMode" label="&offlineGoOfflineCmd.label;" oncommand="setOfflineStatus(true);"/>
</broadcasterset>
<!-- online/offline status indicators -->
<broadcaster id="Communicator:WorkMode" label="&offlineGoOfflineCmd.label;" oncommand="setOfflineStatus(true);"/>
<statusbarpanel id="offline-status" tooltip="aTooltip" observes="Communicator:WorkMode"/>
<menuitem id="offlineGoOfflineCmd" accesskey="&offlineGoOfflineCmd.accesskey;" observes="Communicator:WorkMode"/>
<menuitem id="offlineGoOfflineCmd" label="&offlineGoOfflineCmd.label;" accesskey="&offlineGoOfflineCmd.accesskey;" observes="Communicator:WorkMode"/>
<!-- File Menu -->
<menu id="menu_File" label="&fileMenu.label;" accesskey="&fileMenu.accesskey;"/>
<!-- New SubMenu (Under File Menu) -->
<broadcaster id="cmd_newNavigator" oncommand="OpenBrowserWindow()"/>
<broadcaster id="cmd_newEditor" oncommand="NewEditorWindow();"/>
<!-- NOT IMPLEMENTED, so temporarily disabled -->
<broadcaster id="cmd_newEditorTemplate" disabled="true" oncommand="NewEditorFromTemplate();"/>
<broadcaster id="cmd_newEditorDraft" disabled="true" oncommand="NewEditorFromDraft();"/>
<broadcaster id="cmd_pageSetup" label="&pageSetupCmd.label;" disabled="true" oncommand="goPageSetup();"/>
<command id="cmd_newNavigator" oncommand="OpenBrowserWindow()"/>
<command id="cmd_newEditor" oncommand="NewEditorWindow();"/>
<!-- NOT IMPLEMENTED, so temporarily disabled
<command id="cmd_newEditorTemplate" disabled="true" oncommand="NewEditorFromTemplate();"/>
<command id="cmd_newEditorDraft" disabled="true" oncommand="NewEditorFromDraft();"/>
<command id="cmd_pageSetup" disabled="true" oncommand="goPageSetup();"/>
-->
<menuitem id="menu_newEditor" label="&newBlankPageCmd.label;" accesskey="&newBlankPageCmd.accesskey;" key="key_newBlankPage" observes="cmd_newEditor"/>
<menuitem id="menu_newEditorTemplate" label="&newPageFromTemplateCmd.label;" accesskey="&newPageFromTemplateCmd.accesskey;" observes="cmd_newEditorTemplate"/>
<menuitem id="menu_newEditorDraft" label="&newPageFromDraftCmd.label;" accesskey="&newPageFromDraftCmd.accesskey;" observes="cmd_newEditorDraft"/>
<menuitem id="menu_newEditor" label="&newBlankPageCmd.label;" accesskey="&newBlankPageCmd.accesskey;" key="key_newBlankPage" command="cmd_newEditor"/>
<menuitem id="menu_newEditorTemplate" label="&newPageFromTemplateCmd.label;" accesskey="&newPageFromTemplateCmd.accesskey;" command="cmd_newEditorTemplate"/>
<menuitem id="menu_newEditorDraft" label="&newPageFromDraftCmd.label;" accesskey="&newPageFromDraftCmd.accesskey;" command="cmd_newEditorDraft"/>
<menu id="menu_New" label="&newMenu.label;" accesskey="&newMenu.accesskey;"/>
<menuitem id="menu_newNavigator" label="&newNavigatorCmd.label;" accesskey="&newNavigatorCmd.accesskey;" key="key_newNavigator" observes="cmd_newNavigator"/>
<menuitem id="menu_newNavigator" label="&newNavigatorCmd.label;" accesskey="&newNavigatorCmd.accesskey;" key="key_newNavigator" command="cmd_newNavigator"/>
<key id="key_newBlankPage" key="&newBlankPageCmd.key;" observes="cmd_newEditor" modifiers="accel, shift"/>
<key id="key_newNavigator" key="&newNavigatorCmd.key;" observes="cmd_newNavigator" modifiers="accel"/>
<key id="key_newBlankPage" key="&newBlankPageCmd.key;" command="cmd_newEditor" modifiers="accel, shift"/>
<key id="key_newNavigator" key="&newNavigatorCmd.key;" command="cmd_newNavigator" modifiers="accel"/>
<!-- Edit Menu -->
<menu id="menu_Edit" label="&editMenu.label;" accesskey="&editMenu.accesskey;"/>
<menuitem id="menu_undo" label="&undoCmd.label;" key="key_undo" accesskey="&undoCmd.accesskey;" observes="cmd_undo"/>
<menuitem id="menu_redo" label="&redoCmd.label;" key="key_redo" accesskey="&redoCmd.accesskey;" observes="cmd_redo"/>
<menuitem id="menu_cut" label="&cutCmd.label;" key="key_cut" accesskey="&cutCmd.accesskey;" observes="cmd_cut"/>
<menuitem id="menu_copy" label="&copyCmd.label;" key="key_copy" accesskey="&copyCmd.accesskey;" observes="cmd_copy"/>
<menuitem id="menu_paste" label="&pasteCmd.label;" key="key_paste" accesskey="&pasteCmd.accesskey;" observes="cmd_paste"/>
<menuitem id="menu_delete" label="&deleteCmd.label;" key="key_delete" accesskey="&deleteCmd.accesskey;" observes="cmd_delete"/>
<menuitem id="menu_selectAll" label="&selectAllCmd.label;" key="key_selectAll" accesskey="&selectAllCmd.accesskey;" observes="cmd_selectAll"/>
<menuitem id="menu_undo" label="&undoCmd.label;" key="key_undo" accesskey="&undoCmd.accesskey;" command="cmd_undo"/>
<menuitem id="menu_redo" label="&redoCmd.label;" key="key_redo" accesskey="&redoCmd.accesskey;" command="cmd_redo"/>
<menuitem id="menu_cut" label="&cutCmd.label;" key="key_cut" accesskey="&cutCmd.accesskey;" command="cmd_cut"/>
<menuitem id="menu_copy" label="&copyCmd.label;" key="key_copy" accesskey="&copyCmd.accesskey;" command="cmd_copy"/>
<menuitem id="menu_paste" label="&pasteCmd.label;" key="key_paste" accesskey="&pasteCmd.accesskey;" command="cmd_paste"/>
<menuitem id="menu_delete" label="&deleteCmd.label;" key="key_delete" accesskey="&deleteCmd.accesskey;" command="cmd_delete"/>
<menuitem id="menu_selectAll" label="&selectAllCmd.label;" key="key_selectAll" accesskey="&selectAllCmd.accesskey;" command="cmd_selectAll"/>
<!-- These key nodes are here only for show. -->
<!-- The real bindings come from XBL, in platformHTMLBindings.xml. -->
@ -86,26 +86,26 @@
events="clipboard"
oncommandupdate="goUpdatePasteMenuItems()"/>
<broadcaster id="cmd_undo"
<command id="cmd_undo"
oncommand="goDoCommand('cmd_undo')"
disabled="true"/>
<broadcaster id="cmd_redo"
<command id="cmd_redo"
oncommand="goDoCommand('cmd_redo')"
disabled="true"/>
<broadcaster id="cmd_cut"
<command id="cmd_cut"
oncommand="goDoCommand('cmd_cut')"
disabled="true"/>
<broadcaster id="cmd_copy"
<command id="cmd_copy"
oncommand="goDoCommand('cmd_copy')"
disabled="true"/>
<broadcaster id="cmd_paste"
<command id="cmd_paste"
oncommand="goDoCommand('cmd_paste')"
disabled="true"/>
<broadcaster id="cmd_delete"
<command id="cmd_delete"
oncommand="goDoCommand('cmd_delete')"
valueDefault="&deleteCmd.label;"
disabled="true"/>
<broadcaster id="cmd_selectAll"
<command id="cmd_selectAll"
oncommand="goDoCommand('cmd_selectAll')"
disabled="true"/>
@ -114,11 +114,7 @@
<menuitem id="menu_preferences"
label="&preferencesCmd.label;"
key="key_preferences"
accesskey="&preferencesCmd.accesskey;"
observes="cmd_preferences"/>
<!-- Search Menu -->
accesskey="&preferencesCmd.accesskey;"/>
<!-- View Menu -->
<menu id="menu_View" label="&viewMenu.label;" accesskey="&viewMenu.accesskey;"/>
@ -135,8 +131,8 @@
<menuitem accesskey="&releaseCmd.accesskey;" label="&releaseCmd.label;"
id="releaseUrl" oncommand="openTopWin('&releaseURL;');"/>
<menuseparator/>
<menuitem class="about" accesskey="&aboutCommPluginsCmd.accesskey;" label="&aboutCommPluginsCmd.label;"
id="pluginInfo" oncommand="openTopWin('about:plugins')"/>
<menuitem class="about" accesskey="&aboutCommPluginsCmd.accesskey;" label="&aboutCommPluginsCmd.label;"
id="pluginInfo" oncommand="openTopWin('about:plugins')"/>
<menuitem accesskey="&aboutCmd.accesskey;" label="&aboutCmd.label;"
id="aboutName" oncommand="goAboutDialog();"/>
</menupopup>

View File

@ -43,28 +43,26 @@
<script type="application/x-javascript" src="chrome://communicator/content/viewZoomOverlay.js"/>
<stringbundleset id="stringbundleset">
<stringbundle id="bundle_viewZoom" src="chrome://communicator/locale/viewZoomOverlay.properties"/>
</stringbundleset>
<stringbundle id="bundle_viewZoom" src="chrome://communicator/locale/viewZoomOverlay.properties"/>
<keyset id="keyset">
<key id="key_textZoomReduce" key="&textZoomReduceCmd.commandkey;" observes="cmd_textZoomReduce" modifiers="accel"/>
<key id="key_textZoomEnlarge" key="&textZoomEnlargeCmd.commandkey;" observes="cmd_textZoomEnlarge" modifiers="accel"/>
<key key="&textZoomEnlargeCmd.commandkey;" observes="cmd_textZoomEnlarge" modifiers="accel,shift"/>
<key key="&textZoomEnlargeCmd.commandkey2;" observes="cmd_textZoomEnlarge" modifiers="accel"/>
<key key="&textZoomResetCmd.commandkey;" observes="cmd_textZoomReset" modifiers="accel"/>
<keyset id="viewZoomKeys">
<key id="key_textZoomReduce" key="&textZoomReduceCmd.commandkey;" command="cmd_textZoomReduce" modifiers="accel"/>
<key id="key_textZoomEnlarge" key="&textZoomEnlargeCmd.commandkey;" command="cmd_textZoomEnlarge" modifiers="accel"/>
<key key="&textZoomEnlargeCmd.commandkey;" command="cmd_textZoomEnlarge" modifiers="accel,shift"/>
<key key="&textZoomEnlargeCmd.commandkey2;" command="cmd_textZoomEnlarge" modifiers="accel"/>
<key key="&textZoomResetCmd.commandkey;" command="cmd_textZoomReset" modifiers="accel"/>
</keyset>
<broadcasterset id="broadcasterset">
<broadcaster id="cmd_textZoomReduce" oncommand="ZoomManager.prototype.getInstance().reduce();"/>
<broadcaster id="cmd_textZoomEnlarge" oncommand="ZoomManager.prototype.getInstance().enlarge();"/>
<broadcaster id="cmd_textZoomReset" oncommand="ZoomManager.prototype.getInstance().reset();"/>
</broadcasterset>
<commandset id="viewZoomCommands">
<command id="cmd_textZoomReduce" oncommand="ZoomManager.prototype.getInstance().reduce();"/>
<command id="cmd_textZoomEnlarge" oncommand="ZoomManager.prototype.getInstance().enlarge();"/>
<command id="cmd_textZoomReset" oncommand="ZoomManager.prototype.getInstance().reset();"/>
</commandset>
<menu id="menu_textZoom" accesskey="&textZoomMenu.accesskey;" hidden="true">
<menupopup id="menu_textZoomPopup" oncreate="updateTextZoomMenu();">
<menuitem key="key_textZoomReduce" label="&textZoomReduceCmd.label;" accesskey="&textZoomReduceCmd.accesskey;" observes="cmd_textZoomReduce"/>
<menuitem key="key_textZoomEnlarge" label="&textZoomEnlargeCmd.label;" accesskey="&textZoomEnlargeCmd.accesskey;" observes="cmd_textZoomEnlarge"/>
<menuitem key="key_textZoomReduce" label="&textZoomReduceCmd.label;" accesskey="&textZoomReduceCmd.accesskey;" command="cmd_textZoomReduce"/>
<menuitem key="key_textZoomEnlarge" label="&textZoomEnlargeCmd.label;" accesskey="&textZoomEnlargeCmd.accesskey;" command="cmd_textZoomEnlarge"/>
<menuseparator/>
<menuseparator id="menu_textZoomInsertBefore"/>
<menuitem id="menu_textZoomOther" type="radio" name="textZoom" accesskey="&textZoomOtherCmd.accesskey;" oncommand="setTextZoomOther();"/>