Skip to content

Commit

Permalink
Generate serialization for WebCore::TextRecognitionDataDetector
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=267641
rdar://121125342

Reviewed by Alex Christensen.

* Source/WebCore/platform/TextRecognitionResult.h:
(WebCore::TextRecognitionDataDetector::TextRecognitionDataDetector):
* Source/WebKit/Shared/Cocoa/WebCoreArgumentCodersCocoa.mm:
(IPC::ArgumentCoder<WebCore::TextRecognitionDataDetector>::encodePlatformData): Deleted.
(IPC::ArgumentCoder<WebCore::TextRecognitionDataDetector>::decodePlatformData): Deleted.
* Source/WebKit/Shared/WebCoreArgumentCoders.cpp:
(IPC::ArgumentCoder<TextRecognitionDataDetector>::encode): Deleted.
(IPC::ArgumentCoder<TextRecognitionDataDetector>::decode): Deleted.
* Source/WebKit/Shared/WebCoreArgumentCoders.h:
* Source/WebKit/Shared/WebCoreArgumentCoders.serialization.in:

Canonical link: https://commits.webkit.org/273361@main
  • Loading branch information
sheeparegreat authored and achristensen07 committed Jan 23, 2024
1 parent 2887eed commit 74e3ec7
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 57 deletions.
4 changes: 2 additions & 2 deletions Source/WebCore/platform/TextRecognitionResult.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ struct TextRecognitionLineData {

struct TextRecognitionDataDetector {
TextRecognitionDataDetector() = default;
TextRecognitionDataDetector(DDScannerResult *scannerResult, Vector<FloatQuad>&& quads)
: result(scannerResult)
TextRecognitionDataDetector(RetainPtr<DDScannerResult>&& scannerResult, Vector<FloatQuad>&& quads)
: result(WTFMove(scannerResult))
, normalizedQuads(WTFMove(quads))
{
}
Expand Down
18 changes: 0 additions & 18 deletions Source/WebKit/Shared/Cocoa/WebCoreArgumentCodersCocoa.mm
Original file line number Diff line number Diff line change
Expand Up @@ -671,24 +671,6 @@
}
#endif

#if ENABLE(IMAGE_ANALYSIS) && ENABLE(DATA_DETECTION)

void ArgumentCoder<WebCore::TextRecognitionDataDetector>::encodePlatformData(Encoder& encoder, const WebCore::TextRecognitionDataDetector& info)
{
encoder << info.result.get();
}

bool ArgumentCoder<WebCore::TextRecognitionDataDetector>::decodePlatformData(Decoder& decoder, WebCore::TextRecognitionDataDetector& result)
{
auto scannerResult = decoder.decodeWithAllowedClasses<DDScannerResult>();
if (!scannerResult)
return false;

result.result = WTFMove(*scannerResult);
return true;
}

#endif // ENABLE(IMAGE_ANALYSIS) && ENABLE(DATA_DETECTION)

#if ENABLE(IMAGE_ANALYSIS_ENHANCEMENTS)

Expand Down
25 changes: 0 additions & 25 deletions Source/WebKit/Shared/WebCoreArgumentCoders.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -907,29 +907,4 @@ std::optional<WebCore::CDMInstanceSession::Message> ArgumentCoder<WebCore::CDMI
}
#endif // ENABLE(ENCRYPTED_MEDIA)

#if ENABLE(IMAGE_ANALYSIS) && ENABLE(DATA_DETECTION)

void ArgumentCoder<TextRecognitionDataDetector>::encode(Encoder& encoder, const TextRecognitionDataDetector& info)
{
encodePlatformData(encoder, info);
encoder << info.normalizedQuads;
}

std::optional<TextRecognitionDataDetector> ArgumentCoder<TextRecognitionDataDetector>::decode(Decoder& decoder)
{
TextRecognitionDataDetector result;
if (!decodePlatformData(decoder, result))
return std::nullopt;

std::optional<Vector<FloatQuad>> normalizedQuads;
decoder >> normalizedQuads;
if (!normalizedQuads)
return std::nullopt;

result.normalizedQuads = WTFMove(*normalizedQuads);
return WTFMove(result);
}

#endif // ENABLE(IMAGE_ANALYSIS) && ENABLE(DATA_DETECTION)

} // namespace IPC
12 changes: 0 additions & 12 deletions Source/WebKit/Shared/WebCoreArgumentCoders.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,6 @@ class SystemImage;
struct CompositionUnderline;
struct DataDetectorElementInfo;
struct SoupNetworkProxySettings;
struct TextRecognitionDataDetector;
struct ViewportArguments;

template <class>
Expand Down Expand Up @@ -308,17 +307,6 @@ template<> struct ArgumentCoder<WebCore::CDMInstanceSession::Message> {
};
#endif

#if ENABLE(IMAGE_ANALYSIS) && ENABLE(DATA_DETECTION)

template<> struct ArgumentCoder<WebCore::TextRecognitionDataDetector> {
static void encode(Encoder&, const WebCore::TextRecognitionDataDetector&);
static WARN_UNUSED_RETURN std::optional<WebCore::TextRecognitionDataDetector> decode(Decoder&);
static void encodePlatformData(Encoder&, const WebCore::TextRecognitionDataDetector&);
static WARN_UNUSED_RETURN bool decodePlatformData(Decoder&, WebCore::TextRecognitionDataDetector&);
};

#endif // ENABLE(IMAGE_ANALYSIS) && ENABLE(DATA_DETECTION)

#if ENABLE(IMAGE_ANALYSIS_ENHANCEMENTS)

template<> struct ArgumentCoder<RetainPtr<VKCImageAnalysis>> {
Expand Down
8 changes: 8 additions & 0 deletions Source/WebKit/Shared/WebCoreArgumentCoders.serialization.in
Original file line number Diff line number Diff line change
Expand Up @@ -7284,6 +7284,14 @@ enum class WebCore::GraphicsContextGLSurfaceBuffer : bool;
InvalidEnum
};

#if ENABLE(IMAGE_ANALYSIS) && ENABLE(DATA_DETECTION)
header: <WebCore/TextRecognitionResult.h>
[CustomHeader] struct WebCore::TextRecognitionDataDetector {
RetainPtr<DDScannerResult> result;
Vector<WebCore::FloatQuad> normalizedQuads;
};
#endif // ENABLE(IMAGE_ANALYSIS) && ENABLE(DATA_DETECTION)

#if ENABLE(VIDEO)

header: <WebCore/AudioTrackPrivate.h>
Expand Down

0 comments on commit 74e3ec7

Please sign in to comment.