Last Comment Bug 705707 - Style Inspector doesn't take into account chrome:// stylesheets
: Style Inspector doesn't take into account chrome:// stylesheets
Status: RESOLVED FIXED
[computedview][ruleview]
:
Product: Firefox
Classification: Client Software
Component: Developer Tools: Inspector (show other bugs)
: Trunk
: All All
: P2 normal (vote)
: Firefox 13
Assigned To: Michael Ratcliffe [:miker] [:mratcliffe]
:
Mentors:
Depends on: 953379
Blocks: 717910
  Show dependency treegraph
 
Reported: 2011-11-28 08:53 PST by Panos Astithas [:past]
Modified: 2013-12-28 17:37 PST (History)
6 users (show)
See Also:
Crash Signature:
(edit)
QA Whiteboard:
Iteration: ---
Points: ---


Attachments
Patch (13.65 KB, patch)
2012-01-16 07:50 PST, Michael Ratcliffe [:miker] [:mratcliffe]
no flags Details | Diff | Review
Patch now uses root namespace to detect XUL docs (13.91 KB, patch)
2012-01-17 03:25 PST, Michael Ratcliffe [:miker] [:mratcliffe]
no flags Details | Diff | Review
Patch without chrome check (14.62 KB, patch)
2012-01-25 04:51 PST, Michael Ratcliffe [:miker] [:mratcliffe]
no flags Details | Diff | Review
chrome check added again (13.91 KB, patch)
2012-01-26 07:49 PST, Michael Ratcliffe [:miker] [:mratcliffe]
no flags Details | Diff | Review
isSystemStyleSheet renamed to isNotContentStyleSheet (15.69 KB, patch)
2012-01-27 05:47 PST, Michael Ratcliffe [:miker] [:mratcliffe]
dao: feedback-
Details | Diff | Review
Complete rewrite (22.62 KB, patch)
2012-02-02 08:58 PST, Michael Ratcliffe [:miker] [:mratcliffe]
no flags Details | Diff | Review
Fixed bad comments (22.41 KB, patch)
2012-02-02 11:10 PST, Michael Ratcliffe [:miker] [:mratcliffe]
mihai.sucan: review+
dao: feedback+
Details | Diff | Review
[in-fx-team] Whitelist xul iri for the test (22.85 KB, patch)
2012-02-13 06:52 PST, Michael Ratcliffe [:miker] [:mratcliffe]
no flags Details | Diff | Review

Description Panos Astithas [:past] 2011-11-28 08:53:31 PST
Apparently using the rule view or the property view of our style inspector does not work for XUL documents. I've tried both chrome:// and file:// URLs, without any observable difference. Try opening one of the following:

chrome://browser/content/styleeditor.xul
file:///path/to/your/repo/browser/devtools/styleeditor/styleeditor.xul

For the latter you need to set dom.allow_XUL_XBL_for_file to true. Highlight the search box and observe that the rule view is empty. The property view is empty as well, but if you uncheck the "only user styles" option, you can see there is a matching max-width rule from splitview.css. There is also a -moz-margin-start in that rule that is not displayed at all.

It would make working in browser/extension code much easier if these tools could properly display such information.
Comment 1 Michael Ratcliffe [:miker] [:mratcliffe] 2012-01-11 04:06:03 PST
Bug triage, filter on PEGASUS.
Comment 2 Michael Ratcliffe [:miker] [:mratcliffe] 2012-01-12 07:37:06 PST
This is because we block chrome stylesheets when the "only user styles" checkbox is checked (that is the meaning of the option).

If I remember correctly, there was more to this bug ... I will need to discuss it with Panos.
Comment 3 Panos Astithas [:past] 2012-01-13 06:06:46 PST
(In reply to Michael Ratcliffe from comment #2)
> This is because we block chrome stylesheets when the "only user styles"
> checkbox is checked (that is the meaning of the option).

Unchecking the option is not a workaround that can be used in the rules view, unfortunately. Furthermore, from the POV of a XUL application/add-on developer, styles included in a XUL file *are* the user styles. The label is misleading in that particular use case.
Comment 4 Michael Ratcliffe [:miker] [:mratcliffe] 2012-01-13 06:49:07 PST
The meaning of "only user styles" in normal docs is "only show properties that have been changed from their defaults and to hide chrome CSS." The meaning in XUL docs will be "only show properties that have been changed from their defaults."

-moz-*-start and -moz-*-end are simply aliases to -moz-*-left and -moz-*-right (depending on the locale) so they would be shown in computed styles as margin-(left|right). All that we need to do here is include chrome css when inspecting XUL documents.
Comment 5 Michael Ratcliffe [:miker] [:mratcliffe] 2012-01-13 06:53:12 PST
Sorry, I obviously meant:
-moz-*-start and -moz-*-end are simply aliases to *-left and *-right (depending on the locale) so they would be shown in computed styles as margin-(left|right). All that we need to do here is include chrome css when inspecting XUL documents.
Comment 6 Michael Ratcliffe [:miker] [:mratcliffe] 2012-01-16 07:50:07 PST
Created attachment 588883 [details] [diff] [review]
Patch

This patch allows the computed and rule views to work with XUL documents.
Comment 7 Michael Ratcliffe [:miker] [:mratcliffe] 2012-01-16 08:12:12 PST
msucan pointed out that using the file extension to determine if we have a xul doc is probably not the best way. I will change this to use the root namespace instead.
Comment 8 Michael Ratcliffe [:miker] [:mratcliffe] 2012-01-17 03:25:05 PST
Created attachment 589145 [details] [diff] [review]
Patch now uses root namespace to detect XUL docs

Obviously using the file extension to check for a xul doc was not ideal so now we use the root element's namespace instead.
Comment 9 Dão Gottwald [:dao] 2012-01-20 12:05:41 PST
Why does CssLogic.isSystemStyleSheet return true for chrome: URIs? This seems bogus.
Comment 10 Rob Campbell [:rc] (:robcee) 2012-01-23 08:08:20 PST
chrome == system for the sake of this method. The implementation of this is basically straight out of firebug.
Comment 11 Dão Gottwald [:dao] 2012-01-23 08:11:51 PST
(In reply to Rob Campbell [:rc] (robcee) from comment #10)
> chrome == system for the sake of this method.

What chrome stylesheets affect web pages?

> The implementation of this is basically straight out of firebug.

Sure, but this doesn't make it right.
Comment 12 Rob Campbell [:rc] (:robcee) 2012-01-23 12:47:57 PST
it does for about 99% of our content inspection needs. When we poll the style system for a list of stylesheets, it gives us everything on the page. That includes a good number of chrome: stylesheets that come from the system.

It might be worth somehow separating these from the stylesheets lookup itself, but that'll require some extra smarts from the layout machinery.
Comment 13 Dão Gottwald [:dao] 2012-01-24 02:48:53 PST
Does DOM Inspector use the same approach to solve this?
Comment 14 Rob Campbell [:rc] (:robcee) 2012-01-24 06:21:55 PST
(In reply to Dão Gottwald [:dao] from comment #13)
> Does DOM Inspector use the same approach to solve this?

I expect so since they were both written by the same guy.

http://hg.mozilla.org/dom-inspector/
Comment 15 Dão Gottwald [:dao] 2012-01-24 06:39:49 PST
But does DOMi contain the patch proposed here? DOMi doesn't suffer from this bug, so presumably it doesn't have exactly the same code as Firebug.
Comment 16 Michael Ratcliffe [:miker] [:mratcliffe] 2012-01-25 04:51:25 PST
Created attachment 591421 [details] [diff] [review]
Patch without chrome check

Dão is correct here, we do not need to filter chrome url's in CssLogic.isSystemStyleSheet because they are only included when the UA filter is enabled and then we need to see them anyway.

In effect this check did nothing except waste cycles. Removing the check causes no issues so ... done.
Comment 17 Dão Gottwald [:dao] 2012-01-25 05:14:38 PST
Comment on attachment 591421 [details] [diff] [review]
Patch without chrome check

Why do you need to detect XUL documents at this point?

Note that XML documents can mix different namespaces, which makes "XUL document" kind of meaningless...
Comment 18 Michael Ratcliffe [:miker] [:mratcliffe] 2012-01-26 07:47:18 PST
After discussing this as a group we didn't like the idea of removing the chrome check even though it does not affect CSSLogic. Our reasoning is that CssLogic is a utility that could be used by other tools (it is used by the rule view). And these other tools should be able to make use of this method.

We are struggling to understand exactly what your issue is with this method, to all intents and purposes chrome stylesheets are system stylesheets so all of these checks are valid and there is no bug.

Can you explain your issue with CssLogic.isSystemStyleSheet? Is it just the name of the method or is it the definition of what constitutes a system stylesheet?
Comment 19 Michael Ratcliffe [:miker] [:mratcliffe] 2012-01-26 07:49:43 PST
Created attachment 591800 [details] [diff] [review]
chrome check added again
Comment 20 Dão Gottwald [:dao] 2012-01-26 08:01:34 PST
(In reply to Michael Ratcliffe from comment #18)
> After discussing this as a group we didn't like the idea of removing the
> chrome check even though it does not affect CSSLogic. Our reasoning is that
> CssLogic is a utility that could be used by other tools (it is used by the
> rule view). And these other tools should be able to make use of this method.

I'm not sure what this means. What exactly is the impact on the rule view?

> to all intents and purposes chrome stylesheets are system stylesheets so all
> of these checks are valid and there is no bug.

Chrome stylesheets styling chrome documents aren't system stylesheets. This seems to be what this bug is about.

> Can you explain your issue with CssLogic.isSystemStyleSheet? Is it just the name of
> the method or is it the definition of what constitutes a system stylesheet?

The latter.

Has somebody checked by now what DOM Inspector is doing?
Comment 21 Michael Ratcliffe [:miker] [:mratcliffe] 2012-01-27 05:47:26 PST
Created attachment 592108 [details] [diff] [review]
isSystemStyleSheet renamed to isNotContentStyleSheet

Robcee has already looked at this patch so he may as well be the one to review it.

(In reply to Dão Gottwald [:dao] from comment #20)
> (In reply to Michael Ratcliffe from comment #18)
> > After discussing this as a group we didn't like the idea of removing the
> > chrome check even though it does not affect CSSLogic. Our reasoning is that
> > CssLogic is a utility that could be used by other tools (it is used by the
> > rule view). And these other tools should be able to make use of this method.
> 
> I'm not sure what this means. What exactly is the impact on the rule view?
> 

Probably none actually, but the intent of the method should not be changed.

> > to all intents and purposes chrome stylesheets are system stylesheets so all
> > of these checks are valid and there is no bug.
> 
> Chrome stylesheets styling chrome documents aren't system stylesheets. This
> seems to be what this bug is about.
> 

True

> Has somebody checked by now what DOM Inspector is doing?

Yes, but it works completely differently because it has no "only user styles" "only user styles" checkbox.

> > Can you explain your issue with CssLogic.isSystemStyleSheet? Is it just the name of
> > the method or is it the definition of what constitutes a system stylesheet?
> 
> The latter.
> 

Ah, okay then ... method renamed to isNotContentStyleSheet as that is actually the intent of this method.
Comment 22 Rob Campbell [:rc] (:robcee) 2012-01-27 06:09:57 PST
Comment on attachment 592108 [details] [diff] [review]
isSystemStyleSheet renamed to isNotContentStyleSheet

-CssLogic.isSystemStyleSheet = function CssLogic_isSystemStyleSheet(aSheet)
+CssLogic.isNotContentStyleSheet = function CssLogic_isNotContentStyleSheet(aSheet)

I honestly didn't have a problem with the original name, I find this one uglier, but in the interests of appeasing everyone, let's go with it.
Comment 23 Dão Gottwald [:dao] 2012-01-27 06:21:04 PST
(In reply to Michael Ratcliffe from comment #21)
> > Has somebody checked by now what DOM Inspector is doing?
> 
> Yes, but it works completely differently because it has no "only user
> styles" "only user styles" checkbox.

Nor does it list chrome: stylesheets for web content. What problem is the exclusion of chrome: trying to solve?
Comment 24 Dão Gottwald [:dao] 2012-01-27 06:22:26 PST
Comment on attachment 592108 [details] [diff] [review]
isSystemStyleSheet renamed to isNotContentStyleSheet

As mentioned earlier, the XUL document check is bogus since XUL and other languages such as HTML can be mixed.
Comment 25 Rob Campbell [:rc] (:robcee) 2012-01-27 06:53:10 PST
Comment on attachment 592108 [details] [diff] [review]
isSystemStyleSheet renamed to isNotContentStyleSheet

+      // Refresh source filter in case the element being inspected is inside a
+      // XUL document.
+      this.refreshSourceFilter();

...

 
+      // Refresh source filter in case the element being inspected is inside a
+      // XUL document. This must be done after templateRoot has been processed.
+      this.refreshSourceFilter();

...

+    let xul =
+      this.viewedElement.ownerDocument.documentElement.namespaceURI == XUL_NS;

Dão's right about this being overly-specific.

What about using a check similar to the isNotContentStyleSheet (ugh) method to check if the page we're inspecting is one of about: resource: chrome: URLs? That might get us a little closer to being accurate.

I really do wish we had a better name for these classes of pages. "System" feels about right.
Comment 26 Rob Campbell [:rc] (:robcee) 2012-01-27 06:54:17 PST
... though the check does conform with the intent of this bug as described in the Summary.

dcamp, what say you?
Comment 27 Dão Gottwald [:dao] 2012-01-27 07:32:45 PST
(In reply to Rob Campbell [:rc] (robcee) from comment #26)
> ... though the check does conform with the intent of this bug as described
> in the Summary.

Rather than modelling the patch after some inaccurate summary, let's fix the summary? ;)
Comment 28 Rob Campbell [:rc] (:robcee) 2012-01-27 10:58:43 PST
this is acceptable! :)
Comment 29 Michael Ratcliffe [:miker] [:mratcliffe] 2012-01-30 07:47:55 PST
So, let's rethink this ... if a user has only added one line of CSS to an element they do not expect to see hundreds of rules (we want to show only non-default values by default). We have been doing this by filtering out chrome & system stylesheets.

The problem is that theoretically any chrome: or resource: stylesheet can be used by any page. What we really need is a simple way to tell if a rule comes from a stylesheet on the page or whether it comes from outside the page.

We could just use styleSheets.ownerNode.baseURI to check if the sheet is from outside the document.
Comment 30 Michael Ratcliffe [:miker] [:mratcliffe] 2012-02-02 08:58:01 PST
Created attachment 593867 [details] [diff] [review]
Complete rewrite

I have totally rewritten the isSystemStylesheet method and changed it to isContentStylesheet (reversing the logic). We no longer rely on URL prefixes to detect non-content stylesheets as this approach works fine in all situations.
Comment 31 Dão Gottwald [:dao] 2012-02-02 09:10:12 PST
Comment on attachment 593867 [details] [diff] [review]
Complete rewrite

>+      // Refresh source filter in case the element being inspected is inside a
>+      // XUL document.

>+      // Refresh source filter in case the element being inspected is inside a
>+      // XUL document. This must be done after templateRoot has been processed.

>+  /**
>+   * When onlyUserStyles.checked is true we do not display properties that have
>+   * no matched selectors, and we do not display UA styles unless we are
>+   * inspecting a XUL document. If .checked is false we display properties with
>+   * and without matched selectors, and we include the UA styles.
>+   */

Are these comments about XUL still accurate? Your code doesn't seem to care for XUL at all (which is good).
Comment 32 Michael Ratcliffe [:miker] [:mratcliffe] 2012-02-02 11:10:31 PST
Created attachment 593914 [details] [diff] [review]
Fixed bad comments

You are right, we don't care about the document type any longer.

I have fixed all comments now.
Comment 33 Dão Gottwald [:dao] 2012-02-02 11:24:05 PST
Comment on attachment 593914 [details] [diff] [review]
Fixed bad comments

Looks solid to me overall.
Comment 34 Mihai Sucan [:msucan] 2012-02-02 11:48:56 PST
Comment on attachment 593914 [details] [diff] [review]
Fixed bad comments

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

This looks really good! Thanks Mike!

::: browser/devtools/styleinspector/CssLogic.jsm
@@ +878,5 @@
>      return true;
>    }
>  
> +  // If the sheet has a CSSImportRule we need to check the parent stylesheet.
> +  if (aSheet.ownerRule instanceof Ci.nsIDOMCSSImportRule) {

Can ownerRule be something different than null or Ci.nsIDOMCSSImportRule?
Comment 35 Michael Ratcliffe [:miker] [:mratcliffe] 2012-02-02 15:11:54 PST
Nope, just null or importRule ... see http://www.w3.org/TR/2000/REC-DOM-Level-2-Style-20001113/css.html#CSS-CSSStyleSheet-ownerRule

I still think we should keep the instance check in case of future expansion.
Comment 36 Rob Campbell [:rc] (:robcee) 2012-02-10 07:26:46 PST
https://hg.mozilla.org/integration/fx-team/rev/17a1f5c47b25
Comment 37 Michael Ratcliffe [:miker] [:mratcliffe] 2012-02-10 11:27:11 PST
backed out in rev 4a07e7 due to bug 726101
Comment 38 Michael Ratcliffe [:miker] [:mratcliffe] 2012-02-13 06:52:55 PST
Created attachment 596676 [details] [diff] [review]
[in-fx-team] Whitelist xul iri for the test

A workaround for bug 726101
Comment 39 Michael Ratcliffe [:miker] [:mratcliffe] 2012-02-13 06:53:43 PST
Green on try now so this should now be landable.
Comment 40 Mihai Sucan [:msucan] 2012-02-17 08:54:54 PST
Comment on attachment 596676 [details] [diff] [review]
[in-fx-team] Whitelist xul iri for the test

Landed:
https://hg.mozilla.org/integration/fx-team/rev/30cb97299656
Comment 41 Tim Taubert [:ttaubert] 2012-02-17 17:10:22 PST
https://hg.mozilla.org/mozilla-central/rev/30cb97299656

Note You need to log in before you can comment on or make changes to this bug.


Privacy Policy