Commit e51ece1e authored by eric@webkit.org's avatar eric@webkit.org

2009-12-19 Alejandro G. Castro <alex@igalia.com>

        Reviewed by Xan Lopez.

        Tests for https://bugs.webkit.org/show_bug.cgi?id=28153
        can't middle-button paste within a single window

        * LayoutTests/platform/gtk/editing/pasteboard/middle-button-paste-expected.txt: Added
        * LayoutTests/platform/gtk/editing/pasteboard/middle-button-paste.html: Adeed
2009-12-19  Alejandro G. Castro  <alex@igalia.com>

        Reviewed by Xan Lopez.

        Fixed the problem when pasting in the same window with the
        middle-button, now we store a reference to the range instead of
        requesting it every time, and we do not release it until the
        clipboard is requested.
        https://bugs.webkit.org/show_bug.cgi?id=28153

        * WebKit/gtk/WebCoreSupport/EditorClientGtk.cpp:
        * WebKit/gtk/WebCoreSupport/EditorClientGtk.h:

git-svn-id: svn://svn.chromium.org/blink/trunk@52389 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 82060741
2009-12-19 Alejandro G. Castro <alex@igalia.com>
Reviewed by Xan Lopez.
Tests for https://bugs.webkit.org/show_bug.cgi?id=28153
can't middle-button paste within a single window
* LayoutTests/platform/gtk/editing/pasteboard/middle-button-paste-expected.txt: Added
* LayoutTests/platform/gtk/editing/pasteboard/middle-button-paste.html: Adeed
2009-12-19 MORITA Hajime <morrita@gmail.com> 2009-12-19 MORITA Hajime <morrita@gmail.com>
Reviewed by Darin Adler. Reviewed by Darin Adler.
Select me, selecSelect mt me, select me
The original text was "Select me, select me, select me", after selecting and pasting the result should be "Select me, selecSelect mt me, select me"
<html>
<head>
<script type="text/javascript">
if (window.layoutTestController)
layoutTestController.dumpAsText();
</script>
<style>
body { margin: 0; padding: 0 }
</style>
<script type="text/javascript">
function runTest()
{
var target = document.getElementById("text");
var x = target.offsetParent.offsetLeft + target.offsetLeft;
var y = target.offsetParent.offsetTop + target.offsetTop +
target.offsetHeight / 2;
eventSender.mouseDown();
eventSender.mouseMoveTo(x, y);
eventSender.mouseMoveTo(x + 50, y);
eventSender.mouseUp();
eventSender.mouseMoveTo(x + 100, y);
eventSender.mouseDown(1);
eventSender.mouseUp(1);
}
</script>
</head>
<body onload="runTest()">
<div id="text" contenteditable>Select me, select me, select me</div>
<br/>
<p>The original text was "Select me, select me, select me", after selecting and pasting the result should be "Select me, selecSelect mt me, select me"</p>
</body>
</html>
2009-12-19 Alejandro G. Castro <alex@igalia.com>
Reviewed by Xan Lopez.
Fixed the problem when pasting in the same window with the
middle-button, now we store a reference to the range instead of
requesting it every time, and we do not release it until the
clipboard is requested.
https://bugs.webkit.org/show_bug.cgi?id=28153
* WebKit/gtk/WebCoreSupport/EditorClientGtk.cpp:
* WebKit/gtk/WebCoreSupport/EditorClientGtk.h:
2009-12-19 Gustavo Noronha Silva <gustavo.noronha@collabora.co.uk> 2009-12-19 Gustavo Noronha Silva <gustavo.noronha@collabora.co.uk>
Reviewed by Xan Lopez. Reviewed by Xan Lopez.
......
...@@ -185,29 +185,28 @@ void EditorClient::respondToChangedContents() ...@@ -185,29 +185,28 @@ void EditorClient::respondToChangedContents()
notImplemented(); notImplemented();
} }
static void clipboard_get_contents_cb(GtkClipboard* clipboard, GtkSelectionData* selection_data, guint info, gpointer data) void clipboard_get_contents_cb(GtkClipboard* clipboard, GtkSelectionData* selection_data, guint info, gpointer data)
{ {
WebKitWebView* webView = reinterpret_cast<WebKitWebView*>(data); EditorClient* client = static_cast<EditorClient*>(data);
Frame* frame = core(webView)->focusController()->focusedOrMainFrame();
PassRefPtr<Range> selectedRange = frame->selection()->toNormalizedRange(); if (!client->m_range)
return;
if (static_cast<gint>(info) == WEBKIT_WEB_VIEW_TARGET_INFO_HTML) { if (static_cast<gint>(info) == WEBKIT_WEB_VIEW_TARGET_INFO_HTML) {
String markup = createMarkup(selectedRange.get(), 0, AnnotateForInterchange); String markup = createMarkup(client->m_range.get(), 0, AnnotateForInterchange);
gtk_selection_data_set(selection_data, selection_data->target, 8, gtk_selection_data_set(selection_data, selection_data->target, 8,
reinterpret_cast<const guchar*>(markup.utf8().data()), markup.utf8().length()); reinterpret_cast<const guchar*>(markup.utf8().data()), markup.utf8().length());
} else { } else {
String text = selectedRange->text(); String text = client->m_range->text();
gtk_selection_data_set_text(selection_data, text.utf8().data(), text.utf8().length()); gtk_selection_data_set_text(selection_data, text.utf8().data(), text.utf8().length());
} }
} }
static void clipboard_clear_contents_cb(GtkClipboard* clipboard, gpointer data) void clipboard_clear_contents_cb(GtkClipboard* clipboard, gpointer data)
{ {
WebKitWebView* webView = reinterpret_cast<WebKitWebView*>(data); EditorClient* client = static_cast<EditorClient*>(data);
Frame* frame = core(webView)->focusController()->focusedOrMainFrame();
// Collapse the selection without clearing it client->m_range = 0;
frame->selection()->setBase(frame->selection()->extent(), frame->selection()->affinity());
} }
void EditorClient::respondToChangedSelection() void EditorClient::respondToChangedSelection()
...@@ -226,11 +225,11 @@ void EditorClient::respondToChangedSelection() ...@@ -226,11 +225,11 @@ void EditorClient::respondToChangedSelection()
GtkTargetList* targetList = webkit_web_view_get_copy_target_list(m_webView); GtkTargetList* targetList = webkit_web_view_get_copy_target_list(m_webView);
gint targetCount; gint targetCount;
GtkTargetEntry* targets = gtk_target_table_new_from_list(targetList, &targetCount); GtkTargetEntry* targets = gtk_target_table_new_from_list(targetList, &targetCount);
gtk_clipboard_set_with_owner(clipboard, targets, targetCount, gtk_clipboard_set_with_data(clipboard, targets, targetCount,
clipboard_get_contents_cb, clipboard_clear_contents_cb, G_OBJECT(m_webView)); clipboard_get_contents_cb, clipboard_clear_contents_cb, this);
m_range = targetFrame->selection()->toNormalizedRange();
gtk_target_table_free(targets, targetCount); gtk_target_table_free(targets, targetCount);
} else if (gtk_clipboard_get_owner(clipboard) == G_OBJECT(m_webView)) }
gtk_clipboard_clear(clipboard);
if (!targetFrame->editor()->hasComposition()) if (!targetFrame->editor()->hasComposition())
return; return;
...@@ -551,6 +550,7 @@ void EditorClient::handleInputMethodKeydown(KeyboardEvent* event) ...@@ -551,6 +550,7 @@ void EditorClient::handleInputMethodKeydown(KeyboardEvent* event)
EditorClient::EditorClient(WebKitWebView* webView) EditorClient::EditorClient(WebKitWebView* webView)
: m_isInRedo(false) : m_isInRedo(false)
, m_webView(webView) , m_webView(webView)
, m_range(0)
{ {
WebKitWebViewPrivate* priv = m_webView->priv; WebKitWebViewPrivate* priv = m_webView->priv;
g_signal_connect(priv->imContext, "commit", G_CALLBACK(imContextCommitted), this); g_signal_connect(priv->imContext, "commit", G_CALLBACK(imContextCommitted), this);
......
...@@ -34,6 +34,7 @@ ...@@ -34,6 +34,7 @@
#include <wtf/Deque.h> #include <wtf/Deque.h>
#include <wtf/Forward.h> #include <wtf/Forward.h>
#include <gtk/gtk.h>
typedef struct _WebKitWebView WebKitWebView; typedef struct _WebKitWebView WebKitWebView;
...@@ -120,6 +121,10 @@ namespace WebKit { ...@@ -120,6 +121,10 @@ namespace WebKit {
private: private:
WebKitWebView* m_webView; WebKitWebView* m_webView;
RefPtr<WebCore::Range> m_range;
friend void clipboard_get_contents_cb(GtkClipboard* clipboard, GtkSelectionData* selection_data, guint info, gpointer data);
friend void clipboard_clear_contents_cb(GtkClipboard* clipboard, gpointer data);
}; };
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment