Ejemplo n.º 1
0
static void testWebViewEditorSelectAllEditable(EditorTest* test, gconstpointer)
{
    static const char* selectedSpanHTML = "<html><body contentEditable=\"true\">"
        "<span id=\"mainspan\">All work and no play <span id=\"subspan\">make Jack a dull</span> boy.</span>"
        "<script>document.getSelection().collapse();\n"
        "document.getSelection().selectAllChildren(document.getElementById('subspan'));\n"
        "</script></body></html>";

    g_assert(test->canExecuteEditingCommand(WEBKIT_EDITING_COMMAND_SELECT_ALL));

    test->loadHtml(selectedSpanHTML, 0);
    test->waitUntilLoadFinished();

    g_assert(test->canExecuteEditingCommand(WEBKIT_EDITING_COMMAND_SELECT_ALL));

    test->copyClipboard();
    GUniquePtr<char> clipboardText(gtk_clipboard_wait_for_text(test->m_clipboard));

    // Initially only the subspan is selected.
    g_assert_cmpstr(clipboardText.get(), ==, "make Jack a dull");

    webkit_web_view_execute_editing_command(test->m_webView, WEBKIT_EDITING_COMMAND_SELECT_ALL);
    test->copyClipboard();
    clipboardText.reset(gtk_clipboard_wait_for_text(test->m_clipboard));

    // The mainspan should be selected after calling SELECT_ALL.
    g_assert_cmpstr(clipboardText.get(), ==, "All work and no play make Jack a dull boy.");
}
Ejemplo n.º 2
0
 void copyClipboard()
 {
     webkit_web_view_execute_editing_command(m_webView, WEBKIT_EDITING_COMMAND_COPY);
     // There's no way to know when the selection has been copied to
     // the clipboard, so use a timeout source to query the clipboard.
     m_triesCount = 0;
     g_timeout_add(kClipboardWaitTimeout, reinterpret_cast<GSourceFunc>(waitForClipboardText), this);
     g_main_loop_run(m_mainLoop);
 }
Ejemplo n.º 3
0
void wk_html_select_all(WkHtml *html)
{
#ifdef USE_WEBKIT2
	webkit_web_view_execute_editing_command(WEBKIT_WEB_VIEW(html),
						WEBKIT_EDITING_COMMAND_SELECT_ALL);
#else
	webkit_web_view_select_all(WEBKIT_WEB_VIEW(html));
#endif
}
Ejemplo n.º 4
0
void wk_html_copy_selection(WkHtml *html)
{
#ifdef USE_WEBKIT2
	webkit_web_view_execute_editing_command(WEBKIT_WEB_VIEW(html),
						WEBKIT_EDITING_COMMAND_COPY);
#else
	if (webkit_web_view_has_selection(WEBKIT_WEB_VIEW(html)))
		webkit_web_view_copy_clipboard(WEBKIT_WEB_VIEW(html));
#endif
}
Ejemplo n.º 5
0
static VbResult normal_search_selection(Client *c, const NormalCmdInfo *info)
{
    int count;
    char *query;

    /* there is no function to get the selected text so we copy current
     * selection to clipboard */
    webkit_web_view_execute_editing_command(c->webview, WEBKIT_EDITING_COMMAND_COPY);
    query = gtk_clipboard_wait_for_text(gtk_clipboard_get(GDK_SELECTION_PRIMARY));
    if (!query) {
        return RESULT_ERROR;
    }
    count = (info->count > 0) ? info->count : 1;

    command_search(c, &((Arg){info->key == '*' ? count : -count, query}), TRUE);
    g_free(query);

    return RESULT_COMPLETE;
}
Ejemplo n.º 6
0
static gboolean button_release_handler(GtkWidget *widget, GdkEventButton *event)
{
	if (event->type == GDK_BUTTON_RELEASE && db_click) {
		XI_message((" button 1 = %s", "double click!\n"));

#ifdef USE_WEBKIT2
		webkit_web_view_execute_editing_command(WEBKIT_WEB_VIEW(widget),
							WEBKIT_EDITING_COMMAND_COPY);
#else
		if (webkit_web_view_has_selection(WEBKIT_WEB_VIEW(widget))) {
			webkit_web_view_copy_clipboard(WEBKIT_WEB_VIEW(widget));
		}
#endif
		GtkClipboard *clipboard = gtk_widget_get_clipboard(widget, GDK_SELECTION_CLIPBOARD);
		gtk_clipboard_request_text(clipboard, gui_get_clipboard_text_for_lookup, NULL);
	}

	return FALSE;
}
Ejemplo n.º 7
0
void wxWebViewWebKit::Redo()
{
    webkit_web_view_execute_editing_command(m_web_view,
                                            WEBKIT_EDITING_COMMAND_REDO);
}
Ejemplo n.º 8
0
void wxWebViewWebKit::Paste()
{
    webkit_web_view_execute_editing_command(m_web_view,
                                            WEBKIT_EDITING_COMMAND_PASTE);
}
Ejemplo n.º 9
0
void wxWebViewWebKit::Copy()
{
    webkit_web_view_execute_editing_command(m_web_view,
                                            WEBKIT_EDITING_COMMAND_COPY);
}
Ejemplo n.º 10
0
void wxWebViewWebKit::SelectAll()
{
    webkit_web_view_execute_editing_command(m_web_view,
                                            WEBKIT_EDITING_COMMAND_SELECT_ALL);
}
Ejemplo n.º 11
0
void WebViewTest::selectAll()
{
    webkit_web_view_execute_editing_command(m_webView, "SelectAll");
}