Changeset 60834 in webkit
- Timestamp:
- Jun 8, 2010 4:25:10 AM (14 years ago)
- Location:
- trunk/WebKit/gtk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebKit/gtk/ChangeLog
r60819 r60834 1 2010-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 1 20 2010-06-07 Martin Robinson <mrobinson@igalia.com> 2 21 -
trunk/WebKit/gtk/tests/testhittestresult.c
r48998 r60834 83 83 guint context; 84 84 GdkEventButton event; 85 WebKitDOMNode* node; 86 85 87 event.type = GDK_BUTTON_PRESS; 86 88 /* Close enough to 0,0 */ … … 90 92 result = webkit_web_view_get_hit_test_result(webView, &event); 91 93 g_assert(result); 94 92 95 g_object_get(result, "context", &context, NULL); 93 96 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 94 116 g_object_unref(result); 95 117 g_main_loop_quit(loop); -
trunk/WebKit/gtk/webkit/webkithittestresult.cpp
r56825 r60834 23 23 24 24 #include "GOwnPtr.h" 25 #include "WebKitDOMNode.h" 25 26 #include "webkitenumtypes.h" 26 27 #include "webkitprivate.h" … … 44 45 char* imageURI; 45 46 char* mediaURI; 47 WebKitDOMNode* innerNode; 46 48 }; 47 49 … … 54 56 PROP_LINK_URI, 55 57 PROP_IMAGE_URI, 56 PROP_MEDIA_URI 58 PROP_MEDIA_URI, 59 PROP_INNER_NODE 57 60 }; 58 61 … … 87 90 g_value_set_string(value, priv->mediaURI); 88 91 break; 92 case PROP_INNER_NODE: 93 g_value_set_object(value, priv->innerNode); 94 break; 89 95 default: 90 96 G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propertyID, pspec); … … 112 118 g_free (priv->mediaURI); 113 119 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)); 114 123 break; 115 124 default: … … 185 194 static_cast<GParamFlags>(WEBKIT_PARAM_READWRITE|G_PARAM_CONSTRUCT_ONLY))); 186 195 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 187 218 g_type_class_add_private(webHitTestResultClass, sizeof(WebKitHitTestResultPrivate)); 188 219 } -
trunk/WebKit/gtk/webkit/webkitprivate.cpp
r60819 r60834 42 42 #include "SecurityOrigin.h" 43 43 #include "TextEncodingRegistry.h" 44 #include "WebKitDOMBinding.h" 44 45 #include "webkitnetworkresponse.h" 45 46 #include "webkitsoupauthdialog.h" … … 141 142 GOwnPtr<char> imageURI(0); 142 143 GOwnPtr<char> mediaURI(0); 144 WebKitDOMNode* node = 0; 143 145 144 146 if (!result.absoluteLinkURL().isEmpty()) { … … 163 165 context |= WEBKIT_HIT_TEST_RESULT_CONTEXT_EDITABLE; 164 166 167 if (result.innerNonSharedNode()) 168 node = static_cast<WebKitDOMNode*>(kit(result.innerNonSharedNode())); 169 165 170 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)); 171 177 } 172 178
Note: See TracChangeset
for help on using the changeset viewer.