Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Issue 5500: Clicking style side panel things fails randomly

  • Loading branch information...
commit 240a0c4f8c7957c7e4a90e1ca395cf57b08b715b 1 parent 0423e62
@simonlindholm simonlindholm authored
View
74 extension/content/firebug/css/cssPanel.js
@@ -709,33 +709,70 @@ Firebug.CSSStyleSheetPanel.prototype = Obj.extend(Firebug.Panel,
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+ // When handling disable button clicks, we cannot simply use a 'click'
+ // event, because refresh() may be (and often is) called in between
+ // mousedown and mouseup, replacing the DOM structure. Instead, a
+ // description of the moused-down disable button's property is saved
+ // and explicitly checked on mouseup (issue 5500).
+ clickedPropTag: null,
+
+ getPropTag: function(event)
+ {
+ var row = Dom.getAncestorByClass(event.target, "cssProp");
+ var rule = Firebug.getRepObject(row);
+ var propName = Dom.getChildByClass(row, "cssPropName").textContent;
+ return {
+ a: rule, b: propName,
+ equals: function(other)
+ {
+ return (other && this.a === other.a && this.b === other.b);
+ }
+ };
+ },
+
+ clickedDisableButton: function(event)
+ {
+ // XXX hack
+ if (event.clientX > 20)
+ return false;
+ if (Css.hasClass(event.target, "textEditor inlineExpander"))
+ return false;
+ var row = Dom.getAncestorByClass(event.target, "cssProp");
+ return (row && Css.hasClass(row, "editGroup"));
+ },
+
onMouseDown: function(event)
{
+ this.clickedPropTag = null;
+ if (Events.isLeftClick(event) && this.clickedDisableButton(event))
+ {
+ this.clickedPropTag = this.getPropTag(event);
+
+ // Don't select text when double-clicking the disable button.
+ Events.cancelEvent(event);
+ }
},
- onClick: function(event)
+ onMouseUp: function(event)
{
- var row;
+ if (Events.isLeftClick(event) && this.clickedDisableButton(event) &&
+ this.getPropTag(event).equals(this.clickedPropTag))
+ {
+ var row = Dom.getAncestorByClass(event.target, "cssProp");
+ this.disablePropertyRow(row);
+ Events.cancelEvent(event);
+ }
+ this.clickedPropTag = null;
+ },
+ onClick: function(event)
+ {
if (!Events.isLeftClick(event))
return;
- // XXjoe Hack to only allow clicking on the checkbox
- if ((event.clientX <= 20) && Events.isSingleClick(event))
- {
- if (Css.hasClass(event.target, "textEditor inlineExpander"))
- return;
-
- row = Dom.getAncestorByClass(event.target, "cssProp");
- if (row && Css.hasClass(row, "editGroup"))
- {
- this.disablePropertyRow(row);
- Events.cancelEvent(event);
- }
- }
- else if ((event.clientX >= 20) && Events.isDoubleClick(event))
+ if (Events.isDoubleClick(event) && !this.clickedDisableButton(event))
{
- row = Dom.getAncestorByClass(event.target, "cssRule");
+ var row = Dom.getAncestorByClass(event.target, "cssRule");
if (row && !Dom.getAncestorByClass(event.target, "cssPropName")
&& !Dom.getAncestorByClass(event.target, "cssPropValue"))
{
@@ -759,6 +796,7 @@ Firebug.CSSStyleSheetPanel.prototype = Obj.extend(Firebug.Panel,
initialize: function()
{
this.onMouseDown = Obj.bind(this.onMouseDown, this);
+ this.onMouseUp = Obj.bind(this.onMouseUp, this);
this.onClick = Obj.bind(this.onClick, this);
Firebug.Panel.initialize.apply(this, arguments);
@@ -778,6 +816,7 @@ Firebug.CSSStyleSheetPanel.prototype = Obj.extend(Firebug.Panel,
initializeNode: function(oldPanelNode)
{
Events.addEventListener(this.panelNode, "mousedown", this.onMouseDown, false);
+ Events.addEventListener(this.panelNode, "mouseup", this.onMouseUp, false);
Events.addEventListener(this.panelNode, "click", this.onClick, false);
Firebug.Panel.initializeNode.apply(this, arguments);
@@ -786,6 +825,7 @@ Firebug.CSSStyleSheetPanel.prototype = Obj.extend(Firebug.Panel,
destroyNode: function()
{
Events.removeEventListener(this.panelNode, "mousedown", this.onMouseDown, false);
+ Events.removeEventListener(this.panelNode, "mouseup", this.onMouseUp, false);
Events.removeEventListener(this.panelNode, "click", this.onClick, false);
Firebug.Panel.destroyNode.apply(this, arguments);
View
15 extension/content/firebug/css/stylePanel.js
@@ -138,6 +138,10 @@ CSSStylePanel.prototype = Obj.extend(CSSStyleSheetPanel.prototype,
this.removeSystemRules(rules, sections);
}
+ // Reset the selection, so that clicking that starts before the view
+ // update still result in proper mouseup events (issue 5500).
+ this.document.defaultView.getSelection().removeAllRanges();
+
if (rules.length || sections.length)
{
inheritLabel = Locale.$STR("InheritedFrom");
@@ -173,6 +177,9 @@ CSSStylePanel.prototype = Obj.extend(CSSStyleSheetPanel.prototype,
Events.dispatch([Firebug.A11yModel], "onCSSRulesAdded", [this, result]);
}
+
+ // Avoid a flickering "disable" icon by forcing a reflow (issue 5500).
+ this.panelNode.offsetHeight;
},
getStylesheetURL: function(rule, getBaseUri)
@@ -457,14 +464,11 @@ CSSStylePanel.prototype = Obj.extend(CSSStyleSheetPanel.prototype,
initialize: function()
{
- this.onMouseDown = Obj.bind(this.onMouseDown, this);
- this.onClick = Obj.bind(this.onClick, this);
this.onStateChange = Obj.bindFixed(this.contentStateCheck, this);
this.onHoverChange = Obj.bindFixed(this.contentStateCheck, this, STATE_HOVER);
this.onActiveChange = Obj.bindFixed(this.contentStateCheck, this, STATE_ACTIVE);
- // We only need the basic panel initialize, not the intermeditate objects
- Firebug.Panel.initialize.apply(this, arguments);
+ CSSStyleSheetPanel.prototype.initialize.apply(this, arguments);
},
show: function(state)
@@ -528,9 +532,6 @@ CSSStylePanel.prototype = Obj.extend(CSSStyleSheetPanel.prototype,
return;
}
- if (!element)
- return;
-
this.updateView(element);
},
Please sign in to comment.
Something went wrong with that request. Please try again.