зеркало из https://github.com/mozilla/gecko-dev.git
Bug 345260 - handle dynamic changes to tab title, tab icon and busy (loading) state in all tabs menu. r=sspitzer/mconnor.
This commit is contained in:
Родитель
e80fa8f0f4
Коммит
7177a74ae0
|
@ -2733,33 +2733,62 @@
|
||||||
-->
|
-->
|
||||||
<binding id="tabbrowser-alltabs-popup"
|
<binding id="tabbrowser-alltabs-popup"
|
||||||
extends="chrome://global/content/bindings/popup.xml#popup">
|
extends="chrome://global/content/bindings/popup.xml#popup">
|
||||||
<implementation>
|
<implementation implements="nsIDOMEventListener">
|
||||||
<field name="_allTabsMenuItemCommandHandler" readonly="true">
|
<method name="_menuItemOnCommand">
|
||||||
<![CDATA[({
|
<parameter name="aEvent"/>
|
||||||
mOuter: this,
|
<body><![CDATA[
|
||||||
handleEvent: function handleEvent(aEvent) {
|
|
||||||
if (!aEvent.isTrusted) {
|
|
||||||
// Don't let untrusted events mess with tabs.
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// note, the tab may not be valid (if after we built the popup
|
// note, the tab may not be valid (if after we built the popup
|
||||||
// the tab was closed. but selectedItem setter handles that
|
// the tab was closed. but selectedItem setter handles that
|
||||||
// gracefully.
|
// gracefully.
|
||||||
var tabcontainer = document.getBindingParent(this.mOuter);
|
var tabcontainer = document.getBindingParent(this);
|
||||||
tabcontainer.selectedItem = aEvent.target.tab;
|
tabcontainer.selectedItem = aEvent.target.tab;
|
||||||
}
|
]]></body>
|
||||||
})]]>
|
</method>
|
||||||
</field>
|
|
||||||
|
<method name="_tabOnAttrModified">
|
||||||
|
<parameter name="aEvent"/>
|
||||||
|
<body><![CDATA[
|
||||||
|
var menuItem = aEvent.target.mCorrespondingMenuitem;
|
||||||
|
if (menuItem) {
|
||||||
|
var attrName = aEvent.attrName;
|
||||||
|
switch (attrName) {
|
||||||
|
case "label":
|
||||||
|
case "crop":
|
||||||
|
case "busy":
|
||||||
|
case "image":
|
||||||
|
if (aEvent.attrChange == aEvent.REMOVAL)
|
||||||
|
menuItem.removeAttribute(attrName);
|
||||||
|
else
|
||||||
|
menuItem.setAttribute(attrName, aEvent.newValue);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]]></body>
|
||||||
|
</method>
|
||||||
|
|
||||||
|
<method name="handleEvent">
|
||||||
|
<parameter name="aEvent"/>
|
||||||
|
<body><![CDATA[
|
||||||
|
if (!aEvent.isTrusted)
|
||||||
|
return;
|
||||||
|
|
||||||
|
switch (aEvent.type) {
|
||||||
|
case "command":
|
||||||
|
this._menuItemOnCommand(aEvent);
|
||||||
|
break;
|
||||||
|
case "DOMAttrModified":
|
||||||
|
this._tabOnAttrModified(aEvent);
|
||||||
|
}
|
||||||
|
]]></body>
|
||||||
|
</method>
|
||||||
|
|
||||||
<method name="_onHidingAllTabsPopup">
|
<method name="_onHidingAllTabsPopup">
|
||||||
<body><![CDATA[
|
<body><![CDATA[
|
||||||
// clear out the menu popup and remove the listeners
|
// clear out the menu popup and remove the listeners
|
||||||
while (this.hasChildNodes()) {
|
while (this.hasChildNodes()) {
|
||||||
var menuItem = this.lastChild;
|
var menuItem = this.lastChild;
|
||||||
menuItem.removeEventListener("command",
|
menuItem.removeEventListener("command", this, false);
|
||||||
this._allTabsMenuItemCommandHandler,
|
menuItem.tab.removeEventListener("DOMAttrModified", this, false);
|
||||||
false);
|
menuItem.tab.mCorrespondingMenuitem = null;
|
||||||
this.removeChild(menuItem);
|
this.removeChild(menuItem);
|
||||||
}
|
}
|
||||||
]]></body>
|
]]></body>
|
||||||
|
@ -2781,21 +2810,25 @@
|
||||||
menuItem.setAttribute("selected", "true");
|
menuItem.setAttribute("selected", "true");
|
||||||
menuItem.setAttribute("class", "menuitem-iconic alltabs-item");
|
menuItem.setAttribute("class", "menuitem-iconic alltabs-item");
|
||||||
|
|
||||||
// XXX todo
|
|
||||||
// what if uri, image/favicon, title change
|
|
||||||
// while this popup is open?
|
|
||||||
// mano warns: "be careful of leaks when addressing this."
|
|
||||||
menuItem.setAttribute("label", curTab.label);
|
menuItem.setAttribute("label", curTab.label);
|
||||||
|
menuItem.setAttribute("crop", curTab.getAttribute("crop"));
|
||||||
menuItem.setAttribute("image", curTab.getAttribute("image"));
|
menuItem.setAttribute("image", curTab.getAttribute("image"));
|
||||||
var URI = curTab.linkedBrowser.currentURI.spec;
|
if (curTab.hasAttribute("busy"))
|
||||||
|
menuItem.setAttribute("busy", curTab.getAttribute("busy"));
|
||||||
|
|
||||||
// XXX todo
|
// XXX todo
|
||||||
// statustext not working yet, since I don't have a menubar
|
// statustext not working yet, since I don't have a menubar
|
||||||
// reuse the menubar statustext logic
|
// reuse the menubar statustext logic
|
||||||
|
var URI = curTab.linkedBrowser.currentURI.spec;
|
||||||
menuItem.setAttribute("statustext", URI);
|
menuItem.setAttribute("statustext", URI);
|
||||||
|
|
||||||
|
// Keep some attributes of the menuitem in sync with its
|
||||||
|
// corresponding tab (e.g. the tab label)
|
||||||
|
curTab.mCorrespondingMenuitem = menuItem;
|
||||||
|
curTab.addEventListener("DOMAttrModified", this, false);
|
||||||
|
|
||||||
menuItem.tab = curTab;
|
menuItem.tab = curTab;
|
||||||
menuItem.addEventListener("command",
|
menuItem.addEventListener("command", this, false);
|
||||||
this._allTabsMenuItemCommandHandler,
|
|
||||||
false);
|
|
||||||
this.appendChild(menuItem);
|
this.appendChild(menuItem);
|
||||||
}
|
}
|
||||||
]]></body>
|
]]></body>
|
||||||
|
@ -2872,6 +2905,7 @@
|
||||||
|
|
||||||
<implementation>
|
<implementation>
|
||||||
<field name="mOverCloseButton">false</field>
|
<field name="mOverCloseButton">false</field>
|
||||||
|
<field name="mCorrespondingMenuitem">null</field>
|
||||||
</implementation>
|
</implementation>
|
||||||
|
|
||||||
<handlers>
|
<handlers>
|
||||||
|
|
Загрузка…
Ссылка в новой задаче