mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-26 12:20:56 +00:00
Bug 1402721 - Add/edit bookmark panel should open anchored on the page action (ellipsis) button instead of on the identity block (left side of the address bar) when the bookmarks star action is not pinned/visible. r=Gijs
MozReview-Commit-ID: JMviXx5ov7F --HG-- extra : rebase_source : b205b0ae9d0e4eb7ed34b912f62e28fb2e2f9467
This commit is contained in:
parent
a24cf9bf2e
commit
2fa9f06a0b
@ -262,11 +262,20 @@ var BrowserPageActions = {
|
||||
return panelNode;
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns the node in the urlbar to which popups for the given action should
|
||||
* be anchored. If the action is null, a sensible anchor is returned.
|
||||
*
|
||||
* @param action (PageActions.Action, optional)
|
||||
* The action you want to anchor.
|
||||
* @return (DOM node, nonnull) The node to which the action should be
|
||||
* anchored.
|
||||
*/
|
||||
panelAnchorNodeForAction(action) {
|
||||
// Try each of the following nodes in order, using the first that's visible.
|
||||
let potentialAnchorNodeIDs = [
|
||||
action.anchorIDOverride || null,
|
||||
this._urlbarButtonNodeIDForActionID(action.id),
|
||||
action && action.anchorIDOverride,
|
||||
action && this._urlbarButtonNodeIDForActionID(action.id),
|
||||
this.mainButtonNode.id,
|
||||
"identity-icon",
|
||||
];
|
||||
@ -283,7 +292,8 @@ var BrowserPageActions = {
|
||||
}
|
||||
}
|
||||
}
|
||||
throw new Error(`PageActions: No anchor node for '${action.id}'`);
|
||||
let id = action ? action.id : "<no action>";
|
||||
throw new Error(`PageActions: No anchor node for ${id}`);
|
||||
},
|
||||
|
||||
get activatedActionPanelNode() {
|
||||
|
@ -302,21 +302,13 @@ var StarUI = {
|
||||
|
||||
this.beginBatch();
|
||||
|
||||
if (aAnchorElement) {
|
||||
// Set the open=true attribute if the anchor is a
|
||||
// descendent of a toolbarbutton.
|
||||
let parent = aAnchorElement.parentNode;
|
||||
while (parent) {
|
||||
if (parent.localName == "toolbarbutton") {
|
||||
break;
|
||||
}
|
||||
parent = parent.parentNode;
|
||||
}
|
||||
if (parent) {
|
||||
this._anchorToolbarButton = parent;
|
||||
parent.setAttribute("open", "true");
|
||||
}
|
||||
if (aAnchorElement && aAnchorElement.closest("#urlbar")) {
|
||||
this._anchorToolbarButton = aAnchorElement;
|
||||
aAnchorElement.setAttribute("open", "true");
|
||||
} else {
|
||||
this._anchorToolbarButton = null;
|
||||
}
|
||||
|
||||
let onPanelReady = fn => {
|
||||
let target = this.panel;
|
||||
if (target.parentNode) {
|
||||
@ -334,13 +326,6 @@ var StarUI = {
|
||||
hiddenRows: ["description", "location",
|
||||
"loadInSidebar", "keyword"],
|
||||
focusedElement: "preferred"});
|
||||
|
||||
if (aAnchorElement && aAnchorElement.id == BookmarkingUI.STAR_BOX_ID) {
|
||||
aAnchorElement.setAttribute("open", "true");
|
||||
this.panel.addEventListener("popuphiding", () => {
|
||||
aAnchorElement.removeAttribute("open");
|
||||
});
|
||||
}
|
||||
this.panel.openPopup(aAnchorElement, aPosition);
|
||||
},
|
||||
|
||||
@ -1371,18 +1356,8 @@ var BookmarkingUI = {
|
||||
},
|
||||
|
||||
get anchor() {
|
||||
// Try to anchor the panel to:
|
||||
// 1. The bookmarks star box (using the star itself is trickier because it
|
||||
// can be hidden while the star animation is visible)
|
||||
// 2. The identity icon
|
||||
if (this.starBox && isVisible(this.starBox)) {
|
||||
return this.starBox;
|
||||
}
|
||||
let identityIcon = document.getElementById("identity-icon");
|
||||
if (identityIcon && isVisible(identityIcon)) {
|
||||
return identityIcon;
|
||||
}
|
||||
return null;
|
||||
let action = PageActions.actionForID(PageActions.ACTION_ID_BOOKMARK);
|
||||
return BrowserPageActions.panelAnchorNodeForAction(action);
|
||||
},
|
||||
|
||||
get notifier() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user