Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

ATG

macrumors regular
Original poster
Aug 7, 2005
187
0
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 :)
 

kainjow

Moderator emeritus
Jun 15, 2000
7,958
7
You could try playing with:

- (DOMHTMLElement *)frameElement

Discussion
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.
 

ATG

macrumors regular
Original poster
Aug 7, 2005
187
0
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
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.