[epiphany] ephy-web-view: do not warn of modified forms for short text in input elements
- From: Xan Lopez <xan src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [epiphany] ephy-web-view: do not warn of modified forms for short text in input elements
- Date: Fri, 10 Jun 2011 14:49:19 +0000 (UTC)
commit b130e1f89c752e0aa09dfbb62616ad0ec6792c36
Author: Xan Lopez <xlopez igalia com>
Date: Fri Jun 10 16:48:30 2011 +0200
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).
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 8830bc3..3194795 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;
+ }
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]