Fix for bug 224416 - tabs don't remember focused element.

patch by Will Devine. <yakgoatcamel@myrealbox.com>
This commit is contained in:
ben%bengoodger.com 2003-12-16 00:16:19 +00:00
parent 69246e3c9c
commit e436627911
3 changed files with 36 additions and 6 deletions

View File

@ -412,6 +412,14 @@
<field name="mFormFillAttached">
false
</field>
<field name="focusedWindow">
null
</field>
<field name="focusedElement">
null
</field>
<constructor>
<![CDATA[

View File

@ -302,8 +302,10 @@
if (next && next != startTab) {
this.selectedItem = next;
next.focus();
document.commandDispatcher.advanceFocusIntoSubtree(next);
if (this.getAttribute("setfocus") != "false") {
next.focus();
document.commandDispatcher.advanceFocusIntoSubtree(next);
}
}
]]>
</body>

View File

@ -78,6 +78,7 @@
</xul:menupopup>
<xul:tabs class="tabbrowser-tabs" closebutton="true" flex="1"
setfocus="false"
onclick="this.parentNode.parentNode.parentNode.onTabClick(event);"
onmousedown="this.parentNode.parentNode.parentNode.updateContextTab(event);"
ondragover="nsDragAndDrop.dragOver(event, this.parentNode.parentNode.parentNode);
@ -421,8 +422,11 @@
if (this.mCurrentBrowser == newBrowser)
return;
if (this.mCurrentBrowser)
this.mCurrentBrowser.setAttribute("type", "content");
if (this.mCurrentBrowser) {
this.mCurrentBrowser.focusedWindow = document.commandDispatcher.focusedWindow;
this.mCurrentBrowser.focusedElement = document.commandDispatcher.focusedElement;
this.mCurrentBrowser.setAttribute("type", "content");
}
var updatePageReport = false;
if ((this.mCurrentBrowser.pageReport && !newBrowser.pageReport) ||
@ -484,8 +488,24 @@
}
}
// Focus our new content area.
setTimeout("window._content.focus()", 0);
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);
}
}
else if (newBrowser.focusedWindow)
setFocus(newBrowser.focusedWindow);
else // new tab, focus our new content area
setTimeout(setFocus, 0, window.content);
document.commandDispatcher.suppressFocusScroll = false;
]]>
</body>
</method>