haikuwebkit/LayoutTests/editing/text-placeholder
Daniel Bates 6ce0e1eead [iOS] Caret should be before text placeholder instead of after it
https://bugs.webkit.org/show_bug.cgi?id=214319
<rdar://problem/65295523>

Source/WebCore:

Reviewed by Wenson Hsieh.

Move the caret to before the text placeholder to match UIKit.

Tests: editing/text-placeholder/caret-before-zero-width-placeholder-in-content-editable-end-of-word.html
       editing/text-placeholder/caret-before-zero-width-placeholder-in-content-editable-start-of-word.html
       editing/text-placeholder/insert-into-content-editable-and-remove-via-mutation-event.html

* editing/Editor.cpp:
(WebCore::Editor::insertTextPlaceholder): Compute the position before the placeholder in its parent.
This computation can only be done if the placeholder still has a parent. It may not after insertion
because arbitrary JavaScript code can run. If this happens then bail out and return nullptr. Otherwise,
set the new selection.

LayoutTests:

Reviewed by Wenson Hsieh and Simon Fraser (1).

Add some tests.

[1] Simon only reviewed editing/text-placeholder/insert-into-content-editable-and-remove-via-mutation-event.html.

* editing/text-placeholder/caret-before-zero-width-placeholder-in-content-editable-end-of-word-expected.txt: Added.
* editing/text-placeholder/caret-before-zero-width-placeholder-in-content-editable-end-of-word.html: Added.
* editing/text-placeholder/caret-before-zero-width-placeholder-in-content-editable-start-of-word-expected.txt: Added.
* editing/text-placeholder/caret-before-zero-width-placeholder-in-content-editable-start-of-word.html: Added.
* editing/text-placeholder/insert-into-content-editable-and-remove-via-mutation-event-expected.txt: Added.
* editing/text-placeholder/insert-into-content-editable-and-remove-via-mutation-event.html: Added.
* resources/js-test.js:
(shouldBeLessThanOrEqual): Added. Just like shouldBeGreaterThanOrEqual, but for <=.

Canonical link: https://commits.webkit.org/227169@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@264418 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-07-15 20:28:06 +00:00
..
resources
caret-before-zero-width-placeholder-in-content-editable-end-of-word-expected.txt [iOS] Caret should be before text placeholder instead of after it 2020-07-15 20:28:06 +00:00
caret-before-zero-width-placeholder-in-content-editable-end-of-word.html [iOS] Caret should be before text placeholder instead of after it 2020-07-15 20:28:06 +00:00
caret-before-zero-width-placeholder-in-content-editable-start-of-word-expected.txt [iOS] Caret should be before text placeholder instead of after it 2020-07-15 20:28:06 +00:00
caret-before-zero-width-placeholder-in-content-editable-start-of-word.html [iOS] Caret should be before text placeholder instead of after it 2020-07-15 20:28:06 +00:00
insert-and-remove-into-text-field-expected.html
insert-and-remove-into-text-field.html
insert-into-content-editable-and-remove-via-mutation-event-expected.txt [iOS] Caret should be before text placeholder instead of after it 2020-07-15 20:28:06 +00:00
insert-into-content-editable-and-remove-via-mutation-event.html [iOS] Caret should be before text placeholder instead of after it 2020-07-15 20:28:06 +00:00
insert-into-content-editable-expected.html
insert-into-content-editable-non-zero-width-and-height-expected.html
insert-into-content-editable-non-zero-width-and-height.html
insert-into-content-editable-zero-width-expected.html
insert-into-content-editable-zero-width.html
insert-into-content-editable.html
insert-into-empty-text-field-expected.html
insert-into-empty-text-field.html
insert-into-text-field-expected.html
insert-into-text-field-in-iframe-expected.html
insert-into-text-field-in-iframe.html
insert-into-text-field.html