[webkit-gtk] hovering-over-link signal and HitTestResult in WebKit2 API

Martin Robinson mrobinson at webkit.org
Thu Feb 2 08:21:31 PST 2012


On Thu, Feb 2, 2012 at 5:56 AM, Carlos Garcia Campos <cgarcia at igalia.com> wrote:
> WebKitWebView::element-hovered: signal that receives the mouse modifiers
> and a WebKitWebElement object.
>
> WebKitWebElement could be similar to HitTestResult in wk1 API:

This seems like a nice API, but I would still suggest using
WebKitHItTestResult for accuracy sake. This object is actually
something other than an element.

> WebKitWebElementContext: with flags DOCUMENT, LINK, IMAGE, MEDIA,
> SELECTION, EDITABLE
>
> gboolean webkit_web_element_is_document();
> gboolean webkit_web_element_is_link();
> gboolean webkit_web_element_is_image();
> gboolean webkit_web_element_is_media();
> gboolean webkit_web_element_is_selection();
> gboolean webkit_web_element_is_editable();
>
> That just checks the flags, so more than one can return TRUE for the
> same element like an image that is a link.

Notice here that it can be a selection. In WebKit a selection may
contains many elements. I believe this is also the case with Document.
An Element is a subclass of Node and a Document is a subclass of Node,
but Document isn't a subclass of Element. So perhaps the WebKitHitTest
may not even contain an Element at all?

We had the WebKitHitTestResult in WebKit1 as well. Later, if we manage
to get the DOM bindings into the WebKit2 API, I think we can do what
we did in WebKit1 and make the actual element a property of the
WebKitHitTestResult.

> const gchar *webkit_web_element_get_link_uri();
> const gchar *webkit_web_element_get_link_title();
> const gchar *webkit_web_element_get_link_label();
> const gchar *webkit_web_element_get_image_uri();
> const gchar *webkit_web_element_get_media_uri();
>
> What do you think?

This API seems awesome, but names like WebKitHitTestResult,
WebKitMouseTarget, or anything that avoids confusing it with a piece
of the DOM are far more apt, in my view. The class is actually just a
description of what the mouse is hovering over, not any single DOM
element. The WebCore designers are very careful in giving names, so I
think we can be safe here keeping the name intact.

--Martin


More information about the webkit-gtk mailing list