Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 1b4675b62ba332657e2461a9e45e6068c391a3df
      
https://github.com/WebKit/WebKit/commit/1b4675b62ba332657e2461a9e45e6068c391a3df
  Author: Wenson Hsieh <[email protected]>
  Date:   2024-10-10 (Thu, 10 Oct 2024)

  Changed paths:
    M Source/WebCore/editing/cocoa/EditorCocoa.mm
    M Source/WebCore/editing/cocoa/HTMLConverter.h
    M Source/WebCore/editing/cocoa/HTMLConverter.mm
    M Source/WebCore/editing/mac/EditorMac.mm
    M Source/WebKit/WebProcess/WebPage/Cocoa/WebPageCocoa.mm
    M Source/WebKit/WebProcess/WebPage/mac/WebPageMac.mm
    M Source/WebKitLegacy/mac/WebCoreSupport/WebSelectionServiceController.mm
    M Source/WebKitLegacy/mac/WebView/WebHTMLView.mm
    M Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebViewGetContents.mm

  Log Message:
  -----------
  [iPadOS 18] Unable to include header row when copy and pasting table from 
confluence to Notes
https://bugs.webkit.org/show_bug.cgi?id=281230
rdar://137088450

Reviewed by Aditya Keerthi.

On Confluence, table header content is styled with `-webkit-user-select: 
none;`, which (in addition
to text selection) normally prevents the text from being serialized when 
writing content to the
system pasteboard when copying. This policy decision is overridden by a 
site-specific quirk (added
in 265939@main) which makes us *not* ignore `user-select: none;` when copying 
on this website. This
quirk works by detecting Confluence via the presence of a `meta` tag with 
`confluence-request-time`
and making `HTMLConverter` and `serializePreservingVisualAppearance` not ignore 
content inside of
`-webkit-user-select: none;` subtrees. When pasting into Notes, Notes asks for 
attributed string
data, which contains this `user-select: none;` content when copied from 
Confluence.

On iPad running iOS 18 and later, however, we no longer write 
`NSAttributedString` data directly to
the pasteboard when copying in WebKit apps, and instead defer to `UIFoundation` 
to perform this
conversion only if needed when pasting. Underneath the hood, this ultimately 
still uses WebKit
through `nsattributedstringagent`, which receives either web archive or HTML 
markup data and
generates an equivalent `NSAttributedString` / RTF data. Because the offscreen 
web view in
`nsattributedstringagent` only converts web archive data to an attributed 
string (and importantly,
doesn't load Confluence), it doesn't enable the aforementioned quirk, and so 
table header content
ends up getting dropped from the converted attributed string.

To fix this, we adjust `-[WKWebView 
_getContentsAsAttributedStringWithCompletionHandler:]` (and all
upstream API/SPIs) to *not* ignore `-webkit-user-select: none;` when converting 
webpage content
into attributed strings.

* Source/WebCore/editing/cocoa/EditorCocoa.mm:
(WebCore::selectionAsAttributedString):
* Source/WebCore/editing/cocoa/HTMLConverter.h:
* Source/WebCore/editing/cocoa/HTMLConverter.mm:
(HTMLConverter::HTMLConverter):
(WebCore::attributedString):

Add more plumbing for the `IgnoreUserSelectNone` flag, through attributed 
string serialization
codepaths.

* Source/WebCore/editing/mac/EditorMac.mm:
(WebCore::Editor::dataSelectionForPasteboard):
* Source/WebKit/WebProcess/WebPage/Cocoa/WebPageCocoa.mm:

Implement the fix by passing `IgnoreUserSelectNone::No` into 
`attributedString()`. See above for
more details.

(WebKit::WebPage::getContentsAsAttributedString):
* Source/WebKit/WebProcess/WebPage/mac/WebPageMac.mm:
(WebKit::WebPage::handleSelectionServiceClick):
* Source/WebKitLegacy/mac/WebCoreSupport/WebSelectionServiceController.mm:
(WebSelectionServiceController::handleSelectionServiceClick):
* Source/WebKitLegacy/mac/WebView/WebHTMLView.mm:
(-[WebHTMLView _legacyAttributedStringFrom:offset:to:offset:]):
(-[WebHTMLView attributedString]):
(-[WebHTMLView selectedAttributedString]):
* Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebViewGetContents.mm:
(TEST(WKWebView, AttributedStringIncludesUserSelectNoneContent)):

Add an API test to exercise the new behavior (see above for more details).

Canonical link: https://commits.webkit.org/284993@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to