2022-03-15 00:35:05 +00:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
#ifndef mozilla_widget_nsTextRecognition__
|
|
|
|
#define mozilla_widget_nsTextRecognition__
|
|
|
|
|
|
|
|
#include "mozilla/MozPromise.h"
|
|
|
|
#include "mozilla/gfx/Point.h"
|
|
|
|
#include "nsTArray.h"
|
|
|
|
|
|
|
|
class imgIContainer;
|
2022-03-15 18:14:08 +00:00
|
|
|
namespace mozilla {
|
2022-03-15 00:35:05 +00:00
|
|
|
|
2022-03-15 18:14:08 +00:00
|
|
|
namespace dom {
|
|
|
|
class ShadowRoot;
|
|
|
|
class TextRecognitionResultOrError;
|
|
|
|
class TextRecognitionResult;
|
|
|
|
} // namespace dom
|
2022-03-15 00:35:05 +00:00
|
|
|
|
2022-03-15 18:14:08 +00:00
|
|
|
namespace gfx {
|
|
|
|
class SourceSurface;
|
|
|
|
class DataSourceSurface;
|
|
|
|
} // namespace gfx
|
2022-03-15 00:35:05 +00:00
|
|
|
|
2022-03-15 18:14:08 +00:00
|
|
|
namespace widget {
|
2022-03-15 00:35:05 +00:00
|
|
|
|
2022-03-15 18:14:08 +00:00
|
|
|
class TextRecognition final {
|
2022-03-15 00:35:05 +00:00
|
|
|
public:
|
2022-03-15 18:14:08 +00:00
|
|
|
using NativePromise = MozPromise<dom::TextRecognitionResult, nsCString,
|
2022-03-15 00:35:05 +00:00
|
|
|
/* IsExclusive = */ true>;
|
|
|
|
|
|
|
|
TextRecognition() = default;
|
|
|
|
|
2022-03-15 18:14:08 +00:00
|
|
|
static void FillShadow(dom::ShadowRoot&, const dom::TextRecognitionResult&);
|
|
|
|
|
2022-08-10 19:38:46 +00:00
|
|
|
static RefPtr<NativePromise> FindText(imgIContainer&,
|
|
|
|
const nsTArray<nsCString>&);
|
|
|
|
static RefPtr<NativePromise> FindText(gfx::DataSourceSurface&,
|
|
|
|
const nsTArray<nsCString>&);
|
2022-08-17 15:41:12 +00:00
|
|
|
static bool IsSupported();
|
2022-03-15 00:35:05 +00:00
|
|
|
|
|
|
|
protected:
|
2022-03-15 18:14:08 +00:00
|
|
|
// This should be implemented in the OS specific file.
|
2022-08-10 19:38:46 +00:00
|
|
|
static RefPtr<NativePromise> DoFindText(gfx::DataSourceSurface&,
|
|
|
|
const nsTArray<nsCString>&);
|
2022-03-15 18:14:08 +00:00
|
|
|
|
2022-03-15 00:35:05 +00:00
|
|
|
~TextRecognition() = default;
|
|
|
|
};
|
|
|
|
|
2022-03-15 18:14:08 +00:00
|
|
|
} // namespace widget
|
|
|
|
} // namespace mozilla
|
2022-03-15 00:35:05 +00:00
|
|
|
|
|
|
|
#endif
|