Changeset 207797 in webkit


Ignore:
Timestamp:
Oct 24, 2016 6:48:42 PM (7 years ago)
Author:
Chris Dumez
Message:

event.(dataTransfer|clipboardData).getData('text/html') (onpaste, ondrop)
https://bugs.webkit.org/show_bug.cgi?id=19893
<rdar://problem/6055546>

Reviewed by Ryosuke Niwa.

Source/WebCore:

We now write selection as HTML as well to the pasteboard so that
event.(dataTransfer|clipboardData).getData('text/html') now works.

I have verified manually that it is still possible to copy text from
Safari and paste it to Excel 2011 Mac after this change. The text is
now pasted as HTML instead of text, which is fine because Excel can
display HTML.

No new tests, unskipped existing tests.

  • editing/Editor.h:
  • editing/mac/EditorMac.mm:

(WebCore::Editor::selectionInHTMLFormat):
(WebCore::Editor::writeSelectionToPasteboard):

  • platform/Pasteboard.h:
  • platform/mac/PasteboardMac.mm:

(WebCore::Pasteboard::write):

LayoutTests:

Unskip corresponding tests on Mac.

  • editing/pasteboard/onpaste-text-html-expected.txt:
  • fast/events/ondrop-text-html-expected.txt:
  • platform/mac/TestExpectations:
  • platform/wk2/TestExpectations:
Location:
trunk
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r207795 r207797  
     12016-10-24  Chris Dumez  <cdumez@apple.com>
     2
     3        event.(dataTransfer|clipboardData).getData('text/html') (onpaste, ondrop)
     4        https://bugs.webkit.org/show_bug.cgi?id=19893
     5        <rdar://problem/6055546>
     6
     7        Reviewed by Ryosuke Niwa.
     8
     9        Unskip corresponding tests on Mac.
     10
     11        * editing/pasteboard/onpaste-text-html-expected.txt:
     12        * fast/events/ondrop-text-html-expected.txt:
     13        * platform/mac/TestExpectations:
     14        * platform/wk2/TestExpectations:
     15
    1162016-10-24  Alex Christensen  <achristensen@webkit.org>
    217
  • trunk/LayoutTests/editing/pasteboard/onpaste-text-html-expected.txt

    r145168 r207797  
    11CONSOLE MESSAGE: line 21: text/plain: This test verifies that we can get text/html from the clipboard during an onpaste event.
    2 CONSOLE MESSAGE: line 23: text/html: <span style="color: rgb(0, 0, 0); font-size: medium; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; display: inline !important; float: none;">This test verifies that we can get text/html from the clipboard during an onpaste event.<span class="Apple-converted-space"> </span></span>
     2CONSOLE MESSAGE: line 23: text/html: <span style="color: rgb(0, 0, 0); font-size: medium; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; display: inline !important; float: none;">This test verifies that we can get text/html from the clipboard during an onpaste event.<span class="Apple-converted-space"> </span></span>
    33This test verifies that we can get text/html from the clipboard during an onpaste event. This test requires DRT.
    44Paste content in this div.This test verifies that we can get text/html from the clipboard during an onpaste event. 
  • trunk/LayoutTests/fast/events/ondrop-text-html-expected.txt

    r145168 r207797  
    11CONSOLE MESSAGE: line 21: text/plain: This test verifies that we can get text/html from the drag object during an ondrop event.
    2 CONSOLE MESSAGE: line 23: text/html: <span style="color: rgb(0, 0, 0); font-size: medium; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; display: inline !important; float: none;">This test verifies that we can get text/html from the drag object during an ondrop event.<span class="Apple-converted-space"> </span></span>
     2CONSOLE MESSAGE: line 23: text/html: <span style="color: rgb(0, 0, 0); font-size: medium; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; display: inline !important; float: none;">This test verifies that we can get text/html from the drag object during an ondrop event.<span class="Apple-converted-space"> </span></span>
    33This test verifies that we can get text/html from the drag object during an ondrop event. This test requires DRT.
    44PASS
  • trunk/LayoutTests/platform/mac/TestExpectations

    r207786 r207797  
    9696# Need to add functionality to DumpRenderTree to handle scrollbar policy changes
    9797fast/overflow/scrollbar-restored-and-then-locked.html
    98 
    99 # Mac port doesn't put text/html on the pasteboard for app compatibility: https://bugs.webkit.org/show_bug.cgi?id=19893
    100 editing/pasteboard/onpaste-text-html-types.html
    101 editing/pasteboard/onpaste-text-html.html
    102 fast/events/ondrop-text-html.html
    10398
    10499# EventSendingController does not send events on areas outside the WebView.
  • trunk/LayoutTests/platform/wk2/TestExpectations

    r207330 r207797  
    225225fast/events/moving-text-should-fire-drop-and-dragend-events.html
    226226fast/events/moving-text-should-fire-drop-and-dragend-events-2.html
     227fast/events/ondrop-text-html.html
    227228editing/pasteboard/drag-drop-url-with-style.html
    228229
  • trunk/Source/WebCore/ChangeLog

    r207795 r207797  
     12016-10-24  Chris Dumez  <cdumez@apple.com>
     2
     3        event.(dataTransfer|clipboardData).getData('text/html') (onpaste, ondrop)
     4        https://bugs.webkit.org/show_bug.cgi?id=19893
     5        <rdar://problem/6055546>
     6
     7        Reviewed by Ryosuke Niwa.
     8
     9        We now write selection as HTML as well to the pasteboard so that
     10        event.(dataTransfer|clipboardData).getData('text/html') now works.
     11
     12        I have verified manually that it is still possible to copy text from
     13        Safari and paste it to Excel 2011 Mac after this change. The text is
     14        now pasted as HTML instead of text, which is fine because Excel can
     15        display HTML.
     16
     17        No new tests, unskipped existing tests.
     18
     19        * editing/Editor.h:
     20        * editing/mac/EditorMac.mm:
     21        (WebCore::Editor::selectionInHTMLFormat):
     22        (WebCore::Editor::writeSelectionToPasteboard):
     23        * platform/Pasteboard.h:
     24        * platform/mac/PasteboardMac.mm:
     25        (WebCore::Pasteboard::write):
     26
    1272016-10-24  Alex Christensen  <achristensen@webkit.org>
    228
  • trunk/Source/WebCore/editing/Editor.h

    r207670 r207797  
    510510#if PLATFORM(COCOA)
    511511    RefPtr<SharedBuffer> selectionInWebArchiveFormat();
     512    String selectionInHTMLFormat();
    512513    RefPtr<SharedBuffer> imageInWebArchiveFormat(Element&);
    513514    RefPtr<Range> adjustedSelectionRange();
  • trunk/Source/WebCore/editing/mac/EditorMac.mm

    r206965 r207797  
    311311}
    312312
     313String Editor::selectionInHTMLFormat()
     314{
     315    return createMarkup(*selectedRange(), nullptr, AnnotateForInterchange, false, ResolveNonLocalURLs);
     316}
     317
    313318RefPtr<SharedBuffer> Editor::imageInWebArchiveFormat(Element& imageElement)
    314319{
     
    394399    content.dataInRTFDFormat = [attributedString containsAttachments] ? dataInRTFDFormat(attributedString) : 0;
    395400    content.dataInRTFFormat = dataInRTFFormat(attributedString);
     401    content.dataInHTMLFormat = selectionInHTMLFormat();
    396402    content.dataInStringFormat = stringSelectionForPasteboardWithImageAltText();
    397403    client()->getClientPasteboardDataForRange(selectedRange().get(), content.clientTypes, content.clientData);
  • trunk/Source/WebCore/platform/Pasteboard.h

    r206965 r207797  
    7171    RefPtr<SharedBuffer> dataInRTFDFormat;
    7272    RefPtr<SharedBuffer> dataInRTFFormat;
     73    String dataInHTMLFormat;
    7374    String dataInStringFormat;
    7475    Vector<String> clientTypes;
  • trunk/Source/WebCore/platform/mac/PasteboardMac.mm

    r206965 r207797  
    154154    if (content.dataInRTFFormat)
    155155        types.append(String(NSRTFPboardType));
     156    if (!content.dataInHTMLFormat.isNull())
     157        types.append(String(NSHTMLPboardType));
    156158    if (!content.dataInStringFormat.isNull())
    157159        types.append(String(NSStringPboardType));
     
    171173    if (content.dataInRTFFormat)
    172174        m_changeCount = platformStrategies()->pasteboardStrategy()->setBufferForType(content.dataInRTFFormat.get(), NSRTFPboardType, m_pasteboardName);
     175    if (!content.dataInHTMLFormat.isNull())
     176        m_changeCount = platformStrategies()->pasteboardStrategy()->setStringForType(content.dataInHTMLFormat, NSHTMLPboardType, m_pasteboardName);
    173177    if (!content.dataInStringFormat.isNull())
    174178        m_changeCount = platformStrategies()->pasteboardStrategy()->setStringForType(content.dataInStringFormat, NSStringPboardType, m_pasteboardName);
Note: See TracChangeset for help on using the changeset viewer.