Bug 1156291 - Prevent tooltip from displaying null on line number for inline styles. r=jdescottes
authorjdinartejesus <jdinartejesus@gmail.com>
Thu, 04 Aug 2016 20:11:46 +0200
changeset 399633 6275988f9d94c9694d9a28f505ab92289110f1d5
parent 399632 4fb7850312d547f61a467f0150ad835b281aacfc
child 399634 5d16dca06481c0d2303bfcf8c7d13f9d27b865a8
push id25905
push userdtownsend@mozilla.com
push dateThu, 11 Aug 2016 17:57:58 +0000
reviewersjdescottes
bugs1156291
milestone51.0a1
Bug 1156291 - Prevent tooltip from displaying null on line number for inline styles. r=jdescottes
devtools/client/inspector/layout/layout.js
devtools/client/inspector/layout/test/browser_layout_tooltips.js
--- a/devtools/client/inspector/layout/layout.js
+++ b/devtools/client/inspector/layout/layout.js
@@ -12,17 +12,19 @@ const {Cc, Ci} = require("chrome");
 const {Task} = require("devtools/shared/task");
 const {InplaceEditor, editableItem} =
       require("devtools/client/shared/inplace-editor");
 const {ReflowFront} = require("devtools/shared/fronts/layout");
 const {LocalizationHelper} = require("devtools/client/shared/l10n");
 const {getCssProperties} = require("devtools/shared/fronts/css-properties");
 
 const STRINGS_URI = "chrome://devtools/locale/shared.properties";
+const STRINGS_INSPECTOR = "chrome://devtools-shared/locale/styleinspector.properties";
 const SHARED_L10N = new LocalizationHelper(STRINGS_URI);
+const INSPECTOR_L10N = new LocalizationHelper(STRINGS_INSPECTOR);
 const NUMERIC = /^-?[\d\.]+$/;
 const LONG_TEXT_ROTATE_LIMIT = 3;
 
 /**
  * An instance of EditingSession tracks changes that have been made during the
  * modification of box model values. All of these changes can be reverted by
  * calling revert. The main parameter is the LayoutView that created it.
  *
@@ -729,18 +731,24 @@ LayoutView.prototype = {
       }
     }
 
     let title = property;
     if (sourceRule && sourceRule.selectors) {
       title += "\n" + sourceRule.selectors.join(", ");
     }
     if (sourceRule && sourceRule.parentStyleSheet) {
-      title += "\n" + sourceRule.parentStyleSheet.href + ":" + sourceRule.line;
+      if (sourceRule.parentStyleSheet.href) {
+        title += "\n" + sourceRule.parentStyleSheet.href + ":" + sourceRule.line;
+      } else {
+        title += "\n" + INSPECTOR_L10N.getStr("rule.sourceInline") +
+          ":" + sourceRule.line;
+      }
     }
+
     el.setAttribute("title", title);
   },
 
   /**
    * Show the box-model highlighter on the currently selected element
    * @param {Object} options Options passed to the highlighter actor
    */
   showBoxModel: function (options = {}) {
--- a/devtools/client/inspector/layout/test/browser_layout_tooltips.js
+++ b/devtools/client/inspector/layout/test/browser_layout_tooltips.js
@@ -23,55 +23,55 @@ const TEST_URI = "<style>" +
 //   - name: the name of the property that is set by the css rule
 //   - ruleSelector: the selector of the rule
 //   - styleSheetLocation: the fileName:lineNumber
 const VALUES_TEST_DATA = [{
   selector: "#div1",
   values: [{
     name: "margin-top",
     ruleSelector: "#div1",
-    styleSheetLocation: "null:1"
+    styleSheetLocation: "inline:1"
   }, {
     name: "margin-right",
     ruleSelector: "#div1",
-    styleSheetLocation: "null:1"
+    styleSheetLocation: "inline:1"
   }, {
     name: "margin-bottom",
     ruleSelector: "#div1",
-    styleSheetLocation: "null:1"
+    styleSheetLocation: "inline:1"
   }, {
     name: "margin-left",
     ruleSelector: "#div1",
-    styleSheetLocation: "null:1"
+    styleSheetLocation: "inline:1"
   }]
 }, {
   selector: "#div2",
   values: [{
     name: "border-bottom-width",
     ruleSelector: "#div2",
-    styleSheetLocation: "null:2"
+    styleSheetLocation: "inline:2"
   }]
 }, {
   selector: "#div3",
   values: [{
     name: "padding-top",
     ruleSelector: "html, body, #div3",
-    styleSheetLocation: "null:3"
+    styleSheetLocation: "inline:3"
   }, {
     name: "padding-right",
     ruleSelector: "html, body, #div3",
-    styleSheetLocation: "null:3"
+    styleSheetLocation: "inline:3"
   }, {
     name: "padding-bottom",
     ruleSelector: "html, body, #div3",
-    styleSheetLocation: "null:3"
+    styleSheetLocation: "inline:3"
   }, {
     name: "padding-left",
     ruleSelector: "html, body, #div3",
-    styleSheetLocation: "null:3"
+    styleSheetLocation: "inline:3"
   }]
 }];
 
 add_task(function* () {
   yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI));
   let {inspector, view} = yield openLayoutView();
 
   info("Checking the regions tooltips");