1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
// Copyright (C) 2021 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
//
// W A R N I N G
// -------------
//
// This file is not part of the Qt API. It exists purely as an
// implementation detail. This header file may change from version to
// version without notice, or even be removed.
//
// We mean it.
//
#ifndef FIND_TEXT_HELPER_H
#define FIND_TEXT_HELPER_H
#include <QtWebEngineCore/private/qtwebenginecoreglobal_p.h>
#include <QJSValue>
#include <QMap>
#include <QString>
#include <functional>
namespace content {
class WebContents;
}
namespace gfx {
class Rect;
}
QT_FORWARD_DECLARE_CLASS(QWebEngineFindTextResult)
namespace QtWebEngineCore {
class WebContentsAdapterClient;
class Q_WEBENGINECORE_PRIVATE_EXPORT FindTextHelper {
public:
FindTextHelper(content::WebContents *webContents, WebContentsAdapterClient *viewClient);
~FindTextHelper();
void startFinding(const QString &findText, bool caseSensitively, bool findBackward, const std::function<void(const QWebEngineFindTextResult &)> &resultCallback);
void startFinding(const QString &findText, bool caseSensitively, bool findBackward, const QJSValue &resultCallback);
void startFinding(const QString &findText, bool caseSensitively, bool findBackward);
void stopFinding();
bool isFindTextInProgress() const;
void handleFindReply(content::WebContents *source, int requestId, int numberOfMatches, const gfx::Rect &selectionRect, int activeMatch, bool finalUpdate);
void handleLoadCommitted();
private:
void invokeResultCallback(int requestId, int numberOfMatches, int activeMatch);
content::WebContents *m_webContents;
WebContentsAdapterClient *m_viewClient;
static int m_findRequestIdCounter;
int m_currentFindRequestId;
int m_lastCompletedFindRequestId;
QString m_previousFindText;
QMap<int, QJSValue> m_quickCallbacks;
QMap<int, std::function<void(const QWebEngineFindTextResult &)>> m_widgetCallbacks;
};
} // namespace QtWebEngineCore
#endif // FIND_TEXT_HELPER_H
|