[webkit-help] Computing clientX & clientY for a Node.

huangxueqing huangxueqing at baidu.com
Mon Mar 5 18:09:12 PST 2012

Try this:
IntRect rect = static_cast<Element*>(node)->screenRect();
IntPoint p = m_page->chrome()->client()->screenToWindow(rect.x(), rect.y());

Which could return a coordinate relative viewport and has included scroll

>Message: 1
>Date: Mon, 05 Mar 2012 09:01:19 -0800
>From: Sam White <samuel_white at apple.com>
>To: webkit-help at lists.webkit.org
>Subject: [webkit-help] Computing clientX & clientY for a Node.
>Message-ID: <46CA0658-EDEC-4F37-9CE9-02008B8D93F3 at apple.com>
>Content-Type: text/plain; CHARSET=US-ASCII

>Hey WebKit,

>I'm trying to compute clientX & clientY for a Node in a way that is
relative to the viewport. So far I've only found the absoluteBoundingBoxRect
function on renderObject but the rect it returns is relative to the
>document. Any help with this would be great.


More information about the webkit-help mailing list