Backed out changeset 9d8b4c0b99ed (bug 1945683) for causing btime failures. CLOSED...
[gecko.git] / dom / base / TextDirectiveFinder.h
blobe1128b1bce3cdf440e82f05e107e1d5f4fe1d409
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim:set ts=2 sw=2 sts=2 et cindent: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef DOM_TEXTDIRECTIVEFINDER_H_
8 #define DOM_TEXTDIRECTIVEFINDER_H_
9 #include "mozilla/RefPtr.h"
10 #include "nsTArray.h"
12 class nsRange;
13 struct TextDirective;
14 namespace mozilla::dom {
16 class Document;
18 /**
19 * @brief Finds one or more `TextDirective`s in a `Document`.
21 * This class is designed to consume the `TextDirective`s.
22 * Every `TextDirective` which is found is removed from the list of uninvoked
23 * text directives, and is returned as an `nsRange`.
25 * Internally, finding a text directive in a document uses Gecko's find-in-page
26 * implementation `nsFind`.
28 class TextDirectiveFinder final {
29 public:
30 TextDirectiveFinder(Document& aDocument,
31 nsTArray<TextDirective>&& aTextDirectives);
33 /**
34 * @brief Attempts to convert all uninvoked text directives to ranges.
36 * This method is the main entry point of this class.
38 nsTArray<RefPtr<nsRange>> FindTextDirectivesInDocument();
40 /**
41 * Returns true if there are text directives left which were not yet found in
42 * the document.
44 bool HasUninvokedDirectives() const;
46 /**
47 * Finds a range for _one_ text directive.
49 RefPtr<nsRange> FindRangeForTextDirective(
50 const TextDirective& aTextDirective);
52 private:
53 Document& mDocument;
54 nsTArray<TextDirective> mUninvokedTextDirectives;
56 } // namespace mozilla::dom
58 #endif