Closed Bug 886037 Opened 11 years ago Closed 11 years ago

Add a styles actor for the style inspectors

Categories

(DevTools :: Inspector, defect)

x86
macOS
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED
Firefox 26

People

(Reporter: dcamp, Assigned: dcamp)

References

Details

Attachments

(1 file, 4 obsolete files)

      No description provided.
Attached patch styles-actor.diff (obsolete) — Splinter Review
Attachment #785176 - Flags: review?(jwalker)
Comment on attachment 785176 [details] [diff] [review]
styles-actor.diff

This doesn't have tests of its own (although it does pass the rule view and style inspector tests when they are ported).  Switching from review to feedback while I get those tests written.
Attachment #785176 - Flags: review?(jwalker) → feedback?(jwalker)
Comment on attachment 785176 [details] [diff] [review]
styles-actor.diff

Review of attachment 785176 [details] [diff] [review]:
-----------------------------------------------------------------

Several console/dump calls to remove. Guess you're expecting that nit.

There are a few places where I wasn't sure of your intent - like why htmlComplete went away. I'm know you get a better review if I don't have to work that out for myself, and I'm fairly sure that there is a net benefit to Mozilla too.

Not finished reviewing yet. Not looked at styles.js, and only part way through computed-view.js. Will complete when home.

::: toolkit/devtools/styleinspector/css-logic.js
@@ +63,5 @@
>   * Special values for filter, in addition to an href these values can be used
>   */
>  CssLogic.FILTER = {
> +  ALL: "user", // show properties from all user style sheets
> +  USER: "user",

Would s/ALL/USER be hard? My gut is that we should do it.
Attached patch styles-actor.diff (obsolete) — Splinter Review
This version has tests for `getApplied` and `modifyProperties` but still needs some tests for computed styles and matched selectors.
Attachment #785176 - Attachment is obsolete: true
Attachment #785176 - Flags: feedback?(jwalker)
I think I'm happy with the tests now.

Previous patches had some porting gunk, that's been removed.
Attachment #786089 - Attachment is obsolete: true
Attachment #786735 - Flags: review?(jwalker)
Sorry, missed your earlier comments:

The htmlComplete stuff didn't belong in this patch, sorry.  Let me know where else you need intent explained.

s/ALL/USER/ wouldn't be hard at all, but might be clearer in an immediate followup?  Or at least a separate patch on this bug, up to you.
Comment on attachment 786735 [details] [diff] [review]
styles-actor.diff

Review of attachment 786735 [details] [diff] [review]:
-----------------------------------------------------------------

::: toolkit/devtools/server/actors/styles.js
@@ +139,5 @@
> +    this.cssLogic.highlight(node.rawNode);
> +    let computed = this.cssLogic._computedStyle;
> +
> +    Array.prototype.forEach.call(computed, name => {
> +      let matched = undefined;

Unused?

@@ +206,5 @@
> +   *     // The full form of any sheets referenced.
> +   *     sheets: [ <domsheet>, ... ]
> +   *  }
> +   */
> +  getMatchedSelectors: method(function(node, property, options) {

got here

@@ +219,5 @@
> +    let matched = [];
> +    let propInfo = this.cssLogic.getPropertyInfo(property);
> +    for (let selectorInfo of propInfo.matchedSelectors) {
> +      let cssRule = selectorInfo.selector._cssRule;
> +      let domRule = cssRule.sourceElement || cssRule._domRule;

We should have a clear picture of what _ means. I've generally used it to mean "don't use a _ property unless it's used as this._" i.e. the common definition of private. There is an alternative definition which is "If you use this and it breaks, that's your fault". I wonder if we shouldn't make _cssRule and _domRule (and others) 'public' if we commonly need them outside of the class in which they're defined.

@@ +255,5 @@
> +  }),
> +
> +  // Get a selector source for a CssSelectorInfor relative to a given
> +  // node.
> +  // XXX: This could probably be done in the frontend?

I'm not sure I'm 100% behind Mozilla style here, but aren't we supposed to raise a bug rather than XXXing.

@@ +317,5 @@
> +    }
> +
> +    let rules = new Set;
> +    let sheets = new Set;
> +    entries.forEach(entry => rules.add(entry.rule));

entries.forEach(entry => { rules.add(entry.rule); });

For great ES6 win.

@@ +667,5 @@
> +  /**
> +   * Return a new RuleModificationList for this node.
> +   */
> +  startModifyingProperties: function() {
> +  return new RuleModificationList(this);

indentation nit
Attachment #786735 - Flags: review?(jwalker) → review+
(In reply to Joe Walker [:jwalker] from comment #7)
> Comment on attachment 786735 [details] [diff] [review]
> styles-actor.diff
> @@ +219,5 @@
> > +    let matched = [];
> > +    let propInfo = this.cssLogic.getPropertyInfo(property);
> > +    for (let selectorInfo of propInfo.matchedSelectors) {
> > +      let cssRule = selectorInfo.selector._cssRule;
> > +      let domRule = cssRule.sourceElement || cssRule._domRule;
> 
> We should have a clear picture of what _ means. I've generally used it to
> mean "don't use a _ property unless it's used as this._" i.e. the common
> definition of private. There is an alternative definition which is "If you
> use this and it breaks, that's your fault". I wonder if we shouldn't make
> _cssRule and _domRule (and others) 'public' if we commonly need them outside
> of the class in which they're defined.

Fair enough - I do need the raw rules, so I can make those public.

> @@ +255,5 @@
> > +  }),
> > +
> > +  // Get a selector source for a CssSelectorInfor relative to a given
> > +  // node.
> > +  // XXX: This could probably be done in the frontend?
> 
> I'm not sure I'm 100% behind Mozilla style here, but aren't we supposed to
> raise a bug rather than XXXing.

I'll just remove that comment for now.  I tried to do it in the frontend and it involved a lot more work.
 
> @@ +317,5 @@
> > +    }
> > +
> > +    let rules = new Set;
> > +    let sheets = new Set;
> > +    entries.forEach(entry => rules.add(entry.rule));
> 
> entries.forEach(entry => { rules.add(entry.rule); });
> 
> For great ES6 win.

While "function() expression" is not legal ES6, "() => expression" is, see http://wiki.ecmascript.org/doku.php?id=harmony:arrow_function_syntax
Blocks: 886038
Attached patch csslogic-filter-rename.diff (obsolete) — Splinter Review
Removes the old FILTER.ALL
Attachment #787148 - Flags: review?(jwalker)
Attached patch csslogic-public-domrules.diff (obsolete) — Splinter Review
Makes public the CssLogic properties we use.
Attachment #787149 - Flags: review?(jwalker)
https://hg.mozilla.org/integration/fx-team/rev/986f7c642b9f
Assignee: nobody → dcamp
Whiteboard: [fixed-in-fx-team]
Comment on attachment 787148 [details] [diff] [review]
csslogic-filter-rename.diff

Moved to a followup
Attachment #787148 - Attachment is obsolete: true
Attachment #787148 - Flags: review?(jwalker)
Comment on attachment 787149 [details] [diff] [review]
csslogic-public-domrules.diff

Moved to a followup
Attachment #787149 - Attachment is obsolete: true
Attachment #787149 - Flags: review?(jwalker)
https://hg.mozilla.org/mozilla-central/rev/b14e58f0e3ab
Status: NEW → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
Whiteboard: [fixed-in-fx-team]
Target Milestone: --- → Firefox 26
Product: Firefox → DevTools
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: