Closed Bug 757253 Opened 13 years ago Closed 13 years ago

Implement real update in the rule view

Categories

(DevTools :: Inspector, defect)

13 Branch
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED
Firefox 15

People

(Reporter: dcamp, Assigned: dcamp)

References

Details

Attachments

(1 file, 1 obsolete file)

Attached patch v1 (obsolete) — Splinter Review
The rule view doesn't have a real refresh method. When we refresh for pseudo-class lock it's a complete destroy + rebuild, which can lose a small amount of user data (disabled properties, doubled-up properties, etc) as well as being a bit inefficient. Attached patch implements a real refresh method for the rule view. Asking for review from Rob because he did the initial rule view review, but if paul wants to steal the review I wouldn't complain.
Attachment #625796 - Flags: review?(rcampbell)
(I think you forgot to remove a couple of dump calls)
Indeed, will get rid of them in the next version of the patch.
Comment on attachment 625796 [details] [diff] [review] v1 - let rule = new Rule(this, aOptions); + let rule = null; + + // If we're refreshing and the rule previously existed, reuse the + // Rule object. + for each (let r in (this._refreshRules || [])) { + if (r.matches(aOptions)) { + rule = r; + rule.refresh(); + break; + } + } + + // If this is a new rule, create its Rule object. + if (!rule) { + rule = new Rule(this, aOptions); + } I might rework this a bit. let rule = null; for each (rule in (this._refreshRules || [])) { if (rule.matches(aOptions)) { rule.refresh(); break; } } gets rid of an extra assignment, I think. /** + * Returns true if the rule matches the creation options + * specified. + */ + matches: function Rule_matches(aOptions) + { + return (this.style === (aOptions.style || aOptions.domRule.style)); + }, Could use an @param on your javadoc. NIT in _getTextProperties: in for each loop: if(!matches || !matches[2]) continue; missing space. + _updateTextProperty: function Rule__updateTextProperty(aNewProp) { could use an @param in your javadoc. + let rank = 1; maybe add a comment // 1 for matching name + if (prop.enabled) { + rank += 1; + } that's only worth 1? :) After reading through this, I might score the rankings in your method comment: + * Name, value, and priority match, enabled. (6) + * Name, value, and priority match, disabled. (5) + * Name and value match, enabled (4) + * Name and value match, disabled (3) + * Name matches, enabled (2) + * Name matches, disabled. (1) not sure if that helps or not. in nodeChanged: + dump("Refresh took " + (end - start) + "ms\n"); one of the missed dumps, I presume. don't forget the start and end times.
Attachment #625796 - Flags: review?(rcampbell) → review+
(In reply to Rob Campbell [:rc] (:robcee) from comment #3) > Comment on attachment 625796 [details] [diff] [review] > v1 > > - let rule = new Rule(this, aOptions); > + let rule = null; > + > + // If we're refreshing and the rule previously existed, reuse the > + // Rule object. > + for each (let r in (this._refreshRules || [])) { > + if (r.matches(aOptions)) { > + rule = r; > + rule.refresh(); > + break; > + } > + } > + > + // If this is a new rule, create its Rule object. > + if (!rule) { > + rule = new Rule(this, aOptions); > + } > > I might rework this a bit. > > let rule = null; > for each (rule in (this._refreshRules || [])) { Make this a for...of loop: for (foo of (this._refreshRules || [])) {
Blocks: 740543
Attached patch v2Splinter Review
Attachment #625796 - Attachment is obsolete: true
(In reply to Rob Campbell [:rc] (:robcee) from comment #3) > I might rework this a bit. > > let rule = null; > for each (rule in (this._refreshRules || [])) { > if (rule.matches(aOptions)) { > rule.refresh(); > break; > } > } > > gets rid of an extra assignment, I think. Yeah, but it leaves rule assigned if rule didn't match any rule. I didn't come up with a more compact way to do this. > + matches: function Rule_matches(aOptions) > Could use an @param on your javadoc. Done. > NIT in _getTextProperties: > missing space. Done. > + _updateTextProperty: function Rule__updateTextProperty(aNewProp) { > could use an @param in your javadoc. Done. > + let rank = 1; > > maybe add a comment // 1 for matching name > > + if (prop.enabled) { > + rank += 1; > + } > > that's only worth 1? :) I beefed up inline comments about the ranking system. > > After reading through this, I might score the rankings in your method > comment: > not sure if that helps or not. I think it did, I added those. > in nodeChanged: > + dump("Refresh took " + (end - start) + "ms\n"); > > one of the missed dumps, I presume. don't forget the start and end times. Stripped out that dump and associated timers. (In reply to Dão Gottwald [:dao] from comment #4) > Make this a for...of loop: > for (foo of (this._refreshRules || [])) { Indeed, I did this throughout the patch.
Whiteboard: [fixed-in-fx-team]
Status: ASSIGNED → RESOLVED
Closed: 13 years ago
Resolution: --- → FIXED
Whiteboard: [fixed-in-fx-team]
Target Milestone: --- → Firefox 15
Product: Firefox → DevTools
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: