[webkit-changes] [WebKit/WebKit] 1d5684: Deleting content immediately before a `<picture>` ...

Aditya Keerthi noreply at github.com
Tue Sep 10 20:20:59 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 1d56845bb42e19b8f4574231e668b34c8a2e2aa8
      https://github.com/WebKit/WebKit/commit/1d56845bb42e19b8f4574231e668b34c8a2e2aa8
  Author: Aditya Keerthi <akeerthi at apple.com>
  Date:   2024-09-10 (Tue, 10 Sep 2024)

  Changed paths:
    A LayoutTests/editing/deleting/delete-picture-expected.txt
    A LayoutTests/editing/deleting/delete-picture.html
    A LayoutTests/editing/deleting/delete-text-before-picture-expected.txt
    A LayoutTests/editing/deleting/delete-text-before-picture.html
    M Source/WebCore/editing/DeleteSelectionCommand.cpp

  Log Message:
  -----------
  Deleting content immediately before a `<picture>` unexpectedly removes `<source>`s
https://bugs.webkit.org/show_bug.cgi?id=279467
rdar://128100106

Reviewed by Wenson Hsieh and Abrar Rahman Protyasha.

`<picture>` elements may contain one or more `<source>` elements (which are not
rendered) and an `<img>` element. When making selections around a `<picture>`
element, the selection is anchored before or after the `<img>` child.

Consequently, when the selection is visually before a `<picture>` element, and
deletion is performed, all `<source>` elements before the selection are also
removed. This is incorrect, as the `<picture>` element and all its children should
be left intact.

Fix by avoiding removal of nodes that have a parent node which cannot have
children for editing. Only the direct parent is checked, since traversal is
performed in document order.

A longer term solution would be to (again) experiment with making
`canContainRangeEndPoint` return `false` for `HTMLPictureElement`. That change would
solve this issue by ensuring the selection could never be inside a `<picture>`.
However, that change is much higher risk, and also causes other selection related
issues, which need to be investigated independently.

* LayoutTests/editing/deleting/delete-picture-expected.txt: Added.
* LayoutTests/editing/deleting/delete-picture.html: Added.

Test already working behavior to delete a `<picture> element.

* LayoutTests/editing/deleting/delete-text-before-picture-expected.txt: Added.
* LayoutTests/editing/deleting/delete-text-before-picture.html: Added.

Test the issue fixed by this patch.

* Source/WebCore/editing/DeleteSelectionCommand.cpp:
(WebCore::DeleteSelectionCommand::handleGeneralDelete):

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