Bug 175893. Make tab labels focusable (when clicking on label of foreground tab). Make unmodified arrow key navigation work with tabs. r=neil, sr=?

This commit is contained in:
aaronleventhal@moonset.net 2007-08-21 21:59:28 -07:00
parent 1c931fe475
commit 63f2cd8cd3

View File

@ -425,7 +425,11 @@
if (this.mCurrentBrowser) {
this.mCurrentBrowser.focusedWindow = document.commandDispatcher.focusedWindow;
this.mCurrentBrowser.focusedElement = document.commandDispatcher.focusedElement;
this.mCurrentBrowser.setAttribute("type", "content");
if (this.mCurrentBrowser.focusedElement) {
// Clear focus outline before we draw on top of it
this.mCurrentBrowser.focusedElement.blur();
}
this.mCurrentBrowser.setAttribute("type", "content");
}
var updatePageReport = false;
@ -489,22 +493,31 @@
}
function setFocus(element) {
Components.lookupMethod(element, "focus").call(element);
}
// Focus the previously focused element or window
document.commandDispatcher.suppressFocusScroll = true;
if (newBrowser.focusedElement) {
try {
setFocus(newBrowser.focusedElement);
} catch (e) {
setFocus(newBrowser.focusedWindow);
if (document.commandDispatcher.focusedElement &&
document.commandDispatcher.focusedElement.parentNode ==
this.mCurrentTab.parentNode) {
// The focus is on a tab in the same tab panel
return; // If focus was on a tab, switching tabs focuses the new tab
}
}
else if (newBrowser.focusedWindow)
setFocus(newBrowser.focusedWindow);
else // new tab, focus our new content area
setTimeout(setFocus, 0, window.content);
var whatToFocus = window.content;
// Focus the previously focused element or window
if (newBrowser.focusedElement) {
if (newBrowser.focusedElement.parentNode !=
this.mCurrentTab.parentNode) {
// Focus the remembered element unless it's in the current tab panel
whatToFocus = newBrowser.focusedElement;
}
}
else if (newBrowser.focusedWindow) {
whatToFocus = newBrowser.focusedWindow;
}
document.commandDispatcher.suppressFocusScroll = true;
// Use setTimeout to avoid focus outline ghosting.
setTimeout(setFocus, 0, whatToFocus);
document.commandDispatcher.suppressFocusScroll = false;
]]>
</body>