Bug 1867925 - Mark some storage-access-api tests as intermittent after wpt-sync....
[gecko.git] / accessible / xpcom / xpcAccessibleTextRange.h
blob01ca228ade2805b707aa52b92fdc6dd940d5d5a0
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=2 et sw=2 tw=80: */
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 file,
5 * You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef mozilla_a11y_xpcAccessibleTextRange_h_
8 #define mozilla_a11y_xpcAccessibleTextRange_h_
10 #include <utility>
12 #include "TextRange.h"
13 #include "nsIAccessibleTextRange.h"
14 #include "xpcAccessibleHyperText.h"
16 namespace mozilla {
17 namespace a11y {
19 class TextRange;
21 #define NS_ACCESSIBLETEXTRANGE_IMPL_IID \
22 { /* 133c8bf4-4913-4355-bd50-426bd1d6e1ad */ \
23 0xb17652d9, 0x4f54, 0x4c56, { \
24 0xbb, 0x62, 0x6d, 0x5b, 0xf1, 0xef, 0x91, 0x0c \
25 } \
28 class xpcAccessibleTextRange final : public nsIAccessibleTextRange {
29 public:
30 explicit xpcAccessibleTextRange(TextRange& aRange) { SetRange(aRange); }
32 NS_DECL_ISUPPORTS
34 NS_IMETHOD GetStartContainer(nsIAccessibleText** aAnchor) final;
35 NS_IMETHOD GetStartOffset(int32_t* aOffset) final;
36 NS_IMETHOD GetEndContainer(nsIAccessibleText** aAnchor) final;
37 NS_IMETHOD GetEndOffset(int32_t* aOffset) final;
38 NS_IMETHOD GetContainer(nsIAccessible** aContainer) final;
39 NS_IMETHOD Compare(nsIAccessibleTextRange* aOtherRange, bool* aResult) final;
40 NS_IMETHOD CompareEndPoints(uint32_t aEndPoint,
41 nsIAccessibleTextRange* aOtherRange,
42 uint32_t aOtherRangeEndPoint,
43 int32_t* aResult) final;
44 NS_IMETHOD Crop(nsIAccessible* aContainer, bool* aSuccess) final;
46 NS_DECLARE_STATIC_IID_ACCESSOR(NS_ACCESSIBLETEXTRANGE_IMPL_IID)
48 private:
49 xpcAccessibleTextRange() {}
51 ~xpcAccessibleTextRange() {}
53 friend class xpcAccessibleHyperText;
55 xpcAccessibleTextRange& operator=(const xpcAccessibleTextRange&) = delete;
57 void SetRange(TextRange& aRange);
59 TextRange Range();
61 // We can't hold a strong reference to an Accessible, but XPCOM needs strong
62 // references. Thus, instead of holding a TextRange here, we hold
63 // xpcAccessibleHyperText references and create the TextRange for each call
64 // using Range().
65 RefPtr<xpcAccessibleHyperText> mRoot;
66 RefPtr<xpcAccessibleHyperText> mStartContainer;
67 int32_t mStartOffset;
68 RefPtr<xpcAccessibleHyperText> mEndContainer;
69 int32_t mEndOffset;
72 NS_DEFINE_STATIC_IID_ACCESSOR(xpcAccessibleTextRange,
73 NS_ACCESSIBLETEXTRANGE_IMPL_IID)
75 } // namespace a11y
76 } // namespace mozilla
78 #endif