Boris Zbarsky wrote:
John J. Barton wrote:
Firebug uses:
domUtils.getCSSStyleRules(element)
and fails to get rules for the element if the rule is like:
a:hover {
color:#FF00FF;
text-decoration:none;
}
This is if the element is not in fact in :hover state at the time, right?
Correct.
However, the rules are found if we "inspect" the element and the mouse
is over the element. It is as if the result of
getCSSStyleRules(element) depends on content state.
It does, indeed. It also depends on the attributes the element has, its
position in the tree, and so forth. These are all no different from
each other, really.
Well from the developer's viewpoint attributes and position are quite
different from 'hover'. We need the mouse to run the debugger so we
can't be hovering all day...
Would it be wise to flip the state bits temporarily around the
getCSSStyleRules() call with
void setContentState ( nsIDOMElement element , PRInt32 state );
and if so are the stage bits documented?
Doing that would sorta work if you only twiddle the ESM-managed bits,
but it would actually change the ESM's state (for example, you can't
remove hover state by unsetting the hover bit this way, as far as I can
tell). In general, the content state stuff in inspector utils is pretty
broken and could use some serious work, imo.
What is an ESM?
That said, I'm not sure I understand what your precise use case is. Do
you want all rules that might match an element if it were in some other
defined set of states? Something else? nsIInspectorCSSUtils will
likely need to grow more methods to address whatever the use cases are
here (and some of these might need some interesting core changes).
I guess Firebug needs to present 'what if' options to the user, at least
for mouse-dependent rules. So imagine the element rules that are active
followed grey-ed rules that would apply to the element if certain
conditions are met, eg "hovered". The user can move the debugger mouse
over the grey-ed rules and they will be activated temporarily so the
developer can take a look. And if the mouse does hover, then the rules
are activated.
That would require a getAllCSSStyleRules(element) as well as temporary
get/set bits working.
Is there anything like an 'onHover'? onContentStateChange? Firebug could
at least reflect the hover change in its UI if it got an event.
jjb
_______________________________________________
dev-tech-layout mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-layout