Bug 495818 Zoom menu applies to the message pane rather than the browser in the selected tab. r=philringnalda

This commit is contained in:
Mark Banner 2009-06-05 09:25:42 +01:00
Родитель 971a458069
Коммит 463eb8cdca
8 изменённых файлов: 165 добавлений и 11 удалений

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

@ -229,6 +229,10 @@ var DefaultController =
case "cmd_selectThread": case "cmd_selectThread":
case "cmd_moveToFolderAgain": case "cmd_moveToFolderAgain":
case "cmd_selectFlagged": case "cmd_selectFlagged":
case "cmd_fullZoomReduce":
case "cmd_fullZoomEnlarge":
case "cmd_fullZoomReset":
case "cmd_fullZoomToggle":
return true; return true;
case "cmd_downloadFlagged": case "cmd_downloadFlagged":
case "cmd_downloadSelected": case "cmd_downloadSelected":
@ -496,6 +500,11 @@ var DefaultController =
} }
return pref.getCharPref("mail.last_msg_movecopy_target_uri") && return pref.getCharPref("mail.last_msg_movecopy_target_uri") &&
GetNumSelectedMessages() > 0; GetNumSelectedMessages() > 0;
case "cmd_fullZoomReduce":
case "cmd_fullZoomEnlarge":
case "cmd_fullZoomReset":
case "cmd_fullZoomToggle":
return IsFolderSelected() && !IsMessagePaneCollapsed();
default: default:
return false; return false;
} }
@ -784,6 +793,18 @@ var DefaultController =
case "cmd_selectFlagged": case "cmd_selectFlagged":
gDBView.doCommand(nsMsgViewCommandType.selectFlagged); gDBView.doCommand(nsMsgViewCommandType.selectFlagged);
break; break;
case "cmd_fullZoomReduce":
ZoomManager.reduce();
break;
case "cmd_fullZoomEnlarge":
ZoomManager.enlarge();
break;
case "cmd_fullZoomReset":
ZoomManager.reset();
break;
case "cmd_fullZoomToggle":
ZoomManager.toggleZoom();
break;
} }
}, },

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

@ -148,7 +148,7 @@ function InitMsgWindow()
Components.classes["@mozilla.org/messenger/services/session;1"] Components.classes["@mozilla.org/messenger/services/session;1"]
.getService(Components.interfaces.nsIMsgMailSession) .getService(Components.interfaces.nsIMsgMailSession)
.AddMsgWindow(msgWindow); .AddMsgWindow(msgWindow);
getBrowser().docShell.allowAuth = false; document.getElementById("messagepane").docShell.allowAuth = false;
msgWindow.rootDocShell.allowAuth = true; msgWindow.rootDocShell.allowAuth = true;
msgWindow.rootDocShell.appType = Components.interfaces.nsIDocShell.APP_TYPE_MAIL; msgWindow.rootDocShell.appType = Components.interfaces.nsIDocShell.APP_TYPE_MAIL;
// Ensure we don't load xul error pages into the main window // Ensure we don't load xul error pages into the main window
@ -545,10 +545,13 @@ function HidingThreadPane()
document.getElementById("key_toggleMessagePane").setAttribute("disabled", "true"); document.getElementById("key_toggleMessagePane").setAttribute("disabled", "true");
} }
// the find toolbar needs a method called getBrowser // The zoom manager, view source and possibly some other functions still rely
// on the getBrowser function.
function getBrowser() function getBrowser()
{ {
return document.getElementById("messagepane"); let tabmail = document.getElementById('tabmail');
return tabmail ? tabmail.getBrowserForSelectedTab() :
document.getElementById("messagepane");
} }
var gCurrentDisplayDeckId = ""; var gCurrentDisplayDeckId = "";

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

@ -1732,6 +1732,10 @@ let mailTabType = {
} }
if (aTab.msgSelectedFolder) if (aTab.msgSelectedFolder)
aTab.mailView = GetMailViewForFolder(aTab.msgSelectedFolder); aTab.mailView = GetMailViewForFolder(aTab.msgSelectedFolder);
// Now let other tabs have a primary browser if they want.
document.getElementById("messagepane").setAttribute("type",
"content-targetable");
}, },
_displayFolderAndThreadPane: function(show) { _displayFolderAndThreadPane: function(show) {
@ -1804,6 +1808,10 @@ let mailTabType = {
}, },
showTab: function(aTab) { showTab: function(aTab) {
// Set the messagepane as the primary browser for content.
document.getElementById("messagepane").setAttribute("type",
"content-primary");
// restore globals // restore globals
messenger = aTab.messenger; messenger = aTab.messenger;
gDBView = aTab.dbView; gDBView = aTab.dbView;
@ -1889,6 +1897,11 @@ let mailTabType = {
onEvent: function(aTab, aEvent) { onEvent: function(aTab, aEvent) {
DefaultController.onEvent(aEvent); DefaultController.onEvent(aEvent);
},
getBrowser: function(aTab) {
// We currently use the messagepane element for all tab types.
return document.getElementById("messagepane");
} }
}; };

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

@ -142,11 +142,18 @@
<command id="cmd_viewThreadsWithUnread" oncommand="goDoCommand('cmd_viewThreadsWithUnread')" disabled="true"/> <command id="cmd_viewThreadsWithUnread" oncommand="goDoCommand('cmd_viewThreadsWithUnread')" disabled="true"/>
<command id="cmd_viewWatchedThreadsWithUnread" oncommand="goDoCommand('cmd_viewWatchedThreadsWithUnread')" disabled="true"/> <command id="cmd_viewWatchedThreadsWithUnread" oncommand="goDoCommand('cmd_viewWatchedThreadsWithUnread')" disabled="true"/>
<command id="cmd_viewIgnoredThreads" oncommand="goDoCommand('cmd_viewIgnoredThreads')" disabled="true"/> <command id="cmd_viewIgnoredThreads" oncommand="goDoCommand('cmd_viewIgnoredThreads')" disabled="true"/>
<commandset id="viewZoomCommands"> <commandset id="viewZoomCommands"
<command id="cmd_fullZoomReduce" oncommand="ZoomManager.reduce()"/> commandupdater="true"
<command id="cmd_fullZoomEnlarge" oncommand="ZoomManager.enlarge()"/> events="create-menu-view"
<command id="cmd_fullZoomReset" oncommand="ZoomManager.reset()"/> oncommandupdate="goUpdateMailMenuItems(this);">
<command id="cmd_fullZoomToggle" oncommand="ZoomManager.toggleZoom();"/> <command id="cmd_fullZoomReduce"
oncommand="goDoCommand('cmd_fullZoomReduce');"/>
<command id="cmd_fullZoomEnlarge"
oncommand="goDoCommand('cmd_fullZoomEnlarge');"/>
<command id="cmd_fullZoomReset"
oncommand="goDoCommand('cmd_fullZoomReset');"/>
<command id="cmd_fullZoomToggle"
oncommand="goDoCommand('cmd_fullZoomToggle');"/>
</commandset> </commandset>
</commandset> </commandset>

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

@ -806,6 +806,10 @@ var MessageWindowController =
case "cmd_createFilterFromPopup": case "cmd_createFilterFromPopup":
case "cmd_createFilterFromMenu": case "cmd_createFilterFromMenu":
case "cmd_moveToFolderAgain": case "cmd_moveToFolderAgain":
case "cmd_fullZoomReduce":
case "cmd_fullZoomEnlarge":
case "cmd_fullZoomReset":
case "cmd_fullZoomToggle":
return true; return true;
case "cmd_synchronizeOffline": case "cmd_synchronizeOffline":
case "cmd_downloadFlagged": case "cmd_downloadFlagged":
@ -909,6 +913,10 @@ var MessageWindowController =
case "cmd_goForward": case "cmd_goForward":
case "cmd_goBack": case "cmd_goBack":
case "cmd_applyFiltersToSelection": case "cmd_applyFiltersToSelection":
case "cmd_fullZoomReduce":
case "cmd_fullZoomEnlarge":
case "cmd_fullZoomReset":
case "cmd_fullZoomToggle":
return true; return true;
case "button_goForward": case "button_goForward":
case "button_goBack": case "button_goBack":
@ -1123,6 +1131,18 @@ var MessageWindowController =
case "cmd_applyFiltersToSelection": case "cmd_applyFiltersToSelection":
MsgApplyFiltersToSelection(); MsgApplyFiltersToSelection();
break; break;
case "cmd_fullZoomReduce":
ZoomManager.reduce();
break;
case "cmd_fullZoomEnlarge":
ZoomManager.enlarge();
break;
case "cmd_fullZoomReset":
ZoomManager.reset();
break;
case "cmd_fullZoomToggle":
ZoomManager.toggleZoom();
break;
} }
}, },

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

@ -1095,7 +1095,10 @@ function GetMessagePane()
function GetMessagePaneFrame() function GetMessagePaneFrame()
{ {
return window.content; // We must use the message pane element directly here, as other tabs can
// have browser elements as well (which could be set to content-primary,
// which would confuse things with a window.content return).
return document.getElementById("messagepane").contentWindow;
} }
function getMailToolbox() function getMailToolbox()

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

@ -63,6 +63,7 @@ var specialTabs = {
contentTabType: { contentTabType: {
name: "contentTab", name: "contentTab",
perTabPanel: "vbox", perTabPanel: "vbox",
lastBrowserId: 0,
modes: { modes: {
contentTab: { contentTab: {
type: "contentTab", type: "contentTab",
@ -98,23 +99,89 @@ var specialTabs = {
openTab: function onTabOpened(aTab, aContentPage, aTitle) { openTab: function onTabOpened(aTab, aContentPage, aTitle) {
// You can't dynamically change an iframe from a non-content to a content // You can't dynamically change an iframe from a non-content to a content
// type, therefore we dynamically create the element instead. // type, therefore we dynamically create the element instead.
let iframe = document.createElement("iframe"); let iframe = document.createElement("browser");
iframe.setAttribute("type", "content"); iframe.setAttribute("type", "content-primary");
iframe.setAttribute("flex", "1"); iframe.setAttribute("flex", "1");
iframe.setAttribute("autocompleteenabled", false);
iframe.setAttribute("disablehistory", true);
iframe.setAttribute("id", "contentTabType" + this.lastBrowserId);
aTab.panel.appendChild(iframe); aTab.panel.appendChild(iframe);
iframe.setAttribute("src", aContentPage); iframe.setAttribute("src", aContentPage);
aTab.title = aTitle; aTab.title = aTitle;
let findbar = document.createElement("findbar");
findbar.setAttribute("browserid", "contentTabType" + this.lastBrowserId);
aTab.panel.appendChild(findbar);
this.lastBrowserId++;
}, },
closeTab: function onTabClosed(aTab) { closeTab: function onTabClosed(aTab) {
}, },
saveTabState: function onSaveTabState(aTab) { saveTabState: function onSaveTabState(aTab) {
aTab.panel.firstChild.setAttribute("type", "content-targetable");
}, },
showTab: function onShowTab(aTab) { showTab: function onShowTab(aTab) {
aTab.panel.firstChild.setAttribute("type", "content-primary");
}, },
onTitleChanged: function onTitleChanged(aTab) { onTitleChanged: function onTitleChanged(aTab) {
},
supportsCommand: function supportsCommand(aTab, aCommand) {
switch (aCommand) {
case "cmd_fullZoomReduce":
case "cmd_fullZoomEnlarge":
case "cmd_fullZoomReset":
case "cmd_fullZoomToggle":
case "cmd_find":
case "cmd_findAgain":
case "cmd_findPrevious":
return true;
default:
return false;
}
},
isCommandEnabled: function isCommandEnabled(aTab, aCommand) {
switch (aCommand) {
case "cmd_fullZoomReduce":
case "cmd_fullZoomEnlarge":
case "cmd_fullZoomReset":
case "cmd_fullZoomToggle":
case "cmd_find":
case "cmd_findAgain":
case "cmd_findPrevious":
return true;
default:
return false;
}
},
doCommand: function isCommandEnabled(aTab, aCommand) {
switch (aCommand) {
case "cmd_fullZoomReduce":
ZoomManager.reduce();
break;
case "cmd_fullZoomEnlarge":
ZoomManager.enlarge();
break;
case "cmd_fullZoomReset":
ZoomManager.reset();
break;
case "cmd_fullZoomToggle":
ZoomManager.toggleZoom();
break;
case "cmd_find":
aTab.panel.childNodes[1].onFindCommand();
break;
case "cmd_findAgain":
aTab.panel.childNodes[1].onFindAgainCommand(false);
break;
case "cmd_findPrevious":
aTab.panel.childNodes[1].onFindAgainCommand(true);
break;
}
},
getBrowser: function getBrowser(aTab) {
return aTab.panel.firstChild;
} }
}, },

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

@ -168,6 +168,10 @@
- be executed. Perform the action appropriate to the command. - be executed. Perform the action appropriate to the command.
- * onEvent(aTab, aEvent): This can be used to handle different events on - * onEvent(aTab, aEvent): This can be used to handle different events on
- the window. - the window.
- * getBrowser(aTab): This function should return the browser element for
- your tab if there is one (return null or don't define this function
- otherwise). It is used for some toolkit functions that require a
- global "getBrowser" function, e.g. ZoomManager.
- -
- Tab monitoring code is expected to be used for widgets on the screen - Tab monitoring code is expected to be used for widgets on the screen
- outside of the tab box that need to update themselves as the active tab - outside of the tab box that need to update themselves as the active tab
@ -486,6 +490,22 @@
]]> ]]>
</body> </body>
</method> </method>
<!-- getBrowserForSelectedTab is required as some toolkit functions
require a getBrowser() function. -->
<method name="getBrowserForSelectedTab">
<body><![CDATA[
if (!this.currentTabInfo)
this.currentTabInfo = this.tabInfo[0];
let tab = this.currentTabInfo;
let browserFunc = tab.mode.getBrowser || tab.mode.tabType.getBrowser;
if (browserFunc)
return browserFunc.call(tab.mode.tabType, tab);
return null;
]]></body>
</method>
<method name="removeCurrentTab"> <method name="removeCurrentTab">
<body><![CDATA[ <body><![CDATA[
this.removeTabByNode( this.removeTabByNode(