- From: Ludger Buenger <ludger.buenger@realobjects.com>
- Date: Mon, 23 Mar 2009 19:20:14 +0100
- To: "Innovimax SARL" <innovimax@gmail.com>, <www-style@w3.org>
- Message-ID: <96458C389BF1724995FFD7FAD889263722D4E3@ex.nc-sb.de>
This is already possible in a slightly different way, so please read the fine standard!
Try this:
CSSPrimitiveValue widthValue = ((CSSPrimitiveValue)getComputedStyle(element).getPropertyCSSValue(“width”));
int widthInEM = widthValue.getFloatValue(CSSPrimitiveValue.CSS_EM);
or
int widthInPX = widthValue.getFloatValue(CSSPrimitiveValue.CSS_PX);
For convenience, I omitted instance, type null and other checks…
Ludger
From: www-style-request@w3.org [mailto:www-style-request@w3.org] On Behalf Of Innovimax SARL
Sent: Monday, March 23, 2009 6:08 PM
To: www-style@w3.org
Subject: [CSSOM] GetComputedStyle : choose the unit
Dear,
For the moment in http://dev.w3.org/csswg/cssom/
We can find
[[
interface ViewCSS {
CSSStyleDeclaration getComputedStyle(in Element elt);
CSSStyleDeclaration getComputedStyle(in Element elt, in DOMString pseudoElt);
};
The getComputedStyle method must return a live CSSStyleDeclaration object that contains the computed style declaration block for elt, when the pseudoElt argument is null, the empty string or omitted. Otherwise, for the pseudo-element pseudoElt of elt. [CSS]
]]
And then
[[
interface CSSStyleDeclaration {
attribute DOMString cssText;
DOMString getPropertyValue(in DOMString property);
DOMString getPropertyPriority(in DOMString property);
DOMString removeProperty(in DOMString property);
void setProperty(in DOMString property, in DOMString value);
void setProperty(in DOMString property, in DOMString value, in DOMString priority);
readonly attribute unsigned long length;
DOMString item(in unsigned long index);
readonly attribute CSSRule parentRule;
};
]]
So it means, if I want to have access to the width of an element
getComputedStyle(el, "").getPropertyValue("width");
I propose to add a new parameter to getPropertyValue so that you can choose the unit
something like
getComputedStyle(el, "").getPropertyValue("width", "px");
And even to get information with respect to relative value
getComputedStyle(el, "").getPropertyValue("width", "em");
Regards,
Mohamed ZERGAOUI
--
Innovimax SARL
Consulting, Training & XML Development
9, impasse des Orteaux
75020 Paris
Tel : +33 9 52 475787
Fax : +33 1 4356 1746
http://www.innovimax.fr
RCS Paris 488.018.631
SARL au capital de 10.000 €
--
This message was scanned by ESVA and is believed to be clean.
Click here to report this message as spam. <http://mailfilter.nc-sb.de/cgi-bin/learn-msg.cgi?id=BB09C27F1E.D307A>
Received on Monday, 23 March 2009 18:22:02 UTC