Skip to content

Conversation

rr-codes
Copy link
Contributor

@rr-codes rr-codes commented Jul 8, 2024

292bb3d

[Writing Tools] Make Table: Mail: Generated table has extra borderlines
https://bugs.webkit.org/show_bug.cgi?id=276315
rdar://129926389

Reviewed by Aditya Keerthi.

When `didReceiveText` is invoked multiple times when replacing text with a table, multiple table
elements were being created. This is because when the controller tries to re-create the context range
after the first table, it is unable to do so since selections cannot encompass a table or list element.

Fix by not trying to re-create the context range at all; instead, just undo the previous replacements,
and then the context range will always just be the original range for the current composition.

To facilitate this, add a 'silent' option when undo-ing a composition edit command so that a command can
be undone without adding it to the undo stack or emitting any type of event.

Additionally, since the TextAnimationController currently relies on being able to get the current range using
the session identifier, add a new property to the Writing Tools command to give this information.

* Source/WebCore/editing/CompositeEditCommand.cpp:
(WebCore::EditCommandComposition::unapply):
* Source/WebCore/editing/CompositeEditCommand.h:
* Source/WebCore/editing/WritingToolsCompositionCommand.cpp:
(WebCore::WritingToolsCompositionCommand::WritingToolsCompositionCommand):
(WebCore::WritingToolsCompositionCommand::replaceContentsOfRangeWithFragment):
* Source/WebCore/editing/WritingToolsCompositionCommand.h:
(WebCore::WritingToolsCompositionCommand::currentContextRange const):
* Source/WebCore/page/writing-tools/WritingToolsController.mm:
(WebCore::WritingToolsController::compositionSessionDidReceiveTextWithReplacementRange):
(WebCore::WritingToolsController::contextRangeForSessionWithID const):
* Tools/TestWebKitAPI/Tests/WebKitCocoa/WritingTools.mm:
(makeTableAttributedString):
(TEST(WritingTools, CompositionWithTable)):
(TEST(WritingTools, SmartReplyWithInsertedSpace)):

Canonical link: https://commits.webkit.org/281780@main

f8c257f

Misc iOS, visionOS, tvOS & watchOS macOS Linux Windows
✅ 🧪 style ✅ 🛠 ios ✅ 🛠 mac ✅ 🛠 wpe ✅ 🛠 wincairo
✅ 🧪 bindings ✅ 🛠 ios-sim ✅ 🛠 mac-AS-debug 🧪 wpe-wk2 ✅ 🧪 wincairo-tests
✅ 🧪 webkitperl 🧪 ios-wk2 🧪 api-mac ✅ 🧪 api-wpe
✅ 🧪 ios-wk2-wpt ✅ 🧪 mac-wk1 ✅ 🛠 wpe-cairo
🧪 api-ios ✅ 🧪 mac-wk2 ✅ 🛠 gtk
✅ 🛠 vision 🧪 mac-AS-debug-wk2 🧪 gtk-wk2
✅ 🛠 vision-sim ✅ 🧪 mac-wk2-stress 🧪 api-gtk
✅ 🛠 🧪 merge ✅ 🧪 vision-wk2
🛠 tv
🛠 tv-sim
🛠 watch
🛠 watch-sim

@rr-codes rr-codes requested review from cdumez and rniwa as code owners July 8, 2024 14:45
@rr-codes rr-codes self-assigned this Jul 8, 2024
@rr-codes rr-codes added the HTML Editing For bugs in HTML editing support (including designMode and contentEditable). label Jul 8, 2024
@rr-codes rr-codes requested a review from pxlcoder July 8, 2024 21:52
@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label Jul 9, 2024
@rr-codes rr-codes removed the merging-blocked Applied to prevent a change from being merged label Jul 9, 2024
@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label Jul 9, 2024
@rr-codes rr-codes removed the merging-blocked Applied to prevent a change from being merged label Jul 14, 2024
@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label Jul 16, 2024
@rr-codes rr-codes removed the merging-blocked Applied to prevent a change from being merged label Jul 16, 2024
@rr-codes rr-codes added the merge-queue Applied to send a pull request to merge-queue label Aug 2, 2024
https://bugs.webkit.org/show_bug.cgi?id=276315
rdar://129926389

Reviewed by Aditya Keerthi.

When `didReceiveText` is invoked multiple times when replacing text with a table, multiple table
elements were being created. This is because when the controller tries to re-create the context range
after the first table, it is unable to do so since selections cannot encompass a table or list element.

Fix by not trying to re-create the context range at all; instead, just undo the previous replacements,
and then the context range will always just be the original range for the current composition.

To facilitate this, add a 'silent' option when undo-ing a composition edit command so that a command can
be undone without adding it to the undo stack or emitting any type of event.

Additionally, since the TextAnimationController currently relies on being able to get the current range using
the session identifier, add a new property to the Writing Tools command to give this information.

* Source/WebCore/editing/CompositeEditCommand.cpp:
(WebCore::EditCommandComposition::unapply):
* Source/WebCore/editing/CompositeEditCommand.h:
* Source/WebCore/editing/WritingToolsCompositionCommand.cpp:
(WebCore::WritingToolsCompositionCommand::WritingToolsCompositionCommand):
(WebCore::WritingToolsCompositionCommand::replaceContentsOfRangeWithFragment):
* Source/WebCore/editing/WritingToolsCompositionCommand.h:
(WebCore::WritingToolsCompositionCommand::currentContextRange const):
* Source/WebCore/page/writing-tools/WritingToolsController.mm:
(WebCore::WritingToolsController::compositionSessionDidReceiveTextWithReplacementRange):
(WebCore::WritingToolsController::contextRangeForSessionWithID const):
* Tools/TestWebKitAPI/Tests/WebKitCocoa/WritingTools.mm:
(makeTableAttributedString):
(TEST(WritingTools, CompositionWithTable)):
(TEST(WritingTools, SmartReplyWithInsertedSpace)):

Canonical link: https://commits.webkit.org/281780@main
@webkit-commit-queue
Copy link
Collaborator

Committed 281780@main (292bb3d): https://commits.webkit.org/281780@main

Reviewed commits have been landed. Closing PR #30564 and removing active labels.

@webkit-commit-queue webkit-commit-queue merged commit 292bb3d into WebKit:main Aug 2, 2024
@webkit-commit-queue webkit-commit-queue removed the merge-queue Applied to send a pull request to merge-queue label Aug 2, 2024
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

Development

Successfully merging this pull request may close these issues.

6 participants