Bug 120148 Tabs don't remember which element [frame, textfield, etc] was focused when switching tabs

patch by tryandguessit@yahoo.com r=caillon sr=bryner
This commit is contained in:
timeless%mozdev.org 2003-10-31 03:56:22 +00:00
Родитель 5571870865
Коммит b693cafc7a
3 изменённых файлов: 33 добавлений и 5 удалений

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

@ -305,6 +305,14 @@
null
</field>
<field name="focusedWindow">
null
</field>
<field name="focusedElement">
null
</field>
<property name="userTypedValue"
onget="return this._userTypedValue;"
onset="this.userTypedClear = false; return this._userTypedValue = val;"/>

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

@ -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>

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

@ -82,6 +82,7 @@
<xul:tabs class="tabbrowser-tabs" closebutton="true" flex="1"
tooltiptextnew="&newTabButton.tooltip;"
setfocus="false"
onclick="this.parentNode.parentNode.parentNode.onTabClick(event);"
onmousedown="this.parentNode.parentNode.parentNode.updateContextTab(event);"
ondragover="nsDragAndDrop.dragOver(event, this.parentNode.parentNode.parentNode);
@ -500,8 +501,11 @@
<body>
<![CDATA[
var newBrowser = this.mPanelContainer.childNodes[this.mPanelContainer.selectedIndex];
if (this.mCurrentBrowser)
if (this.mCurrentBrowser) {
this.mCurrentBrowser.focusedWindow = document.commandDispatcher.focusedWindow;
this.mCurrentBrowser.focusedElement = document.commandDispatcher.focusedElement;
this.mCurrentBrowser.setAttribute("type", "content");
}
newBrowser.setAttribute("type", "content-primary");
this.mCurrentBrowser = newBrowser;
@ -558,8 +562,22 @@
}
}
// 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
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);
]]>
</body>
</method>