Bug 820311 - Script URLs no longer appear in tooltips, r=past
authorVictor Porof <vporof@mozilla.com>
Thu, 20 Dec 2012 19:20:50 +0200
changeset 116654 7a3d7c03aab5109d0c21d3f1a226c187e4a00528
parent 116653 b99d6a6557f479318a9f941c251966ae9325c4bd
child 116655 4b7b934b358a3e02402371877443653ff910781a
push id24060
push userpastithas@mozilla.com
push dateFri, 21 Dec 2012 08:30:24 +0000
treeherdermozilla-central@c965fa0804cf [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspast
bugs820311
milestone20.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 820311 - Script URLs no longer appear in tooltips, r=past
browser/devtools/debugger/debugger-controller.js
browser/devtools/debugger/debugger-view.js
--- a/browser/devtools/debugger/debugger-controller.js
+++ b/browser/devtools/debugger/debugger-controller.js
@@ -1161,16 +1161,17 @@ SourceScripts.prototype = {
    *        - forced: force the source to be immediately added
    */
   _addSource: function SS__addSource(aSource, aOptions = {}) {
     let url = aSource.url;
     let label = SourceUtils.getSourceLabel(url);
 
     DebuggerView.Sources.push(label, url, {
       forced: aOptions.forced,
+      tooltip: url,
       attachment: aSource
     });
   },
 
   /**
    * Gets a specified source's text.
    *
    * @param object aSource
--- a/browser/devtools/debugger/debugger-view.js
+++ b/browser/devtools/debugger/debugger-view.js
@@ -613,28 +613,29 @@ MenuContainer.prototype = {
    * @param string aValue
    *        The actual internal value of the item.
    * @param object aOptions [optional]
    *        Additional options or flags supported by this operation:
    *          - forced: true to force the item to be immediately appended
    *          - unsorted: true if the items should not always remain sorted
    *          - relaxed: true if this container should allow dupes & degenerates
    *          - description: an optional description of the item
+   *          - tooltip: an optional tooltip for the item
    *          - attachment: some attached primitive/object
    * @return MenuItem
    *         The item associated with the displayed element if a forced push,
    *         undefined if the item was staged for a later commit.
    */
   push: function DVMC_push(aLabel, aValue, aOptions = {}) {
     let item = new MenuItem(
       aLabel, aValue, aOptions.description, aOptions.attachment);
 
     // Batch the item to be added later.
     if (!aOptions.forced) {
-      this._stagedItems.push(item);
+      this._stagedItems.push({ item: item, options: aOptions });
     }
     // Immediately insert the item at the specified index.
     else if (aOptions.forced && aOptions.forced.atIndex !== undefined) {
       return this._insertItemAt(aOptions.forced.atIndex, item, aOptions);
     }
     // Find the target position in this container and insert the item there.
     else if (!aOptions.unsorted) {
       return this._insertItemAt(this._findExpectedIndex(aLabel), item, aOptions);
@@ -652,21 +653,22 @@ MenuContainer.prototype = {
    *        Additional options or flags supported by this operation:
    *          - unsorted: true if the items should not be sorted beforehand
    */
   commit: function DVMC_commit(aOptions = {}) {
     let stagedItems = this._stagedItems;
 
     // By default, sort the items before adding them to this container.
     if (!aOptions.unsorted) {
-      stagedItems.sort(function(a, b) a.label.toLowerCase() > b.label.toLowerCase());
+      stagedItems.sort(function(a, b) a.item.label.toLowerCase() >
+                                      b.item.label.toLowerCase());
     }
     // Append the prepared items to this container.
-    for (let item of stagedItems) {
-      this._appendItem(item, aOptions);
+    for (let { item, options } of stagedItems) {
+      this._appendItem(item, options);
     }
     // Recreate the temporary items list for ulterior pushes.
     this._stagedItems = [];
   },
 
   /**
    * Updates this container to reflect the information provided by the
    * currently selected item.
@@ -745,31 +747,31 @@ MenuContainer.prototype = {
    *
    * @param string aLabel
    *        The item's label.
    * @return boolean
    *         True if the label is known, false otherwise.
    */
   containsLabel: function DVMC_containsLabel(aLabel) {
     return this._itemsByLabel.has(aLabel) ||
-           this._stagedItems.some(function(o) o.label == aLabel);
+           this._stagedItems.some(function({item}) item.label == aLabel);
   },
 
   /**
    * Checks whether an item with the specified value is among the elements
    * shown in this container.
    *
    * @param string aValue
    *        The item's value.
    * @return boolean
    *         True if the value is known, false otherwise.
    */
   containsValue: function DVMC_containsValue(aValue) {
     return this._itemsByValue.has(aValue) ||
-           this._stagedItems.some(function(o) o.value == aValue);
+           this._stagedItems.some(function({item}) item.value == aValue);
   },
 
   /**
    * Checks whether an item with the specified trimmed value is among the
    * elements shown in this container.
    *
    * @param string aValue
    *        The item's value.
@@ -783,17 +785,17 @@ MenuContainer.prototype = {
                                      aTrim = SourceUtils.trimUrlQuery) {
     let trimmedValue = aTrim(aValue);
 
     for (let [value] of this._itemsByValue) {
       if (aTrim(value) == trimmedValue) {
         return true;
       }
     }
-    return this._stagedItems.some(function(o) aTrim(o.value) == trimmedValue);
+    return this._stagedItems.some(function({item}) aTrim(item.value) == trimmedValue);
   },
 
   /**
    * Gets the preferred selected value to be displayed in this container.
    * @return string
    */
   get preferredValue() this._preferredValue,
 
@@ -1041,18 +1043,25 @@ MenuContainer.prototype = {
    * @return MenuItem
    *         The item associated with the displayed element, null if rejected.
    */
   _appendItem: function DVMC__appendItem(aItem, aOptions = {}) {
     if (!aOptions.relaxed && !this.isEligible(aItem)) {
       return null;
     }
 
-    return this._entangleItem(aItem, this._container.appendItem(
+    this._entangleItem(aItem, this._container.appendItem(
       aItem.label, aItem.value, "", aOptions.attachment));
+
+    // Handle any additional options after entangling the item.
+    if (aOptions.tooltip) {
+      aItem._target.setAttribute("tooltiptext", aOptions.tooltip);
+    }
+
+    return aItem;
   },
 
   /**
    * Immediately inserts an item in this container at the specified index.
    *
    * @param number aIndex
    *        The position in the container intended for this item.
    * @param MenuItem aItem
@@ -1063,18 +1072,25 @@ MenuContainer.prototype = {
    * @return MenuItem
    *         The item associated with the displayed element, null if rejected.
    */
   _insertItemAt: function DVMC__insertItemAt(aIndex, aItem, aOptions) {
     if (!aOptions.relaxed && !this.isEligible(aItem)) {
       return null;
     }
 
-    return this._entangleItem(aItem, this._container.insertItemAt(
+    this._entangleItem(aItem, this._container.insertItemAt(
       aIndex, aItem.label, aItem.value, "", aOptions.attachment));
+
+    // Handle any additional options after entangling the item.
+    if (aOptions.tooltip) {
+      aItem._target.setAttribute("tooltiptext", aOptions.tooltip);
+    }
+
+    return aItem;
   },
 
   /**
    * Entangles an item (model) with a displayed node element (view).
    *
    * @param MenuItem aItem
    *        The item describing the element.
    * @param nsIDOMNode aElement