Note: There are a few cases of duplicates in user autocompletion which are being worked on.

Style Inspector needs a no-results placeholder

RESOLVED FIXED in Firefox 10

Status

()

Firefox
Developer Tools
P2
normal
RESOLVED FIXED
6 years ago
6 years ago

People

(Reporter: dcamp, Assigned: miker)

Tracking

unspecified
Firefox 10
x86
All
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

(Whiteboard: [minotaur][styleinspector][fixed-in-fx-team])

Attachments

(1 attachment, 5 obsolete attachments)

(Reporter)

Description

6 years ago
When an element has no user styles, or when we search for a string that doesn't exist, there should be some sort of placeholder text rather than a blank style inspector.
(Reporter)

Updated

6 years ago
OS: Mac OS X → All
Whiteboard: [minotaur]
True, very true
Whiteboard: [minotaur] → [minotaur][styleinspector]
Assignee: nobody → mratcliffe
Depends on: 672748
Created attachment 564617 [details] [diff] [review]
Patch 1
Attachment #564617 - Flags: review?(mihai.sucan)
Comment on attachment 564617 [details] [diff] [review]
Patch 1

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

Patch looks good. Tests pass!

Please address the comments below. Thank you!

::: browser/devtools/styleinspector/CssHtmlTree.jsm
@@ +230,5 @@
>              this.gotoMdnIcon.addEventListener("click", function() {
>                this.win.open(PropertyView.link, "MDNWindow");
>              }.bind(this));
> +            this.noResults.style.display = this.numVisibleProperties ?
> +                                           "none" : "block";

Please use noResults.hidden.

@@ +245,5 @@
>     */
>    refreshPanel: function CssHtmlTree_refreshPanel()
>    {
>      this.win.clearTimeout(this._panelRefreshTimeout);
> +    this.noResults.style.display = "none";

Same as above.

@@ +269,5 @@
>          // display the next batch of 15.
>          this._panelRefreshTimeout = this.win.setTimeout(refreshView.bind(this), 0);
>        } else {
> +        this.noResults.style.display = this.numVisibleProperties ?
> +                                       "none" : "block";

Same as above.

@@ +501,5 @@
>    {
>      if (!this.visible) {
>        return;
>      }
> +    this.tree.numVisibleProperties++;

This should be in PropertyView.refresh().

::: browser/devtools/styleinspector/test/browser/browser_styleinspector_bug_689759_no_results_placeholder.js
@@ +11,5 @@
> +{
> +  doc.body.innerHTML = '<style type="text/css"> ' +
> +    '.matches {color: #F00;}</style>' +
> +    '<span id="matches" class="matches">Some styled text</span>' +
> +    '</div>';

There's no open tag for <div>.

@@ +27,5 @@
> +
> +  ok(stylePanel.isOpen(), "style inspector is open");
> +
> +  Services.obs.addObserver(SI_AddFilterText, "StyleInspector-populated", false);
> +  SI_inspectNode();

You can merge SI_inspectNode() into runStyleInspectorTests().

@@ +32,5 @@
> +}
> +
> +function SI_inspectNode()
> +{
> +  var span = doc.querySelector("#matches");

s/var/let/

@@ +49,5 @@
> +{
> +  Services.obs.removeObserver(SI_AddFilterText, "StyleInspector-populated", false);
> +
> +  let iframe = stylePanel.querySelector("iframe");
> +  let searchbar = iframe.contentDocument.querySelector(".searchfield");

You can do:
let searchbar = stylePanel.cssHtmlTree.searchField;

@@ +58,5 @@
> +  EventUtils.synthesizeKey("x", {}, iframe.contentWindow);
> +  EventUtils.synthesizeKey("x", {}, iframe.contentWindow);
> +  EventUtils.synthesizeKey("x", {}, iframe.contentWindow);
> +  EventUtils.synthesizeKey("x", {}, iframe.contentWindow);
> +  EventUtils.synthesizeKey("x", {}, iframe.contentWindow);

You can do:

for each (let c in "xxxxxx") {
  EventUtils.synthesizeKey(c, {}, iframe.contentWindow);
}

@@ +66,5 @@
> +{
> +  Services.obs.removeObserver(SI_checkPlaceholderVisible, "StyleInspector-populated", false);
> +info("SI_checkPlaceholderVisible called");
> +  let iframe = stylePanel.querySelector("iframe");
> +  let placeholder = iframe.contentDocument.querySelector("#noResults");

let placehoder = stylePanel.cssHtmlTree.noResults;

@@ +77,5 @@
> +
> +function SI_ClearFilterText()
> +{
> +  let iframe = stylePanel.querySelector("iframe");
> +  let searchbar = iframe.contentDocument.querySelector(".searchfield");

Same as above.

@@ +89,5 @@
> +
> +function SI_checkPlaceholderHidden()
> +{
> +  Services.obs.removeObserver(SI_checkPlaceholderHidden, "StyleInspector-populated", false);
> +    let iframe = stylePanel.querySelector("iframe");

Wrong indentation in this function.

@@ +90,5 @@
> +function SI_checkPlaceholderHidden()
> +{
> +  Services.obs.removeObserver(SI_checkPlaceholderHidden, "StyleInspector-populated", false);
> +    let iframe = stylePanel.querySelector("iframe");
> +    let placeholder = iframe.contentDocument.querySelector("#noResults");

Same as above.

::: browser/locales/en-US/chrome/browser/styleinspector.dtd
@@ +21,5 @@
> +
> +<!-- LOCALIZATION NOTE (noPropertiesFound): In the case where there are no CSS
> +  -  properties to display e.g. due to search criteria this message is
> +  -  displayed. -->
> +<!ENTITY noPropertiesFound     "No CSS properties found">

Should probably have a period at the end.

::: browser/themes/gnomestripe/browser/devtools/csshtmltree.css
@@ +223,5 @@
> +
> +#noResults {
> +  display: none;
> +  font-weight: bold;
> +  margin: 5px;

I would've expected an increased font size and centered text.

Please ping shorlander about this.
Attachment #564617 - Flags: review?(mihai.sucan) → review+
Created attachment 567028 [details] [diff] [review]
Patch 2

(In reply to Mihai Sucan [:msucan] from comment #3)
> Comment on attachment 564617 [details] [diff] [review] [diff] [details] [review]
> Patch 1
> 
> Review of attachment 564617 [details] [diff] [review] [diff] [details] [review]:
> -----------------------------------------------------------------
> 
> Patch looks good. Tests pass!
> 
> Please address the comments below. Thank you!
> 
> ::: browser/devtools/styleinspector/CssHtmlTree.jsm
> @@ +230,5 @@
> >              this.gotoMdnIcon.addEventListener("click", function() {
> >                this.win.open(PropertyView.link, "MDNWindow");
> >              }.bind(this));
> > +            this.noResults.style.display = this.numVisibleProperties ?
> > +                                           "none" : "block";
> 
> Please use noResults.hidden.
> 

Done ... I had not realized that you can use the hidden="" attribute and then toggle using element.hidden, awesome.

> @@ +245,5 @@
> >     */
> >    refreshPanel: function CssHtmlTree_refreshPanel()
> >    {
> >      this.win.clearTimeout(this._panelRefreshTimeout);
> > +    this.noResults.style.display = "none";
> 
> Same as above.
> 

Done

> @@ +269,5 @@
> >          // display the next batch of 15.
> >          this._panelRefreshTimeout = this.win.setTimeout(refreshView.bind(this), 0);
> >        } else {
> > +        this.noResults.style.display = this.numVisibleProperties ?
> > +                                       "none" : "block";
> 
> Same as above.
> 

Done

> @@ +501,5 @@
> >    {
> >      if (!this.visible) {
> >        return;
> >      }
> > +    this.tree.numVisibleProperties++;
> 
> This should be in PropertyView.refresh().
> 

Done

> :::
> browser/devtools/styleinspector/test/browser/
> browser_styleinspector_bug_689759_no_results_placeholder.js
> @@ +11,5 @@
> > +{
> > +  doc.body.innerHTML = '<style type="text/css"> ' +
> > +    '.matches {color: #F00;}</style>' +
> > +    '<span id="matches" class="matches">Some styled text</span>' +
> > +    '</div>';
> 
> There's no open tag for <div>.
> 

Removed

> @@ +27,5 @@
> > +
> > +  ok(stylePanel.isOpen(), "style inspector is open");
> > +
> > +  Services.obs.addObserver(SI_AddFilterText, "StyleInspector-populated", false);
> > +  SI_inspectNode();
> 
> You can merge SI_inspectNode() into runStyleInspectorTests().
> 

Done

> @@ +32,5 @@
> > +}
> > +
> > +function SI_inspectNode()
> > +{
> > +  var span = doc.querySelector("#matches");
> 
> s/var/let/
> 

Done

> @@ +49,5 @@
> > +{
> > +  Services.obs.removeObserver(SI_AddFilterText, "StyleInspector-populated", false);
> > +
> > +  let iframe = stylePanel.querySelector("iframe");
> > +  let searchbar = iframe.contentDocument.querySelector(".searchfield");
> 
> You can do:
> let searchbar = stylePanel.cssHtmlTree.searchField;
> 

Done.

> @@ +58,5 @@
> > +  EventUtils.synthesizeKey("x", {}, iframe.contentWindow);
> > +  EventUtils.synthesizeKey("x", {}, iframe.contentWindow);
> > +  EventUtils.synthesizeKey("x", {}, iframe.contentWindow);
> > +  EventUtils.synthesizeKey("x", {}, iframe.contentWindow);
> > +  EventUtils.synthesizeKey("x", {}, iframe.contentWindow);
> 
> You can do:
> 
> for each (let c in "xxxxxx") {
>   EventUtils.synthesizeKey(c, {}, iframe.contentWindow);
> }
> 

Done

> @@ +66,5 @@
> > +{
> > +  Services.obs.removeObserver(SI_checkPlaceholderVisible, "StyleInspector-populated", false);
> > +info("SI_checkPlaceholderVisible called");
> > +  let iframe = stylePanel.querySelector("iframe");
> > +  let placeholder = iframe.contentDocument.querySelector("#noResults");
> 
> let placehoder = stylePanel.cssHtmlTree.noResults;
> 

Done

> @@ +77,5 @@
> > +
> > +function SI_ClearFilterText()
> > +{
> > +  let iframe = stylePanel.querySelector("iframe");
> > +  let searchbar = iframe.contentDocument.querySelector(".searchfield");
> 
> Same as above.
> 

Done

> @@ +89,5 @@
> > +
> > +function SI_checkPlaceholderHidden()
> > +{
> > +  Services.obs.removeObserver(SI_checkPlaceholderHidden, "StyleInspector-populated", false);
> > +    let iframe = stylePanel.querySelector("iframe");
> 
> Wrong indentation in this function.
> 

Fixed

> @@ +90,5 @@
> > +function SI_checkPlaceholderHidden()
> > +{
> > +  Services.obs.removeObserver(SI_checkPlaceholderHidden, "StyleInspector-populated", false);
> > +    let iframe = stylePanel.querySelector("iframe");
> > +    let placeholder = iframe.contentDocument.querySelector("#noResults");
> 
> Same as above.
> 

Fixed

> ::: browser/locales/en-US/chrome/browser/styleinspector.dtd
> @@ +21,5 @@
> > +
> > +<!-- LOCALIZATION NOTE (noPropertiesFound): In the case where there are no CSS
> > +  -  properties to display e.g. due to search criteria this message is
> > +  -  displayed. -->
> > +<!ENTITY noPropertiesFound     "No CSS properties found">
> 
> Should probably have a period at the end.
> 

Done

> ::: browser/themes/gnomestripe/browser/devtools/csshtmltree.css
> @@ +223,5 @@
> > +
> > +#noResults {
> > +  display: none;
> > +  font-weight: bold;
> > +  margin: 5px;
> 
> I would've expected an increased font size and centered text.
> 
> Please ping shorlander about this.

I want him to have a general look at the new UI anyhow so I plan on upping to try and then pinging him.
Attachment #564617 - Attachment is obsolete: true
Attachment #567028 - Flags: review?(mihai.sucan)
Try build:
http://ftp.mozilla.org/pub/mozilla.org/firefox/try-builds/mratcliffe@mozilla.com-499bdbfeabc0/
Comment on attachment 567028 [details] [diff] [review]
Patch 2

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

Giving r+ as long as the patch passes all the try server runs.

Please note the patch needs rebase - could not to test it locally.

Thanks for the update!

::: browser/devtools/styleinspector/CssHtmlTree.jsm
@@ +620,5 @@
>      }
>  
> +    if (this.visible) {
> +      this.tree.numVisibleProperties++;
> +    }

The if is not needed. This code path is not executed if this.visible is false.

::: browser/devtools/styleinspector/test/browser/browser_styleinspector_bug_689759_no_results_placeholder.js
@@ +13,5 @@
> +    '.matches {color: #F00;}</style>' +
> +    '<span id="matches" class="matches">Some styled text</span>';
> +  doc.title = "Tests that the no results placeholder works properly";
> +  ok(window.StyleInspector, "StyleInspector exists");
> +  ok(StyleInspector.isEnabled, "style inspector preference is enabled");

This is not needed here.
Attachment #567028 - Flags: review?(mihai.sucan) → review+
Created attachment 569951 [details] [diff] [review]
Rebased
Attachment #567028 - Attachment is obsolete: true
Whiteboard: [minotaur][styleinspector] → [minotaur][styleinspector][r+]
(Reporter)

Comment 8

6 years ago
We're doing developer tool prioritization, filter on 'brontozaur'
to ignore the spam.
Priority: -- → P2
Created attachment 571959 [details] [diff] [review]
Rebased
Attachment #569951 - Attachment is obsolete: true
Whiteboard: [minotaur][styleinspector][r+] → [minotaur][styleinspector][land-in-fx-team]
Created attachment 572190 [details] [diff] [review]
Rebased

Rebased to land on top of bug 689759
Attachment #571959 - Attachment is obsolete: true
Oops, I meant that I rebased it on top of bug 698762
Depends on: 698762
No longer depends on: 672748
https://hg.mozilla.org/integration/fx-team/rev/b73aa0bd2b4e
Status: NEW → ASSIGNED
Whiteboard: [minotaur][styleinspector][land-in-fx-team] → [minotaur][styleinspector][fixed-in-fx-team]
backed out in:

https://hg.mozilla.org/integration/fx-team/rev/90b03b0aa9ee
Whiteboard: [minotaur][styleinspector][fixed-in-fx-team] → [minotaur][styleinspector][backed-out]
Created attachment 572279 [details] [diff] [review]
another rebase

Another rebase.

This patch now depends on bug 698762.
Attachment #572190 - Attachment is obsolete: true
(Reporter)

Comment 15

6 years ago
https://hg.mozilla.org/integration/fx-team/rev/100b93342d7c
Whiteboard: [minotaur][styleinspector][backed-out] → [minotaur][styleinspector][fixed-in-fx-team]
https://hg.mozilla.org/mozilla-central/rev/100b93342d7c
Status: ASSIGNED → RESOLVED
Last Resolved: 6 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 10
You need to log in before you can comment on or make changes to this bug.