Changeset 60834 in webkit


Ignore:
Timestamp:
Jun 8, 2010 4:25:10 AM (14 years ago)
Author:
xan@webkit.org
Message:

2010-06-08 Xan Lopez <xlopez@igalia.com>

Reviewed by Gustavo Noronha.

[GTK] Add inner-node property to WebKitHitTestResult
https://bugs.webkit.org/show_bug.cgi?id=40131

Add a 'inner-node' property to WebKitHitTestResult, carrying the
DOM node where the hit test happened.

  • tests/testhittestresult.c: (load_status_cb):
  • webkit/webkithittestresult.cpp: (webkit_hit_test_result_get_property): (webkit_hit_test_result_set_property): (webkit_hit_test_result_class_init):
  • webkit/webkitprivate.cpp: (WebKit::kit):
Location:
trunk/WebKit/gtk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebKit/gtk/ChangeLog

    r60819 r60834  
     12010-06-08  Xan Lopez  <xlopez@igalia.com>
     2
     3        Reviewed by Gustavo Noronha.
     4
     5        [GTK] Add inner-node property to WebKitHitTestResult
     6        https://bugs.webkit.org/show_bug.cgi?id=40131
     7
     8        Add a 'inner-node' property to WebKitHitTestResult, carrying the
     9        DOM node where the hit test happened.
     10
     11        * tests/testhittestresult.c:
     12        (load_status_cb):
     13        * webkit/webkithittestresult.cpp:
     14        (webkit_hit_test_result_get_property):
     15        (webkit_hit_test_result_set_property):
     16        (webkit_hit_test_result_class_init):
     17        * webkit/webkitprivate.cpp:
     18        (WebKit::kit):
     19
    1202010-06-07  Martin Robinson  <mrobinson@igalia.com>
    221
  • trunk/WebKit/gtk/tests/testhittestresult.c

    r48998 r60834  
    8383        guint context;
    8484        GdkEventButton event;
     85        WebKitDOMNode* node;
     86
    8587        event.type = GDK_BUTTON_PRESS;
    8688        /* Close enough to 0,0 */
     
    9092        result = webkit_web_view_get_hit_test_result(webView, &event);
    9193        g_assert(result);
     94
    9295        g_object_get(result, "context", &context, NULL);
    9396        g_assert(context & info->flag);
     97
     98        g_object_get(result, "inner-node", &node, NULL);
     99        g_assert(node);
     100        g_assert(WEBKIT_DOM_IS_NODE(node));
     101        /* We can only test these node types at the moment. In the
     102         * input case there seems to be an extra layer with a DIV on
     103         * top of the input, which gets assigned to the inner-node.
     104         * tag */
     105        if (info->flag == WEBKIT_HIT_TEST_RESULT_CONTEXT_DOCUMENT)
     106            g_assert(WEBKIT_DOM_IS_HTML_HTML_ELEMENT(node));
     107        else if (info->flag == WEBKIT_HIT_TEST_RESULT_CONTEXT_IMAGE)
     108            g_assert(WEBKIT_DOM_IS_HTML_IMAGE_ELEMENT(node));
     109        else if (info->flag == WEBKIT_HIT_TEST_RESULT_CONTEXT_LINK) {
     110            /* The hit test will give us the inner text node, we want
     111             * the A tag */
     112            WebKitDOMNode* parent = webkit_dom_node_get_parent_node(node);
     113            g_assert(WEBKIT_DOM_IS_HTML_ANCHOR_ELEMENT(parent));
     114        }
     115
    94116        g_object_unref(result);
    95117        g_main_loop_quit(loop);
  • trunk/WebKit/gtk/webkit/webkithittestresult.cpp

    r56825 r60834  
    2323
    2424#include "GOwnPtr.h"
     25#include "WebKitDOMNode.h"
    2526#include "webkitenumtypes.h"
    2627#include "webkitprivate.h"
     
    4445    char* imageURI;
    4546    char* mediaURI;
     47    WebKitDOMNode* innerNode;
    4648};
    4749
     
    5456    PROP_LINK_URI,
    5557    PROP_IMAGE_URI,
    56     PROP_MEDIA_URI
     58    PROP_MEDIA_URI,
     59    PROP_INNER_NODE
    5760};
    5861
     
    8790        g_value_set_string(value, priv->mediaURI);
    8891        break;
     92    case PROP_INNER_NODE:
     93        g_value_set_object(value, priv->innerNode);
     94        break;
    8995    default:
    9096        G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propertyID, pspec);
     
    112118        g_free (priv->mediaURI);
    113119        priv->mediaURI = g_value_dup_string(value);
     120        break;
     121    case PROP_INNER_NODE:
     122        priv->innerNode = static_cast<WebKitDOMNode*>(g_value_get_object(value));
    114123        break;
    115124    default:
     
    185194                                                        static_cast<GParamFlags>(WEBKIT_PARAM_READWRITE|G_PARAM_CONSTRUCT_ONLY)));
    186195
     196    /**
     197     * WebKitHitTestResult:inner-node:
     198     *
     199     * The DOM node at the coordinates where the hit test
     200     * happened. Keep in mind that the node might not be
     201     * representative of the information given in the context
     202     * property, since WebKit uses a series of heuristics to figure
     203     * out that information. One common example is inner-node having
     204     * the text node inside the anchor (<a>) tag; WebKit knows the
     205     * whole context and will put WEBKIT_HIT_TEST_RESULT_CONTEXT_LINK
     206     * in the 'context' property, but the user might be confused by
     207     * the lack of any link tag in 'inner-node'.
     208     *
     209     * Since: 1.3.2
     210     */
     211    g_object_class_install_property(objectClass, PROP_INNER_NODE,
     212                                    g_param_spec_object("inner-node",
     213                                                        _("Inner node"),
     214                                                        _("The inner DOM node associated with the hit test result."),
     215                                                        WEBKIT_TYPE_DOM_NODE,
     216                                                        static_cast<GParamFlags>(WEBKIT_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)));
     217
    187218    g_type_class_add_private(webHitTestResultClass, sizeof(WebKitHitTestResultPrivate));
    188219}
  • trunk/WebKit/gtk/webkit/webkitprivate.cpp

    r60819 r60834  
    4242#include "SecurityOrigin.h"
    4343#include "TextEncodingRegistry.h"
     44#include "WebKitDOMBinding.h"
    4445#include "webkitnetworkresponse.h"
    4546#include "webkitsoupauthdialog.h"
     
    141142    GOwnPtr<char> imageURI(0);
    142143    GOwnPtr<char> mediaURI(0);
     144    WebKitDOMNode* node = 0;
    143145
    144146    if (!result.absoluteLinkURL().isEmpty()) {
     
    163165        context |= WEBKIT_HIT_TEST_RESULT_CONTEXT_EDITABLE;
    164166
     167    if (result.innerNonSharedNode())
     168        node = static_cast<WebKitDOMNode*>(kit(result.innerNonSharedNode()));
     169
    165170    return WEBKIT_HIT_TEST_RESULT(g_object_new(WEBKIT_TYPE_HIT_TEST_RESULT,
    166                                            "link-uri", linkURI.get(),
    167                                            "image-uri", imageURI.get(),
    168                                            "media-uri", mediaURI.get(),
    169                                            "context", context,
    170                                            NULL));
     171                                               "link-uri", linkURI.get(),
     172                                               "image-uri", imageURI.get(),
     173                                               "media-uri", mediaURI.get(),
     174                                               "context", context,
     175                                               "inner-node", node,
     176                                               NULL));
    171177}
    172178
Note: See TracChangeset for help on using the changeset viewer.