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_
12 #include "TextRange.h"
13 #include "nsIAccessibleTextRange.h"
14 #include "xpcAccessibleHyperText.h"
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 \
28 class xpcAccessibleTextRange final
: public nsIAccessibleTextRange
{
30 explicit xpcAccessibleTextRange(TextRange
& aRange
) { SetRange(aRange
); }
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
)
49 xpcAccessibleTextRange() {}
51 ~xpcAccessibleTextRange() {}
53 friend class xpcAccessibleHyperText
;
55 xpcAccessibleTextRange
& operator=(const xpcAccessibleTextRange
&) = delete;
57 void SetRange(TextRange
& aRange
);
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
65 RefPtr
<xpcAccessibleHyperText
> mRoot
;
66 RefPtr
<xpcAccessibleHyperText
> mStartContainer
;
68 RefPtr
<xpcAccessibleHyperText
> mEndContainer
;
72 NS_DEFINE_STATIC_IID_ACCESSOR(xpcAccessibleTextRange
,
73 NS_ACCESSIBLETEXTRANGE_IMPL_IID
)
76 } // namespace mozilla