Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Impossible to place an editable selection inside empty elements #10503

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

rniwa
Copy link
Member

@rniwa rniwa commented Feb 22, 2023

4136be1

Impossible to place an editable selection inside empty elements
https://bugs.webkit.org/show_bug.cgi?id=15256

Reviewed by NOBODY (OOPS!).

Use the uncanonicalized selection ends for text insertion.

* LayoutTests/editing/deleting/delete-3775172-fix-expected.txt:
* LayoutTests/editing/execCommand/5142012-3-expected.txt:
* LayoutTests/editing/execCommand/typing-should-not-trigger-scrolling-when-selection-is-visible.html:
* LayoutTests/editing/inserting/4840662.html:
* LayoutTests/editing/inserting/5156401-2.html:
* LayoutTests/editing/inserting/5510537-expected.txt:
* LayoutTests/editing/inserting/editable-html-element-expected.txt:
* LayoutTests/editing/inserting/editing-empty-divs-expected.txt:
* LayoutTests/editing/inserting/insert-3778059-fix-expected.txt:
* LayoutTests/editing/inserting/insert-at-end-01-expected.txt:
* LayoutTests/editing/inserting/insert-at-end-02-expected.txt:
* LayoutTests/editing/inserting/insert-before-link-1-expected.txt:
* LayoutTests/editing/inserting/insert-html-crash-01-expected.txt:
* LayoutTests/editing/inserting/typing-003-expected.txt:
* LayoutTests/editing/inserting/typing-around-image-001-expected.txt:
* LayoutTests/editing/selection/4983858-expected.txt:
* LayoutTests/editing/spelling/centering-misspelling-dots-expected.txt:
* LayoutTests/editing/spelling/misspelling-dots-dont-extend-beyond-words-expected.txt:
* LayoutTests/editing/style/remove-underline-across-paragraph-expected.txt:
* LayoutTests/editing/style/remove-underline-across-paragraph-in-bold-expected.txt:
* LayoutTests/editing/style/remove-underline-after-paragraph-expected.txt:
* LayoutTests/editing/style/remove-underline-after-paragraph-in-bold-expected.txt:
* LayoutTests/editing/style/remove-underline-expected.txt:
* LayoutTests/editing/style/remove-underline-from-stylesheet-expected.txt:
* LayoutTests/editing/style/remove-underline-in-bold-expected.txt:
* LayoutTests/editing/style/typing-style-003-expected.txt:
* LayoutTests/editing/style/unbold-in-bold-expected.txt:
* LayoutTests/editing/style/underline-expected.txt:
* LayoutTests/editing/unsupported-content/list-type-before.html:
* LayoutTests/editing/unsupported-content/table-type-before-expected.txt:
* LayoutTests/platform/mac/editing/inserting/insert-text-at-tabspan-003-expected.txt:

* Source/WebCore/editing/CompositeEditCommand.cpp:
(WebCore::CompositeEditCommand::positionOutsideTabSpan): Consider the case where the anchor node
is the WebKit tab span element.

* Source/WebCore/editing/InsertTextCommand.cpp:
(WebCore::InsertTextCommand::positionInsideTextNode): Consider the text node before or after
the position.
(WebCore::InsertTextCommand::doApply): Use the uncanonicalized selection start as the start position.
Also don't rebalance whitespaces at the end if the starting position was not a candidate (e.g.
we're at a visually empty text node) and the inserted text didn't end with a whitespace.

4136be1

Misc iOS, tvOS & watchOS macOS Linux Windows
βœ… πŸ§ͺ style βœ… πŸ›  ios βœ… πŸ›  mac βœ… πŸ›  wpe βœ… πŸ›  wincairo
βœ… πŸ§ͺ bindings βœ… πŸ›  ios-sim βœ… πŸ›  mac-AS-debug βœ… πŸ›  gtk
βœ… πŸ§ͺ webkitperl ❌ πŸ§ͺ ios-wk2 βœ… πŸ§ͺ api-mac ❌ πŸ§ͺ gtk-wk2
❌ πŸ§ͺ api-ios ❌ πŸ§ͺ mac-wk1 βœ… πŸ§ͺ api-gtk
βœ… πŸ›  tv ❌ πŸ§ͺ mac-wk2
βœ… πŸ›  tv-sim ❌ πŸ§ͺ mac-AS-debug-wk2
βœ… πŸ›  watch βœ… πŸ§ͺ mac-wk2-stress
βœ… πŸ›  watch-sim

https://bugs.webkit.org/show_bug.cgi?id=15256

Reviewed by NOBODY (OOPS!).

Use the uncanonicalized selection ends for text insertion.

* LayoutTests/editing/deleting/delete-3775172-fix-expected.txt:
* LayoutTests/editing/execCommand/5142012-3-expected.txt:
* LayoutTests/editing/execCommand/typing-should-not-trigger-scrolling-when-selection-is-visible.html:
* LayoutTests/editing/inserting/4840662.html:
* LayoutTests/editing/inserting/5156401-2.html:
* LayoutTests/editing/inserting/5510537-expected.txt:
* LayoutTests/editing/inserting/editable-html-element-expected.txt:
* LayoutTests/editing/inserting/editing-empty-divs-expected.txt:
* LayoutTests/editing/inserting/insert-3778059-fix-expected.txt:
* LayoutTests/editing/inserting/insert-at-end-01-expected.txt:
* LayoutTests/editing/inserting/insert-at-end-02-expected.txt:
* LayoutTests/editing/inserting/insert-before-link-1-expected.txt:
* LayoutTests/editing/inserting/insert-html-crash-01-expected.txt:
* LayoutTests/editing/inserting/typing-003-expected.txt:
* LayoutTests/editing/inserting/typing-around-image-001-expected.txt:
* LayoutTests/editing/selection/4983858-expected.txt:
* LayoutTests/editing/spelling/centering-misspelling-dots-expected.txt:
* LayoutTests/editing/spelling/misspelling-dots-dont-extend-beyond-words-expected.txt:
* LayoutTests/editing/style/remove-underline-across-paragraph-expected.txt:
* LayoutTests/editing/style/remove-underline-across-paragraph-in-bold-expected.txt:
* LayoutTests/editing/style/remove-underline-after-paragraph-expected.txt:
* LayoutTests/editing/style/remove-underline-after-paragraph-in-bold-expected.txt:
* LayoutTests/editing/style/remove-underline-expected.txt:
* LayoutTests/editing/style/remove-underline-from-stylesheet-expected.txt:
* LayoutTests/editing/style/remove-underline-in-bold-expected.txt:
* LayoutTests/editing/style/typing-style-003-expected.txt:
* LayoutTests/editing/style/unbold-in-bold-expected.txt:
* LayoutTests/editing/style/underline-expected.txt:
* LayoutTests/editing/unsupported-content/list-type-before.html:
* LayoutTests/editing/unsupported-content/table-type-before-expected.txt:
* LayoutTests/platform/mac/editing/inserting/insert-text-at-tabspan-003-expected.txt:

* Source/WebCore/editing/CompositeEditCommand.cpp:
(WebCore::CompositeEditCommand::positionOutsideTabSpan): Consider the case where the anchor node
is the WebKit tab span element.

* Source/WebCore/editing/InsertTextCommand.cpp:
(WebCore::InsertTextCommand::positionInsideTextNode): Consider the text node before or after
the position.
(WebCore::InsertTextCommand::doApply): Use the uncanonicalized selection start as the start position.
Also don't rebalance whitespaces at the end if the starting position was not a candidate (e.g.
we're at a visually empty text node) and the inserted text didn't end with a whitespace.
@rniwa rniwa self-assigned this Feb 22, 2023
@rniwa rniwa added the HTML Editing For bugs in HTML editing support (including designMode and contentEditable). label Feb 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
HTML Editing For bugs in HTML editing support (including designMode and contentEditable).
Projects
None yet
2 participants