Title: [285670] trunk/Source/WebCore
- Revision
- 285670
- Author
- [email protected]
- Date
- 2021-11-11 14:43:51 -0800 (Thu, 11 Nov 2021)
Log Message
[Live Text] Augment TextRecognitionResult with a new type of text recognition data
https://bugs.webkit.org/show_bug.cgi?id=233009
Reviewed by Devin Rousso.
Add the new type, along with encoding/decoding support. No change in behavior.
* platform/TextRecognitionResult.h:
(WebCore::TextRecognitionBlockData::TextRecognitionBlockData):
(WebCore::TextRecognitionBlockData::encode const):
(WebCore::TextRecognitionBlockData::decode):
(WebCore::TextRecognitionResult::isEmpty const):
(WebCore::TextRecognitionResult::encode const):
(WebCore::TextRecognitionResult::decode):
* testing/Internals.cpp:
(WebCore::Internals::installImageOverlay):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (285669 => 285670)
--- trunk/Source/WebCore/ChangeLog 2021-11-11 22:41:39 UTC (rev 285669)
+++ trunk/Source/WebCore/ChangeLog 2021-11-11 22:43:51 UTC (rev 285670)
@@ -1,3 +1,22 @@
+2021-11-11 Wenson Hsieh <[email protected]>
+
+ [Live Text] Augment TextRecognitionResult with a new type of text recognition data
+ https://bugs.webkit.org/show_bug.cgi?id=233009
+
+ Reviewed by Devin Rousso.
+
+ Add the new type, along with encoding/decoding support. No change in behavior.
+
+ * platform/TextRecognitionResult.h:
+ (WebCore::TextRecognitionBlockData::TextRecognitionBlockData):
+ (WebCore::TextRecognitionBlockData::encode const):
+ (WebCore::TextRecognitionBlockData::decode):
+ (WebCore::TextRecognitionResult::isEmpty const):
+ (WebCore::TextRecognitionResult::encode const):
+ (WebCore::TextRecognitionResult::decode):
+ * testing/Internals.cpp:
+ (WebCore::Internals::installImageOverlay):
+
2021-11-11 Nikolaos Mouchtaris <[email protected]>
REGRESSION: (r283871) [ macOS wk2 Release ] 2 css/cssom-view/scroll-behavior-main-frame tests are failing
Modified: trunk/Source/WebCore/platform/TextRecognitionResult.h (285669 => 285670)
--- trunk/Source/WebCore/platform/TextRecognitionResult.h 2021-11-11 22:41:39 UTC (rev 285669)
+++ trunk/Source/WebCore/platform/TextRecognitionResult.h 2021-11-11 22:43:51 UTC (rev 285670)
@@ -131,6 +131,41 @@
return {{ WTFMove(*normalizedQuad), WTFMove(*children) }};
}
+struct TextRecognitionBlockData {
+ TextRecognitionBlockData(const String& theText, FloatQuad&& quad)
+ : text(theText)
+ , normalizedQuad(WTFMove(quad))
+ {
+ }
+
+ String text;
+ FloatQuad normalizedQuad;
+
+ template<class Encoder> void encode(Encoder&) const;
+ template<class Decoder> static std::optional<TextRecognitionBlockData> decode(Decoder&);
+};
+
+template<class Encoder> void TextRecognitionBlockData::encode(Encoder& encoder) const
+{
+ encoder << text;
+ encoder << normalizedQuad;
+}
+
+template<class Decoder> std::optional<TextRecognitionBlockData> TextRecognitionBlockData::decode(Decoder& decoder)
+{
+ std::optional<String> text;
+ decoder >> text;
+ if (!text)
+ return std::nullopt;
+
+ std::optional<FloatQuad> normalizedQuad;
+ decoder >> normalizedQuad;
+ if (!normalizedQuad)
+ return std::nullopt;
+
+ return { { WTFMove(*text), WTFMove(*normalizedQuad) } };
+}
+
struct TextRecognitionResult {
Vector<TextRecognitionLineData> lines;
@@ -138,6 +173,8 @@
Vector<TextRecognitionDataDetector> dataDetectors;
#endif
+ Vector<TextRecognitionBlockData> blocks;
+
bool isEmpty() const
{
if (!lines.isEmpty())
@@ -148,6 +185,9 @@
return false;
#endif
+ if (!blocks.isEmpty())
+ return false;
+
return true;
}
@@ -161,6 +201,7 @@
#if ENABLE(DATA_DETECTION)
encoder << dataDetectors;
#endif
+ encoder << blocks;
}
template<class Decoder> std::optional<TextRecognitionResult> TextRecognitionResult::decode(Decoder& decoder)
@@ -177,11 +218,17 @@
return std::nullopt;
#endif
+ std::optional<Vector<TextRecognitionBlockData>> blocks;
+ decoder >> blocks;
+ if (!blocks)
+ return std::nullopt;
+
return {{
WTFMove(*lines),
#if ENABLE(DATA_DETECTION)
WTFMove(*dataDetectors),
#endif
+ WTFMove(*blocks),
}};
}
Modified: trunk/Source/WebCore/testing/Internals.cpp (285669 => 285670)
--- trunk/Source/WebCore/testing/Internals.cpp 2021-11-11 22:41:39 UTC (rev 285669)
+++ trunk/Source/WebCore/testing/Internals.cpp 2021-11-11 22:43:51 UTC (rev 285670)
@@ -5815,6 +5815,7 @@
#if ENABLE(DATA_DETECTION)
, Vector<TextRecognitionDataDetector>()
#endif
+ , Vector<TextRecognitionBlockData>()
});
#else
UNUSED_PARAM(lines);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes