[webkit-changes] [WebKit/WebKit] 3dfc59: [Writing Tools] Disable editing while content is b...

Aditya Keerthi noreply at github.com
Thu Jul 4 09:15:38 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 3dfc596a48b0a7ac069c6aa6de17d0d453c9f3f2
      https://github.com/WebKit/WebKit/commit/3dfc596a48b0a7ac069c6aa6de17d0d453c9f3f2
  Author: Aditya Keerthi <akeerthi at apple.com>
  Date:   2024-07-04 (Thu, 04 Jul 2024)

  Changed paths:
    M Source/WebCore/editing/Editor.cpp
    M Source/WebCore/editing/Editor.h
    M Source/WebCore/page/writing-tools/WritingToolsController.h
    M Source/WebCore/page/writing-tools/WritingToolsController.mm
    M Tools/TestWebKitAPI/Tests/WebKitCocoa/WritingTools.mm

  Log Message:
  -----------
  [Writing Tools] Disable editing while content is being processed
https://bugs.webkit.org/show_bug.cgi?id=276166
rdar://125812157

Reviewed by Richard Robinson and Abrar Rahman Protyasha.

In order to ensure Writing Tools behaves sensibly, editing should be suppressed
while content is being processed.

For proofreading, suppression ends once the last suggestion is received. For
rewriting, suppression ends only once the session is over, meaning the user
has either accepted, rejected, or cancelled.

* Source/WebCore/editing/Editor.cpp:
(WebCore::Editor::willApplyEditing):

Suppression is effectively implemented by returning false in `willApplyEditing`.

* Source/WebCore/editing/Editor.h:

Add hooks for `WritingToolsController` to suppress editing.

* Source/WebCore/page/writing-tools/WritingToolsController.h:
* Source/WebCore/page/writing-tools/WritingToolsController.mm:
(WebCore::WritingToolsController::EditingScope::EditingScope):
(WebCore::WritingToolsController::EditingScope::~EditingScope):

Use the RAII idiom to temporarily allow editing during the session, so that
replacement can be performed.

(WebCore::WritingToolsController::willBeginWritingToolsSession):

Suppress editing in `willBeginWritingToolsSession`, since the context string is
handed of at this point.

(WebCore::WritingToolsController::proofreadingSessionDidReceiveSuggestions):

Use `WritingToolsController::EditingScope` to enable replacement to occur.

For proofreading, suppression ends once the last suggestion is received.

(WebCore::WritingToolsController::didEndWritingToolsSession):

For rewriting, suppression ends only once the session is over.

(WebCore::WritingToolsController::replaceContentsOfRangeInSession):

Use `WritingToolsController::EditingScope` to enable replacement to occur.

* Tools/TestWebKitAPI/Tests/WebKitCocoa/WritingTools.mm:
(-[WritingToolsWKWebView attemptEditingForTesting]):
(TEST(WritingTools, ProofreadingWithAttemptedEditing)):
(TEST(WritingTools, CompositionWithAttemptedEditing)):

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