Commit f232614a authored by henry's avatar henry Committed by Pier Angelo Vendrame
Browse files

fixup! BB 43902: Modify the new sidebar for Base Browser.

TB 44108: Use the old history panel for the new sidebar.

We do this to avoid the "firefoxview" component.

We modify the old sidebar to include a heading element and a close
button.
parent 4aee1bd9
Loading
Loading
Loading
Loading
+27 −0
Original line number Diff line number Diff line
@@ -91,6 +91,33 @@ window.addEventListener("load", () => {
    bhTooltip.removeAttribute("position")
  );

  // Add a button to close the history sidebar. This should only be visible when
  // this document is used for the revamped sidebar. See tor-browser#44108.
  document
    .getElementById("sidebar-panel-close")
    .addEventListener("click", () => {
      window.browsingContext.embedderWindowGlobal.browsingContext.window.SidebarController.toggle(
        "viewHistorySidebar"
      );
    });
  // Hack to convert the sidebar-menu-history Fluent string's label attribute
  // into text content.
  const headingEl = document.getElementById("sidebar-panel-header-history");
  const updateHeadingText = () => {
    const label = headingEl.getAttribute("label");
    if (!label) {
      return;
    }
    headingEl.textContent = label;
    headingEl.removeAttribute("label");
  };
  const headingElObserver = new MutationObserver(updateHeadingText);
  headingElObserver.observe(headingEl, {
    attributes: true,
    attributeFilter: ["label"],
  });
  updateHeadingText();

  searchHistory("");
});

+23 −0
Original line number Diff line number Diff line
@@ -42,6 +42,9 @@

    <html:link rel="localization" href="toolkit/global/textActions.ftl"/>
    <html:link rel="localization" href="browser/places.ftl"/>
    <!-- Need sidebar-menu-history and sidebar-close-button.
       - tor-browser#44108 -->
    <html:link rel="localization" href="browser/sidebarMenu.ftl"/>
  </linkset>

#include placesCommands.inc.xhtml
@@ -55,6 +58,26 @@

#include placesContextMenu.inc.xhtml
#include bookmarksHistoryTooltip.inc.xhtml
  <!-- For ESR 140, we want to use this old history sidebar for the revamped
     - sidebar as well because it does not require the "firefoxview" component.
     - So we need an internal heading element for this page to be used with the
     - new sidebar only. We copy this from bookmarksSidebar.xhtml.
     - See tor-browser#44108. -->
  <box id="sidebar-panel-header" align="center">
    <!-- (Mis)use the sidebar-menu-history string, which will set a "label"
       - attribute, which we will convert to text content in javascript. -->
    <html:h4
      id="sidebar-panel-header-history"
      data-l10n-id="sidebar-menu-history"
      data-l10n-attrs="label"
    ></html:h4>
    <html:moz-button
        id="sidebar-panel-close"
        type="icon ghost"
        iconsrc="chrome://global/skin/icons/close.svg"
        data-l10n-id="sidebar-close-button">
    </html:moz-button>
  </box>

  <hbox id="sidebar-search-container">
    <html:moz-input-search id="search-box"
+4 −3
Original line number Diff line number Diff line
@@ -114,9 +114,10 @@ var SidebarController = {
        this.makeSidebar({
          name: "history",
          elementId: "sidebar-switcher-history",
          url: this.sidebarRevampEnabled
            ? "chrome://browser/content/sidebar/sidebar-history.html"
            : "chrome://browser/content/places/historySidebar.xhtml",
          // sidebar-history.html requires the "firefoxview" component and
          // requires more work. Stick to historySidebar.xhtml for ESR 140.
          // See tor-browser#44108.
          url: "chrome://browser/content/places/historySidebar.xhtml",
          menuId: "menu_historySidebar",
          triggerButtonId: "appMenuViewHistorySidebar",
          keyId: "key_gotoHistory",