diff options
| author | miguel <miguel@localhost> | 2018-03-20 21:15:10 +0100 |
|---|---|---|
| committer | miguel <miguel@localhost> | 2018-03-20 21:15:10 +0100 |
| commit | 82bf432d6c02e8aed2826b7eea555c80e4d0142e (patch) | |
| tree | eda8f147aaed86508f47d62c2be018cd86f9e03d /webext-piper.c | |
| parent | 85d9c45f02661a41f33e1eecc7b5beeeaa6f3d47 (diff) | |
add input box focus
Diffstat (limited to 'webext-piper.c')
| -rw-r--r-- | webext-piper.c | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/webext-piper.c b/webext-piper.c index 80c765c..6801a26 100644 --- a/webext-piper.c +++ b/webext-piper.c @@ -54,20 +54,24 @@ void hide_hints(WebKitDOMHTMLDocument *doc,int skip) WebKitDOMNode *node = webkit_dom_node_list_item (hints,s); WebKitDOMNode *parent = webkit_dom_node_get_parent_node (node); webkit_dom_node_remove_child (parent,node,NULL); - } } void show_hints(WebKitDOMHTMLDocument *doc) { WebKitDOMElement *body = webkit_dom_document_get_body(doc); - WebKitDOMHTMLCollection *links = webkit_dom_document_get_links(doc); - gulong c = webkit_dom_html_collection_get_length (links); +// WebKitDOMHTMLCollection *links = webkit_dom_document_get_elements_by_tag_name_as_html_collection(doc,"a"); +// gulong c = webkit_dom_html_collection_get_length (links); + WebKitDOMNodeList *links=webkit_dom_element_query_selector_all(body,"a,input,textarea",NULL); + gulong c = webkit_dom_node_list_get_length(links); for(gulong i=0;i<c;i++) { char buf[1024]; - WebKitDOMHTMLAnchorElement *node = webkit_dom_html_collection_item (links,i); +// WebKitDOMHTMLAnchorElement *node = webkit_dom_html_collection_item (links,i); + WebKitDOMElement *node=webkit_dom_node_list_item(links,i); + + WebKitDOMClientRect *rect=webkit_dom_element_get_bounding_client_rect (node); // snprintf(buf,1024,"LINK: %d",i); // webkit_dom_element_set_inner_html(node,buf,NULL); @@ -133,15 +137,19 @@ static void follow_link(int id,int link_num,bool new_win) hide_hints(my_doc[id],link_num); hints_active[id]=false; - WebKitDOMHTMLCollection *links = webkit_dom_document_get_links(my_doc[id]); - gulong c = webkit_dom_html_collection_get_length (links); + WebKitDOMElement *body = webkit_dom_document_get_body(my_doc[id]); + WebKitDOMNodeList *links=webkit_dom_element_query_selector_all(body,"a,input,textarea",NULL); + gulong c = webkit_dom_node_list_get_length(links); + if(link_num>=c)return; - WebKitDOMHTMLAnchorElement *node = webkit_dom_html_collection_item (links,link_num); if(!new_win) { + WebKitDOMElement *node=webkit_dom_node_list_item(links,link_num); + webkit_dom_element_focus(node); webkit_dom_html_element_click(node); return; } + WebKitDOMHTMLAnchorElement *node =webkit_dom_node_list_item(links,link_num); char *href=webkit_dom_html_anchor_element_get_href (node); char buf[1024]; snprintf(buf,1024,"%s\n",href); |
