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

implement getOverrideStyle()

ASSIGNED

Status

()

Core
DOM: CSS Object Model
P3
normal
ASSIGNED
17 years ago
3 years ago

People

(Reporter: Pete Collins (MDG), Assigned: Pete Collins (MDG))

Tracking

({dom2, helpwanted})

Trunk
dom2, helpwanted
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

(Assignee)

Description

17 years ago
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

Comment 1

17 years ago
huh?
Status: NEW → RESOLVED
Last Resolved: 17 years ago
Resolution: --- → INVALID

Comment 2

17 years ago
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 → ---

Comment 5

17 years ago
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

Comment 6

17 years ago
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
(Assignee)

Comment 7

17 years ago
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>"]

(Assignee)

Comment 8

17 years ago
It's listed here among the document class methods.

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

pete

Updated

17 years ago
Status: REOPENED → ASSIGNED
Keywords: helpwanted
Summary: need to set alternative pseudo styles on xul elements → implement getOverrideStyle()
Target Milestone: --- → Future
(Assignee)

Comment 9

17 years ago
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

Comment 10

17 years ago
Updating QA Contact to pmac@netscape.com
QA Contact: paw → pmac

Comment 11

17 years ago
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?

Comment 12

17 years ago
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.

Comment 13

17 years ago
Peter (Trudelle) - is this even a possibility for 6.5?  Is there anyone outside
of your group that could possibly implement it?

Comment 14

17 years ago
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

Comment 17

17 years ago
Todd, Joe - Would love to help out, but we are swamped. (& please note that DOM
level 2 is not our area anyway)
(Assignee)

Comment 18

17 years ago
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
(Assignee)

Comment 21

16 years ago
assigning to myself
Assignee: waterson → petejc
Status: ASSIGNED → NEW
(Assignee)

Updated

16 years ago
Severity: blocker → normal
Status: NEW → ASSIGNED

Comment 22

16 years ago
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
(Assignee)

Comment 23

16 years ago
I have this on my bug list. I will let you know when i get to it.

Thanks

--pete
(Assignee)

Updated

16 years ago
Target Milestone: Future → mozilla0.9.4
(Assignee)

Updated

16 years ago
Target Milestone: mozilla0.9.4 → mozilla1.0

Comment 24

16 years ago
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

Updated

16 years ago
OS: FreeBSD → All
Hardware: PC → All

Comment 25

13 years ago
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).

Comment 26

13 years ago
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 → ---
You need to log in before you can comment on or make changes to this bug.