зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1459556 - Part 1 - Remove the implementation from the "handler" binding. r=jaws
MozReview-Commit-ID: IN1C5NC9Rzb --HG-- extra : rebase_source : 776e8d830ba2f5f37a039889705906e4d9a27096 extra : source : f7b1991ca700088428baf65f38ca8eff3135f8c5
This commit is contained in:
Родитель
9f78fa285f
Коммит
638e666e32
|
@ -11,29 +11,6 @@
|
||||||
xmlns:xbl="http://www.mozilla.org/xbl">
|
xmlns:xbl="http://www.mozilla.org/xbl">
|
||||||
|
|
||||||
<binding id="handler" extends="chrome://global/content/bindings/richlistbox.xml#richlistitem">
|
<binding id="handler" extends="chrome://global/content/bindings/richlistbox.xml#richlistitem">
|
||||||
<implementation>
|
|
||||||
<property name="type" readonly="true">
|
|
||||||
<getter>
|
|
||||||
return this.getAttribute("type");
|
|
||||||
</getter>
|
|
||||||
</property>
|
|
||||||
<!-- Overriding listitem -->
|
|
||||||
<property name="selected" onget="return this.getAttribute('selected') == 'true';">
|
|
||||||
<setter><![CDATA[
|
|
||||||
if (val) {
|
|
||||||
this.setAttribute("selected", "true");
|
|
||||||
gMainPane.rebuildActionsMenu();
|
|
||||||
} else {
|
|
||||||
this.removeAttribute("selected");
|
|
||||||
}
|
|
||||||
|
|
||||||
document.getAnonymousElementByAttribute(this, "anonid", "selected").setAttribute("hidden", !val);
|
|
||||||
document.getAnonymousElementByAttribute(this, "anonid", "not-selected").setAttribute("hidden", !!val);
|
|
||||||
|
|
||||||
return val;
|
|
||||||
]]></setter>
|
|
||||||
</property>
|
|
||||||
</implementation>
|
|
||||||
<content>
|
<content>
|
||||||
<xul:hbox flex="1" equalsize="always">
|
<xul:hbox flex="1" equalsize="always">
|
||||||
<xul:hbox flex="1" align="center" xbl:inherits="tooltiptext=typeDescription">
|
<xul:hbox flex="1" align="center" xbl:inherits="tooltiptext=typeDescription">
|
||||||
|
|
|
@ -583,6 +583,7 @@ var gMainPane = {
|
||||||
// of the preferences page.
|
// of the preferences page.
|
||||||
window.addEventListener("pageshow", async () => {
|
window.addEventListener("pageshow", async () => {
|
||||||
try {
|
try {
|
||||||
|
this._initListEventHandlers();
|
||||||
this._loadData();
|
this._loadData();
|
||||||
await this._rebuildVisibleTypes();
|
await this._rebuildVisibleTypes();
|
||||||
this._sortVisibleTypes();
|
this._sortVisibleTypes();
|
||||||
|
@ -1448,6 +1449,31 @@ var gMainPane = {
|
||||||
|
|
||||||
// View Construction
|
// View Construction
|
||||||
|
|
||||||
|
selectedHandlerListItem: null,
|
||||||
|
|
||||||
|
_initListEventHandlers() {
|
||||||
|
this._list.addEventListener("select", event => {
|
||||||
|
if (event.target != this._list) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let handlerListItem = this._list.selectedItem &&
|
||||||
|
HandlerListItem.forNode(this._list.selectedItem);
|
||||||
|
if (this.selectedHandlerListItem == handlerListItem) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.selectedHandlerListItem) {
|
||||||
|
this.selectedHandlerListItem.showActionsMenu = false;
|
||||||
|
}
|
||||||
|
this.selectedHandlerListItem = handlerListItem;
|
||||||
|
if (handlerListItem) {
|
||||||
|
this.rebuildActionsMenu();
|
||||||
|
handlerListItem.showActionsMenu = true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
async _rebuildVisibleTypes() {
|
async _rebuildVisibleTypes() {
|
||||||
this._visibleTypes = [];
|
this._visibleTypes = [];
|
||||||
|
|
||||||
|
@ -1506,8 +1532,9 @@ var gMainPane = {
|
||||||
},
|
},
|
||||||
|
|
||||||
_rebuildView() {
|
_rebuildView() {
|
||||||
let lastSelectedType = this._list.selectedItem &&
|
let lastSelectedType = this.selectedHandlerListItem &&
|
||||||
HandlerListItem.forNode(this._list.selectedItem).handlerInfoWrapper.type;
|
this.selectedHandlerListItem.handlerInfoWrapper.type;
|
||||||
|
this.selectedHandlerListItem = null;
|
||||||
|
|
||||||
// Clear the list of entries.
|
// Clear the list of entries.
|
||||||
while (this._list.childNodes.length > 1)
|
while (this._list.childNodes.length > 1)
|
||||||
|
@ -1585,7 +1612,7 @@ var gMainPane = {
|
||||||
*/
|
*/
|
||||||
rebuildActionsMenu() {
|
rebuildActionsMenu() {
|
||||||
var typeItem = this._list.selectedItem;
|
var typeItem = this._list.selectedItem;
|
||||||
var handlerInfo = this._handledTypes[typeItem.type];
|
var handlerInfo = this.selectedHandlerListItem.handlerInfoWrapper;
|
||||||
var menu =
|
var menu =
|
||||||
document.getAnonymousElementByAttribute(typeItem, "class", "actionsMenu");
|
document.getAnonymousElementByAttribute(typeItem, "class", "actionsMenu");
|
||||||
var menuPopup = menu.menupopup;
|
var menuPopup = menu.menupopup;
|
||||||
|
@ -1699,7 +1726,7 @@ var gMainPane = {
|
||||||
if (Cc["@mozilla.org/gio-service;1"]) {
|
if (Cc["@mozilla.org/gio-service;1"]) {
|
||||||
let gIOSvc = Cc["@mozilla.org/gio-service;1"].
|
let gIOSvc = Cc["@mozilla.org/gio-service;1"].
|
||||||
getService(Ci.nsIGIOService);
|
getService(Ci.nsIGIOService);
|
||||||
var gioApps = gIOSvc.getAppsForURIScheme(typeItem.type);
|
var gioApps = gIOSvc.getAppsForURIScheme(handlerInfo.type);
|
||||||
let enumerator = gioApps.enumerate();
|
let enumerator = gioApps.enumerate();
|
||||||
let possibleHandlers = handlerInfo.possibleApplicationHandlers;
|
let possibleHandlers = handlerInfo.possibleApplicationHandlers;
|
||||||
while (enumerator.hasMoreElements()) {
|
while (enumerator.hasMoreElements()) {
|
||||||
|
@ -1906,8 +1933,7 @@ var gMainPane = {
|
||||||
},
|
},
|
||||||
|
|
||||||
_storeAction(aActionItem) {
|
_storeAction(aActionItem) {
|
||||||
var typeItem = this._list.selectedItem;
|
var handlerInfo = this.selectedHandlerListItem.handlerInfoWrapper;
|
||||||
var handlerInfo = this._handledTypes[typeItem.type];
|
|
||||||
|
|
||||||
let action = parseInt(aActionItem.getAttribute("action"));
|
let action = parseInt(aActionItem.getAttribute("action"));
|
||||||
|
|
||||||
|
@ -1942,7 +1968,7 @@ var gMainPane = {
|
||||||
handlerInfo.handledOnlyByPlugin = false;
|
handlerInfo.handledOnlyByPlugin = false;
|
||||||
|
|
||||||
// Update the action label and image to reflect the new preferred action.
|
// Update the action label and image to reflect the new preferred action.
|
||||||
HandlerListItem.forNode(typeItem).refreshAction();
|
this.selectedHandlerListItem.refreshAction();
|
||||||
},
|
},
|
||||||
|
|
||||||
manageApp(aEvent) {
|
manageApp(aEvent) {
|
||||||
|
@ -1950,8 +1976,7 @@ var gMainPane = {
|
||||||
// as we handle it specially ourselves.
|
// as we handle it specially ourselves.
|
||||||
aEvent.stopPropagation();
|
aEvent.stopPropagation();
|
||||||
|
|
||||||
var typeItem = this._list.selectedItem;
|
var handlerInfo = this.selectedHandlerListItem.handlerInfoWrapper;
|
||||||
var handlerInfo = this._handledTypes[typeItem.type];
|
|
||||||
|
|
||||||
let onComplete = () => {
|
let onComplete = () => {
|
||||||
// Rebuild the actions menu so that we revert to the previous selection,
|
// Rebuild the actions menu so that we revert to the previous selection,
|
||||||
|
@ -1959,7 +1984,7 @@ var gMainPane = {
|
||||||
this.rebuildActionsMenu();
|
this.rebuildActionsMenu();
|
||||||
|
|
||||||
// update the richlistitem too. Will be visible when selecting another row
|
// update the richlistitem too. Will be visible when selecting another row
|
||||||
HandlerListItem.forNode(typeItem).refreshAction();
|
this.selectedHandlerListItem.refreshAction();
|
||||||
};
|
};
|
||||||
|
|
||||||
gSubDialog.open("chrome://browser/content/preferences/applicationManager.xul",
|
gSubDialog.open("chrome://browser/content/preferences/applicationManager.xul",
|
||||||
|
@ -1998,7 +2023,7 @@ var gMainPane = {
|
||||||
|
|
||||||
if (AppConstants.platform == "win") {
|
if (AppConstants.platform == "win") {
|
||||||
var params = {};
|
var params = {};
|
||||||
var handlerInfo = this._handledTypes[this._list.selectedItem.type];
|
var handlerInfo = this.selectedHandlerListItem.handlerInfoWrapper;
|
||||||
|
|
||||||
if (isFeedType(handlerInfo.type)) {
|
if (isFeedType(handlerInfo.type)) {
|
||||||
// MIME info will be null, create a temp object.
|
// MIME info will be null, create a temp object.
|
||||||
|
@ -2038,7 +2063,7 @@ var gMainPane = {
|
||||||
handlerApp.executable = fp.file;
|
handlerApp.executable = fp.file;
|
||||||
|
|
||||||
// Add the app to the type's list of possible handlers.
|
// Add the app to the type's list of possible handlers.
|
||||||
let handler = this._handledTypes[this._list.selectedItem.type];
|
let handler = this.selectedHandlerListItem.handlerInfoWrapper;
|
||||||
handler.addPossibleApplicationHandler(handlerApp);
|
handler.addPossibleApplicationHandler(handlerApp);
|
||||||
|
|
||||||
chooseAppCallback(handlerApp);
|
chooseAppCallback(handlerApp);
|
||||||
|
@ -2464,6 +2489,13 @@ class HandlerListItem {
|
||||||
this.node.setAttribute("actionIcon", this.handlerInfoWrapper.actionIcon);
|
this.node.setAttribute("actionIcon", this.handlerInfoWrapper.actionIcon);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
set showActionsMenu(value) {
|
||||||
|
document.getAnonymousElementByAttribute(this.node, "anonid", "selected")
|
||||||
|
.setAttribute("hidden", !value);
|
||||||
|
document.getAnonymousElementByAttribute(this.node, "anonid", "not-selected")
|
||||||
|
.setAttribute("hidden", !!value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Загрузка…
Ссылка в новой задаче