WebKit Element/Node Rect

Discussion in 'Mac Programming' started by ATG, Jun 25, 2007.

  1. ATG macrumors regular

    Aug 7, 2005
    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 :)
  2. kainjow Moderator emeritus


    Jun 15, 2000
    You could try playing with:

    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.
  3. ATG thread starter macrumors regular

    Aug 7, 2005
    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

Share This Page