void search(gpointer data, gint direction) { struct Client *c = (struct Client *)data; WebKitWebView *web_view = WEBKIT_WEB_VIEW(c->web_view); WebKitFindController *fc = webkit_web_view_get_find_controller(web_view); if (search_text == NULL) return; switch (direction) { case 0: webkit_find_controller_search(fc, search_text, WEBKIT_FIND_OPTIONS_CASE_INSENSITIVE | WEBKIT_FIND_OPTIONS_WRAP_AROUND, G_MAXUINT); break; case 1: webkit_find_controller_search_next(fc); break; case -1: webkit_find_controller_search_previous(fc); break; } }
void runInSiteSearch(RuskWindow *rusk, const char *query, const int force) { WebKitFindController *finder = webkit_web_view_get_find_controller(rusk->webview); const char *oldquery = webkit_find_controller_get_search_text(finder); if(query && (oldquery == NULL || strcmp(query, oldquery) != 0 || force)) { webkit_find_controller_search(finder, query, WEBKIT_FIND_OPTIONS_CASE_INSENSITIVE|WEBKIT_FIND_OPTIONS_WRAP_AROUND, 128); } }
gboolean wk_html_find_again(WkHtml *html, gboolean forward) { #ifdef USE_WEBKIT2 WebKitFindController *find_controller; find_controller = webkit_web_view_get_find_controller(WEBKIT_WEB_VIEW(html)); webkit_find_controller_search(find_controller, html->priv->find_string, WEBKIT_FIND_OPTIONS_NONE, G_MAXUINT); #else return webkit_web_view_search_text(WEBKIT_WEB_VIEW(html), html->priv->find_string, FALSE, forward, TRUE); #endif }
static void failed_to_find_text_cb (WebKitFindController *controller, EphyFindToolbar *toolbar) { WebKitFindOptions options; options = webkit_find_controller_get_options (controller); if (options & WEBKIT_FIND_OPTIONS_WRAP_AROUND) { set_status (toolbar, EPHY_FIND_RESULT_NOTFOUND); return; } options |= WEBKIT_FIND_OPTIONS_WRAP_AROUND; webkit_find_controller_search (controller, toolbar->find_string, options, G_MAXUINT); }
static void real_find (EphyFindToolbar *toolbar, EphyFindDirection direction) { WebKitFindOptions options = WEBKIT_FIND_OPTIONS_NONE; if (!g_strcmp0 (toolbar->find_string, "")) return; if (!str_has_uppercase (toolbar->find_string)) options |= WEBKIT_FIND_OPTIONS_CASE_INSENSITIVE; if (direction == EPHY_FIND_DIRECTION_PREV) options |= WEBKIT_FIND_OPTIONS_BACKWARDS; webkit_find_controller_search (toolbar->controller, toolbar->find_string, options, G_MAXUINT); }
static void real_find (EphyFindToolbarPrivate *priv, EphyFindDirection direction) { WebKitFindOptions options = WEBKIT_FIND_OPTIONS_NONE; if (!g_strcmp0 (priv->find_string, "")) return; if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->case_sensitive))) options |= WEBKIT_FIND_OPTIONS_CASE_INSENSITIVE; if (direction == EPHY_FIND_DIRECTION_PREV) options |= WEBKIT_FIND_OPTIONS_BACKWARDS; webkit_find_controller_search (priv->controller, priv->find_string, options, G_MAXUINT); }
gboolean wk_html_find(WkHtml *html, const gchar *find_string) { if (html->priv->find_string) g_free(html->priv->find_string); html->priv->find_string = g_strdup(find_string); #ifdef USE_WEBKIT2 WebKitFindController *find_controller; find_controller = webkit_web_view_get_find_controller(WEBKIT_WEB_VIEW(html)); webkit_find_controller_search(find_controller, find_string, WEBKIT_FIND_OPTIONS_CASE_INSENSITIVE, G_MAXUINT); #else return webkit_web_view_search_text(WEBKIT_WEB_VIEW(html), find_string, FALSE, TRUE, TRUE); #endif }
long wxWebViewWebKit::Find(const wxString& text, int flags) { WebKitFindController* findctrl = webkit_web_view_get_find_controller(m_web_view); bool newSearch = false; if(text != m_findText || (flags & wxWEBVIEW_FIND_MATCH_CASE) != (m_findFlags & wxWEBVIEW_FIND_MATCH_CASE)) { newSearch = true; //If it is a new search we need to clear existing highlights webkit_find_controller_search_finish(findctrl); } m_findFlags = flags; m_findText = text; //If the search string is empty then we clear any selection and highlight if(text.empty()) { webkit_find_controller_search_finish(findctrl); ClearSelection(); return wxNOT_FOUND; } bool wrap = false, forward = true; guint32 options = WEBKIT_FIND_OPTIONS_NONE; if(flags & wxWEBVIEW_FIND_WRAP) { wrap = true; options |= WEBKIT_FIND_OPTIONS_WRAP_AROUND; } if(!(flags & wxWEBVIEW_FIND_MATCH_CASE)) { options |= WEBKIT_FIND_OPTIONS_CASE_INSENSITIVE; } if(flags & wxWEBVIEW_FIND_BACKWARDS) { forward = false; options |= WEBKIT_FIND_OPTIONS_BACKWARDS; } if(newSearch) { //Initially we count the matches to know how many we have m_findCount = -1; webkit_find_controller_count_matches(findctrl, wxGTK_CONV(text), options, G_MAXUINT); GMainContext *main_context = g_main_context_get_thread_default(); while (m_findCount == -1) { g_main_context_iteration(main_context, TRUE); } //Highlight them if needed if(flags & wxWEBVIEW_FIND_HIGHLIGHT_RESULT) { webkit_find_controller_search(findctrl, wxGTK_CONV(text), options, G_MAXUINT); } //In this case we return early to match IE behaviour m_findPosition = -1; return m_findCount; } else { if(forward) m_findPosition++; else m_findPosition--; if(m_findPosition < 0) m_findPosition += m_findCount; if(m_findPosition > m_findCount) m_findPosition -= m_findCount; } if(forward) { webkit_find_controller_search_next(findctrl); if(m_findPosition == m_findCount && !wrap) { return wxNOT_FOUND; } } else { webkit_find_controller_search_previous(findctrl); if(m_findPosition == -1 && !wrap) { return wxNOT_FOUND; } } return newSearch ? m_findCount : m_findPosition; }