Skip to content
Browse files

Moved editElementStyle() to stylePanel.js and used the element's style

as repObject
  • Loading branch information...
1 parent 555d229 commit 6e07bc86ac2b312dd9b37da9efea4f713f168e83 @SebastianZ SebastianZ committed Aug 23, 2012
Showing with 39 additions and 35 deletions.
  1. +8 −33 extension/content/firebug/css/cssPanel.js
  2. +31 −2 extension/content/firebug/css/stylePanel.js
View
41 extension/content/firebug/css/cssPanel.js
@@ -588,32 +588,6 @@ Firebug.CSSStyleSheetPanel.prototype = Obj.extend(Firebug.Panel,
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
- editElementStyle: function()
- {
- var rulesBox = this.panelNode.getElementsByClassName("cssElementRuleContainer")[0];
- var styleRuleBox = rulesBox && Firebug.getElementByRepObject(rulesBox, this.selection);
- if (!styleRuleBox)
- {
- var rule = {rule: this.selection, inherited: false, selector: "element.style", props: []};
- if (!rulesBox)
- {
- // The element did not have any displayed styles. We need to create the
- // whole tree and remove the no styles message
- styleRuleBox = this.template.cascadedTag.replace({
- rules: [rule], inherited: [], inheritLabel: Locale.$STR("InheritedFrom")
- }, this.panelNode);
-
- styleRuleBox = styleRuleBox.getElementsByClassName("cssElementRuleContainer")[0];
- }
- else
- styleRuleBox = this.template.ruleTag.insertBefore({rule: rule}, rulesBox);
-
- styleRuleBox = styleRuleBox.getElementsByClassName("insertInto")[0];
- }
-
- Firebug.Editor.insertRowForObject(styleRuleBox);
- },
-
addRelatedRule: function()
{
if (!this.panelNode.getElementsByClassName("cssElementRuleContainer")[0])
@@ -1655,15 +1629,15 @@ CSSEditor.prototype = domplate(Firebug.InlineEditor.prototype,
var rule = Firebug.getRepObject(target);
- if (rule instanceof window.CSSStyleRule || rule instanceof window.Element)
+ if (rule instanceof window.CSSStyleRule || rule instanceof window.CSSStyleDeclaration)
{
if (Css.hasClass(target, "cssPropName"))
{
if (value && previousValue != value) // name of property has changed.
{
- // Record the original CSS text for the inline case so we can reconstruct at a later
- // point for diffing purposes
+ // Record the original CSS text for the inline case so we can reconstruct at a
+ // later point for diffing purposes
var baseText = rule.style ? rule.style.cssText : rule.cssText;
propValue = Dom.getChildByClass(row, "cssPropValue").textContent;
@@ -1686,8 +1660,8 @@ CSSEditor.prototype = domplate(Firebug.InlineEditor.prototype,
parsedValue.priority);
}
- Events.dispatch(CSSModule.fbListeners, "onCSSPropertyNameChanged", [rule, value,
- previousValue, baseText]);
+ Events.dispatch(CSSModule.fbListeners, "onCSSPropertyNameChanged", [rule,
+ value, previousValue, baseText]);
}
else if (!value)
{
@@ -1721,15 +1695,16 @@ CSSEditor.prototype = domplate(Firebug.InlineEditor.prototype,
if (value)
{
- var saveSuccess = !!rule.style.getPropertyValue(propName || value);
+ var style = rule.style || rule;
+ var saveSuccess = !!style.getPropertyValue(propName || value);
if(!saveSuccess && !propName)
{
propName = value.replace(/-./g, function(match)
{
return match[1].toUpperCase()
});
- if (propName in rule.style || propName == "float")
+ if (propName in style || propName == "float")
saveSuccess = "almost";
}
View
33 extension/content/firebug/css/stylePanel.js
@@ -448,9 +448,9 @@ CSSStylePanel.prototype = Obj.extend(CSSStyleSheetPanel.prototype,
this.markOverriddenProps(element, props, usedProps, inheritMode);
- if (props.length)
+ if (props.length != 0)
{
- rules.unshift({rule: element, id: Xpath.getElementXPath(element),
+ rules.unshift({rule: element.style, id: Xpath.getElementXPath(element),
selector: "element.style", props: props, inherited: inheritMode});
}
},
@@ -460,6 +460,34 @@ CSSStylePanel.prototype = Obj.extend(CSSStyleSheetPanel.prototype,
Firebug.chrome.select(rule, "stylesheet");
},
+ editElementStyle: function()
+ {
+ var rulesBox = this.panelNode.getElementsByClassName("cssElementRuleContainer")[0];
+ var styleRuleBox = rulesBox && Firebug.getElementByRepObject(rulesBox, this.selection);
+ if (!styleRuleBox)
+ {
+ FBTrace.sysout("this.selection.style", this.selection.style);
+ var rule = {rule: this.selection.style, inherited: false, selector: "element.style", props: []};
+ if (!rulesBox)
+ {
+ // The element did not have any displayed styles. We need to create the
+ // whole tree and remove the no styles message
+ styleRuleBox = this.template.cascadedTag.replace({
+ rules: [rule], inherited: [], inheritLabel: Locale.$STR("InheritedFrom")
+ }, this.panelNode);
+
+ styleRuleBox = styleRuleBox.getElementsByClassName("cssElementRuleContainer")[0];
+ }
+ else
+ styleRuleBox = this.template.ruleTag.insertBefore({rule: rule}, rulesBox);
+
+ styleRuleBox = styleRuleBox.getElementsByClassName("insertInto")[0];
+ }
+
+ FBTrace.sysout("styleRuleBox", styleRuleBox);
+ Firebug.Editor.insertRowForObject(styleRuleBox);
+ },
+
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// extends Panel
@@ -624,6 +652,7 @@ CSSStylePanel.prototype = Obj.extend(CSSStyleSheetPanel.prototype,
{
var items = CSSStyleSheetPanel.prototype.getContextMenuItems.apply(this, [style, target]);
var insertIndex = 0;
+ var isElementStyle = style instanceof window.CSSStyleDeclaration && !style.parentRule;
for (var i = 0; i < items.length; ++i)
{

0 comments on commit 6e07bc8

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