So what is the right approach here? I use the computed style for the border/padding/margins. To figure out when the margin is auto, I need to start using the node rules and find which one applies. Should I do that for all the values?
I think I just need to get the "bestmatch" value from the property view.
I am not confident about this approach. There might be a shorter path.
Comment on attachment 622691 [details] [diff] [review] patch v1 Review of attachment 622691 [details] [diff] [review]: ----------------------------------------------------------------- If parsing the css styles is the best way to find this, maybe you could reuse ElementStyle from CssRuleView? You can create an ElementStyle with your node, it'll do all the parsing you need. ElementStyle.rules holds a list of Rule objects, Rule.textProps has a list of TextProperty TextProperty.computed has a list of the expanded shorthand properties. Would that help you at all?
Comment on attachment 622691 [details] [diff] [review] patch v1 Looks good but Dave does have a point ... using ElementStyle would simplify things slightly.
Created attachment 626891 [details] [diff] [review] patch v2 ElementStyle would have simplified things a bit, but CssLogic simplifies them a lot.
Comment on attachment 626891 [details] [diff] [review] patch v2 Much better :) Thanks. ># HG changeset patch ># User Paul Rouget <firstname.lastname@example.org> You might want to change that. >+const Cc = Components.classes; >+const Ci = Components.interfaces; > const Cu = Components.utils; > Cu.import("resource://gre/modules/Services.jsm"); > Cu.import("resource:///modules/inspector.jsm"); > Cu.import("resource:///modules/devtools/LayoutHelpers.jsm"); >+Cu.import("resource:///modules/devtools/CssLogic.jsm"); > > var EXPORTED_SYMBOLS = ["LayoutView"]; > >+// Used to split on css line separators >+const CSS_LINE_RE = /(?:[^;\(]*(?:\([^\)]*?\))?[^;\(]*)*;?/g; >+ >+// Used to parse a single property line. >+const CSS_PROP_RE = /\s*([^:\s]*)\s*:\s*(.*?)\s*(?:! (important))?;?$/; >+ I don't think you need these changes anymore.
https://hg.mozilla.org/integration/fx-team/rev/4798809c94d6 (I made the changes from Comment 8)