[webkit-changes] [WebKit/WebKit] aaaee1: Copying and pasting a `<picture>` element and some...

Aditya Keerthi noreply at github.com
Fri May 31 15:07:29 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: aaaee1d25e29a6c1eb0c99ffdf0901418ad30424
      https://github.com/WebKit/WebKit/commit/aaaee1d25e29a6c1eb0c99ffdf0901418ad30424
  Author: Aditya Keerthi <akeerthi at apple.com>
  Date:   2024-05-31 (Fri, 31 May 2024)

  Changed paths:
    A LayoutTests/editing/pasteboard/copy-picture-and-text-expected.txt
    A LayoutTests/editing/pasteboard/copy-picture-and-text.html
    A LayoutTests/platform/ios/editing/pasteboard/copy-picture-and-text-expected.txt
    M Source/WebCore/editing/markup.cpp

  Log Message:
  -----------
  Copying and pasting a `<picture>` element and some text, loses `<source>` elements
https://bugs.webkit.org/show_bug.cgi?id=274874
rdar://124625324

Reviewed by Wenson Hsieh.

When selecting a `<picture>` element, visible positions are before/after the
contained `<img>`. Originally, this resulted in issues where simply copying and
pasting `<picture>` elements would drop other nodes (`<source>`).

276754 at main fixed the issue when the selection being copied was contained to a
single `<picture>`, by consulting the highest common ancestor of the start and
end positions. However, in cases where the selection ends outside of the
`<picture>`, for example, including some text after the image, there is no
common ancestor. Consequently, `<source>` elements continue to be dropped in
that scenario.

Fix by generalizing the solution in 276754 at main to always adjust the start
position for serialization if it is within a `<picture>` element. Add a test to
validate the fix.

* LayoutTests/editing/pasteboard/copy-picture-and-text-expected.txt: Added.
* LayoutTests/editing/pasteboard/copy-picture-and-text.html: Added.
* LayoutTests/platform/ios/editing/pasteboard/copy-picture-and-text-expected.txt: Added.

An iOS-specific expectation is necessary due to smart replace, which inserts an
additional space when pasting this content. The space before `<img>` exists
before and after this patch.

* Source/WebCore/editing/markup.cpp:
(WebCore::serializePreservingVisualAppearanceInternal):

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