Skip to content
Browse files

wip

  • Loading branch information...
1 parent 5f2cda4 commit f7a7bfa4ef6bd31a332ed1f9e6a0bc693bd06649 Simon Lindholm committed
Showing with 28 additions and 15 deletions.
  1. +9 −1 extension/content/firebug/css/cssModule.js
  2. +19 −14 extension/content/firebug/css/saving/manager.js
View
10 extension/content/firebug/css/cssModule.js
@@ -432,14 +432,22 @@ Firebug.CSSModule = Obj.extend(Obj.extend(Firebug.Module, Firebug.EditorSelector
translateName: function(name, value)
{
// Don't show these proprietary Mozilla properties
+ // XXX test this with RTL locale
if (value == "-moz-initial" && /^-moz-background-(clip|origin|inline-policy)$/.test(name))
return null;
if (value == "physical" && /^(margin|padding)-(left|right)-(ltr|rtl)-source$/.test(name))
return null;
+ if (value == "physical" && /^border-(left|right)-(color|style|width)-(ltr|rtl)-source$/.test(name))
+ return null;
+ if (value == "none" && /^-moz-border-[^-]*-colors$/.test(name))
+ return null;
// Translate these back to the form the user probably expects
- if (/^(margin|padding)-(left|right)-value$/.test(name))
+ if (/^(margin|padding)-(left|right)-value$/.test(name) ||
+ /^border-(left|right)-(color|style|width)-value$/.test(name))
+ {
name = name.slice(0, -6);
+ }
return name;
},
View
33 extension/content/firebug/css/saving/manager.js
@@ -64,25 +64,30 @@ function RuleInfo(rule)
{
this.selector = rule.selectorText;
- // like parseCSSProps, but with sorting, and with translateName. maybe we
- // should respect expandShorthandProps somehow. (it would make us able to
- // describe the addition of "padding: 1px" correctly!)
- // maybe we should stripUnits(, false).
- //this.props = CSSModule.parseCSSProps(rule.style, Firebug.expandShorthandProps);
- var style = rule.style, props = [], propMap = new Map();
- for (var i = 0, len = style.length; i < len; ++i)
+ // maybe we should respect expandShorthandProps somehow. maybe we should stripUnits(, false).
+
+ // okay, so, the problem here is that we don't know how the original looked, really.
+ // parseCSSProps(, false) seems like a very reasonable guess, but it could be wrong!
+ // so if we see that margin: 1px is changed to margin: 2px, then we should also
+ // remove properties margin-*.
+ // remember the fun case of: "border: 1px solid black; border-left-style: none;"
+ // (not that Firebug handles that nicely either :) ) (well, it does reasonably,
+ // except it leaves behind -moz-border-*-colors: none (wtf, we should exclude
+ // that in translateName))
+
+ var props = CSSModule.parseCSSProps(rule.style, false);
+ var text = "", propMap = new Map();
+ props.forEach(function(prop)
{
- var name = style.item(i);
- var value = style.getPropertyValue(name);
- var priority = style.getPropertyPriority(name);
- name = CSSModule.translateName(name, value);
+ var name = CSSModule.translateName(prop.name, prop.value);
if (!name)
- continue;
- props.push(name + ":" + Css.stripUnits(value, true) + " " + priority);
+ return;
+ var value = Css.stripUnits(prop.value, true);
+ text += name + ":" + value + (priority ? "1" : "0") + ";";
propMap.set(name, value + (priority ? " " + priority : ""));
}
+ this.text = text;
this.properties = propMap;
- this.text = props.sort().join(";");
}
RuleInfo.prototype.verySimilar = function(other)

0 comments on commit f7a7bfa

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