Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: ac643ee151bc20383f2bedcec717ae457d609ee7
      
https://github.com/WebKit/WebKit/commit/ac643ee151bc20383f2bedcec717ae457d609ee7
  Author: Wenson Hsieh <[email protected]>
  Date:   2025-01-04 (Sat, 04 Jan 2025)

  Changed paths:
    M Source/WebCore/editing/cocoa/HTMLConverter.h
    M Source/WebCore/editing/cocoa/HTMLConverter.mm
    M Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm
    M Tools/TestWebKitAPI/Tests/WebKitCocoa/AdaptiveImageGlyph.mm

  Log Message:
  -----------
  [iOS] Document context requests with attributed string should include 
adaptive image glyphs as attributes
https://bugs.webkit.org/show_bug.cgi?id=285373
rdar://142280535

Reviewed by Megan Gardner and Abrar Rahman Protyasha.

Add support for the `UIWKDocumentRequestAttributed` 
(`BETextDocumentOptionAttributedText`) flag when
handling document editing context requests. We currently just extract plain 
text in the context
range and return an `NSAttributedString` whose string is equal to that plain 
text, but which lacks
any attributes.

This instead uses `WebCore::editingAttributedString` to include a subset of 
presentational and
semantic attributes in the result, including 
`NSAdaptiveImageGlyphAttributeName` when the context
range includes Genmojis.

See below for more detail.

* Source/WebCore/editing/cocoa/HTMLConverter.h:
* Source/WebCore/editing/cocoa/HTMLConverter.mm:
(WebCore::editingAttributedStringInternal):

Move the existing logic in `editingAttributedString` into a separate static 
helper function, so that
we can share the implementation between 
`editingAttributedStringReplacingNoBreakSpace` and
`editingAttributedString` below.

(WebCore::editingAttributedString):
(WebCore::editingAttributedStringReplacingNoBreakSpace):

Add support for a `editingAttributedStringReplacingNoBreakSpace` method that is 
similar to the
extant `editingAttributedString`, except that it:

1.  Replaces non-breaking spaces with a regular space (matching 
`plainTextReplacingNoBreakSpace`'s
    behavior).

2.  Takes in a set of `TextIteratorBehaviors` to use when iterating over the 
range.

* Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::WebPage::requestDocumentEditingContext):

Use `editingAttributedStringReplacingNoBreakSpace` when attributed string data 
is requested, instead
of always falling back on `plainTextReplacingNoBreakSpace`.

* Tools/TestWebKitAPI/Tests/WebKitCocoa/AdaptiveImageGlyph.mm:
(createAdaptiveImageGlyphForTesting):
(TestWebKitAPI::TEST(AdaptiveImageGlyph, 
InsertAdaptiveImageGlyphAsPictureElement)):
(TestWebKitAPI::TEST(AdaptiveImageGlyph, 
InsertAdaptiveImageGlyphAtLargerFontSize)):
(TestWebKitAPI::TEST(AdaptiveImageGlyph, InsertAdaptiveImageGlyphMatchStyle)):
(TestWebKitAPI::TEST(AdaptiveImageGlyph, InsertAndRemoveWKAttachments)):
(TestWebKitAPI::TEST(AdaptiveImageGlyph, InsertWKAttachmentsOnPaste)):
(TestWebKitAPI::TEST(AdaptiveImageGlyph, 
InsertWKAttachmentsCopyFromWebViewPasteToWebView)):
(TestWebKitAPI::TEST(AdaptiveImageGlyph, InsertWKAttachmentsMovingParagraphs)):
(TestWebKitAPI::TEST(AdaptiveImageGlyph, InsertMultiple)):
(TestWebKitAPI::TEST(AdaptiveImageGlyph, InsertTextAfterAdaptiveImageGlyph)):
(TestWebKitAPI::TEST(AdaptiveImageGlyph, ContentsAsAttributedString)):
(TestWebKitAPI::TEST(AdaptiveImageGlyph, 
DragAdaptiveImageGlyphFromContentEditable)):
(TestWebKitAPI::TEST(AdaptiveImageGlyph, DropAdaptiveImageGlyphAsText)):
(TestWebKitAPI::TEST(AdaptiveImageGlyph, DropAdaptiveImageGlyphAsSticker)):
(TestWebKitAPI::TEST(AdaptiveImageGlyph, 
AttributedStringDocumentEditingContext)):

Add a new API test to verify that adaptive image glyphs are surfaced when 
requesting attributed
strings through the document editing context API; also, remove a little code 
duplication in these
tests by adding a new helper method, `createAdaptiveImageGlyphForTesting()`.

Canonical link: https://commits.webkit.org/288436@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