Bug 1534799 - Convert &searchTextBox.clear.label; to fluent. r=emalysz,fluent-reviewers,flod,dao,morgan
authorNiklas Baumgardner <nbaumgardner@mozilla.com>
Fri, 10 Sep 2021 14:52:55 +0000
changeset 591658 d9383eed75f12fd9f02798fa8d95218be45bc3d7
parent 591657 024c2d9e7194a436d1c87b01acd173cd68cd89c3
child 591659 3d7e89c7c8100d8fc599c7077740114c89fa9f0f
push id149535
push useremalysz@mozilla.com
push dateFri, 10 Sep 2021 14:55:20 +0000
treeherderautoland@d9383eed75f1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersemalysz, fluent-reviewers, flod, dao, morgan
bugs1534799
milestone94.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1534799 - Convert &searchTextBox.clear.label; to fluent. r=emalysz,fluent-reviewers,flod,dao,morgan Differential Revision: https://phabricator.services.mozilla.com/D123640
accessible/tests/mochitest/tree/test_txtctrl.xhtml
browser/base/content/browser-doctype.inc
browser/base/content/webext-panels.xhtml
python/l10n/fluent_migrations/bug_1534799_searchTextBox-clear.py
toolkit/content/widgets/moz-input-box.js
toolkit/content/widgets/search-textbox.js
toolkit/locales/en-US/chrome/global/textcontext.dtd
toolkit/locales/en-US/toolkit/global/textActions.ftl
toolkit/locales/jar.mn
toolkit/themes/linux/global/search-textbox.css
toolkit/themes/osx/global/search-textbox.css
toolkit/themes/windows/global/search-textbox.css
--- a/accessible/tests/mochitest/tree/test_txtctrl.xhtml
+++ b/accessible/tests/mochitest/tree/test_txtctrl.xhtml
@@ -41,16 +41,17 @@
            { GROUPING: [
              { ENTRY: [ { TEXT_LEAF: [] } ] },
            ] };
       } else {
          accTree =
            { GROUPING: [
              { ENTRY: [ { TEXT_LEAF: [] } ] },
              { PUSHBUTTON: [] },
+             { PUSHBUTTON: [] },
            ] };
       }
 
       testAccessibleTree("txc_search_searchbutton", accTree);
 
       SimpleTest.finish();
     }
 
--- a/browser/base/content/browser-doctype.inc
+++ b/browser/base/content/browser-doctype.inc
@@ -1,8 +1,6 @@
 <!ENTITY % brandDTD SYSTEM "chrome://branding/locale/brand.dtd" >
 %brandDTD;
 <!ENTITY % browserDTD SYSTEM "chrome://browser/locale/browser.dtd" >
 %browserDTD;
-<!ENTITY % textcontextDTD SYSTEM "chrome://global/locale/textcontext.dtd" >
-%textcontextDTD;
 <!ENTITY % placesDTD SYSTEM "chrome://browser/locale/places/places.dtd">
 %placesDTD;
--- a/browser/base/content/webext-panels.xhtml
+++ b/browser/base/content/webext-panels.xhtml
@@ -7,18 +7,16 @@
 
 <?xml-stylesheet href="chrome://global/skin/global.css" type="text/css"?>
 <?xml-stylesheet href="chrome://browser/skin/" type="text/css"?>
 <?xml-stylesheet href="chrome://browser/content/usercontext/usercontext.css" type="text/css"?>
 
 <!DOCTYPE window [
 <!ENTITY % browserDTD SYSTEM "chrome://browser/locale/browser.dtd">
 %browserDTD;
-<!ENTITY % textcontextDTD SYSTEM "chrome://global/locale/textcontext.dtd">
-%textcontextDTD;
 ]>
 
 <window id="webextpanels-window"
         xmlns:html="http://www.w3.org/1999/xhtml"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
   <script src="chrome://global/content/contentAreaUtils.js"/>
   <script src="chrome://browser/content/browser.js"/>
   <script src="chrome://browser/content/browser-places.js"/>
new file mode 100644
--- /dev/null
+++ b/python/l10n/fluent_migrations/bug_1534799_searchTextBox-clear.py
@@ -0,0 +1,26 @@
+# coding=utf8
+
+# Any copyright is dedicated to the Public Domain.
+# http://creativecommons.org/publicdomain/zero/1.0/
+
+from __future__ import absolute_import
+import fluent.syntax.ast as FTL
+from fluent.migrate.helpers import transforms_from, VARIABLE_REFERENCE
+from fluent.migrate import REPLACE, COPY
+
+
+def migrate(ctx):
+    """Bug 1534799 - Convert searchTextBox.clear.label to Fluent, part {index}"""
+    target = "toolkit/toolkit/global/textActions.ftl"
+    reference = "toolkit/toolkit/global/textActions.ftl"
+    ctx.add_transforms(
+        target,
+        reference,
+        transforms_from(
+            """
+text-action-search-text-box-clear =
+    .title = { COPY(from_path, "searchTextBox.clear.label") }
+""",
+            from_path="toolkit/chrome/global/textcontext.dtd",
+        ),
+    )
--- a/toolkit/content/widgets/moz-input-box.js
+++ b/toolkit/content/widgets/moz-input-box.js
@@ -3,19 +3,16 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 "use strict";
 
 // This is loaded into chrome windows with the subscript loader. Wrap in
 // a block to prevent accidentally leaking globals onto `window`.
 {
   const cachedFragments = {
-    get entities() {
-      return ["chrome://global/locale/textcontext.dtd"];
-    },
     get editMenuItems() {
       return `
       <menuitem data-l10n-id="text-action-undo" cmd="cmd_undo"></menuitem>
       <menuitem data-l10n-id="text-action-redo" cmd="cmd_redo"></menuitem>
       <menuseparator></menuseparator>
       <menuitem data-l10n-id="text-action-cut" cmd="cmd_cut"></menuitem>
       <menuitem data-l10n-id="text-action-copy" cmd="cmd_copy"></menuitem>
       <menuitem data-l10n-id="text-action-paste" cmd="cmd_paste"></menuitem>
@@ -46,18 +43,17 @@
         <menuseparator anonid="spell-suggestions-separator"></menuseparator>
         ${this.editMenuItems}
         <menuseparator anonid="spell-check-separator"></menuseparator>
         <menuitem data-l10n-id="text-action-spell-check-toggle" type="checkbox" anonid="spell-check-enabled" oncommand="this.parentNode.parentNode.spellCheckerUI.toggleEnabled();"></menuitem>
         <menu data-l10n-id="text-action-spell-dictionaries" anonid="spell-dictionaries">
           <menupopup anonid="spell-dictionaries-menu" onpopupshowing="event.stopPropagation();" onpopuphiding="event.stopPropagation();"></menupopup>
         </menu>
       </menupopup>
-    `,
-        this.entities
+    `
       );
       return this.spellcheck;
     },
   };
 
   class MozInputBox extends MozXULElement {
     static get observedAttributes() {
       return ["spellcheck"];
--- a/toolkit/content/widgets/search-textbox.js
+++ b/toolkit/content/widgets/search-textbox.js
@@ -6,16 +6,18 @@
 
 // This is loaded into all XUL windows. Wrap in a block to prevent
 // leaking to window scope.
 {
   class MozSearchTextbox extends MozXULElement {
     constructor() {
       super();
 
+      MozXULElement.insertFTLIfNeeded("toolkit/global/textActions.ftl");
+
       this.inputField = document.createElement("input");
 
       const METHODS = [
         "focus",
         "blur",
         "select",
         "setUserInput",
         "setSelectionRange",
@@ -54,31 +56,23 @@
       return {
         input:
           "value,maxlength,disabled,size,readonly,placeholder,tabindex,accesskey,mozactionhint,spellcheck",
         ".textbox-search-icon": "label=searchbuttonlabel,disabled",
         ".textbox-search-clear": "disabled",
       };
     }
 
-    static get markup() {
-      // TODO: Bug 1534799 - Convert string to Fluent and use manual DOM construction
-      return `
-      <image class="textbox-search-clear" label="&searchTextBox.clear.label;"/>
-      `;
-    }
-
-    static get entities() {
-      return ["chrome://global/locale/textcontext.dtd"];
-    }
-
     connectedCallback() {
       if (this.delayConnectedCallback() || this.connected) {
         return;
       }
+
+      document.l10n.connectRoot(this.shadowRoot);
+
       this.connected = true;
       this.textContent = "";
 
       const stylesheet = document.createElement("link");
       stylesheet.rel = "stylesheet";
       stylesheet.href = "chrome://global/skin/search-textbox.css";
 
       const textboxSign = document.createXULElement("image");
@@ -91,19 +85,23 @@
       input.addEventListener("blur", this);
 
       const searchBtn = (this._searchButtonIcon = document.createXULElement(
         "image"
       ));
       searchBtn.className = "textbox-search-icon";
       searchBtn.addEventListener("click", e => this._iconClick(e));
 
-      let clearBtn = this.constructor.fragment;
-      clearBtn = this._searchClearIcon = clearBtn.querySelector(
-        ".textbox-search-clear"
+      const clearBtn = document.createElement("img");
+      clearBtn.className = "textbox-search-clear";
+      clearBtn.src = "resource://gre-resources/searchfield-cancel.svg";
+      clearBtn.setAttribute("role", "button");
+      document.l10n.setAttributes(
+        clearBtn,
+        "text-action-search-text-box-clear"
       );
       clearBtn.addEventListener("click", () => this._clearSearch());
 
       const deck = (this._searchIcons = document.createXULElement("deck"));
       deck.className = "textbox-search-icons";
       deck.append(searchBtn, clearBtn);
       this.shadowRoot.append(stylesheet, textboxSign, input, deck);
 
@@ -111,16 +109,20 @@
 
       // Ensure the button state is up to date:
       // eslint-disable-next-line no-self-assign
       this.searchButton = this.searchButton;
 
       this.initializeAttributeInheritance();
     }
 
+    disconnectedCallback() {
+      document.l10n.disconnectRoot(this.shadowRoot);
+    }
+
     set timeout(val) {
       this.setAttribute("timeout", val);
     }
 
     get timeout() {
       return parseInt(this.getAttribute("timeout")) || 500;
     }
 
deleted file mode 100644
--- a/toolkit/locales/en-US/chrome/global/textcontext.dtd
+++ /dev/null
@@ -1,5 +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/. -->
-
-<!ENTITY searchTextBox.clear.label "Clear">
--- a/toolkit/locales/en-US/toolkit/global/textActions.ftl
+++ b/toolkit/locales/en-US/toolkit/global/textActions.ftl
@@ -65,8 +65,11 @@ text-action-spell-check-toggle =
 
 text-action-spell-add-dictionaries =
     .label = Add Dictionaries…
     .accesskey = A
 
 text-action-spell-dictionaries =
     .label = Languages
     .accesskey = L
+
+text-action-search-text-box-clear =
+    .title = Clear
--- a/toolkit/locales/jar.mn
+++ b/toolkit/locales/jar.mn
@@ -39,17 +39,16 @@
   locale/@AB_CD@/global/notification.dtd                (%chrome/global/notification.dtd)
 #if !defined(XP_WIN) && !defined(MOZ_FENNEC)
   locale/@AB_CD@/global/printdialog.properties          (%chrome/global/printdialog.properties)
 #endif
   locale/@AB_CD@/global/resetProfile.dtd                (%chrome/global/resetProfile.dtd)
   locale/@AB_CD@/global/resetProfile.properties         (%chrome/global/resetProfile.properties)
   locale/@AB_CD@/global/dialog.properties               (%chrome/global/dialog.properties)
   locale/@AB_CD@/global/tree.dtd                        (%chrome/global/tree.dtd)
-  locale/@AB_CD@/global/textcontext.dtd                 (%chrome/global/textcontext.dtd)
   locale/@AB_CD@/global/videocontrols.dtd               (%chrome/global/videocontrols.dtd)
   locale/@AB_CD@/global/viewSource.properties           (%chrome/global/viewSource.properties)
   locale/@AB_CD@/global/wizard.properties               (%chrome/global/wizard.properties)
 % locale global-platform @AB_CD@ %locale/@AB_CD@/global-platform/unix/ os=LikeUnix os=Android
 % locale global-platform @AB_CD@ %locale/@AB_CD@/global-platform/mac/ os=Darwin
 % locale global-platform @AB_CD@ %locale/@AB_CD@/global-platform/win/ os=WINNT
   locale/@AB_CD@/global-platform/mac/platformKeys.properties  (%chrome/global-platform/mac/platformKeys.properties)
   locale/@AB_CD@/global-platform/unix/platformKeys.properties (%chrome/global-platform/unix/platformKeys.properties)
--- a/toolkit/themes/linux/global/search-textbox.css
+++ b/toolkit/themes/linux/global/search-textbox.css
@@ -52,21 +52,17 @@ html|input {
   list-style-image: url(chrome://global/skin/icons/search-textbox.svg);
   margin-inline-end: 5px;
 }
 
 :host([searchbutton]) .textbox-search-icon {
   list-style-image: url(chrome://global/skin/icons/search-textbox.svg);
 }
 
-.textbox-search-clear {
-  list-style-image: url(resource://gre-resources/searchfield-cancel.svg);
-}
-
 :host([searchbutton]) .textbox-search-icon:not([disabled]),
-.textbox-search-clear:not([disabled]) {
+html|*.textbox-search-clear:not([disabled]) {
   cursor: pointer;
 }
 
 /* Don't leave extra blank space with long placeholders (see bug 1385902) */
 :host(:not([searchbutton])) > .textbox-search-icons:not([selectedIndex="1"]) {
   display: none;
 }
--- a/toolkit/themes/osx/global/search-textbox.css
+++ b/toolkit/themes/osx/global/search-textbox.css
@@ -37,21 +37,20 @@ html|input {
 :host([disabled="true"]) {
   cursor: default;
   background-color: -moz-Dialog;
   color: GrayText;
 }
 
 /* ::::: icons ::::: */
 
-.textbox-search-clear {
-  list-style-image: url(resource://gre-resources/searchfield-cancel.svg);
+html|*.textbox-search-clear {
   margin-bottom: 1px;
 }
 
-.textbox-search-clear:not([disabled]) {
+html|*.textbox-search-clear:not([disabled]) {
   cursor: default;
 }
 
 /* Don't leave extra blank space with long placeholders (see bug 1385902) */
 .textbox-search-icons:not([selectedIndex="1"]) {
   display: none;
 }
--- a/toolkit/themes/windows/global/search-textbox.css
+++ b/toolkit/themes/windows/global/search-textbox.css
@@ -61,20 +61,16 @@ html|input {
 .textbox-search-icon:-moz-locale-dir(rtl) {
   transform: scaleX(-1);
 }
 
 :host([searchbutton]) .textbox-search-icon:not([disabled]) {
   cursor: pointer;
 }
 
-.textbox-search-clear {
-  list-style-image: url(resource://gre-resources/searchfield-cancel.svg);
-}
-
-.textbox-search-clear:not([disabled]) {
+html|*.textbox-search-clear:not([disabled]) {
   cursor: default;
 }
 
 /* Don't leave extra blank space with long placeholders (see bug 1385902) */
 :host(:not([searchbutton])) > .textbox-search-icons:not([selectedIndex="1"]) {
   display: none;
 }