-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Unified Text Replacement] Refactor UnifiedTextReplacementController …
…methods to pass in a session type instead of separate parameters https://bugs.webkit.org/show_bug.cgi?id=274356 rdar://128333023 Reviewed by Wenson Hsieh. Work towards using more strongly typed objects instead of passing around UUIDs everywhere by creating a new `WebUnifiedTextReplacementSessionData` type and using that, similar to the existing `WebUnifiedTextReplacementContextData` type. This also has the advantage of being more expressive with regards to optional-ness. * Source/WebKit/Scripts/webkit/messages.py: (headers_for_type): * Source/WebKit/Shared/UnifiedTextReplacement.serialization.in: * Source/WebKit/Shared/WebUnifiedTextReplacementContextData.h: * Source/WebKit/Shared/WebUnifiedTextReplacementSessionData.h: Copied from Source/WebKit/Shared/WebUnifiedTextReplacementContextData.h. * Source/WebKit/UIProcess/Cocoa/WebPageProxyCocoa.mm: (WebKit::WebPageProxy::willBeginTextReplacementSession): (WebKit::WebPageProxy::didBeginTextReplacementSession): (WebKit::WebPageProxy::textReplacementSessionDidReceiveReplacements): (WebKit::WebPageProxy::textReplacementSessionDidUpdateStateForReplacement): (WebKit::WebPageProxy::didEndTextReplacementSession): (WebKit::WebPageProxy::textReplacementSessionDidReceiveTextWithReplacementRange): (WebKit::WebPageProxy::textReplacementSessionDidReceiveEditAction): (WebKit::WebPageProxy::addTextIndicatorStyleForID): * Source/WebKit/UIProcess/WebPageProxy.h: * Source/WebKit/WebKit.xcodeproj/project.pbxproj: * Source/WebKit/WebProcess/WebPage/Cocoa/UnifiedTextReplacementController.mm: (WebKit::UnifiedTextReplacementController::willBeginTextReplacementSession): (WebKit::UnifiedTextReplacementController::didBeginTextReplacementSession): (WebKit::UnifiedTextReplacementController::textReplacementSessionDidReceiveReplacements): (WebKit::UnifiedTextReplacementController::textReplacementSessionDidUpdateStateForReplacement): (WebKit::UnifiedTextReplacementController::didEndTextReplacementSession<WebUnifiedTextReplacementSessionData::ReplacementType::PlainText>): (WebKit::UnifiedTextReplacementController::didEndTextReplacementSession<WebUnifiedTextReplacementSessionData::ReplacementType::RichText>): (WebKit::UnifiedTextReplacementController::didEndTextReplacementSession): (WebKit::UnifiedTextReplacementController::textReplacementSessionDidReceiveTextWithReplacementRange): (WebKit::UnifiedTextReplacementController::textReplacementSessionDidReceiveEditAction): (WebKit::UnifiedTextReplacementController::textReplacementSessionPerformEditActionForPlainText): (WebKit::UnifiedTextReplacementController::textReplacementSessionPerformEditActionForRichText): (WebKit::UnifiedTextReplacementController::didEndTextReplacementSession<WebUnifiedTextReplacementType::PlainText>): Deleted. (WebKit::UnifiedTextReplacementController::didEndTextReplacementSession<WebUnifiedTextReplacementType::RichText>): Deleted. * Source/WebKit/WebProcess/WebPage/Cocoa/WebPageCocoa.mm: (WebKit::WebPage::updateTextIndicatorStyleVisibilityForID): (WebKit::WebPage::willBeginTextReplacementSession): (WebKit::WebPage::didBeginTextReplacementSession): (WebKit::WebPage::textReplacementSessionDidReceiveReplacements): (WebKit::WebPage::textReplacementSessionDidUpdateStateForReplacement): (WebKit::WebPage::didEndTextReplacementSession): (WebKit::WebPage::textReplacementSessionDidReceiveTextWithReplacementRange): (WebKit::WebPage::textReplacementSessionDidReceiveEditAction): * Source/WebKit/WebProcess/WebPage/UnifiedTextReplacementController.h: * Source/WebKit/WebProcess/WebPage/WebPage.h: * Source/WebKit/WebProcess/WebPage/WebPage.messages.in: Canonical link: https://commits.webkit.org/278965@main
- Loading branch information
Showing
12 changed files
with
222 additions
and
167 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
Source/WebKit/Shared/WebUnifiedTextReplacementSessionData.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
* Copyright (C) 2024 Apple Inc. All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions | ||
* are met: | ||
* 1. Redistributions of source code must retain the above copyright | ||
* notice, this list of conditions and the following disclaimer. | ||
* 2. Redistributions in binary form must reproduce the above copyright | ||
* notice, this list of conditions and the following disclaimer in the | ||
* documentation and/or other materials provided with the distribution. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' | ||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, | ||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS | ||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF | ||
* THE POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#if ENABLE(UNIFIED_TEXT_REPLACEMENT) | ||
|
||
#import <wtf/UUID.h> | ||
|
||
namespace WebKit { | ||
|
||
enum class WebUnifiedTextReplacementSessionDataReplacementType : uint8_t { | ||
PlainText, | ||
RichText, | ||
}; | ||
|
||
struct WebUnifiedTextReplacementSessionData { | ||
using ReplacementType = WebUnifiedTextReplacementSessionDataReplacementType; | ||
|
||
WTF::UUID uuid; | ||
ReplacementType replacementType { ReplacementType::RichText }; | ||
}; | ||
|
||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.