forked from mirrors/gecko-dev
Bug 1792748 - Persist sidebar style attribute rather than width attribute. r=Gijs
Differential Revision: https://phabricator.services.mozilla.com/D158291
This commit is contained in:
parent
3b13923820
commit
ddbec758d4
6 changed files with 68 additions and 7 deletions
|
|
@ -3,7 +3,7 @@
|
||||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
|
||||||
<hbox flex="1" id="browser">
|
<hbox flex="1" id="browser">
|
||||||
<vbox id="sidebar-box" hidden="true" style="min-width: 14em; width: 18em; max-width: 36em" class="chromeclass-extrachrome">
|
<vbox id="sidebar-box" hidden="true" class="chromeclass-extrachrome">
|
||||||
<box id="sidebar-header" align="center">
|
<box id="sidebar-header" align="center">
|
||||||
<toolbarbutton id="sidebar-switcher-target" class="tabbable">
|
<toolbarbutton id="sidebar-switcher-target" class="tabbable">
|
||||||
<image id="sidebar-icon" consumeanchor="sidebar-switcher-target"/>
|
<image id="sidebar-icon" consumeanchor="sidebar-switcher-target"/>
|
||||||
|
|
|
||||||
|
|
@ -144,7 +144,7 @@ var SidebarUI = {
|
||||||
xulStore.removeValue(document.documentURI, "sidebar-box", "checked");
|
xulStore.removeValue(document.documentURI, "sidebar-box", "checked");
|
||||||
}
|
}
|
||||||
|
|
||||||
xulStore.persist(this._box, "width");
|
xulStore.persist(this._box, "style");
|
||||||
xulStore.persist(this._title, "value");
|
xulStore.persist(this._title, "value");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -345,10 +345,7 @@ var SidebarUI = {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
this._box.setAttribute(
|
this._box.style.width = sourceUI._box.getBoundingClientRect().width + "px";
|
||||||
"width",
|
|
||||||
sourceUI._box.getBoundingClientRect().width
|
|
||||||
);
|
|
||||||
this.showInitially(commandID);
|
this.showInitially(commandID);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
||||||
|
|
@ -1482,6 +1482,12 @@ printpreview-pagination:focus-within,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#sidebar-box {
|
||||||
|
min-width: 14em;
|
||||||
|
max-width: 36em;
|
||||||
|
width: 18em;
|
||||||
|
}
|
||||||
|
|
||||||
/* WebExtension Sidebars */
|
/* WebExtension Sidebars */
|
||||||
#sidebar-box[sidebarcommand$="-sidebar-action"] > #sidebar-header > #sidebar-switcher-target > #sidebar-icon {
|
#sidebar-box[sidebarcommand$="-sidebar-action"] > #sidebar-header > #sidebar-switcher-target > #sidebar-icon {
|
||||||
list-style-image: var(--webextension-menuitem-image, inherit);
|
list-style-image: var(--webextension-menuitem-image, inherit);
|
||||||
|
|
|
||||||
|
|
@ -4,4 +4,5 @@
|
||||||
[browser_sidebar_app_locale_changed.js]
|
[browser_sidebar_app_locale_changed.js]
|
||||||
[browser_sidebar_keys.js]
|
[browser_sidebar_keys.js]
|
||||||
[browser_sidebar_move.js]
|
[browser_sidebar_move.js]
|
||||||
|
[browser_sidebar_persist.js]
|
||||||
[browser_sidebar_switcher.js]
|
[browser_sidebar_switcher.js]
|
||||||
|
|
|
||||||
37
browser/base/content/test/sidebar/browser_sidebar_persist.js
Normal file
37
browser/base/content/test/sidebar/browser_sidebar_persist.js
Normal file
|
|
@ -0,0 +1,37 @@
|
||||||
|
/* Any copyright is dedicated to the Public Domain.
|
||||||
|
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||||
|
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
add_task(async function persist_sidebar_width() {
|
||||||
|
{
|
||||||
|
// Make the main test window not count as a browser window any longer,
|
||||||
|
// which allows the persitence code to kick in.
|
||||||
|
const docEl = document.documentElement;
|
||||||
|
const oldWinType = docEl.getAttribute("windowtype");
|
||||||
|
docEl.setAttribute("windowtype", "navigator:testrunner");
|
||||||
|
registerCleanupFunction(() => {
|
||||||
|
docEl.setAttribute("windowtype", oldWinType);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
info("Showing new window and setting sidebar box");
|
||||||
|
const win = await BrowserTestUtils.openNewBrowserWindow();
|
||||||
|
await win.SidebarUI.show("viewBookmarksSidebar");
|
||||||
|
win.document.getElementById("sidebar-box").style.width = "100px";
|
||||||
|
await BrowserTestUtils.closeWindow(win);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
info("Showing new window and seeing persisted width");
|
||||||
|
const win = await BrowserTestUtils.openNewBrowserWindow();
|
||||||
|
await win.SidebarUI.show("viewBookmarksSidebar");
|
||||||
|
is(
|
||||||
|
win.document.getElementById("sidebar-box").style.width,
|
||||||
|
"100px",
|
||||||
|
"Width style should be persisted"
|
||||||
|
);
|
||||||
|
await BrowserTestUtils.closeWindow(win);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
@ -3511,7 +3511,7 @@ BrowserGlue.prototype = {
|
||||||
_migrateUI: function BG__migrateUI() {
|
_migrateUI: function BG__migrateUI() {
|
||||||
// Use an increasing number to keep track of the current migration state.
|
// Use an increasing number to keep track of the current migration state.
|
||||||
// Completely unrelated to the current Firefox release number.
|
// Completely unrelated to the current Firefox release number.
|
||||||
const UI_VERSION = 128;
|
const UI_VERSION = 129;
|
||||||
const BROWSER_DOCURL = AppConstants.BROWSER_CHROME_URL;
|
const BROWSER_DOCURL = AppConstants.BROWSER_CHROME_URL;
|
||||||
|
|
||||||
const PROFILE_DIR = Services.dirsvc.get("ProfD", Ci.nsIFile).path;
|
const PROFILE_DIR = Services.dirsvc.get("ProfD", Ci.nsIFile).path;
|
||||||
|
|
@ -4287,6 +4287,26 @@ BrowserGlue.prototype = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function migrateXULAttributeToStyle(id, attr) {
|
||||||
|
try {
|
||||||
|
let value = Services.xulStore.getValue(BROWSER_DOCURL, id, attr);
|
||||||
|
if (value) {
|
||||||
|
Services.xulStore.setValue(
|
||||||
|
BROWSER_DOCURL,
|
||||||
|
"style",
|
||||||
|
`width: ${value}px;`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} catch (ex) {
|
||||||
|
Cu.reportError(`Error migrating ${id}'s ${attr} value: ` + ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Bug 1792748, migrate sidebar persisted attribute from width to style.
|
||||||
|
if (currentUIVersion < 129) {
|
||||||
|
migrateXULAttributeToStyle("sidebar-box", "width");
|
||||||
|
}
|
||||||
|
|
||||||
// Update the migration version.
|
// Update the migration version.
|
||||||
Services.prefs.setIntPref("browser.migration.version", UI_VERSION);
|
Services.prefs.setIntPref("browser.migration.version", UI_VERSION);
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue