View Full Version : WebKit Element/Node Rect

Jun 25, 2007, 02:20 PM
How can I get an NSRect frame of a WebKit Element/Node?

Like how Coda and CSSEdit 2 allow you to click an element and then get a bounding box. I want to do virtually the same so I need the NSRect frame (not WebFrame) of an elementAtPoint:

(this is Cocoa - compatibility is Tiger+)

Thanks in advance :)

Jun 25, 2007, 07:39 PM
You could try playing with:

- (DOMHTMLElement *)frameElement

The returned object may be an instance of either DOMHTMLFrameElement, DOMHTMLIFrameElement or DOMHTMLObjectElement. Returns nil if the receiver is the main frame.

DOMHTMLElement is a subclass of DOMElement which appears to have some location info. If that's not it, I'm sure it's in those DOM classes somewhere.

Jun 26, 2007, 03:56 AM
Wouldn't that just return the <frame> of an element?

The best I've got is that you can call elementAtPoint: on an WebHTMLView to get a dictionary to get a DOMHTMLElement. But I can't find anything in that class or any of it's subclasses for location or size. DOMHTMLTableElement and DOMHTMLFrameElement seem to have something, but most elements are not frames or tables (or hopefully they aren't frames or tables, otherwise that web developer has some serious questions to answer :p).

I just googled RenderBlock which is apparently a C++ class and part of webkit. I think this has location info (safari 2 debug render inspector) so I'm going to look into that.

Any help is welcome :)

EDIT: Looks like I can use WebCoreBridge