зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1459556 - Part 2 - Remove the "handler" binding. r=bgrins
MozReview-Commit-ID: GOUOKuoR1rs --HG-- extra : rebase_source : aefa4e36842278d00de678e357f5a03b7c5c901d extra : amend_source : d8e60b7cd5b52d03765dd3f2a235bebce6b4515e
This commit is contained in:
Родитель
638e666e32
Коммит
5a8b4a90e8
|
@ -2,10 +2,6 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#handlersView > richlistitem {
|
||||
-moz-binding: url("chrome://browser/content/preferences/handlers.xml#handler");
|
||||
}
|
||||
|
||||
#containersView > richlistitem {
|
||||
-moz-binding: none;
|
||||
}
|
||||
|
|
|
@ -1,36 +0,0 @@
|
|||
<?xml version="1.0"?>
|
||||
|
||||
<!-- This Source Code Form is subject to the terms of the Mozilla Public
|
||||
- License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
|
||||
<!-- import-globals-from in-content/main.js -->
|
||||
|
||||
<bindings id="handlerBindings"
|
||||
xmlns="http://www.mozilla.org/xbl"
|
||||
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||
xmlns:xbl="http://www.mozilla.org/xbl">
|
||||
|
||||
<binding id="handler" extends="chrome://global/content/bindings/richlistbox.xml#richlistitem">
|
||||
<content>
|
||||
<xul:hbox flex="1" equalsize="always">
|
||||
<xul:hbox flex="1" align="center" xbl:inherits="tooltiptext=typeDescription">
|
||||
<xul:image src="moz-icon://goat?size=16" class="typeIcon"
|
||||
xbl:inherits="src=typeIcon" height="16" width="16"/>
|
||||
<xul:label flex="1" crop="end" xbl:inherits="value=typeDescription"/>
|
||||
</xul:hbox>
|
||||
<xul:hbox anonid="not-selected" flex="1" align="center" xbl:inherits="tooltiptext=actionDescription">
|
||||
<xul:image xbl:inherits="src=actionIcon" height="16" width="16" class="actionIcon"/>
|
||||
<xul:label flex="1" crop="end" xbl:inherits="value=actionDescription"/>
|
||||
</xul:hbox>
|
||||
<xul:hbox hidden="true" anonid="selected" flex="1">
|
||||
<xul:menulist class="actionsMenu" flex="1" crop="end" selectedIndex="1"
|
||||
xbl:inherits="tooltiptext=actionDescription"
|
||||
oncommand="gMainPane.onSelectAction(event.originalTarget)">
|
||||
<xul:menupopup/>
|
||||
</xul:menulist>
|
||||
</xul:hbox>
|
||||
</xul:hbox>
|
||||
</content>
|
||||
</binding>
|
||||
|
||||
</bindings>
|
|
@ -1548,7 +1548,7 @@ var gMainPane = {
|
|||
|
||||
for (let visibleType of visibleTypes) {
|
||||
let item = new HandlerListItem(visibleType);
|
||||
this._list.appendChild(item.node);
|
||||
item.connectAndAppendToList(this._list);
|
||||
|
||||
if (visibleType.type === lastSelectedType) {
|
||||
this._list.selectedItem = item.node;
|
||||
|
@ -1613,8 +1613,7 @@ var gMainPane = {
|
|||
rebuildActionsMenu() {
|
||||
var typeItem = this._list.selectedItem;
|
||||
var handlerInfo = this.selectedHandlerListItem.handlerInfoWrapper;
|
||||
var menu =
|
||||
document.getAnonymousElementByAttribute(typeItem, "class", "actionsMenu");
|
||||
var menu = typeItem.querySelector(".actionsMenu");
|
||||
var menuPopup = menu.menupopup;
|
||||
|
||||
// Clear out existing items.
|
||||
|
@ -2007,8 +2006,7 @@ var gMainPane = {
|
|||
// If the user picked a new app from the menu, select it.
|
||||
if (aHandlerApp) {
|
||||
let typeItem = this._list.selectedItem;
|
||||
let actionsMenu =
|
||||
document.getAnonymousElementByAttribute(typeItem, "class", "actionsMenu");
|
||||
let actionsMenu = typeItem.querySelector(".actionsMenu");
|
||||
let menuItems = actionsMenu.menupopup.childNodes;
|
||||
for (let i = 0; i < menuItems.length; i++) {
|
||||
let menuItem = menuItems[i];
|
||||
|
@ -2452,6 +2450,28 @@ function isFeedType(t) {
|
|||
return t == TYPE_MAYBE_FEED || t == TYPE_MAYBE_VIDEO_FEED || t == TYPE_MAYBE_AUDIO_FEED;
|
||||
}
|
||||
|
||||
// eslint-disable-next-line no-undef
|
||||
let gHandlerListItemFragment = MozXULElement.parseXULToFragment(`
|
||||
<richlistitem>
|
||||
<hbox flex="1" equalsize="always">
|
||||
<hbox class="typeContainer" flex="1" align="center">
|
||||
<image class="typeIcon" width="16" height="16"
|
||||
src="moz-icon://goat?size=16"/>
|
||||
<label class="typeDescription" flex="1" crop="end"/>
|
||||
</hbox>
|
||||
<hbox class="actionContainer" flex="1" align="center">
|
||||
<image class="actionIcon" width="16" height="16"/>
|
||||
<label class="actionDescription" flex="1" crop="end"/>
|
||||
</hbox>
|
||||
<hbox class="actionsMenuContainer" flex="1">
|
||||
<menulist class="actionsMenu" flex="1" crop="end" selectedIndex="1">
|
||||
<menupopup/>
|
||||
</menulist>
|
||||
</hbox>
|
||||
</hbox>
|
||||
</richlistitem>
|
||||
`);
|
||||
|
||||
/**
|
||||
* This is associated to <richlistitem> elements in the handlers view.
|
||||
*/
|
||||
|
@ -2462,39 +2482,54 @@ class HandlerListItem {
|
|||
|
||||
constructor(handlerInfoWrapper) {
|
||||
this.handlerInfoWrapper = handlerInfoWrapper;
|
||||
this.node = document.createElement("richlistitem");
|
||||
}
|
||||
|
||||
setOrRemoveAttributes(iterable) {
|
||||
for (let [selector, name, value] of iterable) {
|
||||
let node = selector ? this.node.querySelector(selector) : this.node;
|
||||
if (value) {
|
||||
node.setAttribute(name, value);
|
||||
} else {
|
||||
node.removeAttribute(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
connectAndAppendToList(list) {
|
||||
list.appendChild(document.importNode(gHandlerListItemFragment, true));
|
||||
this.node = list.lastChild;
|
||||
gNodeToObjectMap.set(this.node, this);
|
||||
|
||||
this.node.setAttribute("type", this.handlerInfoWrapper.type);
|
||||
this.node.setAttribute("typeDescription",
|
||||
this.handlerInfoWrapper.typeDescription);
|
||||
if (this.handlerInfoWrapper.smallIcon) {
|
||||
this.node.setAttribute("typeIcon", this.handlerInfoWrapper.smallIcon);
|
||||
} else {
|
||||
this.node.removeAttribute("typeIcon");
|
||||
}
|
||||
this.node.querySelector(".actionsMenu").addEventListener("command",
|
||||
event => gMainPane.onSelectAction(event.originalTarget));
|
||||
|
||||
let typeDescription = this.handlerInfoWrapper.typeDescription;
|
||||
this.setOrRemoveAttributes([
|
||||
[null, "type", this.handlerInfoWrapper.type],
|
||||
[".typeContainer", "tooltiptext", typeDescription],
|
||||
[".typeDescription", "value", typeDescription],
|
||||
[".typeIcon", "src", this.handlerInfoWrapper.smallIcon],
|
||||
]);
|
||||
this.refreshAction();
|
||||
this.showActionsMenu = false;
|
||||
}
|
||||
|
||||
refreshAction() {
|
||||
this.node.setAttribute("actionDescription",
|
||||
this.handlerInfoWrapper.actionDescription);
|
||||
if (this.handlerInfoWrapper.actionIconClass) {
|
||||
this.node.setAttribute(APP_ICON_ATTR_NAME,
|
||||
this.handlerInfoWrapper.actionIconClass);
|
||||
this.node.removeAttribute("actionIcon");
|
||||
} else {
|
||||
this.node.removeAttribute(APP_ICON_ATTR_NAME);
|
||||
this.node.setAttribute("actionIcon", this.handlerInfoWrapper.actionIcon);
|
||||
}
|
||||
let { actionIconClass, actionDescription } = this.handlerInfoWrapper;
|
||||
this.setOrRemoveAttributes([
|
||||
[null, APP_ICON_ATTR_NAME, actionIconClass],
|
||||
[".actionContainer", "tooltiptext", actionDescription],
|
||||
[".actionDescription", "value", actionDescription],
|
||||
[".actionIcon", "src", actionIconClass ? null :
|
||||
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);
|
||||
this.setOrRemoveAttributes([
|
||||
[".actionContainer", "hidden", value],
|
||||
[".actionsMenuContainer", "hidden", !value],
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -16,7 +16,6 @@ browser.jar:
|
|||
content/browser/preferences/connection.js
|
||||
content/browser/preferences/fonts.xul
|
||||
content/browser/preferences/fonts.js
|
||||
content/browser/preferences/handlers.xml
|
||||
content/browser/preferences/handlers.css
|
||||
content/browser/preferences/languages.xul
|
||||
content/browser/preferences/languages.js
|
||||
|
|
Загрузка…
Ссылка в новой задаче