Bug 203386 CTRL+TAB navigation inconsistent when focus is not on one of the three main panes p=mcow@well.com r=me sr=mscott

This commit is contained in:
neil%parkwaycc.co.uk 2004-12-01 23:23:38 +00:00
Родитель 4ef6f59981
Коммит 028f46c57e
1 изменённых файлов: 19 добавлений и 18 удалений

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

@ -724,11 +724,10 @@ function FocusRingUpdate_Mail()
// we really only care about nsFocusController::Focus() happens, // we really only care about nsFocusController::Focus() happens,
// which calls nsFocusController::SetFocusedElement(element) // which calls nsFocusController::SetFocusedElement(element)
var currentFocusedElement = WhichPaneHasFocus(); var currentFocusedElement = WhichPaneHasFocus();
if (!currentFocusedElement)
return;
if (currentFocusedElement != gLastFocusedElement) { if (currentFocusedElement != gLastFocusedElement) {
currentFocusedElement.setAttribute("focusring", "true"); if (currentFocusedElement)
currentFocusedElement.setAttribute("focusring", "true");
if (gLastFocusedElement) if (gLastFocusedElement)
gLastFocusedElement.removeAttribute("focusring"); gLastFocusedElement.removeAttribute("focusring");
@ -746,7 +745,6 @@ function FocusRingUpdate_Mail()
function WhichPaneHasFocus() function WhichPaneHasFocus()
{ {
var threadTree = GetThreadTree(); var threadTree = GetThreadTree();
var searchInput = GetSearchInput();
var folderTree = GetFolderTree(); var folderTree = GetFolderTree();
var messagePane = GetMessagePane(); var messagePane = GetMessagePane();
@ -756,7 +754,6 @@ function WhichPaneHasFocus()
var currentNode = top.document.commandDispatcher.focusedElement; var currentNode = top.document.commandDispatcher.focusedElement;
while (currentNode) { while (currentNode) {
if (currentNode === threadTree || if (currentNode === threadTree ||
currentNode === searchInput ||
currentNode === folderTree || currentNode === folderTree ||
currentNode === messagePane) currentNode === messagePane)
return currentNode; return currentNode;
@ -1053,17 +1050,22 @@ function SearchBarToggled()
function SwitchPaneFocus(event) function SwitchPaneFocus(event)
{ {
var focusedElement = WhichPaneHasFocus();
var folderTree = GetFolderTree(); var folderTree = GetFolderTree();
var threadTree = GetThreadTree(); var threadTree = GetThreadTree();
var searchInput = GetSearchInput();
var messagePane = GetMessagePane(); var messagePane = GetMessagePane();
// Although internally this is actually a four-pane window, it is presented as
// a three-pane -- the search pane is more of a toolbar. So, shift among the
// three main panes.
var focusedElement = WhichPaneHasFocus();
if (focusedElement == null) // focus not on one of the main three panes?
focusedElement = threadTree; // treat as if on thread tree
if (event && event.shiftKey) if (event && event.shiftKey)
{ {
if (focusedElement == threadTree && searchInput.parentNode.getAttribute('hidden') != 'true') // Reverse traversal: Message -> Thread -> Folder -> Message
searchInput.focus(); if (focusedElement == threadTree && !IsFolderPaneCollapsed())
else if ((focusedElement == threadTree || focusedElement == searchInput) && !IsFolderPaneCollapsed())
folderTree.focus(); folderTree.focus();
else if (focusedElement != messagePane && !IsMessagePaneCollapsed()) else if (focusedElement != messagePane && !IsMessagePaneCollapsed())
SetFocusMessagePane(); SetFocusMessagePane();
@ -1072,14 +1074,11 @@ function SwitchPaneFocus(event)
} }
else else
{ {
if (focusedElement == searchInput) // Forward traversal: Folder -> Thread -> Message -> Folder
threadTree.focus(); if (focusedElement == threadTree && !IsMessagePaneCollapsed())
else if (focusedElement == threadTree && !IsMessagePaneCollapsed())
SetFocusMessagePane(); SetFocusMessagePane();
else if (focusedElement != folderTree && !IsFolderPaneCollapsed()) else if (focusedElement != folderTree && !IsFolderPaneCollapsed())
folderTree.focus(); folderTree.focus();
else if (searchInput.parentNode.getAttribute('hidden') != 'true')
searchInput.focus();
else else
threadTree.focus(); threadTree.focus();
} }
@ -1099,8 +1098,10 @@ function SetFocusThreadPane()
function SetFocusMessagePane() function SetFocusMessagePane()
{ {
var messagePaneFrame = GetMessagePaneFrame(); // XXX hack: to clear the focus on the previous element first focus
messagePaneFrame.focus(); // on the message pane element then focus on the main content window
GetMessagePane().focus();
GetMessagePaneFrame().focus();
} }
function is_collapsed(element) function is_collapsed(element)