Closed Bug 45424 Opened 24 years ago Closed 2 years ago

implement getOverrideStyle()

Categories

(Core :: DOM: CSS Object Model, defect, P5)

defect

Tracking

()

RESOLVED INVALID

People

(Reporter: pete, Unassigned)

References

Details

(Keywords: dom2, helpwanted)

I need some way to dynamically set alternative pseudo styles 

ex: hover, active etc . . . 

the style property for xul element objects i don't think will give me this.
It just when implemented, give me the "normal" style rules. Which i don't need
right now.

This is a blocker for the Theme Builder.

Any ideas?

Thanks

pete
huh?
Status: NEW → RESOLVED
Closed: 24 years ago
Resolution: --- → INVALID
Here is a better discription:

http://bugzilla.mozilla.org/show_bug.cgi?id=7639

I was asked to file this bug. I am just not explaining what i need properly.

Thanks

pete
How do you want to set them?  If the element has an ID or a class (which you 
can give it dynamically) you could dynamically add a rule to a stylesheet.  I 
think that's the only way right now, and the only way within any standards.
Pete, answering your questions in bug 7639: Yes, this can be done with
document.getOverrideStyle(), look at

  http://www.w3.org/TR/DOM-Level-2/css.html#CSS-DocumentCSS

with getOverrideStyle() you can access the override style, pseudo or not, for
any element, what you get is a CSSStyleDeclaration, i.e. same as you get through
element.style so yes, you can both set and get values from the override style.
Please note that the delcaration you get from getOverrideStyle() is for one
element only, i.e. if you have other elements with the same name their style
should remain uneffected by any changes made to the override style...

Waterson, I think this is a valid bug, but this should most likely be futured...
Status: RESOLVED → REOPENED
Resolution: INVALID → ---
Yea, thanks Johnny, i was reading it over.
getOverrideStyle(in Element elt,in DOMString pseudoElt);

I would call it like this:
var doc = document;
var foo = doc.getElementById('someID');
doc.getOverrideStyle(foo, 'hover');

or

doc.getOverrideStyle(foo, 'active');

And then to set it, i would do:

doc.getOverrideStyle(foo, 'hover') = "color: red;"

If this is correct, then yes this is EXACTLY what i need. 

I am assumeing that this is a top level dom call similar to getElementByID().

I am willing to help out any way i can to get this implemented.

pete
Tim Hill posted the correct usage in the layout ng:

styledecl = document.getOverrideStyle(element, "hover");
styledecl.setProperty("background-color", "black", "");
styledecl.setProperty("color", "white", "");

This is definitely what i'm looking for.

pete
Yes, here is a test case from xul.

<button
  id        = "stop-button"
  class     = "button-toolbar-1 top"
  onclick   = "var foo = document.getOverrideStyle(this,'hover');"/>

result:

JavaScript error:
 line 0: uncaught exception: [Exception... "Object is of wrong type"  code:
"1002" nsresult: "0x805303ea (NS_ERROR_DOM_WRONG_TYPE_ERR)"  location:
"<unknown>"]

It's listed here among the document class methods.

http://lxr.mozilla.org/seamonkey/source/dom/src/coreDOM/nsJSDocument.cpp#1418

pete
Status: REOPENED → ASSIGNED
Keywords: helpwanted
Summary: need to set alternative pseudo styles on xul elements → implement getOverrideStyle()
Target Milestone: --- → Future
Hey Chris, is this in any way possible to implement from JS?

If so i would definately have a go at it. 

If the interfaces that contain all of the css style rules etc . . are scriptable
then you never know what could happen.

pete
Updating QA Contact to pmac@netscape.com
QA Contact: paw → pmac
Joe -

This is preventing Alphanumerica from being able to implement the import theme
functionality we wanted in the themebuilder tool.  Right now the modern theme is
hardcoded in and is the only starting point.  Any ideas?
Todd, this is just one of the many DOM Level 2 things that aren't implemented 
but would be nice to have... you'd probably have to bug trudelle to find 
someone to implement it if they have the time, which is probably not likely at 
the moment given the current priorities.
Peter (Trudelle) - is this even a possibility for 6.5?  Is there anyone outside
of your group that could possibly implement it?
Themes Triage Team changing to DOM Level 2
Component: Themes → DOM Level 2
*** Bug 62695 has been marked as a duplicate of this bug. ***
Keywords: dom2
Component: DOM Level 2 → DOM Style
Taking QA Contact on all open or unverified DOM Style bugs...
QA Contact: pmac → ian
Todd, Joe - Would love to help out, but we are swamped. (& please note that DOM
level 2 is not our area anyway)
I started looking into this and Johnny S is helping me out.
I just don't have any time. Arg!

I really hope to resume in a week or two.
There is only so much i can do in that hour ride on the train home. ;-)

--pete

Nominating this bug for nsbeta1 on behalf of gerardok@netscape.com.
Keywords: nsbeta1
Removing nsbeta1 nomination -- there was a misunderstanding and some "approved
out features" were nominated by mistake! Sorry!
Keywords: nsbeta1
assigning to myself
Assignee: waterson → petejc
Status: ASSIGNED → NEW
Severity: blocker → normal
Status: NEW → ASSIGNED
pete are u working on this implementation ?? i cold not find any implementation
of nsDOMDocumentStyle also and hence nsDOMDocumentCSS has not been implement. I
would like to help in getting this working.. let me know if you need help
I have this on my bug list. I will let you know when i get to it.

Thanks

--pete
Target Milestone: Future → mozilla0.9.4
Target Milestone: mozilla0.9.4 → mozilla1.0
Bugs targeted at mozilla1.0 without the mozilla1.0 keyword moved to mozilla1.0.1 
(you can query for this string to delete spam or retrieve the list of bugs I've 
moved)
Target Milestone: mozilla1.0 → mozilla1.0.1
OS: FreeBSD → All
Hardware: PC → All
In Seamonkey/Javascript, please implement the DocumentCSS interface on
XMLDocument or Window so it is possible to programmatically *set* style on
Element nodes. It is currently possible to *get* style on such nodes using
getComputedStyle from the ViewCSS interface (implemented by Window).
Does getOverrideStyle() should accept pseudo-classes (hover,
activates...) in second argument ?

DOM CSS say (for getComputedStyle() and getOverrideStyle()):
"pseudoElt of type DOMString
    The pseudo-element or null if none."
FWIW, this feature -- getOverrideStyle() -- is probably needed to support SVG/SMIL Animation of CSS properties.

Quoting the SMIL Animation Specification:

"When animation is applied to CSS properties of a particular element, the base value to be animated is read using the (readonly) getComputedStyle() method on that element. The values produced by the animation are written into an override stylesheet for that element, which may be obtained using the getOverrideStyle() method. These new values then affect the cascade and are reflected in a new computed value (and thus, modified presentation)."

Also, FWIW -- the above paragraph is a bit vague on whether or not a change to getOverrideStyle() should modify the output of getComputedStyle().  But per discussion on www-style ([2], [3]) it sounds like it *is* supposed to modify the computed style.

[1] http://www.w3.org/TR/smil-animation/#AnimationSandwichModel
[2] http://lists.w3.org/Archives/Public/www-style/2003Nov/0013.html
[3] http://lists.w3.org/Archives/Public/www-style/2003Nov/0041.html
QA Contact: ian → general
QA Contact: general → style-system
(In reply to Daniel Holbert [:dholbert] from comment #27)
> FWIW, this feature -- getOverrideStyle() -- is probably needed to support
> SVG/SMIL Animation of CSS properties.

(Just to follow up on this -- we didn't end up needing this for SMIL -- we ended up going with a custom SMIL-specific override stylesheet that's not exposed via the DOM at all.  For reference, see bug 474049 comment 10, first bullet-point.)
Target Milestone: mozilla1.0.1 → ---
Bulk priority change, per :mdaly
Priority: P3 → P5

The bug assignee is inactive on Bugzilla, so the assignee is being reset.

Assignee: pete → nobody
Status: ASSIGNED → NEW

It looks like this API (and its "DocumentCSS" interface) ended up being dropped from the spec, as best I can tell?

There's no documentation on MDN or implementation data on caniuse.com; and I found this post suggesting we remove it from the CSSOM spec in 2007 (where it lived at that time):
https://lists.w3.org/Archives/Public/www-style/2007Feb/0150.html

and it looks like it was indeed removed later that year, in this commit:
https://github.com/w3c/csswg-drafts/commit/a6e57f9475885797a8dfb8a20fa1b962b607928a

and it's still gone in the current published version of CSSOM:
https://www.w3.org/TR/cssom-1/

Status: NEW → RESOLVED
Closed: 24 years ago2 years ago
Resolution: --- → INVALID

Yes, mentioning of the "Overriding styles" and related concepts have been removed from the specs: https://github.com/w3c/csswg-drafts/issues/1385#issuecomment-341272054

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