From 45905403026cc7f6547b6f559c68e4882422eb05 Mon Sep 17 00:00:00 2001 From: Daniel Carl Date: Mon, 20 Jul 2015 12:54:26 +0200 Subject: [PATCH] Removed function from public scope. The function dom_auto_insert_unless_strict_focus was only used internal and was really small, so the content was moved to the only placed where it was called. Also added a missed comment that might still be interesting. --- src/dom.c | 28 ++++++++++++++-------------- src/dom.h | 1 - 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/src/dom.c b/src/dom.c index 7fc24bb..3e86e81 100644 --- a/src/dom.c +++ b/src/dom.c @@ -30,19 +30,6 @@ static gboolean editable_focus_cb(Element *element, Event *event); static Element *get_active_element(Document *doc); -void dom_auto_insert_unless_strict_focus(Document *doc) -{ - Element *active = webkit_dom_html_document_get_active_element(WEBKIT_DOM_HTML_DOCUMENT(doc)); - - if (active) { - if (!vb.config.strict_focus) { - auto_insert(active); - } else if (vb.mode->id != 'i') { - webkit_dom_element_blur(active); - } - } -} - void dom_install_focus_blur_callbacks(Document *doc) { HtmlElement *element = webkit_dom_document_get_body(doc); @@ -62,7 +49,20 @@ void dom_install_focus_blur_callbacks(Document *doc) void dom_check_auto_insert(Document *doc) { - dom_auto_insert_unless_strict_focus(doc); + Element *active = webkit_dom_html_document_get_active_element(WEBKIT_DOM_HTML_DOCUMENT(doc)); + + if (active) { + if (!vb.config.strict_focus) { + auto_insert(active); + } else if (vb.mode->id != 'i') { + /* If strict-focus is enabled and the editable element becomes + * focus, we explicitely remove the focus. But only if vimb isn't + * in input mode at the time. This prevents from leaving input + * mode that was started by user interaction like click to + * editable element, or the 'gi' normal mode command. */ + webkit_dom_element_blur(active); + } + } dom_install_focus_blur_callbacks(doc); } diff --git a/src/dom.h b/src/dom.h index db3331a..892a2d8 100644 --- a/src/dom.h +++ b/src/dom.h @@ -33,7 +33,6 @@ #define HtmlTextareaElement WebKitDOMHTMLTextAreaElement void dom_install_focus_blur_callbacks(Document *doc); -void dom_auto_insert_unless_strict_focus(Document *doc); void dom_check_auto_insert(Document *doc); void dom_clear_focus(WebKitWebView *view); gboolean dom_focus_input(Document *doc); -- 2.20.1