Changeset 71031 in webkit


Ignore:
Timestamp:
Nov 1, 2010 9:00:01 AM (13 years ago)
Author:
Martin Robinson
Message:

2010-11-01 Martin Robinson <mrobinson@igalia.com>

Reviewed by Xan Lopez.

[GTK] Pasting markup into Thunderbird compose window produces no text
https://bugs.webkit.org/show_bug.cgi?id=43737

Include a content-type meta tag prefix on all clipboard markup. Programs like
Thunderbird expect this meta tag and will not paste anything unless it is there.

This is covered by changes to WebKit/gtk/tests/testcopyandpaste.c. This patch was
written in such a way as to not affect layout test results, otherwise there
would be many new GTK+-specific results that say "FAIL").

  • platform/gtk/PasteboardHelper.cpp: (WebCore::removeMarkupPrefix): Added this helper which removes the prefix when found on incoming clipboard and drag-and-drop text. (WebCore::PasteboardHelper::getClipboardContents): Remove the meta tag prefix. (WebCore::PasteboardHelper::fillSelectionData): Add the meta tag prefix. (WebCore::PasteboardHelper::fillDataObjectFromDropData): Remove the meta tag prefix

2010-11-01 Martin Robinson <mrobinson@igalia.com>

Reviewed by Xan Lopez.

[GTK] Pasting markup into Thunderbird compose window produces no text
https://bugs.webkit.org/show_bug.cgi?id=43737

Added a test verifying that the meta tag prefix on markup data exists.

  • tests/testcopyandpaste.c: (load_status_cb): Add a check for the meta tag prefix.
Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r71027 r71031  
     12010-11-01  Martin Robinson  <mrobinson@igalia.com>
     2
     3        Reviewed by Xan Lopez.
     4
     5        [GTK] Pasting markup into Thunderbird compose window produces no text
     6        https://bugs.webkit.org/show_bug.cgi?id=43737
     7
     8        Include a content-type meta tag prefix on all clipboard markup. Programs like
     9        Thunderbird expect this meta tag and will not paste anything unless it is there.
     10
     11        This is covered by changes to WebKit/gtk/tests/testcopyandpaste.c. This patch was
     12        written in such a way as to not affect layout test results, otherwise there
     13        would be many new GTK+-specific results that say "FAIL").
     14
     15        * platform/gtk/PasteboardHelper.cpp:
     16        (WebCore::removeMarkupPrefix): Added this helper which removes the prefix
     17        when found on incoming clipboard and drag-and-drop text.
     18        (WebCore::PasteboardHelper::getClipboardContents): Remove the meta tag prefix.
     19        (WebCore::PasteboardHelper::fillSelectionData): Add the meta tag prefix.
     20        (WebCore::PasteboardHelper::fillDataObjectFromDropData): Remove the meta tag prefix
     21
    1222010-11-01  Justin Schuh  <jschuh@chromium.org>
    223
  • trunk/WebCore/platform/gtk/PasteboardHelper.cpp

    r69530 r71031  
    3939static GdkAtom netscapeURLAtom = gdk_atom_intern("_NETSCAPE_URL", FALSE);
    4040static GdkAtom uriListAtom = gdk_atom_intern("text/uri-list", FALSE);
     41static String gMarkupPrefix = "<meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\">";
     42
     43static void removeMarkupPrefix(String& markup)
     44{
     45
     46    // The markup prefix is not harmful, but we remove it from the string anyway, so that
     47    // we can have consistent results with other ports during the layout tests.
     48    if (markup.startsWith(gMarkupPrefix))
     49        markup.remove(0, gMarkupPrefix.length());
     50}
    4151
    4252PasteboardHelper::PasteboardHelper()
     
    113123    if (gtk_clipboard_wait_is_target_available(clipboard, markupAtom)) {
    114124        if (GtkSelectionData* data = gtk_clipboard_wait_for_contents(clipboard, markupAtom)) {
    115             dataObject->setMarkup(selectionDataToUTF8String(data));
     125            String markup(selectionDataToUTF8String(data));
     126            removeMarkupPrefix(markup);
     127            dataObject->setMarkup(markup);
    116128            gtk_selection_data_free(data);
    117129        }
     
    132144
    133145    else if (info == getIdForTargetType(TargetTypeMarkup)) {
    134         GOwnPtr<gchar> markup(g_strdup(dataObject->markup().utf8().data()));
     146        // Some Linux applications refuse to accept pasted markup unless it is
     147        // prefixed by a content-type meta tag.
     148        CString markup = (gMarkupPrefix + dataObject->markup()).utf8();
    135149        gtk_selection_data_set(selectionData, markupAtom, 8,
    136             reinterpret_cast<const guchar*>(markup.get()), strlen(markup.get()) + 1);
     150            reinterpret_cast<const guchar*>(markup.data()), markup.length() + 1);
    137151
    138152    } else if (info == getIdForTargetType(TargetTypeURIList)) {
     
    188202    if (target == textPlainAtom)
    189203        dataObject->setText(selectionDataToUTF8String(data));
    190     else if (target == markupAtom)
    191         dataObject->setMarkup(selectionDataToUTF8String(data));
    192     else if (target == uriListAtom) {
     204    else if (target == markupAtom) {
     205        String markup(selectionDataToUTF8String(data));
     206        removeMarkupPrefix(markup);
     207        dataObject->setMarkup(markup);
     208    } else if (target == uriListAtom) {
    193209        dataObject->setURIList(selectionDataToUTF8String(data));
    194210    } else if (target == netscapeURLAtom) {
  • trunk/WebKit/gtk/ChangeLog

    r71026 r71031  
     12010-11-01  Martin Robinson  <mrobinson@igalia.com>
     2
     3        Reviewed by Xan Lopez.
     4
     5        [GTK] Pasting markup into Thunderbird compose window produces no text
     6        https://bugs.webkit.org/show_bug.cgi?id=43737
     7
     8        Added a test verifying that the meta tag prefix on markup data exists.
     9
     10        * tests/testcopyandpaste.c:
     11        (load_status_cb): Add a check for the meta tag prefix.
     12
    1132010-11-01  Mario Sanchez Prada  <msanchez@igalia.com>
    214
  • trunk/WebKit/gtk/tests/testcopyandpaste.c

    r69293 r71031  
    9393    g_free(text);
    9494
     95    // Verify that the markup starts with the proper content-type meta tag prefix.
     96    GtkSelectionData* selectionData = gtk_clipboard_wait_for_contents(clipboard, gdk_atom_intern("text/html", FALSE));
     97    if (selectionData) {
     98        static const char* markupPrefix = "<meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\">";
     99        char* markup = g_strndup((const char*) gtk_selection_data_get_data(selectionData),
     100            gtk_selection_data_get_length(selectionData));
     101        g_assert(strlen(markupPrefix) <= strlen(markup));
     102        g_assert(!strncmp(markupPrefix, markup, strlen(markupPrefix)));
     103        g_free(markup);
     104    }
     105
    95106    g_assert(!gtk_clipboard_wait_is_uris_available(clipboard));
    96107    g_assert(!gtk_clipboard_wait_is_image_available(clipboard));
Note: See TracChangeset for help on using the changeset viewer.