⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 286861 in webkit


Ignore:
Timestamp:
Dec 10, 2021, 11:02:55 AM (5 years ago)
Author:
Devin Rousso
Message:

Add a way to write a SharedBuffer to the Pasteboard
https://bugs.webkit.org/show_bug.cgi?id=234065

Reviewed by Wenson Hsieh.

In order to match the WK1 implementation of -pasteFont: <https://webkit.org/b/191379>, we
need to be able to write a SharedBuffer (with an associated type) to the font pasteboard.

Create a struct PasteboardBuffer to wrap the SharedBuffer and String type (and a
String contentOrigin on Cocoa platforms, which is used to decide whether to show a "Paste"
callout to the user as a gate on crossorigin content sharing) in a single object.

Though it isn't used in this patch, -pasteFont: <https://webkit.org/b/191379> will use
this to write RTF data (which contains the necessary font data).

No change in behavior.

  • platform/Pasteboard.h:
  • platform/Pasteboard.cpp:
  • platform/libwpe/PasteboardLibWPE.cpp:

(WebCore::Pasteboard::write):

  • platform/gtk/PasteboardGtk.cpp:

(WebCore::Pasteboard::write):

  • platform/ios/PasteboardIOS.mm:

(WebCore::Pasteboard::write):

  • platform/mac/PasteboardMac.mm:

(WebCore::Pasteboard::write):

  • platform/win/PasteboardWin.cpp:

(WebCore::Pasteboard::write):

Location:
trunk/Source/WebCore
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r286860 r286861  
     12021-12-10  Devin Rousso  <drousso@apple.com>
     2
     3        Add a way to write a `SharedBuffer` to the Pasteboard
     4        https://bugs.webkit.org/show_bug.cgi?id=234065
     5
     6        Reviewed by Wenson Hsieh.
     7
     8        In order to match the WK1 implementation of `-pasteFont:` <https://webkit.org/b/191379>, we
     9        need to be able to write a `SharedBuffer` (with an associated type) to the font pasteboard.
     10
     11        Create a `struct PasteboardBuffer` to wrap the `SharedBuffer` and `String type` (and a
     12        `String contentOrigin` on Cocoa platforms, which is used to decide whether to show a "Paste"
     13        callout to the user as a gate on crossorigin content sharing) in a single object.
     14
     15        Though it isn't used in this patch, `-pasteFont:` <https://webkit.org/b/191379> will use
     16        this to write RTF data (which contains the necessary font data).
     17
     18        No change in behavior.
     19
     20        * platform/Pasteboard.h:
     21        * platform/Pasteboard.cpp:
     22        * platform/libwpe/PasteboardLibWPE.cpp:
     23        (WebCore::Pasteboard::write):
     24        * platform/gtk/PasteboardGtk.cpp:
     25        (WebCore::Pasteboard::write):
     26        * platform/ios/PasteboardIOS.mm:
     27        (WebCore::Pasteboard::write):
     28        * platform/mac/PasteboardMac.mm:
     29        (WebCore::Pasteboard::write):
     30        * platform/win/PasteboardWin.cpp:
     31        (WebCore::Pasteboard::write):
     32
    1332021-12-10  Patrick Griffis  <pgriffis@igalia.com>
    234
  • trunk/Source/WebCore/platform/Pasteboard.cpp

    r278253 r286861  
    3838PasteboardImage::PasteboardImage() = default;
    3939PasteboardImage::~PasteboardImage() = default;
     40
     41// Making this non-inline so that WebKit 2's decoding doesn't have to include SharedBuffer.h.
     42PasteboardBuffer::PasteboardBuffer() = default;
     43PasteboardBuffer::~PasteboardBuffer() = default;
    4044
    4145bool Pasteboard::isSafeTypeForDOMToReadAndWrite(const String& type)
  • trunk/Source/WebCore/platform/Pasteboard.h

    r278253 r286861  
    136136};
    137137
     138struct PasteboardBuffer {
     139    WEBCORE_EXPORT PasteboardBuffer();
     140    WEBCORE_EXPORT ~PasteboardBuffer();
     141
     142#if PLATFORM(COCOA)
     143    String contentOrigin;
     144#endif
     145    String type;
     146    RefPtr<SharedBuffer> data;
     147};
     148
    138149// For reading from the pasteboard.
    139150
     
    224235    virtual WEBCORE_EXPORT void writeTrustworthyWebURLsPboardType(const PasteboardURL&);
    225236    virtual WEBCORE_EXPORT void write(const PasteboardImage&);
     237    virtual WEBCORE_EXPORT void write(const PasteboardBuffer&);
    226238    virtual WEBCORE_EXPORT void write(const PasteboardWebContent&);
    227239
  • trunk/Source/WebCore/platform/gtk/PasteboardGtk.cpp

    r278340 r286861  
    184184}
    185185
     186void Pasteboard::write(const PasteboardBuffer&)
     187{
     188}
     189
    186190void Pasteboard::write(const PasteboardWebContent& pasteboardContent)
    187191{
  • trunk/Source/WebCore/platform/ios/PasteboardIOS.mm

    r278253 r286861  
    129129}
    130130
     131void Pasteboard::write(const PasteboardBuffer&)
     132{
     133}
     134
    131135void Pasteboard::writePlainText(const String& text, SmartReplaceOption)
    132136{
  • trunk/Source/WebCore/platform/libwpe/PasteboardLibWPE.cpp

    r278340 r286861  
    124124}
    125125
     126void Pasteboard::write(const PasteboardBuffer&)
     127{
     128}
     129
    126130void Pasteboard::write(const PasteboardWebContent& content)
    127131{
  • trunk/Source/WebCore/platform/mac/PasteboardMac.mm

    r278253 r286861  
    299299}
    300300
     301void Pasteboard::write(const PasteboardBuffer& pasteboardBuffer)
     302{
     303    ASSERT(!pasteboardBuffer.type.isEmpty());
     304    ASSERT(pasteboardBuffer.data);
     305
     306    m_changeCount = platformStrategies()->pasteboardStrategy()->setTypes({ pasteboardBuffer.type, PasteboardCustomData::cocoaType() }, m_pasteboardName, context());
     307
     308    m_changeCount = platformStrategies()->pasteboardStrategy()->setBufferForType(pasteboardBuffer.data.get(), pasteboardBuffer.type, m_pasteboardName, context());
     309
     310    PasteboardCustomData pasteboardCustomData;
     311    pasteboardCustomData.setOrigin(pasteboardBuffer.contentOrigin);
     312    m_changeCount = platformStrategies()->pasteboardStrategy()->setBufferForType(pasteboardCustomData.createSharedBuffer().ptr(), PasteboardCustomData::cocoaType(), m_pasteboardName, context());
     313}
     314
    301315bool Pasteboard::canSmartReplace()
    302316{
  • trunk/Source/WebCore/platform/win/PasteboardWin.cpp

    r286772 r286861  
    11191119}
    11201120
     1121void Pasteboard::write(const PasteboardBuffer&)
     1122{
     1123}
     1124
    11211125void Pasteboard::writeCustomData(const Vector<PasteboardCustomData>& data)
    11221126{
Note: See TracChangeset for help on using the changeset viewer.