Bug 1040697 - Prevent rule view marking all new properties as overridden r=bgrins
authorMichael Ratcliffe <mratcliffe@mozilla.com>
Sun, 20 Jul 2014 22:50:41 +0100
changeset 195361 0859e0ab393418a461522898b70a210ef81ffc7a
parent 195360 b9c60f0356c2b04f31feb232d04d2e5841f2573b
child 195362 cebc0f24e83973a8232422e6c8d6d74a41a55acc
push id46575
push userkwierso@gmail.com
push dateTue, 22 Jul 2014 00:35:21 +0000
treeherdermozilla-inbound@fee5c4bdd713 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbgrins
bugs1040697
milestone33.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 1040697 - Prevent rule view marking all new properties as overridden r=bgrins
browser/devtools/styleinspector/rule-view.js
browser/devtools/styleinspector/test/browser_ruleview_add-property_01.js
--- a/browser/devtools/styleinspector/rule-view.js
+++ b/browser/devtools/styleinspector/rule-view.js
@@ -991,25 +991,35 @@ TextProperty.prototype = {
     // for this text property, we'll set the property on a dummy element
     // and see what the computed style looks like.
     let dummyElement = this.rule.elementStyle.dummyElement;
     let dummyStyle = dummyElement.style;
     dummyStyle.cssText = "";
     dummyStyle.setProperty(this.name, this.value, this.priority);
 
     this.computed = [];
-    for (let i = 0, n = dummyStyle.length; i < n; i++) {
-      let prop = dummyStyle.item(i);
-      this.computed.push({
-        textProp: this,
-        name: prop,
-        value: dummyStyle.getPropertyValue(prop),
-        priority: dummyStyle.getPropertyPriority(prop),
-      });
-    }
+
+    try {
+      // Manually get all the properties that are set when setting a value on
+      // this.name and check the computed style on dummyElement for each one.
+      // If we just read dummyStyle, it would skip properties when value == "".
+      let subProps = domUtils.getSubpropertiesForCSSProperty(this.name);
+
+      for (let prop of subProps) {
+        this.computed.push({
+          textProp: this,
+          name: prop,
+          value: dummyStyle.getPropertyValue(prop),
+          priority: dummyStyle.getPropertyPriority(prop),
+        });
+      }
+    } catch(e) {
+      // This is a partial property name, probably from cutting and pasting
+      // text. At this point don't check for computed properties.
+     }
   },
 
   /**
    * Set all the values from another TextProperty instance into
    * this TextProperty instance.
    *
    * @param {TextProperty} aOther
    *        The other TextProperty instance.
--- a/browser/devtools/styleinspector/test/browser_ruleview_add-property_01.js
+++ b/browser/devtools/styleinspector/test/browser_ruleview_add-property_01.js
@@ -69,10 +69,11 @@ function* testCreateNew(view) {
   editor.input.value = "#XYZ";
   let onBlur = once(editor.input, "blur");
   let onModifications = elementRuleEditor.rule._applyingModifications;
   editor.input.blur();
   yield onBlur;
   yield onModifications;
 
   is(textProp.value, "#XYZ", "Text prop should have been changed.");
+  is(textProp.overridden, false, "Property should not be overridden");
   is(textProp.editor.isValid(), false, "#XYZ should not be a valid entry");
 }