Branch: refs/heads/main Home: https://github.com/WebKit/WebKit Commit: 93c20dcc345ada6c4f5b8c5b04987e8bd8cd4140 https://github.com/WebKit/WebKit/commit/93c20dcc345ada6c4f5b8c5b04987e8bd8cd4140 Author: Aditya Keerthi <akeer...@apple.com> Date: 2024-08-27 (Tue, 27 Aug 2024)
Changed paths: A LayoutTests/editing/inserting/insert-text-before-picture-expected.txt A LayoutTests/editing/inserting/insert-text-before-picture.html M Source/WebCore/editing/Editing.cpp Log Message: ----------- Attempting to insert text before a <picture> element inserts the text after the element https://bugs.webkit.org/show_bug.cgi?id=278748 rdar://134378236 Reviewed by Wenson Hsieh. `<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. `CompositeEditCommand::insertNodeAt` is invoked when inserting a node at the editing position. Since `HTMLPictureElement` cannot have children as a result of editing (`canHaveChildrenForEditing`) and `caretMinOffset` is 0, the created text node is always inserted using `insertNodeAfter`. Fix by updating `caretMinOffset` to return the index of the `<img>` child for `<picture>` elements. This ensures that when the offset of the parent anchored equivalent is before the `<img>`, `insertNodeBefore` will be used rather than `insertNodeAfter`. * LayoutTests/editing/inserting/insert-text-before-picture-expected.txt: Added. * LayoutTests/editing/inserting/insert-text-before-picture.html: Added. * Source/WebCore/editing/Editing.cpp: (WebCore::caretMinOffset): `RenderText` is the only renderer-type that returns a non-zero value for `caretMinOffset`. Consequently, it is safe to consult the `renderer` in that scenario, similar to `caretMaxOffset`. Canonical link: https://commits.webkit.org/282825@main To unsubscribe from these emails, change your notification settings at https://github.com/WebKit/WebKit/settings/notifications _______________________________________________ webkit-changes mailing list webkit-changes@lists.webkit.org https://lists.webkit.org/mailman/listinfo/webkit-changes