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:
Gijs Kruitbosch 2017-04-22 10:41:03 +01:00
Родитель 33b270d26a
Коммит 9941e89ec3
6 изменённых файлов: 75 добавлений и 34 удалений

Просмотреть файл

@ -234,6 +234,13 @@ var CustomizableUIInternal = {
}, true);
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 = [
"urlbar-container",
"search-container",
@ -897,9 +904,8 @@ var CustomizableUIInternal = {
return [null, null];
},
registerMenuPanel(aPanelContents) {
if (gBuildAreas.has(CustomizableUI.AREA_PANEL) &&
gBuildAreas.get(CustomizableUI.AREA_PANEL).has(aPanelContents)) {
registerMenuPanel(aPanelContents, aArea) {
if (gBuildAreas.has(aArea) && gBuildAreas.get(aArea).has(aPanelContents)) {
return;
}
@ -910,9 +916,9 @@ var CustomizableUIInternal = {
this.addPanelCloseListeners(this._getPanelForNode(aPanelContents));
let placements = gPlacements.get(CustomizableUI.AREA_PANEL);
this.buildArea(CustomizableUI.AREA_PANEL, placements, aPanelContents);
this.notifyListeners("onAreaNodeRegistered", CustomizableUI.AREA_PANEL, aPanelContents);
let placements = gPlacements.get(aArea);
this.buildArea(aArea, placements, aPanelContents);
this.notifyListeners("onAreaNodeRegistered", aArea, aPanelContents);
for (let child of aPanelContents.children) {
if (child.localName != "toolbarbutton") {
@ -925,7 +931,7 @@ var CustomizableUIInternal = {
child.setAttribute("wrap", "true");
}
this.registerBuildArea(CustomizableUI.AREA_PANEL, aPanelContents);
this.registerBuildArea(aArea, aPanelContents);
},
onWidgetAdded(aWidgetId, aArea, aPosition) {
@ -1489,8 +1495,9 @@ var CustomizableUIInternal = {
} else if (aWidget.type == "view") {
let ownerWindow = aNode.ownerGlobal;
let area = this.getPlacementOfWidget(aNode.id).area;
let areaType = CustomizableUI.getAreaType(area);
let anchor = aNode;
if (area != CustomizableUI.AREA_PANEL) {
if (areaType != CustomizableUI.TYPE_MENU_PANEL) {
let wrapper = this.wrapWidget(aWidget.id).forWindow(ownerWindow);
if (wrapper && !wrapper.overflowed && wrapper.anchor) {
@ -2151,7 +2158,8 @@ var CustomizableUIInternal = {
let addToDefaultPlacements = false;
let area = gAreas.get(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;
}
@ -2824,6 +2832,11 @@ this.CustomizableUI = {
* @deprecated
*/
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.
*/
@ -3045,10 +3058,11 @@ this.CustomizableUI = {
/**
* Register the menu panel node. This method should not be called by anyone
* 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) {
CustomizableUIInternal.registerMenuPanel(aPanel);
registerMenuPanel(aPanelContents, aArea) {
CustomizableUIInternal.registerMenuPanel(aPanelContents, aArea);
},
/**
* Unregister a customizable area. The inverse of registerArea.
@ -4150,8 +4164,11 @@ OverflowableToolbar.prototype = {
this._panel.removeEventListener("dragover", this);
this._panel.removeEventListener("dragend", this);
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);
}
},
onOverflow(aEvent) {

Просмотреть файл

@ -1006,7 +1006,6 @@ const CustomizableWidgets = [
}
},
onCreated(aNode) {
const kPanelId = "PanelUI-popup";
let document = aNode.ownerDocument;
let updateButton = () => {
@ -1016,27 +1015,32 @@ const CustomizableWidgets = [
aNode.removeAttribute("disabled");
};
if (this.currentArea == CustomizableUI.AREA_PANEL) {
let panel = document.getElementById(kPanelId);
panel.addEventListener("popupshowing", updateButton);
let getPanel = () => {
let {PanelUI} = document.ownerGlobal;
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 = {
onWidgetAdded: (aWidgetId, aArea) => {
if (aWidgetId != this.id)
return;
if (aArea == CustomizableUI.AREA_PANEL) {
let panel = document.getElementById(kPanelId);
panel.addEventListener("popupshowing", updateButton);
if (CustomizableUI.getAreaType(aArea) == CustomizableUI.TYPE_MENU_PANEL) {
getPanel().addEventListener("popupshowing", updateButton);
}
},
onWidgetRemoved: (aWidgetId, aPrevArea) => {
if (aWidgetId != this.id)
return;
aNode.removeAttribute("disabled");
if (aPrevArea == CustomizableUI.AREA_PANEL) {
let panel = document.getElementById(kPanelId);
panel.removeEventListener("popupshowing", updateButton);
if (CustomizableUI.getAreaType(aPrevArea) == CustomizableUI.TYPE_MENU_PANEL) {
getPanel().removeEventListener("popupshowing", updateButton);
}
},
onWidgetInstanceRemoved: (aWidgetId, aDoc) => {
@ -1044,8 +1048,7 @@ const CustomizableWidgets = [
return;
CustomizableUI.removeListener(listener);
let panel = aDoc.getElementById(kPanelId);
panel.removeEventListener("popupshowing", updateButton);
getPanel().removeEventListener("popupshowing", updateButton);
}
};
CustomizableUI.addListener(listener);

Просмотреть файл

@ -379,7 +379,7 @@ AreaPositionManager.prototype = {
var DragPositionManager = {
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.push(aWindow.document.getElementById(kPaletteId));
for (let areaNode of areas) {
@ -393,7 +393,7 @@ var DragPositionManager = {
},
add(aWindow, aArea, aContainer) {
if (CustomizableUI.getAreaType(aArea) != "toolbar") {
if (aArea != CustomizableUI.AREA_PANEL) {
return;
}
@ -401,7 +401,7 @@ var DragPositionManager = {
},
remove(aWindow, aArea, aContainer) {
if (CustomizableUI.getAreaType(aArea) != "toolbar") {
if (aArea != CustomizableUI.AREA_PANEL) {
return;
}

Просмотреть файл

@ -383,6 +383,8 @@
<panelview id="widget-overflow-mainView"
context="toolbar-context-menu">
<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"
overflowfortoolbar="nav-bar"/>
</vbox>

Просмотреть файл

@ -37,13 +37,18 @@ const PanelUI = {
panel: gPhotonStructure ? "appMenu-popup" : "PanelUI-popup",
notificationPanel: "PanelUI-notification-popup",
scroller: "PanelUI-contents-scroller",
footer: "PanelUI-footer"
footer: "PanelUI-footer",
overflowFixedList: gPhotonStructure ? "widget-overflow-fixed-list" : "",
};
},
_initialized: false,
init() {
for (let [k, v] of Object.entries(this.kElements)) {
if (!v) {
continue;
}
// Need to do fresh let-bindings per iteration
let getKey = k;
let id = v;
@ -70,6 +75,12 @@ const PanelUI = {
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;
},
@ -385,11 +396,11 @@ const PanelUI = {
}
if (aCustomizing) {
CustomizableUI.registerMenuPanel(this.contents);
CustomizableUI.registerMenuPanel(this.contents, CustomizableUI.AREA_PANEL);
} else {
this.beginBatchUpdate();
try {
CustomizableUI.registerMenuPanel(this.contents);
CustomizableUI.registerMenuPanel(this.contents, CustomizableUI.AREA_PANEL);
} finally {
this.endBatchUpdate();
}

Просмотреть файл

@ -1203,6 +1203,14 @@ menuitem.panel-subview-footer@menuStateActive@,
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 toolbarseparator,
.cui-widget-panelview menuseparator {
@ -1428,7 +1436,7 @@ toolbarpaletteitem[haswideitem][place="panel"] + toolbarpaletteitem[haswideitem]
margin-bottom: 10px;
}
#widget-overflow-list {
.widget-overflow-list {
width: @menuPanelWidth@;
padding-left: 10px;
padding-right: 10px;
@ -1455,7 +1463,7 @@ toolbaritem[overflowedItem=true],
padding-inline-start: .5em;
}
#widget-overflow-list > .toolbaritem-combined-buttons {
.widget-overflow-list > .toolbaritem-combined-buttons {
min-height: 28px;
}