diff options
author | Xan Lopez <xlopez@igalia.com> | 2011-06-10 22:48:30 +0800 |
---|---|---|
committer | Xan Lopez <xlopez@igalia.com> | 2011-06-10 22:48:30 +0800 |
commit | b130e1f89c752e0aa09dfbb62616ad0ec6792c36 (patch) | |
tree | 1b1078db27ae5c0fd2b094b47bc6b6bae169ae17 | |
parent | 2ee1825bac5ec3db74798fd4ba9367dd55e0b363 (diff) | |
download | gsoc2013-epiphany-b130e1f89c752e0aa09dfbb62616ad0ec6792c36.tar gsoc2013-epiphany-b130e1f89c752e0aa09dfbb62616ad0ec6792c36.tar.gz gsoc2013-epiphany-b130e1f89c752e0aa09dfbb62616ad0ec6792c36.tar.bz2 gsoc2013-epiphany-b130e1f89c752e0aa09dfbb62616ad0ec6792c36.tar.lz gsoc2013-epiphany-b130e1f89c752e0aa09dfbb62616ad0ec6792c36.tar.xz gsoc2013-epiphany-b130e1f89c752e0aa09dfbb62616ad0ec6792c36.tar.zst gsoc2013-epiphany-b130e1f89c752e0aa09dfbb62616ad0ec6792c36.zip |
ephy-web-view: do not warn of modified forms for short text in input elements
It's not likely the user is interested in saving this, and it's pretty
common (eg, google.com).
-rw-r--r-- | embed/ephy-web-view.c | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/embed/ephy-web-view.c b/embed/ephy-web-view.c index 8830bc331..31947954b 100644 --- a/embed/ephy-web-view.c +++ b/embed/ephy-web-view.c @@ -3062,6 +3062,8 @@ ephy_web_view_set_typed_address (EphyWebView *view, g_object_notify (G_OBJECT (view), "typed-address"); } +#define MIN_INPUT_LENGTH 50 + /** * ephy_web_view_has_modified_forms: * @view: an #EphyWebView @@ -3088,6 +3090,7 @@ ephy_web_view_has_modified_forms (EphyWebView *view) WebKitDOMNode *form_element = webkit_dom_html_collection_item (forms, i); gulong elements_n; int j; + gboolean modified_input_element = FALSE; elements = webkit_dom_html_form_element_get_elements (WEBKIT_DOM_HTML_FORM_ELEMENT (form_element)); elements_n = webkit_dom_html_collection_get_length (elements); @@ -3102,8 +3105,26 @@ ephy_web_view_has_modified_forms (EphyWebView *view) return TRUE; if (WEBKIT_DOM_IS_HTML_INPUT_ELEMENT (element)) - if (webkit_dom_html_input_element_is_edited (WEBKIT_DOM_HTML_INPUT_ELEMENT (element))) - return TRUE; + if (webkit_dom_html_input_element_is_edited (WEBKIT_DOM_HTML_INPUT_ELEMENT (element))) { + glong length; + char *text; + + /* A small heuristic here. If there's only one input element + * modified and it does not have a lot of text the user is + * likely not very interested in saving this work, so do + * nothing (eg, google search input). */ + if (modified_input_element) + return TRUE; + + modified_input_element = TRUE; + + text = webkit_dom_html_input_element_get_value (WEBKIT_DOM_HTML_INPUT_ELEMENT (element)); + length = g_utf8_strlen (text, -1); + g_free (text); + + if (length > MIN_INPUT_LENGTH) + return TRUE; + } } } |