Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Element Size - was: Getting a render tree rooted at a certain DOMNode




Am 31.03.2006 um 16:07 Uhr schrieb Andreas Mayer:

Could someone help me out with a few lines of (Cocoa) code that shows how to get at the actual (rendered) size of a DOM object?

No one? Please?

It seems to me that the W3C DOM is really just a model and has no connection at all to the actual rendering.

Also, clientWidth and friends seem to be part of Microsofts IE DHTML object model only and are therefore absent in Apple's implementation of the W3C DOM. (http://developer.mozilla.org/en/docs/ DOM:element.clientWidth)

So how may I find out at what size an element is actually rendered?

I tried reading the style declaration like this:

DOMDocument *myDOMDocument = [[myWebView mainFrame] DOMDocument];
id docElement = [myDOMDocument documentElement];
DOMElement *element = [myDOMDocument getElementById:@"paras"];
DOMCSSStyleDeclaration *style = [myDOMDocument getOverrideStyle:element :@"mm"];
NSLog(@"height: %@", [style height]);
DOMCSSValue *cssValue = [style getPropertyCSSValue:@"height"];
float height = [(DOMCSSPrimitiveValue *)cssValue getFloatValue:DOM_CSS_CM];
NSLog(@"height: %f", height);


But this will always return the height like it is defined in the CSS - no matter how big the element is actually rendered.

On a side note, I thought - (float)getFloatValue:(unsigned short) unitType; was supposed to return the specified value in the unit passed in by unitType. (http://www.w3.org/TR/2000/REC-DOM-Level-2- Style-20001113/css.html#CSS-CSSStyleDeclaration)
But I get always the same value, no matter what unit I specify.


I *really* need to know the size of a specific (text) element, to be able to build my pages correctly. And ideally in a unit other than pixels ...

Any help would be appreciated.


Andreas _______________________________________________ Do not post admin requests to the list. They will be ignored. Webkitsdk-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/webkitsdk-dev/email@hidden

This email sent to email@hidden


Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.