Bug 944947 - automatically hyphenate labels for items in Australis' menupanel, r=MattN
authorGijs Kruitbosch <gijskruitbosch@gmail.com>
Fri, 17 Jan 2014 19:11:57 +0100
changeset 164546 5f84d2973b05e11929bcf01f6562f5819fe85ceb
parent 164545 993ee55e02cb5dba3c07a10e07366c9cd0ad113f
child 164547 228214210aa5d8276584f36e5d74c5308e9b92d6
push id4490
push usergijskruitbosch@gmail.com
push dateWed, 22 Jan 2014 12:50:42 +0000
treeherderfx-team@228214210aa5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersMattN
bugs944947
milestone29.0a1
Bug 944947 - automatically hyphenate labels for items in Australis' menupanel, r=MattN
browser/components/customizableui/content/panelUI.js
browser/themes/shared/customizableui/panelUIOverlay.inc.css
--- a/browser/components/customizableui/content/panelUI.js
+++ b/browser/components/customizableui/content/panelUI.js
@@ -202,16 +202,18 @@ const PanelUI = {
    *
    * @return a Promise that resolves once the panel is ready to roll.
    */
   ensureReady: function(aCustomizing=false) {
     if (this._readyPromise) {
       return this._readyPromise;
     }
     this._readyPromise = Task.spawn(function() {
+      this.contents.setAttributeNS("http://www.w3.org/XML/1998/namespace", "lang",
+                                   getLocale());
       if (!this._scrollWidth) {
         // In order to properly center the contents of the panel, while ensuring
         // that we have enough space on either side to show a scrollbar, we have to
         // do a bit of hackery. In particular, we calculate a new width for the
         // scroller, based on the system scrollbar width.
         this._scrollWidth =
           (yield ScrollbarSampler.getSystemScrollbarWidth()) + "px";
         let cstyle = window.getComputedStyle(this.scroller);
@@ -413,8 +415,30 @@ const PanelUI = {
 
     this.addEventListener("command", PanelUI.onCommandHandler);
   },
 
   _onHelpViewHide: function(aEvent) {
     this.removeEventListener("command", PanelUI.onCommandHandler);
   }
 };
+
+/**
+ * Gets the currently selected locale for display.
+ * @return  the selected locale or "en-US" if none is selected
+ */
+function getLocale() {
+  try {
+    let locale = Services.prefs.getComplexValue(PREF_SELECTED_LOCALE,
+                                                Ci.nsIPrefLocalizedString);
+    if (locale)
+      return locale;
+  }
+  catch (e) { }
+
+  try {
+    return Services.prefs.getCharPref(PREF_SELECTED_LOCALE);
+  }
+  catch (e) { }
+
+  return "en-US";
+}
+
--- a/browser/themes/shared/customizableui/panelUIOverlay.inc.css
+++ b/browser/themes/shared/customizableui/panelUIOverlay.inc.css
@@ -74,16 +74,17 @@ toolbaritem[cui-areatype="menu-panel"][s
   font-size: @panelTextSize@;
 }
 
 .panelUI-grid .toolbarbutton-menubutton-button > .toolbarbutton-multiline-text,
 .panelUI-grid .toolbarbutton-1 > .toolbarbutton-multiline-text {
   font-size: @panelTextSize@;
   margin: 2px 0 0;
   text-align: center;
+  -moz-hyphens: auto;
 }
 
 #wrapper-edit-controls:-moz-any([place="palette"],[place="panel"]) > #edit-controls,
 #wrapper-zoom-controls:-moz-any([place="palette"],[place="panel"]) > #zoom-controls {
   -moz-margin-start: 0;
 }
 
 #PanelUI-contents,