2022-03-15 03:35:05 +03: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 21:14:08 +03:00
|
|
|
namespace mozilla {
|
2022-03-15 03:35:05 +03:00
|
|
|
|
2022-03-15 21:14:08 +03:00
|
|
|
namespace dom {
|
|
|
|
class ShadowRoot;
|
|
|
|
class TextRecognitionResultOrError;
|
|
|
|
class TextRecognitionResult;
|
|
|
|
} // namespace dom
|
2022-03-15 03:35:05 +03:00
|
|
|
|
2022-03-15 21:14:08 +03:00
|
|
|
namespace gfx {
|
|
|
|
class SourceSurface;
|
|
|
|
class DataSourceSurface;
|
|
|
|
} // namespace gfx
|
2022-03-15 03:35:05 +03:00
|
|
|
|
2022-03-15 21:14:08 +03:00
|
|
|
namespace widget {
|
2022-03-15 03:35:05 +03:00
|
|
|
|
2022-03-15 21:14:08 +03:00
|
|
|
class TextRecognition final {
|
2022-03-15 03:35:05 +03:00
|
|
|
public:
|
2022-03-15 21:14:08 +03:00
|
|
|
using NativePromise = MozPromise<dom::TextRecognitionResult, nsCString,
|
2022-03-15 03:35:05 +03:00
|
|
|
/* IsExclusive = */ true>;
|
|
|
|
|
|
|
|
TextRecognition() = default;
|
|
|
|
|
2022-03-15 21:14:08 +03:00
|
|
|
static void FillShadow(dom::ShadowRoot&, const dom::TextRecognitionResult&);
|
|
|
|
|
2022-08-10 22:38:46 +03:00
|
|
|
static RefPtr<NativePromise> FindText(imgIContainer&,
|
|
|
|
const nsTArray<nsCString>&);
|
|
|
|
static RefPtr<NativePromise> FindText(gfx::DataSourceSurface&,
|
|
|
|
const nsTArray<nsCString>&);
|
2022-08-17 18:41:12 +03:00
|
|
|
static bool IsSupported();
|
2022-03-15 03:35:05 +03:00
|
|
|
|
|
|
|
protected:
|
2022-03-15 21:14:08 +03:00
|
|
|
// This should be implemented in the OS specific file.
|
2022-08-10 22:38:46 +03:00
|
|
|
static RefPtr<NativePromise> DoFindText(gfx::DataSourceSurface&,
|
|
|
|
const nsTArray<nsCString>&);
|
2022-03-15 21:14:08 +03:00
|
|
|
|
2022-03-15 03:35:05 +03:00
|
|
|
~TextRecognition() = default;
|
|
|
|
};
|
|
|
|
|
2022-03-15 21:14:08 +03:00
|
|
|
} // namespace widget
|
|
|
|
} // namespace mozilla
|
2022-03-15 03:35:05 +03:00
|
|
|
|
|
|
|
#endif
|