| 930 |
930 |
| 931 static gboolean |
931 static gboolean |
| 932 webview_popup_menu(WebKitWebView *webview) |
932 webview_popup_menu(WebKitWebView *webview) |
| 933 { |
933 { |
| 934 WebKitDOMDocument *doc; |
934 WebKitDOMDocument *doc; |
| 935 WebKitDOMElement *active; |
935 WebKitDOMNode *node = NULL; |
| 936 WebKitDOMElement *link; |
936 int context = WEBKIT_HIT_TEST_RESULT_CONTEXT_DOCUMENT; |
| 937 int context; |
937 char *uri = NULL; |
| 938 char *uri; |
|
| 939 |
|
| 940 context = WEBKIT_HIT_TEST_RESULT_CONTEXT_DOCUMENT; |
|
| 941 uri = NULL; |
|
| 942 |
938 |
| 943 doc = webkit_web_view_get_dom_document(webview); |
939 doc = webkit_web_view_get_dom_document(webview); |
| 944 active = webkit_dom_html_document_get_active_element(WEBKIT_DOM_HTML_DOCUMENT(doc)); |
940 |
| 945 |
941 /* it's unlikely, at least for webkit 1.x */ |
| 946 link = active; |
942 if (WEBKIT_DOM_IS_HTML_DOCUMENT(doc)) { |
| 947 while (link && !WEBKIT_DOM_IS_HTML_ANCHOR_ELEMENT(link)) |
943 WebKitDOMElement *active; |
| 948 link = webkit_dom_node_get_parent_element(WEBKIT_DOM_NODE(link)); |
944 WebKitDOMElement *link; |
| 949 if (WEBKIT_DOM_IS_HTML_ANCHOR_ELEMENT(link)) { |
945 active = webkit_dom_html_document_get_active_element( |
| 950 context |= WEBKIT_HIT_TEST_RESULT_CONTEXT_LINK; |
946 WEBKIT_DOM_HTML_DOCUMENT(doc)); |
| 951 uri = webkit_dom_html_anchor_element_get_href(WEBKIT_DOM_HTML_ANCHOR_ELEMENT(link)); |
947 |
| |
948 link = active; |
| |
949 while (link && !WEBKIT_DOM_IS_HTML_ANCHOR_ELEMENT(link)) |
| |
950 link = webkit_dom_node_get_parent_element(WEBKIT_DOM_NODE(link)); |
| |
951 if (WEBKIT_DOM_IS_HTML_ANCHOR_ELEMENT(link)) { |
| |
952 context |= WEBKIT_HIT_TEST_RESULT_CONTEXT_LINK; |
| |
953 uri = webkit_dom_html_anchor_element_get_href(WEBKIT_DOM_HTML_ANCHOR_ELEMENT(link)); |
| |
954 } |
| 952 } |
955 } |
| 953 |
956 |
| 954 do_popup_menu(webview, 0, gtk_get_current_event_time(), |
957 do_popup_menu(webview, 0, gtk_get_current_event_time(), |
| 955 context, WEBKIT_DOM_NODE(active), uri); |
958 context, node, uri); |
| 956 |
959 |
| 957 g_free(uri); |
960 g_free(uri); |
| 958 |
961 |
| 959 return TRUE; |
962 return TRUE; |
| 960 } |
963 } |