Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Issue 5644: Editing a disabled property makes another

  • Loading branch information...
commit 0411126554bde775630c42d58bf0964aab42b472 1 parent c608716
Simon Lindholm authored July 28, 2012
90  extension/content/firebug/css/cssPanel.js
@@ -518,9 +518,22 @@ Firebug.CSSStyleSheetPanel.prototype = Obj.extend(Firebug.Panel,
518 518
         var moreProps = disabledMap.get(rule);
519 519
         if (moreProps)
520 520
         {
  521
+            var propMap = {};
  522
+            for (var i = 0; i < props.length; ++i)
  523
+                propMap[props[i].name] = true;
  524
+
521 525
             for (var i = 0; i < moreProps.length; ++i)
522 526
             {
523 527
                 var prop = moreProps[i];
  528
+                if (propMap.hasOwnProperty(prop.name))
  529
+                {
  530
+                    // A (probably enabled) property with the same name as this
  531
+                    // disabled one has appeared - remove this one entirely.
  532
+                    moreProps.splice(i, 1);
  533
+                    --i;
  534
+                    continue;
  535
+                }
  536
+                propMap[prop.name] = true;
524 537
                 this.addProperty(prop.name, prop.value, prop.important, true, inheritMode, props);
525 538
             }
526 539
         }
@@ -734,25 +747,11 @@ Firebug.CSSStyleSheetPanel.prototype = Obj.extend(Firebug.Panel,
734 747
         var rule = Firebug.getRepObject(row);
735 748
         var propName = Dom.getChildByClass(row, "cssPropName").textContent;
736 749
 
737  
-        // If the property was disabled, remove it from the relevant map.
738  
-        var didRemoveDisabled = false;
739  
-        var disabledMap = this.getDisabledMap(this.context);
740  
-        var map = disabledMap.get(rule);
741  
-        if (map)
742  
-        {
743  
-            for (var i = 0; i < map.length; ++i)
744  
-            {
745  
-                if (map[i].name == propName)
746  
-                {
747  
-                    map.splice(i, 1);
748  
-                    didRemoveDisabled = true;
749  
-                    break;
750  
-                }
751  
-            }
752  
-        }
  750
+        // Try removing the property from the "disabled" map.
  751
+        var wasDisabled = this.removeDisabledProperty(rule, propName);
753 752
 
754  
-        // Otherwise, remove the actual property.
755  
-        if (!didRemoveDisabled)
  753
+        // If that fails, remove the actual property instead.
  754
+        if (!wasDisabled)
756 755
             CSSModule.deleteProperty(rule, propName, this.context);
757 756
 
758 757
         if (this.name == "stylesheet")
@@ -762,6 +761,23 @@ Firebug.CSSStyleSheetPanel.prototype = Obj.extend(Firebug.Panel,
762 761
         this.markChange(this.name == "stylesheet");
763 762
     },
764 763
 
  764
+    removeDisabledProperty: function(rule, propName)
  765
+    {
  766
+        var disabledMap = this.getDisabledMap(this.context);
  767
+        var map = disabledMap.get(rule);
  768
+        if (!map)
  769
+            return false;
  770
+        for (var i = 0; i < map.length; ++i)
  771
+        {
  772
+            if (map[i].name === propName)
  773
+            {
  774
+                map.splice(i, 1);
  775
+                return true;
  776
+            }
  777
+        }
  778
+        return false;
  779
+    },
  780
+
765 781
     disablePropertyRow: function(row)
766 782
     {
767 783
         Css.toggleClass(row, "disabledStyle");
@@ -770,10 +786,10 @@ Firebug.CSSStyleSheetPanel.prototype = Obj.extend(Firebug.Panel,
770 786
         var propName = Dom.getChildByClass(row, "cssPropName").textContent;
771 787
 
772 788
         var disabledMap = this.getDisabledMap(this.context);
773  
-
774 789
         if (!disabledMap.has(rule))
775 790
             disabledMap.set(rule, []);
776 791
         var map = disabledMap.get(rule);
  792
+
777 793
         var propValue = Dom.getChildByClass(row, "cssPropValue").textContent;
778 794
         var parsedValue = parsePriority(propValue);
779 795
 
@@ -1642,13 +1658,20 @@ CSSEditor.prototype = domplate(Firebug.InlineEditor.prototype,
1642 1658
 
1643 1659
         var propValue, parsedValue, propName;
1644 1660
 
1645  
-        target.innerHTML = Str.escapeForCss(value);
1646  
-
  1661
+        var rule = Firebug.getRepObject(target);
1647 1662
         var row = Dom.getAncestorByClass(target, "cssProp");
1648  
-        if (Css.hasClass(row, "disabledStyle"))
1649  
-            Css.toggleClass(row, "disabledStyle");
1650 1663
 
1651  
-        var rule = Firebug.getRepObject(target);
  1664
+        // If the property was previously disabled, remove it from the "disabled"
  1665
+        // map. (We will then proceed to enable the property.)
  1666
+        if (row && row.classList.contains("disabledStyle"))
  1667
+        {
  1668
+            row.classList.remove("disabledStyle");
  1669
+            propName = Dom.getChildByClass(row, "cssPropName").textContent;
  1670
+
  1671
+            this.panel.removeDisabledProperty(rule, propName);
  1672
+        }
  1673
+
  1674
+        target.textContent = value;
1652 1675
 
1653 1676
         if (rule instanceof window.CSSStyleRule || rule instanceof window.Element)
1654 1677
         {
@@ -1769,6 +1792,23 @@ CSSEditor.prototype = domplate(Firebug.InlineEditor.prototype,
1769 1792
             FBTrace.sysout("CSSEditor.saveEdit (ending) " + this.panel.name, value);
1770 1793
     },
1771 1794
 
  1795
+    beginEditing: function(target, value)
  1796
+    {
  1797
+        var row = Dom.getAncestorByClass(target, "cssProp");
  1798
+        this.initiallyDisabled = (row && row.classList.contains("disabledStyle"));
  1799
+    },
  1800
+
  1801
+    cancelEditing: function(target, value)
  1802
+    {
  1803
+        if (this.initiallyDisabled)
  1804
+        {
  1805
+            // Disable the property again.
  1806
+            var row = Dom.getAncestorByClass(target, "cssProp");
  1807
+            if (row && !row.classList.contains("disabledStyle"))
  1808
+                this.panel.disablePropertyRow(row);
  1809
+        }
  1810
+    },
  1811
+
1772 1812
     advanceToNext: function(target, charCode)
1773 1813
     {
1774 1814
         if (charCode == 58 /*":"*/ && Css.hasClass(target, "cssPropName"))
@@ -2540,7 +2580,7 @@ CSSRuleEditor.prototype = domplate(Firebug.InlineEditor.prototype,
2540 2580
 // StyleSheetEditor
2541 2581
 
2542 2582
 /**
2543  
- * StyleSheetEditor represents an inline editor and is used when editing CSS
  2583
+ * StyleSheetEditor represents the full-sized editor used for Source/Live Edit
2544 2584
  * within the CSS panel.
2545 2585
  */
2546 2586
 function StyleSheetEditor(doc)
6  extension/content/firebug/editor/editor.js
@@ -164,6 +164,8 @@ Firebug.Editor = Obj.extend(Firebug.Module,
164 164
                 if (value != originalValue)
165 165
                     this.saveEditAndNotifyListeners(currentTarget, originalValue, previousValue);
166 166
 
  167
+                currentEditor.cancelEditing(currentTarget, originalValue);
  168
+
167 169
                 if (removeGroup && !originalValue && currentGroup)
168 170
                     currentGroup.parentNode.removeChild(currentGroup);
169 171
             }
@@ -548,6 +550,10 @@ Firebug.BaseEditor = Obj.extend(Firebug.MeasureBox,
548 550
         return true;
549 551
     },
550 552
 
  553
+    cancelEditing: function(target, value)
  554
+    {
  555
+    },
  556
+
551 557
     insertNewRow: function(target, insertWhere)
552 558
     {
553 559
     },

0 notes on commit 0411126

Please sign in to comment.
Something went wrong with that request. Please try again.