Closed Bug 1167669 Opened 9 years ago Closed 9 years ago

[rule view] Rules and properties that are newly added or modified should be highlighted if it matches the style filter

Categories

(DevTools :: Inspector, defect)

defect
Not set
normal

Tracking

(firefox42 fixed)

RESOLVED FIXED
Firefox 42
Tracking Status
firefox42 --- fixed

People

(Reporter: gl, Assigned: gl)

References

Details

Attachments

(4 files, 13 obsolete files)

15.64 KB, patch
bgrins
: review+
Details | Diff | Splinter Review
9.21 KB, patch
bgrins
: review+
Details | Diff | Splinter Review
7.13 KB, patch
Details | Diff | Splinter Review
12.57 KB, patch
Details | Diff | Splinter Review
Currently, the filter styles does not apply a highlight to rules and properties that are newly added or modified and matches the filter style search value.
Depends on: 1120616
Assignee: nobody → gabriel.luong
Status: NEW → ASSIGNED
Depends on: 1159922
No longer depends on: 1120616
Attachment #8632680 - Flags: review?(bgrinstead)
Summary of Changes:
- Broke apart CssRuleView.highlightRules and moved the logical components for highlighting selectors and stylesheet source into RuleEditor and highlighting properties and computed properties to TextPropertyEditor
- Removed isValidSearchTerm trim check since we should allow people to search for " " if they wanted.
- Added this.ruleView reference to TextPropertyEditor
Attachment #8632680 - Attachment is obsolete: true
Attachment #8633044 - Flags: review?(bgrinstead)
Attachment #8633046 - Flags: review?(bgrinstead)
Attachment #8633047 - Attachment is obsolete: true
Attachment #8633047 - Flags: review?(bgrinstead)
Attachment #8633053 - Flags: review?(bgrinstead)
Looks like this might interact with the work going on in Bug 1164343 - should we mark one as blocking the other?  I'm assuming it'd be easier for you to rebase on top of that when it's all said and done than vice versa?
(In reply to Brian Grinstead [:bgrins] from comment #7)
> Looks like this might interact with the work going on in Bug 1164343 -
> should we mark one as blocking the other?  I'm assuming it'd be easier for
> you to rebase on top of that when it's all said and done than vice versa?

I applied both changes, and the overlaps are very little. The only reject that I saw was for the new getter for the searchValue which is just a 4 line rebase. This would be safe to review.
ttps://treeherder.mozilla.org/#/jobs?repo=try&revision=4db2a7c48190
Attachment #8633346 - Attachment is obsolete: true
Attachment #8633346 - Flags: review?(bgrinstead)
Attachment #8633051 - Attachment is obsolete: true
Attachment #8633051 - Flags: review?(bgrinstead)
Attachment #8634850 - Flags: review?(bgrinstead)
Attachment #8633053 - Attachment is obsolete: true
Attachment #8633053 - Flags: review?(bgrinstead)
Attachment #8634852 - Flags: review?(bgrinstead)
Comment on attachment 8634849 [details] [diff] [review]
Part 1: Refactor CssRuleView highlighting of rule selector, property and stylesheet source to RuleEditor and TextPropertyEditor [3.0]

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

This is a general comment about parts 1 and 2.  Although I agree the search matching behavior for a rule 'belongs' to the editors, I'm not a big fan of splitting the one nasty function into these functions across the file.  Mostly because (a) we could at least before point to one place that all search stuff was happening and (b) we end up having to reach up to the rule view from the editors to do things like get the current search value, add highlight classes, clear the 'no-match' class, etc.

Of those, (b) is of more concern.  I think I'd be most happy if we kept the bulk of the logic of _highlightRuleProperty, _highlightComputedProperty in the editor, but renamed it to _getMatchingRuleProperty and _getMatchingComputedProperty, then those would return arrays of elements that matched and the rule view would be in charge of actually adding the class, maintaining the state of the search box, etc.  This would especially help I think when part 2 starts to introduce more ruleview specific functionality into the TPE.  So it would look something like this:

  let matchedRules = textProp.editor._getMatchingRuleProperty(this.searchPropertyName, this.searchPropertyValue, this.searchPropertyMatch);
  let isPropertyHighlighted = matchedRules.length > 0;

  for (let rule of matchedRules) {
    rule.classList.add("ruleview-highlight");
  }

We could do similar things for all of the _highlight* functions introduced in the refactor and maybe even keep one big list of things that need their classList updated and do all the updates at once to limit the amount of style recalc.

Alternatively, I'd be fine with splitting things up as you propose, but keeping _highlightRuleProperty, _highlightComputedProperty, _highlightMatches, and then _updateRulePropertyHighlight, _clearRulePropertyHighlights on the rule view and take a rule in as an argument.  Personally I think it makes more sense to have the ruleview manage the TPE than have the TPE manage the rule view.

Thanks for taking this on - this is touching some complicated parts of the rule view so I just want to make sure we are on the same page before proceeding.  Let's chat if you disagree or want further clarification.
Attachment #8634849 - Flags: review?(bgrinstead)
Comment on attachment 8634850 [details] [diff] [review]
Part 2: Highlight new filter style matches when rules and properties are added or modified [3.0]

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

See comments from part 1

::: browser/devtools/styleinspector/rule-view.js
@@ +2987,5 @@
> +
> +    // Highlight the new property if it matches the current search value
> +    // and remove the no search match indicator from the search field if
> +    // a property or computed property was highlighted
> +    if (this._updateRulePropertyHighlight() &&

This is a particular case where it'd be nice to say this.ruleView.highlightRule(this) or similar, and then can get any search box logic out of this object.

@@ +3069,5 @@
>    /**
> +   * Clear the rule property highlight for the current TextProperty.
> +   */
> +  _clearRulePropertyHighlights: function() {
> +    for (let element of this.element.querySelectorAll(".ruleview-highlight")) {

This another case where I'd prefer to see the this.ruleView._editorsExpandedForFilter logic handled from within the rule view.
Attachment #8634850 - Flags: review?(bgrinstead)
Comment on attachment 8634852 [details] [diff] [review]
Part 3: Refactor this.ruleEditor.ruleView to this.ruleView in TextPropertyEditor [3.0]

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

LGTM
Attachment #8634852 - Flags: review?(bgrinstead) → review+
Comment on attachment 8634853 [details] [diff] [review]
Part 4: Add unit tests for highlighting new filter style matches when rule properties are added and modified [3.0]

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

Test cases and overall functionality looks good with the patches applied
Attachment #8634853 - Flags: review?(bgrinstead) → review+
Attachment #8636278 - Attachment description: art 3: Refactor this.ruleEditor.ruleView to this.ruleView in TextPropertyEditor [4.0] → Part 3: Refactor this.ruleEditor.ruleView to this.ruleView in TextPropertyEditor [4.0]
Comment on attachment 8636276 [details] [diff] [review]
Part 1: Refactor the logic for highlighting rule selector, property and stylesheet source [4.0]

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

LGTM - r=me with a green try push
Attachment #8636276 - Flags: review?(bgrinstead) → review+
Attachment #8636277 - Flags: review?(bgrinstead) → review+
Product: Firefox → DevTools
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: