зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1354079 - add sticky / permanent part to overflow panel, r=mikedeboer
MozReview-Commit-ID: 7wv43JWLx8Q --HG-- extra : rebase_source : d8532f3b6d15baea124480cab2f55d4944417b27
This commit is contained in:
Родитель
33b270d26a
Коммит
9941e89ec3
|
@ -234,6 +234,13 @@ var CustomizableUIInternal = {
|
||||||
}, true);
|
}, true);
|
||||||
PanelWideWidgetTracker.init();
|
PanelWideWidgetTracker.init();
|
||||||
|
|
||||||
|
if (Services.prefs.getBoolPref("browser.photon.structure.enabled")) {
|
||||||
|
this.registerArea(CustomizableUI.AREA_FIXED_OVERFLOW_PANEL, {
|
||||||
|
type: CustomizableUI.TYPE_MENU_PANEL,
|
||||||
|
defaultPlacements: [],
|
||||||
|
}, true);
|
||||||
|
}
|
||||||
|
|
||||||
let navbarPlacements = [
|
let navbarPlacements = [
|
||||||
"urlbar-container",
|
"urlbar-container",
|
||||||
"search-container",
|
"search-container",
|
||||||
|
@ -897,9 +904,8 @@ var CustomizableUIInternal = {
|
||||||
return [null, null];
|
return [null, null];
|
||||||
},
|
},
|
||||||
|
|
||||||
registerMenuPanel(aPanelContents) {
|
registerMenuPanel(aPanelContents, aArea) {
|
||||||
if (gBuildAreas.has(CustomizableUI.AREA_PANEL) &&
|
if (gBuildAreas.has(aArea) && gBuildAreas.get(aArea).has(aPanelContents)) {
|
||||||
gBuildAreas.get(CustomizableUI.AREA_PANEL).has(aPanelContents)) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -910,9 +916,9 @@ var CustomizableUIInternal = {
|
||||||
|
|
||||||
this.addPanelCloseListeners(this._getPanelForNode(aPanelContents));
|
this.addPanelCloseListeners(this._getPanelForNode(aPanelContents));
|
||||||
|
|
||||||
let placements = gPlacements.get(CustomizableUI.AREA_PANEL);
|
let placements = gPlacements.get(aArea);
|
||||||
this.buildArea(CustomizableUI.AREA_PANEL, placements, aPanelContents);
|
this.buildArea(aArea, placements, aPanelContents);
|
||||||
this.notifyListeners("onAreaNodeRegistered", CustomizableUI.AREA_PANEL, aPanelContents);
|
this.notifyListeners("onAreaNodeRegistered", aArea, aPanelContents);
|
||||||
|
|
||||||
for (let child of aPanelContents.children) {
|
for (let child of aPanelContents.children) {
|
||||||
if (child.localName != "toolbarbutton") {
|
if (child.localName != "toolbarbutton") {
|
||||||
|
@ -925,7 +931,7 @@ var CustomizableUIInternal = {
|
||||||
child.setAttribute("wrap", "true");
|
child.setAttribute("wrap", "true");
|
||||||
}
|
}
|
||||||
|
|
||||||
this.registerBuildArea(CustomizableUI.AREA_PANEL, aPanelContents);
|
this.registerBuildArea(aArea, aPanelContents);
|
||||||
},
|
},
|
||||||
|
|
||||||
onWidgetAdded(aWidgetId, aArea, aPosition) {
|
onWidgetAdded(aWidgetId, aArea, aPosition) {
|
||||||
|
@ -1489,8 +1495,9 @@ var CustomizableUIInternal = {
|
||||||
} else if (aWidget.type == "view") {
|
} else if (aWidget.type == "view") {
|
||||||
let ownerWindow = aNode.ownerGlobal;
|
let ownerWindow = aNode.ownerGlobal;
|
||||||
let area = this.getPlacementOfWidget(aNode.id).area;
|
let area = this.getPlacementOfWidget(aNode.id).area;
|
||||||
|
let areaType = CustomizableUI.getAreaType(area);
|
||||||
let anchor = aNode;
|
let anchor = aNode;
|
||||||
if (area != CustomizableUI.AREA_PANEL) {
|
if (areaType != CustomizableUI.TYPE_MENU_PANEL) {
|
||||||
let wrapper = this.wrapWidget(aWidget.id).forWindow(ownerWindow);
|
let wrapper = this.wrapWidget(aWidget.id).forWindow(ownerWindow);
|
||||||
|
|
||||||
if (wrapper && !wrapper.overflowed && wrapper.anchor) {
|
if (wrapper && !wrapper.overflowed && wrapper.anchor) {
|
||||||
|
@ -2151,7 +2158,8 @@ var CustomizableUIInternal = {
|
||||||
let addToDefaultPlacements = false;
|
let addToDefaultPlacements = false;
|
||||||
let area = gAreas.get(widget.defaultArea);
|
let area = gAreas.get(widget.defaultArea);
|
||||||
if (!CustomizableUI.isBuiltinToolbar(widget.defaultArea) &&
|
if (!CustomizableUI.isBuiltinToolbar(widget.defaultArea) &&
|
||||||
widget.defaultArea != CustomizableUI.AREA_PANEL) {
|
widget.defaultArea != CustomizableUI.AREA_PANEL &&
|
||||||
|
widget.defaultArea != CustomizableUI.AREA_FIXED_OVERFLOW_PANEL) {
|
||||||
addToDefaultPlacements = true;
|
addToDefaultPlacements = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2824,6 +2832,11 @@ this.CustomizableUI = {
|
||||||
* @deprecated
|
* @deprecated
|
||||||
*/
|
*/
|
||||||
AREA_ADDONBAR: "addon-bar",
|
AREA_ADDONBAR: "addon-bar",
|
||||||
|
/**
|
||||||
|
* Constant reference to the ID of the non-dymanic (fixed) list in the overflow panel.
|
||||||
|
*/
|
||||||
|
AREA_FIXED_OVERFLOW_PANEL: "widget-overflow-fixed-list",
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constant indicating the area is a menu panel.
|
* Constant indicating the area is a menu panel.
|
||||||
*/
|
*/
|
||||||
|
@ -3045,10 +3058,11 @@ this.CustomizableUI = {
|
||||||
/**
|
/**
|
||||||
* Register the menu panel node. This method should not be called by anyone
|
* Register the menu panel node. This method should not be called by anyone
|
||||||
* apart from the built-in PanelUI.
|
* apart from the built-in PanelUI.
|
||||||
* @param aPanel the panel DOM node being registered.
|
* @param aPanelContents the panel contents DOM node being registered.
|
||||||
|
* @param aArea the area for which to register this node.
|
||||||
*/
|
*/
|
||||||
registerMenuPanel(aPanel) {
|
registerMenuPanel(aPanelContents, aArea) {
|
||||||
CustomizableUIInternal.registerMenuPanel(aPanel);
|
CustomizableUIInternal.registerMenuPanel(aPanelContents, aArea);
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* Unregister a customizable area. The inverse of registerArea.
|
* Unregister a customizable area. The inverse of registerArea.
|
||||||
|
@ -4150,8 +4164,11 @@ OverflowableToolbar.prototype = {
|
||||||
this._panel.removeEventListener("dragover", this);
|
this._panel.removeEventListener("dragover", this);
|
||||||
this._panel.removeEventListener("dragend", this);
|
this._panel.removeEventListener("dragend", this);
|
||||||
let doc = aEvent.target.ownerDocument;
|
let doc = aEvent.target.ownerDocument;
|
||||||
let contextMenu = doc.getElementById(this._panel.getAttribute("context"));
|
let contextMenuId = this._panel.getAttribute("context");
|
||||||
|
if (contextMenuId) {
|
||||||
|
let contextMenu = doc.getElementById(contextMenuId);
|
||||||
gELS.removeSystemEventListener(contextMenu, "command", this, true);
|
gELS.removeSystemEventListener(contextMenu, "command", this, true);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
onOverflow(aEvent) {
|
onOverflow(aEvent) {
|
||||||
|
|
|
@ -1006,7 +1006,6 @@ const CustomizableWidgets = [
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onCreated(aNode) {
|
onCreated(aNode) {
|
||||||
const kPanelId = "PanelUI-popup";
|
|
||||||
let document = aNode.ownerDocument;
|
let document = aNode.ownerDocument;
|
||||||
|
|
||||||
let updateButton = () => {
|
let updateButton = () => {
|
||||||
|
@ -1016,27 +1015,32 @@ const CustomizableWidgets = [
|
||||||
aNode.removeAttribute("disabled");
|
aNode.removeAttribute("disabled");
|
||||||
};
|
};
|
||||||
|
|
||||||
if (this.currentArea == CustomizableUI.AREA_PANEL) {
|
let getPanel = () => {
|
||||||
let panel = document.getElementById(kPanelId);
|
let {PanelUI} = document.ownerGlobal;
|
||||||
panel.addEventListener("popupshowing", updateButton);
|
if (PanelUI.overflowContents) {
|
||||||
|
return document.getElementById("widget-overflow");
|
||||||
|
}
|
||||||
|
return PanelUI.panel;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (CustomizableUI.getAreaType(this.currentArea) == CustomizableUI.TYPE_MENU_PANEL) {
|
||||||
|
getPanel().addEventListener("popupshowing", updateButton);
|
||||||
}
|
}
|
||||||
|
|
||||||
let listener = {
|
let listener = {
|
||||||
onWidgetAdded: (aWidgetId, aArea) => {
|
onWidgetAdded: (aWidgetId, aArea) => {
|
||||||
if (aWidgetId != this.id)
|
if (aWidgetId != this.id)
|
||||||
return;
|
return;
|
||||||
if (aArea == CustomizableUI.AREA_PANEL) {
|
if (CustomizableUI.getAreaType(aArea) == CustomizableUI.TYPE_MENU_PANEL) {
|
||||||
let panel = document.getElementById(kPanelId);
|
getPanel().addEventListener("popupshowing", updateButton);
|
||||||
panel.addEventListener("popupshowing", updateButton);
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onWidgetRemoved: (aWidgetId, aPrevArea) => {
|
onWidgetRemoved: (aWidgetId, aPrevArea) => {
|
||||||
if (aWidgetId != this.id)
|
if (aWidgetId != this.id)
|
||||||
return;
|
return;
|
||||||
aNode.removeAttribute("disabled");
|
aNode.removeAttribute("disabled");
|
||||||
if (aPrevArea == CustomizableUI.AREA_PANEL) {
|
if (CustomizableUI.getAreaType(aPrevArea) == CustomizableUI.TYPE_MENU_PANEL) {
|
||||||
let panel = document.getElementById(kPanelId);
|
getPanel().removeEventListener("popupshowing", updateButton);
|
||||||
panel.removeEventListener("popupshowing", updateButton);
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onWidgetInstanceRemoved: (aWidgetId, aDoc) => {
|
onWidgetInstanceRemoved: (aWidgetId, aDoc) => {
|
||||||
|
@ -1044,8 +1048,7 @@ const CustomizableWidgets = [
|
||||||
return;
|
return;
|
||||||
|
|
||||||
CustomizableUI.removeListener(listener);
|
CustomizableUI.removeListener(listener);
|
||||||
let panel = aDoc.getElementById(kPanelId);
|
getPanel().removeEventListener("popupshowing", updateButton);
|
||||||
panel.removeEventListener("popupshowing", updateButton);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
CustomizableUI.addListener(listener);
|
CustomizableUI.addListener(listener);
|
||||||
|
|
|
@ -379,7 +379,7 @@ AreaPositionManager.prototype = {
|
||||||
|
|
||||||
var DragPositionManager = {
|
var DragPositionManager = {
|
||||||
start(aWindow) {
|
start(aWindow) {
|
||||||
let areas = CustomizableUI.areas.filter((area) => CustomizableUI.getAreaType(area) != "toolbar");
|
let areas = [CustomizableUI.AREA_PANEL];
|
||||||
areas = areas.map((area) => CustomizableUI.getCustomizeTargetForArea(area, aWindow));
|
areas = areas.map((area) => CustomizableUI.getCustomizeTargetForArea(area, aWindow));
|
||||||
areas.push(aWindow.document.getElementById(kPaletteId));
|
areas.push(aWindow.document.getElementById(kPaletteId));
|
||||||
for (let areaNode of areas) {
|
for (let areaNode of areas) {
|
||||||
|
@ -393,7 +393,7 @@ var DragPositionManager = {
|
||||||
},
|
},
|
||||||
|
|
||||||
add(aWindow, aArea, aContainer) {
|
add(aWindow, aArea, aContainer) {
|
||||||
if (CustomizableUI.getAreaType(aArea) != "toolbar") {
|
if (aArea != CustomizableUI.AREA_PANEL) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -401,7 +401,7 @@ var DragPositionManager = {
|
||||||
},
|
},
|
||||||
|
|
||||||
remove(aWindow, aArea, aContainer) {
|
remove(aWindow, aArea, aContainer) {
|
||||||
if (CustomizableUI.getAreaType(aArea) != "toolbar") {
|
if (aArea != CustomizableUI.AREA_PANEL) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -383,6 +383,8 @@
|
||||||
<panelview id="widget-overflow-mainView"
|
<panelview id="widget-overflow-mainView"
|
||||||
context="toolbar-context-menu">
|
context="toolbar-context-menu">
|
||||||
<vbox id="widget-overflow-scroller">
|
<vbox id="widget-overflow-scroller">
|
||||||
|
<vbox id="widget-overflow-fixed-list" class="widget-overflow-list" hidden="true"/>
|
||||||
|
<toolbarseparator id="widget-overflow-fixed-separator" hidden="true"/>
|
||||||
<vbox id="widget-overflow-list" class="widget-overflow-list"
|
<vbox id="widget-overflow-list" class="widget-overflow-list"
|
||||||
overflowfortoolbar="nav-bar"/>
|
overflowfortoolbar="nav-bar"/>
|
||||||
</vbox>
|
</vbox>
|
||||||
|
|
|
@ -37,13 +37,18 @@ const PanelUI = {
|
||||||
panel: gPhotonStructure ? "appMenu-popup" : "PanelUI-popup",
|
panel: gPhotonStructure ? "appMenu-popup" : "PanelUI-popup",
|
||||||
notificationPanel: "PanelUI-notification-popup",
|
notificationPanel: "PanelUI-notification-popup",
|
||||||
scroller: "PanelUI-contents-scroller",
|
scroller: "PanelUI-contents-scroller",
|
||||||
footer: "PanelUI-footer"
|
footer: "PanelUI-footer",
|
||||||
|
|
||||||
|
overflowFixedList: gPhotonStructure ? "widget-overflow-fixed-list" : "",
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
_initialized: false,
|
_initialized: false,
|
||||||
init() {
|
init() {
|
||||||
for (let [k, v] of Object.entries(this.kElements)) {
|
for (let [k, v] of Object.entries(this.kElements)) {
|
||||||
|
if (!v) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
// Need to do fresh let-bindings per iteration
|
// Need to do fresh let-bindings per iteration
|
||||||
let getKey = k;
|
let getKey = k;
|
||||||
let id = v;
|
let id = v;
|
||||||
|
@ -70,6 +75,12 @@ const PanelUI = {
|
||||||
this.notificationPanel.addEventListener(event, this);
|
this.notificationPanel.addEventListener(event, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (gPhotonStructure) {
|
||||||
|
this.overflowFixedList.hidden = false;
|
||||||
|
this.overflowFixedList.nextSibling.hidden = false;
|
||||||
|
CustomizableUI.registerMenuPanel(this.overflowFixedList, CustomizableUI.AREA_FIXED_OVERFLOW_PANEL);
|
||||||
|
}
|
||||||
|
|
||||||
this._initialized = true;
|
this._initialized = true;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -385,11 +396,11 @@ const PanelUI = {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (aCustomizing) {
|
if (aCustomizing) {
|
||||||
CustomizableUI.registerMenuPanel(this.contents);
|
CustomizableUI.registerMenuPanel(this.contents, CustomizableUI.AREA_PANEL);
|
||||||
} else {
|
} else {
|
||||||
this.beginBatchUpdate();
|
this.beginBatchUpdate();
|
||||||
try {
|
try {
|
||||||
CustomizableUI.registerMenuPanel(this.contents);
|
CustomizableUI.registerMenuPanel(this.contents, CustomizableUI.AREA_PANEL);
|
||||||
} finally {
|
} finally {
|
||||||
this.endBatchUpdate();
|
this.endBatchUpdate();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1203,6 +1203,14 @@ menuitem.panel-subview-footer@menuStateActive@,
|
||||||
padding-left: 6px;
|
padding-left: 6px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Yeah, the ids are ugly, but this should be reasonably performant, and
|
||||||
|
* using a tagname as the last item would be less so.
|
||||||
|
*/
|
||||||
|
#widget-overflow-fixed-list:empty + #widget-overflow-fixed-separator {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
#widget-overflow-scroller > toolbarseparator,
|
||||||
.PanelUI-subView menuseparator,
|
.PanelUI-subView menuseparator,
|
||||||
.PanelUI-subView toolbarseparator,
|
.PanelUI-subView toolbarseparator,
|
||||||
.cui-widget-panelview menuseparator {
|
.cui-widget-panelview menuseparator {
|
||||||
|
@ -1428,7 +1436,7 @@ toolbarpaletteitem[haswideitem][place="panel"] + toolbarpaletteitem[haswideitem]
|
||||||
margin-bottom: 10px;
|
margin-bottom: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
#widget-overflow-list {
|
.widget-overflow-list {
|
||||||
width: @menuPanelWidth@;
|
width: @menuPanelWidth@;
|
||||||
padding-left: 10px;
|
padding-left: 10px;
|
||||||
padding-right: 10px;
|
padding-right: 10px;
|
||||||
|
@ -1455,7 +1463,7 @@ toolbaritem[overflowedItem=true],
|
||||||
padding-inline-start: .5em;
|
padding-inline-start: .5em;
|
||||||
}
|
}
|
||||||
|
|
||||||
#widget-overflow-list > .toolbaritem-combined-buttons {
|
.widget-overflow-list > .toolbaritem-combined-buttons {
|
||||||
min-height: 28px;
|
min-height: 28px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче