Bug 1217129: Part 4a - Allow creating CustomizableUI widgets without tooltips. r?gijs draft
authorKris Maglione <maglione.k@gmail.com>
Sat, 09 Jan 2016 19:25:16 -0800
changeset 320567 a0c403d89febb8b71846a8dd3238547290186b9d
parent 320566 e56ecc19505725f5c556bf87856bfb7cdecdcaea
child 320568 7e413df414cbbb4af7df9aba1bb5733a687509b8
push id9233
push usermaglione.k@gmail.com
push dateMon, 11 Jan 2016 20:43:12 +0000
reviewersgijs
bugs1217129
milestone46.0a1
Bug 1217129: Part 4a - Allow creating CustomizableUI widgets without tooltips. r?gijs
browser/components/customizableui/CustomizableUI.jsm
--- a/browser/components/customizableui/CustomizableUI.jsm
+++ b/browser/components/customizableui/CustomizableUI.jsm
@@ -1337,17 +1337,19 @@ var CustomizableUIInternal = {
           additionalTooltipArguments.push(ShortcutUtils.prettifyShortcut(keyEl));
         } else {
           ERROR("Key element with id '" + aWidget.shortcutId + "' for widget '" + aWidget.id +
                 "' not found!");
         }
       }
 
       let tooltip = this.getLocalizedProperty(aWidget, "tooltiptext", additionalTooltipArguments);
-      node.setAttribute("tooltiptext", tooltip);
+      if (tooltip) {
+        node.setAttribute("tooltiptext", tooltip);
+      }
       node.setAttribute("class", "toolbarbutton-1 chromeclass-toolbar-additional");
 
       let commandHandler = this.handleWidgetCommand.bind(this, aWidget, node);
       node.addEventListener("command", commandHandler, false);
       let clickHandler = this.handleWidgetClick.bind(this, aWidget, node);
       node.addEventListener("click", clickHandler, false);
 
       // If the widget has a view, and has view showing / hiding listeners,
@@ -1390,34 +1392,36 @@ var CustomizableUIInternal = {
     }
     if (!aWidget) {
       throw new Error("getLocalizedProperty was passed a non-widget to work with.");
     }
     let def, name;
     // Let widgets pass their own string identifiers or strings, so that
     // we can use strings which aren't the default (in case string ids change)
     // and so that non-builtin-widgets can also provide labels, tooltips, etc.
-    if (aWidget[aProp]) {
+    if (aWidget[aProp] != null) {
       name = aWidget[aProp];
       // By using this as the default, if a widget provides a full string rather
       // than a string ID for localization, we will fall back to that string
       // and return that.
       def = aDef || name;
     } else {
       name = aWidget.id + "." + aProp;
       def = aDef || "";
     }
     try {
       if (Array.isArray(aFormatArgs) && aFormatArgs.length) {
         return gWidgetsBundle.formatStringFromName(name, aFormatArgs,
           aFormatArgs.length) || def;
       }
       return gWidgetsBundle.GetStringFromName(name) || def;
     } catch(ex) {
-      if (!def) {
+      // If an empty string was explicitly passed, treat it as an actual
+      // value rather than a missing property.
+      if (!def && name != "") {
         ERROR("Could not localize property '" + name + "'.");
       }
     }
     return def;
   },
 
   addShortcut: function(aShortcutNode, aTargetNode) {
     if (!aTargetNode)