Yeah, I was kind of hoping to avoid reimplementing CSS selectors in
There are mozilla-internal methods for that. It is not exposed to HTML
DOM. I cannot remember the name of the method, but there is a method for
this. I found it on XUL planet, I think.
I looked into Firebug some more, and it looks like they use the
inIDOMUtilsinIDOMUtils interface implemented by @mozilla.org/inspector/
dom-utils;
[email protected]/inspector/dom-utils;1. This provides a
getCSSStyleRulesgetCSSStyleRules method that takes an element and
returns a list of rules. From my limited experimentation so far, it
appears the list is ordered such that index n contains rules that
override rule n-1.
Of course, Firefox doesn't allow access to XPCOM from web/file
resources, so it was a bit of a dance to get around that. I ended up
re-writing the page in XUL, and using XUL Explorer to run it. Given
the dependency on Mozilla, this isn't necessarily a bad thing. Still,
it would be better if there was a cross-browser way.
you might try posting to a Firebug group. Or, if you're interested in
pursuing this, follow up on the www-style mailing list for a
getAppliedRules() method.
I may do that. It seems to me that this would be a relatively common
stylesheet introspection problem.
What are you trying to do?
Well, that's not entirely decided yet ;-). Basically, though, I'm
trying to build an application that would let the user interactively
experiment with different styles. Click on an element, change the
color/background, and see the changes instantly. By determining which
rule an element gets its color from, it is possible to change the
appearance of, for example, all the section headings on the page.
--Nathan Davis> > Yeah, I was kind of hoping to avoid reimplementing
CSS selectors in
There are mozilla-internal methods for that. It is not exposed to HTML
DOM. I cannot remember the name of the method, but there is a method for
this. I found it on XUL planet, I think.
I looked into Firebug some more, and it looks like they use the
inIDOMUtilsinIDOMUtils interface implemented by @mozilla.org/inspector/
dom-utils;
[email protected]/inspector/dom-utils;1. This provides a
getCSSStyleRulesgetCSSStyleRules method that takes an element and
returns a list of rules. From my limited experimentation so far, it
appears the list is ordered such that index n contains rules that
override rule n-1.
Of course, Firefox doesn't allow access to XPCOM from web/file
resources, so it was a bit of a dance to get around that. I ended up
re-writing the page in XUL, and using XUL Explorer to run it. Given
the dependency on Mozilla, this isn't necessarily a bad thing. Still,
it would be better if there was a cross-browser way.
you might try posting to a Firebug group. Or, if you're interested in
pursuing this, follow up on the www-style mailing list for a
getAppliedRules() method.
I may do that. It seems to me that this would be a relatively common
stylesheet introspection problem.
What are you trying to do?
Well, that's not entirely decided yet ;-). Basically, though, I'm
trying to build an application that would let the user interactively
experiment with different styles. Click on an element, change the
color/background, and see the changes instantly. By determining which
rule an element gets its color from, it is possible to change the
appearance of, for example, all the section headings on the page.
--Nathan Davis