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"
14 namespace mozilla::dom
{
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
{
30 TextDirectiveFinder(Document
& aDocument
,
31 nsTArray
<TextDirective
>&& aTextDirectives
);
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();
41 * Returns true if there are text directives left which were not yet found in
44 bool HasUninvokedDirectives() const;
47 * Finds a range for _one_ text directive.
49 RefPtr
<nsRange
> FindRangeForTextDirective(
50 const TextDirective
& aTextDirective
);
54 nsTArray
<TextDirective
> mUninvokedTextDirectives
;
56 } // namespace mozilla::dom