[webkit-changes] [WebKit/WebKit] becb58: Writing tools rewrite incorrectly removes links in...
Wenson Hsieh
noreply at github.com
Fri Oct 18 06:53:08 PDT 2024
Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: becb5858cc51dc73bee1a780568e46b085f41d89
https://github.com/WebKit/WebKit/commit/becb5858cc51dc73bee1a780568e46b085f41d89
Author: Wenson Hsieh <wenson_hsieh at apple.com>
Date: 2024-10-18 (Fri, 18 Oct 2024)
Changed paths:
M Source/WebCore/editing/cocoa/HTMLConverter.mm
M Tools/TestWebKitAPI/Tests/WebKitCocoa/WritingTools.mm
Log Message:
-----------
Writing tools rewrite incorrectly removes links in Mail compose
https://bugs.webkit.org/show_bug.cgi?id=281718
rdar://138041439
Reviewed by Richard Robinson.
Using rewrite currently causes any links in Mail compose to be replaced by a span element that has
the same text color, font and underlines as the link, but (importantly) doesn't contain the actual
link `href`. This happens because the extracted attributed string for WritingTools doesn't contain
any link URL attributes. To fix this, we teach `WebCore::editingAttributedString` to detect when
text is contained inside of a link, extract the URL of the link, and add it as an attributed string
attribute corresponding to `NSLinkAttributeName`.
* Source/WebCore/editing/cocoa/HTMLConverter.mm:
(hasAncestorQualifyingForWritingToolsPreservation):
Drive-by fix: use `find()` to avoid a redundant hash lookup.
(enclosingLinkElement):
Add a helper method to return whether a given node is contained within an enclosing link (determined
via `Node::isLink()`). To avoid redundant tree traversal in the case where text is not inside of a
link, we cache the enclosing link result (which may be null) for each node that is both not a link,
and a parent of some text node in the DOM.
(updateAttributes):
(WebCore::editingAttributedString):
See above for more details.
(updateAttributesForStyle): Deleted.
* Tools/TestWebKitAPI/Tests/WebKitCocoa/WritingTools.mm:
(TEST(WritingTools, ProofreadingWithImage)):
Drive-by fix: typo in a FIXME comment.
(TEST(WritingTools, ProofreadingWithLinks)):
Add a new API test to exercise the change, by verifying that the extracted text context contains
link URLs in the attributed text.
Canonical link: https://commits.webkit.org/285398@main
To unsubscribe from these emails, change your notification settings at https://github.com/WebKit/WebKit/settings/notifications
More information about the webkit-changes
mailing list