Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Issue 5500: Clicking style side panel things fails randomly

  • Loading branch information...
commit 240a0c4f8c7957c7e4a90e1ca395cf57b08b715b 1 parent 0423e62
Simon Lindholm authored
74  extension/content/firebug/css/cssPanel.js
@@ -709,33 +709,70 @@ Firebug.CSSStyleSheetPanel.prototype = Obj.extend(Firebug.Panel,
709 709
 
710 710
     // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
711 711
 
  712
+    // When handling disable button clicks, we cannot simply use a 'click'
  713
+    // event, because refresh() may be (and often is) called in between
  714
+    // mousedown and mouseup, replacing the DOM structure. Instead, a
  715
+    // description of the moused-down disable button's property is saved
  716
+    // and explicitly checked on mouseup (issue 5500).
  717
+    clickedPropTag: null,
  718
+
  719
+    getPropTag: function(event)
  720
+    {
  721
+        var row = Dom.getAncestorByClass(event.target, "cssProp");
  722
+        var rule = Firebug.getRepObject(row);
  723
+        var propName = Dom.getChildByClass(row, "cssPropName").textContent;
  724
+        return {
  725
+            a: rule, b: propName,
  726
+            equals: function(other)
  727
+            {
  728
+                return (other && this.a === other.a && this.b === other.b);
  729
+            }
  730
+        };
  731
+    },
  732
+
  733
+    clickedDisableButton: function(event)
  734
+    {
  735
+        // XXX hack
  736
+        if (event.clientX > 20)
  737
+            return false;
  738
+        if (Css.hasClass(event.target, "textEditor inlineExpander"))
  739
+            return false;
  740
+        var row = Dom.getAncestorByClass(event.target, "cssProp");
  741
+        return (row && Css.hasClass(row, "editGroup"));
  742
+    },
  743
+
712 744
     onMouseDown: function(event)
713 745
     {
  746
+        this.clickedPropTag = null;
  747
+        if (Events.isLeftClick(event) && this.clickedDisableButton(event))
  748
+        {
  749
+            this.clickedPropTag = this.getPropTag(event);
  750
+
  751
+            // Don't select text when double-clicking the disable button.
  752
+            Events.cancelEvent(event);
  753
+        }
714 754
     },
715 755
 
716  
-    onClick: function(event)
  756
+    onMouseUp: function(event)
717 757
     {
718  
-        var row;
  758
+        if (Events.isLeftClick(event) && this.clickedDisableButton(event) &&
  759
+            this.getPropTag(event).equals(this.clickedPropTag))
  760
+        {
  761
+            var row = Dom.getAncestorByClass(event.target, "cssProp");
  762
+            this.disablePropertyRow(row);
  763
+            Events.cancelEvent(event);
  764
+        }
  765
+        this.clickedPropTag = null;
  766
+    },
719 767
 
  768
+    onClick: function(event)
  769
+    {
720 770
         if (!Events.isLeftClick(event))
721 771
             return;
722 772
 
723  
-        // XXjoe Hack to only allow clicking on the checkbox
724  
-        if ((event.clientX <= 20) && Events.isSingleClick(event))
725  
-        {
726  
-            if (Css.hasClass(event.target, "textEditor inlineExpander"))
727  
-                return;
728  
-
729  
-            row = Dom.getAncestorByClass(event.target, "cssProp");
730  
-            if (row && Css.hasClass(row, "editGroup"))
731  
-            {
732  
-                this.disablePropertyRow(row);
733  
-                Events.cancelEvent(event);
734  
-            }
735  
-        }
736  
-        else if ((event.clientX >= 20) && Events.isDoubleClick(event))
  773
+        if (Events.isDoubleClick(event) && !this.clickedDisableButton(event))
737 774
         {
738  
-            row = Dom.getAncestorByClass(event.target, "cssRule");
  775
+            var row = Dom.getAncestorByClass(event.target, "cssRule");
739 776
             if (row && !Dom.getAncestorByClass(event.target, "cssPropName")
740 777
                 && !Dom.getAncestorByClass(event.target, "cssPropValue"))
741 778
             {
@@ -759,6 +796,7 @@ Firebug.CSSStyleSheetPanel.prototype = Obj.extend(Firebug.Panel,
759 796
     initialize: function()
760 797
     {
761 798
         this.onMouseDown = Obj.bind(this.onMouseDown, this);
  799
+        this.onMouseUp = Obj.bind(this.onMouseUp, this);
762 800
         this.onClick = Obj.bind(this.onClick, this);
763 801
 
764 802
         Firebug.Panel.initialize.apply(this, arguments);
@@ -778,6 +816,7 @@ Firebug.CSSStyleSheetPanel.prototype = Obj.extend(Firebug.Panel,
778 816
     initializeNode: function(oldPanelNode)
779 817
     {
780 818
         Events.addEventListener(this.panelNode, "mousedown", this.onMouseDown, false);
  819
+        Events.addEventListener(this.panelNode, "mouseup", this.onMouseUp, false);
781 820
         Events.addEventListener(this.panelNode, "click", this.onClick, false);
782 821
 
783 822
         Firebug.Panel.initializeNode.apply(this, arguments);
@@ -786,6 +825,7 @@ Firebug.CSSStyleSheetPanel.prototype = Obj.extend(Firebug.Panel,
786 825
     destroyNode: function()
787 826
     {
788 827
         Events.removeEventListener(this.panelNode, "mousedown", this.onMouseDown, false);
  828
+        Events.removeEventListener(this.panelNode, "mouseup", this.onMouseUp, false);
789 829
         Events.removeEventListener(this.panelNode, "click", this.onClick, false);
790 830
 
791 831
         Firebug.Panel.destroyNode.apply(this, arguments);
15  extension/content/firebug/css/stylePanel.js
@@ -138,6 +138,10 @@ CSSStylePanel.prototype = Obj.extend(CSSStyleSheetPanel.prototype,
138 138
                 this.removeSystemRules(rules, sections);
139 139
         }
140 140
 
  141
+        // Reset the selection, so that clicking that starts before the view
  142
+        // update still result in proper mouseup events (issue 5500).
  143
+        this.document.defaultView.getSelection().removeAllRanges();
  144
+
141 145
         if (rules.length || sections.length)
142 146
         {
143 147
             inheritLabel = Locale.$STR("InheritedFrom");
@@ -173,6 +177,9 @@ CSSStylePanel.prototype = Obj.extend(CSSStyleSheetPanel.prototype,
173 177
 
174 178
             Events.dispatch([Firebug.A11yModel], "onCSSRulesAdded", [this, result]);
175 179
         }
  180
+
  181
+        // Avoid a flickering "disable" icon by forcing a reflow (issue 5500).
  182
+        this.panelNode.offsetHeight;
176 183
     },
177 184
 
178 185
     getStylesheetURL: function(rule, getBaseUri)
@@ -457,14 +464,11 @@ CSSStylePanel.prototype = Obj.extend(CSSStyleSheetPanel.prototype,
457 464
 
458 465
     initialize: function()
459 466
     {
460  
-        this.onMouseDown = Obj.bind(this.onMouseDown, this);
461  
-        this.onClick = Obj.bind(this.onClick, this);
462 467
         this.onStateChange = Obj.bindFixed(this.contentStateCheck, this);
463 468
         this.onHoverChange = Obj.bindFixed(this.contentStateCheck, this, STATE_HOVER);
464 469
         this.onActiveChange = Obj.bindFixed(this.contentStateCheck, this, STATE_ACTIVE);
465 470
 
466  
-        // We only need the basic panel initialize, not the intermeditate objects
467  
-        Firebug.Panel.initialize.apply(this, arguments);
  471
+        CSSStyleSheetPanel.prototype.initialize.apply(this, arguments);
468 472
     },
469 473
 
470 474
     show: function(state)
@@ -528,9 +532,6 @@ CSSStylePanel.prototype = Obj.extend(CSSStyleSheetPanel.prototype,
528 532
             return;
529 533
         }
530 534
 
531  
-        if (!element)
532  
-            return;
533  
-
534 535
         this.updateView(element);
535 536
     },
536 537
 

0 notes on commit 240a0c4

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