Bug 1343837 - Remove find dialog resources from toolkit. r?florian draft
authorDão Gottwald <dao@mozilla.com>
Thu, 04 Jan 2018 11:36:37 +0100
changeset 715666 2a73593b4aad0e893e018c4929879fc788f8b89d
parent 715663 f78a83244fbebe8a469ae3512fce7f638cab7e1f
child 744848 f1b42bee1c72f4ddb3eab969e9fa6e87e278954f
push id94220
push userdgottwald@mozilla.com
push dateThu, 04 Jan 2018 10:37:01 +0000
reviewersflorian
bugs1343837
milestone59.0a1
Bug 1343837 - Remove find dialog resources from toolkit. r?florian MozReview-Commit-ID: 4NhYHYYpLUJ
browser/base/content/test/static/browser_all_files_referenced.js
toolkit/content/findUtils.js
toolkit/content/finddialog.js
toolkit/content/finddialog.xul
toolkit/content/jar.mn
toolkit/locales/en-US/chrome/global/finddialog.dtd
toolkit/locales/en-US/chrome/global/finddialog.properties
toolkit/locales/jar.mn
toolkit/themes/osx/global/dialog.css
--- a/browser/base/content/test/static/browser_all_files_referenced.js
+++ b/browser/base/content/test/static/browser_all_files_referenced.js
@@ -127,18 +127,16 @@ var whitelist = [
   {file: "resource://shield-recipe-client-content/shield-content-process.js"},
 
   // Starting from here, files in the whitelist are bugs that need fixing.
   // Bug 1339424 (wontfix?)
   {file: "chrome://browser/locale/taskbar.properties",
    platforms: ["linux", "macosx"]},
   // Bug 1316187
   {file: "chrome://global/content/customizeToolbar.xul"},
-  // Bug 1343837
-  {file: "chrome://global/content/findUtils.js"},
   // Bug 1348362
   {file: "chrome://global/skin/icons/warning-64.png", platforms: ["linux"]},
   // Bug 1348525
   {file: "chrome://global/skin/splitter/grip-bottom.gif", platforms: ["linux"]},
   {file: "chrome://global/skin/splitter/grip-left.gif", platforms: ["linux"]},
   {file: "chrome://global/skin/splitter/grip-right.gif", platforms: ["linux"]},
   {file: "chrome://global/skin/splitter/grip-top.gif", platforms: ["linux"]},
   // Bug 1348526
deleted file mode 100644
--- a/toolkit/content/findUtils.js
+++ /dev/null
@@ -1,106 +0,0 @@
-// -*- indent-tabs-mode: nil; js-indent-level: 2 -*-
-
-/* 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/. */
-
-Components.utils.import("resource://gre/modules/Services.jsm");
-
-var gFindBundle;
-
-function nsFindInstData() {}
-nsFindInstData.prototype =
-{
-  // set the next three attributes on your object to override the defaults
-  browser: null,
-
-  get rootSearchWindow() { return this._root || this.window.content; },
-  set rootSearchWindow(val) { this._root = val; },
-
-  get currentSearchWindow() {
-    if (this._current)
-      return this._current;
-
-    var focusedWindow = this.window.document.commandDispatcher.focusedWindow;
-    if (!focusedWindow || focusedWindow == this.window)
-      focusedWindow = this.window.content;
-
-    return focusedWindow;
-  },
-  set currentSearchWindow(val) { this._current = val; },
-
-  get webBrowserFind() { return this.browser.webBrowserFind; },
-
-  init() {
-    var findInst = this.webBrowserFind;
-    // set up the find to search the focussedWindow, bounded by the content window.
-    var findInFrames = findInst.QueryInterface(Components.interfaces.nsIWebBrowserFindInFrames);
-    findInFrames.rootSearchFrame = this.rootSearchWindow;
-    findInFrames.currentSearchFrame = this.currentSearchWindow;
-
-    // always search in frames for now. We could add a checkbox to the dialog for this.
-    findInst.searchFrames = true;
-  },
-
-  window,
-  _root: null,
-  _current: null
-};
-
-// browser is the <browser> element
-// rootSearchWindow is the window to constrain the search to (normally window.content)
-// currentSearchWindow is the frame to start searching (can be, and normally, rootSearchWindow)
-function findInPage(findInstData) {
-  // is the dialog up already?
-  if ("findDialog" in window && window.findDialog)
-    window.findDialog.focus();
-  else {
-    findInstData.init();
-    window.findDialog = window.openDialog("chrome://global/content/finddialog.xul", "_blank", "chrome,resizable=no,dependent=yes", findInstData);
-  }
-}
-
-function findAgainInPage(findInstData, reverse) {
-  if ("findDialog" in window && window.findDialog)
-    window.findDialog.focus();
-  else {
-    // get the find service, which stores global find state, and init the
-    // nsIWebBrowser find with it. We don't assume that there was a previous
-    // Find that set this up.
-    var findService = Components.classes["@mozilla.org/find/find_service;1"]
-                           .getService(Components.interfaces.nsIFindService);
-
-    var searchString = findService.searchString;
-    if (searchString.length == 0) {
-      // no previous find text
-      findInPage(findInstData);
-      return;
-    }
-
-    findInstData.init();
-    var findInst = findInstData.webBrowserFind;
-    findInst.searchString  = searchString;
-    findInst.matchCase     = findService.matchCase;
-    findInst.wrapFind      = findService.wrapFind;
-    findInst.entireWord    = findService.entireWord;
-    findInst.findBackwards = findService.findBackwards ^ reverse;
-
-    var found = findInst.findNext();
-    if (!found) {
-      if (!gFindBundle)
-        gFindBundle = document.getElementById("findBundle");
-
-      Services.prompt.alert(window, gFindBundle.getString("notFoundTitle"), gFindBundle.getString("notFoundWarning"));
-    }
-
-    // Reset to normal value, otherwise setting can get changed in find dialog
-    findInst.findBackwards = findService.findBackwards;
-  }
-}
-
-function canFindAgainInPage() {
-    var findService = Components.classes["@mozilla.org/find/find_service;1"]
-                           .getService(Components.interfaces.nsIFindService);
-    return (findService.searchString.length > 0);
-}
-
deleted file mode 100644
--- a/toolkit/content/finddialog.js
+++ /dev/null
@@ -1,144 +0,0 @@
-// -*- indent-tabs-mode: nil; js-indent-level: 2 -*-
-
-/* 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/. */
-
-// Defined in dialog.xml.
-/* globals moveToAlertPosition */
-
-Components.utils.import("resource://gre/modules/Services.jsm");
-Components.utils.import("resource://gre/modules/FormHistory.jsm");
-
-var dialog; // Quick access to document/form elements.
-var gFindInst; // nsIWebBrowserFind that we're going to use
-var gFindInstData; // use this to update the find inst data
-
-function initDialogObject() {
-  // Create dialog object and initialize.
-  dialog = {};
-  dialog.findKey         = document.getElementById("dialog.findKey");
-  dialog.caseSensitive   = document.getElementById("dialog.caseSensitive");
-  dialog.wrap            = document.getElementById("dialog.wrap");
-  dialog.find            = document.getElementById("btnFind");
-  dialog.up              = document.getElementById("radioUp");
-  dialog.down            = document.getElementById("radioDown");
-  dialog.rg              = dialog.up.radioGroup;
-  dialog.bundle          = null;
-
-  // Move dialog to center, if it not been shown before
-  var windowElement = document.getElementById("findDialog");
-  if (!windowElement.hasAttribute("screenX") || !windowElement.hasAttribute("screenY")) {
-    sizeToContent();
-    moveToAlertPosition();
-  }
-}
-
-function fillDialog() {
-  // get the find service, which stores global find state
-  var findService = Components.classes["@mozilla.org/find/find_service;1"]
-                              .getService(Components.interfaces.nsIFindService);
-
-  // Set initial dialog field contents. Use the gFindInst attributes first,
-  // this is necessary for window.find()
-  dialog.findKey.value           = gFindInst.searchString ? gFindInst.searchString : findService.searchString;
-  dialog.caseSensitive.checked   = gFindInst.matchCase ? gFindInst.matchCase : findService.matchCase;
-  dialog.wrap.checked            = gFindInst.wrapFind ? gFindInst.wrapFind : findService.wrapFind;
-  var findBackwards              = gFindInst.findBackwards ? gFindInst.findBackwards : findService.findBackwards;
-  if (findBackwards)
-    dialog.rg.selectedItem = dialog.up;
-  else
-    dialog.rg.selectedItem = dialog.down;
-}
-
-function saveFindData() {
-  // get the find service, which stores global find state
-  var findService = Components.classes["@mozilla.org/find/find_service;1"]
-                         .getService(Components.interfaces.nsIFindService);
-
-  // Set data attributes per user input.
-  findService.searchString  = dialog.findKey.value;
-  findService.matchCase     = dialog.caseSensitive.checked;
-  findService.wrapFind      = dialog.wrap.checked;
-  findService.findBackwards = dialog.up.selected;
-}
-
-function onLoad() {
-  initDialogObject();
-
-  // get the find instance
-  var arg0 = window.arguments[0];
-  // If the dialog was opened from window.find(),
-  // arg0 will be an instance of nsIWebBrowserFind
-  if (arg0 instanceof Components.interfaces.nsIWebBrowserFind) {
-    gFindInst = arg0;
-  } else {
-    gFindInstData = arg0;
-    gFindInst = gFindInstData.webBrowserFind;
-  }
-
-  fillDialog();
-  doEnabling();
-
-  if (dialog.findKey.value)
-    dialog.findKey.select();
-  dialog.findKey.focus();
-}
-
-function onUnload() {
-  window.opener.findDialog = 0;
-}
-
-function onAccept() {
-  if (gFindInstData && gFindInst != gFindInstData.webBrowserFind) {
-    gFindInstData.init();
-    gFindInst = gFindInstData.webBrowserFind;
-  }
-
-  // Transfer dialog contents to the find service.
-  saveFindData();
-  updateFormHistory();
-
-  // set up the find instance
-  gFindInst.searchString  = dialog.findKey.value;
-  gFindInst.matchCase     = dialog.caseSensitive.checked;
-  gFindInst.wrapFind      = dialog.wrap.checked;
-  gFindInst.findBackwards = dialog.up.selected;
-
-  // Search.
-  var result = gFindInst.findNext();
-
-  if (!result) {
-    if (!dialog.bundle)
-      dialog.bundle = document.getElementById("findBundle");
-    Services.prompt.alert(window, dialog.bundle.getString("notFoundTitle"),
-                                  dialog.bundle.getString("notFoundWarning"));
-    dialog.findKey.select();
-    dialog.findKey.focus();
-  }
-  return false;
-}
-
-function doEnabling() {
-  dialog.find.disabled = !dialog.findKey.value;
-}
-
-function updateFormHistory() {
-  if (window.opener.PrivateBrowsingUtils &&
-      window.opener.PrivateBrowsingUtils.isWindowPrivate(window.opener) ||
-      !dialog.findKey.value)
-    return;
-
-  if (FormHistory.enabled) {
-    FormHistory.update({
-      op: "bump",
-      fieldname: "find-dialog",
-      value: dialog.findKey.value
-    }, {
-      handleError(aError) {
-        Components.utils.reportError("Saving find to form history failed: " +
-                                     aError.message);
-      }
-    });
-  }
-}
deleted file mode 100644
--- a/toolkit/content/finddialog.xul
+++ /dev/null
@@ -1,58 +0,0 @@
-<?xml version="1.0"?> <!-- -*- Mode: HTML -*- -->
-# 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/.
-
-<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
-
-<!DOCTYPE window SYSTEM "chrome://global/locale/finddialog.dtd">
-
-<dialog id="findDialog"
-  xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
-  orient="horizontal"
-  windowtype="findInPage"
-  onload="onLoad();"
-  onunload="onUnload();"
-  ondialogaccept="return onAccept();"
-  buttons="accept,cancel"
-  title="&findDialog.title;"
-  persist="screenX screenY">
-
-  <script type="application/javascript" src="chrome://global/content/finddialog.js"/>
-  <stringbundle id="findBundle" src="chrome://global/locale/finddialog.properties"/>
-
-  <hbox>
-    <vbox>
-      <hbox align="center">
-        <label value="&findField.label;" accesskey="&findField.accesskey;" control="dialog.findKey"/>
-        <textbox id="dialog.findKey" flex="1"
-                 type="autocomplete"
-                 autocompletesearch="form-history"
-                 autocompletesearchparam="find-dialog"
-                 oninput="doEnabling();"/>
-      </hbox>
-      <hbox align="center">
-        <vbox>
-          <checkbox id="dialog.caseSensitive" label="&caseSensitiveCheckbox.label;" accesskey="&caseSensitiveCheckbox.accesskey;"/>
-          <checkbox id="dialog.wrap" label="&wrapCheckbox.label;" accesskey="&wrapCheckbox.accesskey;" checked="true"/>
-        </vbox>
-        <groupbox orient="horizontal">
-          <caption label="&direction.label;"/>
-          <radiogroup orient="horizontal">
-            <radio id="radioUp" label="&up.label;" accesskey="&up.accesskey;"/>
-            <radio id="radioDown" label="&down.label;" accesskey="&down.accesskey;" selected="true"/>
-          </radiogroup>
-        </groupbox>
-      </hbox>
-    </vbox>
-    <vbox>
-      <button id="btnFind" label="&findButton.label;" accesskey="&findButton.accesskey;"
-              dlgtype="accept" icon="find"/>
-#ifdef XP_UNIX
-      <button label="&closeButton.label;" icon="close" dlgtype="cancel"/>
-#else
-      <button label="&cancelButton.label;" icon="cancel" dlgtype="cancel"/>
-#endif
-    </vbox>
-  </hbox>
-</dialog>
--- a/toolkit/content/jar.mn
+++ b/toolkit/content/jar.mn
@@ -44,19 +44,16 @@ toolkit.jar:
    content/global/customizeToolbar.css
    content/global/customizeToolbar.js
    content/global/customizeToolbar.xul
 #endif
    content/global/datepicker.xhtml
 #ifndef MOZ_FENNEC
    content/global/editMenuOverlay.js
 *  content/global/editMenuOverlay.xul
-   content/global/finddialog.js
-*  content/global/finddialog.xul
-   content/global/findUtils.js
 #endif
    content/global/filepicker.properties
    content/global/globalOverlay.js
    content/global/mozilla.xhtml
    content/global/process-content.js
    content/global/resetProfile.css
    content/global/resetProfile.js
    content/global/resetProfile.xul
deleted file mode 100644
--- a/toolkit/locales/en-US/chrome/global/finddialog.dtd
+++ /dev/null
@@ -1,22 +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/. -->
-
-<!-- extracted from finddialog.xul -->
-
-<!ENTITY findDialog.title "Find in This Page">
-<!ENTITY findField.label "Find what:">
-<!ENTITY findField.accesskey "n">
-<!ENTITY caseSensitiveCheckbox.label "Match case">
-<!ENTITY caseSensitiveCheckbox.accesskey "c">
-<!ENTITY wrapCheckbox.label "Wrap">
-<!ENTITY wrapCheckbox.accesskey "W">
-<!ENTITY findButton.label "Find Next">
-<!ENTITY findButton.accesskey "F">
-<!ENTITY cancelButton.label "Cancel">
-<!ENTITY closeButton.label "Close">
-<!ENTITY up.label "Up">
-<!ENTITY up.accesskey "U">
-<!ENTITY down.label "Down">
-<!ENTITY down.accesskey "D">
-<!ENTITY direction.label "Direction">
deleted file mode 100644
--- a/toolkit/locales/en-US/chrome/global/finddialog.properties
+++ /dev/null
@@ -1,6 +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/.
-
-notFoundWarning=The text you entered was not found.
-notFoundTitle=Find
\ No newline at end of file
--- a/toolkit/locales/jar.mn
+++ b/toolkit/locales/jar.mn
@@ -49,18 +49,16 @@
   locale/@AB_CD@/global/filefield.properties            (%chrome/global/filefield.properties)
 #ifdef MOZ_GTK
   locale/@AB_CD@/global/filepicker.dtd                  (%chrome/global/filepicker.dtd)
 #endif
   locale/@AB_CD@/global/filepicker.properties           (%chrome/global/filepicker.properties)
 #ifndef MOZ_FENNEC
   locale/@AB_CD@/global/findbar.dtd                     (%chrome/global/findbar.dtd)
   locale/@AB_CD@/global/findbar.properties              (%chrome/global/findbar.properties)
-  locale/@AB_CD@/global/finddialog.dtd                  (%chrome/global/finddialog.dtd)
-  locale/@AB_CD@/global/finddialog.properties           (%chrome/global/finddialog.properties)
 #endif
   locale/@AB_CD@/global/globalKeys.dtd                  (%chrome/global/globalKeys.dtd)
   locale/@AB_CD@/global/intl.css                        (%chrome/global/intl.css)
   locale/@AB_CD@/global/intl.properties                 (%chrome/global/intl.properties)
   locale/@AB_CD@/global/keys.properties                 (%chrome/global/keys.properties)
   locale/@AB_CD@/global/languageNames.properties        (%chrome/global/languageNames.properties)
   locale/@AB_CD@/global/mozilla.dtd                     (%chrome/global/mozilla.dtd)
 #ifndef MOZ_FENNEC
--- a/toolkit/themes/osx/global/dialog.css
+++ b/toolkit/themes/osx/global/dialog.css
@@ -18,19 +18,8 @@ dialog {
 }
 
 /* ::::: dialog buttons ::::: */
 
 .dialog-button {
   font: menu;
 }
 
-/*XXX - belongs to toolkit/content/finddialog.xul: */
-
-#findDialog,
-#findDialog > menu,
-#findDialog > groupbox {
-  font: menu !important;
-}
-
-#dialog\.caseSensitive {
-  margin-top: 8px;
-}