From 4f4f42a563b26c5c507c04fe229df96c38fcc9e4 Mon Sep 17 00:00:00 2001 From: Dorel Luca Date: Mon, 26 Oct 2020 20:08:38 +0200 Subject: [PATCH] Backed out 2 changesets (bug 1664053) for Browser-chrome failures. CLOSED TREE Backed out changeset 7ead316c420d (bug 1664053) Backed out changeset 7ae93e1c8b86 (bug 1664053) --- browser/base/content/browser-places.js | 64 +------ browser/base/content/browser.xhtml | 13 -- .../places/content/browserPlacesViews.js | 13 -- .../places/tests/browser/browser.ini | 1 - .../browser_toolbar_other_bookmarks.js | 178 ------------------ browser/themes/linux/places/editBookmark.css | 5 + browser/themes/osx/browser.css | 6 + browser/themes/osx/places/editBookmark.css | 5 + browser/themes/shared/jar.inc.mn | 1 + browser/themes/shared/places/tree-icons.css | 4 + .../themes/shared/places/unfiledBookmarks.svg | 9 + browser/themes/shared/toolbarbuttons.inc.css | 3 +- browser/themes/windows/browser.css | 7 + .../themes/windows/places/editBookmark.css | 5 + 14 files changed, 44 insertions(+), 270 deletions(-) delete mode 100644 browser/components/places/tests/browser/browser_toolbar_other_bookmarks.js create mode 100644 browser/themes/shared/places/unfiledBookmarks.svg diff --git a/browser/base/content/browser-places.js b/browser/base/content/browser-places.js index 42be8bc8e420c2..a2e878c9a26daf 100644 --- a/browser/base/content/browser-places.js +++ b/browser/base/content/browser-places.js @@ -2150,10 +2150,6 @@ var BookmarkingUI = { } break; } - - if (ev.parentGuid === PlacesUtils.bookmarks.unfiledGuid) { - this.updateUnfiledBookmarksVisibility(); - } } }, @@ -2191,21 +2187,7 @@ var BookmarkingUI = { onEndUpdateBatch() {}, onBeforeItemRemoved() {}, onItemVisited() {}, - onItemMoved( - aItemId, - aProperty, - aIsAnnotationProperty, - aNewValue, - aLastModified, - aItemType, - aParentId, - aGuid, - aParentGuid - ) { - if (aParentGuid === PlacesUtils.bookmarks.unfiledGuid) { - this.updateUnfiledBookmarksVisibility(); - } - }, + onItemMoved() {}, onWidgetUnderflow(aNode, aContainer) { let win = aNode.ownerGlobal; @@ -2218,49 +2200,5 @@ var BookmarkingUI = { this._uninitView(); }, - async updateUnfiledBookmarksVisibility() { - // Only show the "Other Bookmarks" folder in the toolbar if pref is enabled. - let featureEnabled = Services.prefs.getBoolPref( - "browser.toolbars.bookmarks.2h2020", - false - ); - - if (!featureEnabled) { - return; - } - - let unfiledGuid = PlacesUtils.bookmarks.unfiledGuid; - let unfiledBookmarksFolderId = await PlacesUtils.promiseItemId(unfiledGuid); - - let numberOfBookmarks = await PlacesUtils.withConnectionWrapper( - "PlacesUtils: maybeShowOtherBookmarksFolder", - async db => { - let rows = await db.execute( - `SELECT COUNT(*) as n FROM moz_bookmarks b - WHERE b.parent = :parentId`, - { parentId: unfiledBookmarksFolderId } - ); - return rows[0].getResultByName("n"); - } - ).catch(e => { - // We want to report errors, but we still want to show the folder then: - Cu.reportError(e); - return 0; - }); - - let otherBookmarks = document.getElementById("OtherBookmarks"); - - if (numberOfBookmarks > 0) { - let otherBookmarksPopup = document.getElementById("OtherBookmarksPopup"); - let result = PlacesUtils.getFolderContents(unfiledGuid); - let node = result.root; - otherBookmarksPopup._placesNode = PlacesUtils.asContainer(node); - - otherBookmarks.setAttribute("collapsed", "false"); - } else { - otherBookmarks.setAttribute("collapsed", "true"); - } - }, - QueryInterface: ChromeUtils.generateQI(["nsINavBookmarkObserver"]), }; diff --git a/browser/base/content/browser.xhtml b/browser/base/content/browser.xhtml index 6c9f3617894cd2..80a5e38f1009fb 100644 --- a/browser/base/content/browser.xhtml +++ b/browser/base/content/browser.xhtml @@ -2086,19 +2086,6 @@ tooltip="bhTooltip" popupsinherittooltip="true" context="placesContext"/> - - - diff --git a/browser/components/places/content/browserPlacesViews.js b/browser/components/places/content/browserPlacesViews.js index 6e5ad210fdc780..b984ca15fc949c 100644 --- a/browser/components/places/content/browserPlacesViews.js +++ b/browser/components/places/content/browserPlacesViews.js @@ -863,8 +863,6 @@ function PlacesToolbar(aPlace) { ["_dropIndicator", "PlacesToolbarDropIndicator"], ["_chevron", "PlacesChevron"], ["_chevronPopup", "PlacesChevronPopup"], - ["_otherBookmarks", "OtherBookmarks"], - ["_otherBookmarksPopup", "OtherBookmarksPopup"], ].forEach(function(elementGlobal) { let [name, id] = elementGlobal; thisView.__defineGetter__(name, function() { @@ -1032,8 +1030,6 @@ PlacesToolbar.prototype = { // Otherwise, it will be initialized when the toolbar overflows. this._chevronPopup.place = this.place; } - - BookmarkingUI.updateUnfiledBookmarksVisibility(); }, _insertNewItem: function PT__insertNewItem( @@ -1123,15 +1119,6 @@ PlacesToolbar.prototype = { this._updateChevronPopupNodesVisibility(); }, - _onOtherBookmarksPopupShowing: function PT__onOtherBookmarksPopupShowing( - aEvent - ) { - if (aEvent.target != this._otherBookmarksPopup) { - return; - } - this._rebuildPopup(this._otherBookmarksPopup); - }, - handleEvent: function PT_handleEvent(aEvent) { switch (aEvent.type) { case "unload": diff --git a/browser/components/places/tests/browser/browser.ini b/browser/components/places/tests/browser/browser.ini index 531ae77a9c9e9c..ca3879a192c62f 100644 --- a/browser/components/places/tests/browser/browser.ini +++ b/browser/components/places/tests/browser/browser.ini @@ -96,7 +96,6 @@ skip-if = (os == "mac" && debug) # Bug 1467049 [browser_toolbar_drop_text.js] [browser_toolbar_library_downloads.js] [browser_toolbar_library_open_recent.js] -[browser_toolbar_other_bookmarks.js] [browser_toolbar_overflow.js] skip-if = os == "linux" && bits == 32 && debug # bug 1463443 [browser_toolbarbutton_menu_context.js] diff --git a/browser/components/places/tests/browser/browser_toolbar_other_bookmarks.js b/browser/components/places/tests/browser/browser_toolbar_other_bookmarks.js deleted file mode 100644 index 58a4437919bb1b..00000000000000 --- a/browser/components/places/tests/browser/browser_toolbar_other_bookmarks.js +++ /dev/null @@ -1,178 +0,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/. */ -/* eslint-disable mozilla/no-arbitrary-setTimeout */ - -"use strict"; - -const BOOKMARKS_H2_2020_PREF = "browser.toolbars.bookmarks.2h2020"; -const bookmarksInfo = [ - { - title: "firefox", - url: "http://example.com", - }, - { - title: "rules", - url: "http://example.com/2", - }, - { - title: "yo", - url: "http://example.com/2", - }, -]; - -/** - * Test showing the "Other Bookmarks" folder in the bookmarks toolbar. - */ - -// Setup. -add_task(async function setup() { - let toolbar = document.getElementById("PersonalToolbar"); - let wasCollapsed = toolbar.collapsed; - - // Uncollapse the personal toolbar if needed. - if (wasCollapsed) { - await promiseSetToolbarVisibility(toolbar, true); - } - - // Cleanup. - registerCleanupFunction(async () => { - // Collapse the personal toolbar if needed. - if (wasCollapsed) { - await promiseSetToolbarVisibility(toolbar, false); - } - await PlacesUtils.bookmarks.eraseEverything(); - }); -}); - -// Test the "Other Bookmarks" folder is shown in the toolbar when -// bookmarks are stored under that folder. -add_task(async function testShowingOtherBookmarksInToolbar() { - await SpecialPowers.pushPrefEnv({ - set: [[BOOKMARKS_H2_2020_PREF, true]], - }); - - info("Check visibility of an empty Other Bookmarks folder."); - testIsOtherBookmarksCollapsed("true"); - - info("Ensure folder appears in toolbar when a new bookmark is added."); - let bookmarks = await PlacesUtils.bookmarks.insertTree({ - guid: PlacesUtils.bookmarks.unfiledGuid, - children: bookmarksInfo, - }); - testIsOtherBookmarksCollapsed("false"); - - info("Ensure folder disappears from toolbar when no bookmarks are present."); - await PlacesUtils.bookmarks.remove(bookmarks); - - info("Add bookmarks to the Bookmarks Toolbar folder."); - testIsOtherBookmarksCollapsed("true"); -}); - -// Test that folder visibility is correct when moving bookmarks to an empty -// "Other Bookmarks" folder and vice versa. -add_task(async function testOtherBookmarksVisibilityWhenMovingBookmarks() { - await SpecialPowers.pushPrefEnv({ - set: [[BOOKMARKS_H2_2020_PREF, true]], - }); - - info("Add bookmarks to Bookmarks Toolbar."); - let bookmarks = await PlacesUtils.bookmarks.insertTree({ - guid: PlacesUtils.bookmarks.toolbarGuid, - children: bookmarksInfo, - }); - testIsOtherBookmarksCollapsed("true"); - - info("Move toolbar bookmarks to Other Bookmarks folder."); - await PlacesUtils.bookmarks.moveToFolder( - bookmarks.map(b => b.guid), - PlacesUtils.bookmarks.unfiledGuid, - PlacesUtils.bookmarks.DEFAULT_INDEX - ); - testIsOtherBookmarksCollapsed("false"); - - info("Move bookmarks from Other Bookmarks back to the toolbar."); - await PlacesUtils.bookmarks.moveToFolder( - bookmarks.map(b => b.guid), - PlacesUtils.bookmarks.toolbarGuid, - PlacesUtils.bookmarks.DEFAULT_INDEX - ); - testIsOtherBookmarksCollapsed("true"); -}); - -// Test OtherBookmarksPopup in toolbar. -add_task(async function testOtherBookmarksMenuPopup() { - await SpecialPowers.pushPrefEnv({ - set: [[BOOKMARKS_H2_2020_PREF, true]], - }); - - info("Add bookmarks to Other Bookmarks folder."); - let bookmarks = await PlacesUtils.bookmarks.insertTree({ - guid: PlacesUtils.bookmarks.unfiledGuid, - children: bookmarksInfo, - }); - - let otherBookmarks = document.getElementById("OtherBookmarks"); - await BrowserTestUtils.waitForAttribute("collapsed", otherBookmarks, "false"); - - info("Check the popup menu has correct number of children."); - await openMenuPopup(); - testNumberOfMenuPopupChildren(3); - await closeMenuPopup(); - - info("Remove a bookmark."); - await PlacesUtils.bookmarks.remove(bookmarks[0]); - - await openMenuPopup(); - testNumberOfMenuPopupChildren(2); - await closeMenuPopup(); -}); - -/** - * Tests whether or not the "Other Bookmarks" folder is visible. - */ -async function testIsOtherBookmarksCollapsed(expected) { - info("Test whether or not the 'Other Bookmarks' folder is visible."); - let otherBookmarks = document.getElementById("OtherBookmarks"); - - await BrowserTestUtils.waitForAttribute( - "collapsed", - otherBookmarks, - expected - ); - - ok(true, `Other Bookmarks folder collapsed state should be ${expected}.`); -} - -/** - * Tests number of menu items in Other Bookmarks popup. - */ -function testNumberOfMenuPopupChildren(expected) { - let popup = document.getElementById("OtherBookmarksPopup"); - let items = popup.querySelectorAll("menuitem"); - - is(items.length, expected, `Number of menu items should be ${expected}.`); -} - -/** - * Helper for opening the menupopup - */ -async function openMenuPopup() { - let popup = document.getElementById("OtherBookmarksPopup"); - let target = document.getElementById("OtherBookmarks"); - - EventUtils.synthesizeMouseAtCenter(target, {}); - - await BrowserTestUtils.waitForPopupEvent(popup, "shown"); -} - -/** - * Helper for closing the context menu. - */ -async function closeMenuPopup() { - let popup = document.getElementById("OtherBookmarksPopup"); - - info("Closing menu popup."); - popup.hidePopup(); - await BrowserTestUtils.waitForPopupEvent(popup, "hidden"); -} diff --git a/browser/themes/linux/places/editBookmark.css b/browser/themes/linux/places/editBookmark.css index 2f32c8e04e7c14..8dd4dddd0d6edb 100644 --- a/browser/themes/linux/places/editBookmark.css +++ b/browser/themes/linux/places/editBookmark.css @@ -74,3 +74,8 @@ #editBMPanel_bmRootItem { list-style-image: url("chrome://browser/skin/places/bookmarksMenu.svg") !important; } + +#editBMPanel_folderMenuList[selectedGuid="unfiled_____"], +#editBMPanel_unfiledRootItem { + list-style-image: url("chrome://browser/skin/places/unfiledBookmarks.svg") !important; +} diff --git a/browser/themes/osx/browser.css b/browser/themes/osx/browser.css index 66c1e23bd90750..f5e2d0d5aa4097 100644 --- a/browser/themes/osx/browser.css +++ b/browser/themes/osx/browser.css @@ -191,6 +191,12 @@ list-style-image: url("chrome://browser/skin/places/bookmarksToolbar.svg"); } +#menu_unsortedBookmarks, +#BMB_unsortedBookmarks, +#panelMenu_unsortedBookmarks { + list-style-image: url("chrome://browser/skin/places/unfiledBookmarks.svg"); +} + %include ../shared/toolbarbuttons.inc.css %include ../shared/toolbarbutton-icons.inc.css %include ../shared/menupanel.inc.css diff --git a/browser/themes/osx/places/editBookmark.css b/browser/themes/osx/places/editBookmark.css index 034bf93432317b..1786c7662a50a8 100644 --- a/browser/themes/osx/places/editBookmark.css +++ b/browser/themes/osx/places/editBookmark.css @@ -75,3 +75,8 @@ #editBMPanel_bmRootItem { list-style-image: url("chrome://browser/skin/places/bookmarksMenu.svg") !important; } + +#editBMPanel_folderMenuList[selectedGuid="unfiled_____"], +#editBMPanel_unfiledRootItem { + list-style-image: url("chrome://browser/skin/places/unfiledBookmarks.svg") !important; +} diff --git a/browser/themes/shared/jar.inc.mn b/browser/themes/shared/jar.inc.mn index 80c0e5432f3405..618cce30b1ea73 100644 --- a/browser/themes/shared/jar.inc.mn +++ b/browser/themes/shared/jar.inc.mn @@ -298,6 +298,7 @@ skin/classic/browser/places/folder-smart.svg (../shared/places/folder-smart.svg) skin/classic/browser/places/history.svg (../shared/places/history.svg) skin/classic/browser/places/tag.svg (../shared/places/tag.svg) + skin/classic/browser/places/unfiledBookmarks.svg (../shared/places/unfiledBookmarks.svg) skin/classic/browser/places/tree-icons.css (../shared/places/tree-icons.css) skin/classic/browser/privatebrowsing/aboutPrivateBrowsing.css (../shared/privatebrowsing/aboutPrivateBrowsing.css) skin/classic/browser/privatebrowsing/favicon.svg (../shared/privatebrowsing/favicon.svg) diff --git a/browser/themes/shared/places/tree-icons.css b/browser/themes/shared/places/tree-icons.css index c7a2ccb05a13d8..3f99d64c9ddd8e 100644 --- a/browser/themes/shared/places/tree-icons.css +++ b/browser/themes/shared/places/tree-icons.css @@ -35,6 +35,10 @@ treechildren::-moz-tree-image(container, queryFolder_menu________) { list-style-image: url("chrome://browser/skin/places/bookmarksMenu.svg"); } +treechildren::-moz-tree-image(container, queryFolder_unfiled_____) { + list-style-image: url("chrome://browser/skin/places/unfiledBookmarks.svg"); +} + /* query-nodes should be styled even if they're not expandable */ treechildren::-moz-tree-image(query) { list-style-image: url("chrome://browser/skin/places/folder-smart.svg"); diff --git a/browser/themes/shared/places/unfiledBookmarks.svg b/browser/themes/shared/places/unfiledBookmarks.svg new file mode 100644 index 00000000000000..65dc4a434c96de --- /dev/null +++ b/browser/themes/shared/places/unfiledBookmarks.svg @@ -0,0 +1,9 @@ + + + + + + + diff --git a/browser/themes/shared/toolbarbuttons.inc.css b/browser/themes/shared/toolbarbuttons.inc.css index c95fc8cfcea86d..5780ab3bf95a5d 100644 --- a/browser/themes/shared/toolbarbuttons.inc.css +++ b/browser/themes/shared/toolbarbuttons.inc.css @@ -343,8 +343,7 @@ toolbarbutton.bookmark-item:not(.subviewbutton) { #managed-bookmarks > .toolbarbutton-icon, #bookmarks-toolbar-placeholder > .toolbarbutton-icon, -#PlacesToolbarItems > .bookmark-item > .toolbarbutton-icon[label]:not([label=""]), -#OtherBookmarks.bookmark-item[container] > .toolbarbutton-icon { +#PlacesToolbarItems > .bookmark-item > .toolbarbutton-icon[label]:not([label=""]) { margin-inline-end: 4px; } diff --git a/browser/themes/windows/browser.css b/browser/themes/windows/browser.css index 7ae6b93d8712f6..1b8eaf69a1cd45 100644 --- a/browser/themes/windows/browser.css +++ b/browser/themes/windows/browser.css @@ -720,6 +720,13 @@ notification[value="translation"] { -moz-image-region: auto; } +#menu_unsortedBookmarks, +#BMB_unsortedBookmarks, +#panelMenu_unsortedBookmarks { + list-style-image: url("chrome://browser/skin/places/unfiledBookmarks.svg"); + -moz-image-region: auto; +} + /* Status panel */ #statuspanel-label { diff --git a/browser/themes/windows/places/editBookmark.css b/browser/themes/windows/places/editBookmark.css index 6411b7ad256e61..a89eb2838e3973 100644 --- a/browser/themes/windows/places/editBookmark.css +++ b/browser/themes/windows/places/editBookmark.css @@ -81,3 +81,8 @@ #editBMPanel_bmRootItem { list-style-image: url("chrome://browser/skin/places/bookmarksMenu.svg") !important; } + +#editBMPanel_folderMenuList[selectedGuid="unfiled_____"], +#editBMPanel_unfiledRootItem { + list-style-image: url("chrome://browser/skin/places/unfiledBookmarks.svg") !important; +}