[Site Isolation] Content in cross-origin subframes is missing when copying and pasting
https://bugs.webkit.org/show_bug.cgi?id=319423 rdar://176590191 Reviewed by Abrar Rahman Protyasha. When copying content that includes cross-origin subframes, content in those subframes is missing upon pasting into native apps like TextEdit or Notes, which attempt to read `NSAttributedString`s from the pasteboard. While there's an existing solution added in https://commits.webkit.org/300189@main to ensure that web archives capture cross-origin content under site isolation, there's currently no similar architecture in place for attributed strings, which means we currently just skip over content in cross-origin subframes. To fix this, we apply the same approach taken in 300189@main to attributed string conversion; see comments below for more details. Test: SiteIsolation.ReadAttributedStringFromPasteboardAfterCopyWithCrossSiteIframe * Source/WebCore/editing/cocoa/EditorCocoa.mm: (WebCore::selectionAsAttributedString): Add a `remoteFrameContent` argument here, that represents `AttributedString`s collected from remote frames. (WebCore::populateRichTextDataIfNeeded): When serializing attributed strings, collect all remote frame IDs that represent frames where we need to recursively convert into attributed strings. (WebCore::Editor::writeSelectionToPasteboard): * Source/WebCore/editing/cocoa/NodeHTMLConverter.h: (WebCore::attributedString): * Source/WebCore/editing/cocoa/NodeHTMLConverter.mm: (HTMLConverter::HTMLConverter): (HTMLConverter::_processElement): Slot in attributed strings collected from remote subframes. (WebCore::attributedString): * Source/WebCore/page/EditorClient.h: * Source/WebKit/UIProcess/Cocoa/WebPageProxyCocoa.mm: (WebKit::WebPageProxy::getAttributedStringsForRemoteFrames): * Source/WebKit/UIProcess/WebPageProxy.h: * Source/WebKit/UIProcess/WebPageProxy.messages.in: * Source/WebKit/WebProcess/WebCoreSupport/WebEditorClient.cpp: (WebKit::WebEditorClient::collectAttributedStringsForRemoteFrames): Add a new client hook that takes a list of remote frame IDs, and calls into the UI process to fan out to all remote frames and convert their content into attributed strings. * Source/WebKit/WebProcess/WebCoreSupport/WebEditorClient.h: * Source/WebKit/WebProcess/WebPage/Cocoa/WebPageCocoa.mm: (WebKit::WebPage::getAttributedStringsForRemoteFrames): (WebKit::WebPage::getContentsAsAttributedStringForFrames): * Source/WebKit/WebProcess/WebPage/WebPage.h: * Source/WebKit/WebProcess/WebPage/WebPage.messages.in: * Tools/TestWebKitAPI/Tests/WebKit/WKWebView/SiteIsolation.mm: (TestWebKitAPI::(SiteIsolation, ReadAttributedStringFromPasteboardAfterCopyWithCrossSiteIframe)): Add an API test to exercise the fix. Canonical link: https://commits.webkit.org/317283@main
W
Wenson Hsieh committed
2b157dbbd4053751d8fcf196f2056a7e66e71697
Parent: 3130bd5