Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
michael@0 | 1 | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
michael@0 | 2 | /* vim: set ts=2 et sw=2 tw=80: */ |
michael@0 | 3 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 4 | * License, v. 2.0. If a copy of the MPL was not distributed with this file, |
michael@0 | 5 | * You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 6 | |
michael@0 | 7 | #include "xpcAccessibleTextRange.h" |
michael@0 | 8 | |
michael@0 | 9 | #include "HyperTextAccessible.h" |
michael@0 | 10 | #include "TextRange.h" |
michael@0 | 11 | |
michael@0 | 12 | using namespace mozilla; |
michael@0 | 13 | using namespace mozilla::a11y; |
michael@0 | 14 | |
michael@0 | 15 | // nsISupports and cycle collection |
michael@0 | 16 | |
michael@0 | 17 | NS_IMPL_CYCLE_COLLECTION(xpcAccessibleTextRange, |
michael@0 | 18 | mRange.mRoot, |
michael@0 | 19 | mRange.mStartContainer, |
michael@0 | 20 | mRange.mEndContainer) |
michael@0 | 21 | |
michael@0 | 22 | NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(xpcAccessibleTextRange) |
michael@0 | 23 | NS_INTERFACE_MAP_ENTRY(nsIAccessibleTextRange) |
michael@0 | 24 | NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIAccessibleTextRange) |
michael@0 | 25 | NS_INTERFACE_MAP_END |
michael@0 | 26 | |
michael@0 | 27 | NS_IMPL_CYCLE_COLLECTING_ADDREF(xpcAccessibleTextRange) |
michael@0 | 28 | NS_IMPL_CYCLE_COLLECTING_RELEASE(xpcAccessibleTextRange) |
michael@0 | 29 | |
michael@0 | 30 | // nsIAccessibleTextRange |
michael@0 | 31 | |
michael@0 | 32 | NS_IMETHODIMP |
michael@0 | 33 | xpcAccessibleTextRange::GetStartContainer(nsIAccessible** aAnchor) |
michael@0 | 34 | { |
michael@0 | 35 | NS_ENSURE_ARG_POINTER(aAnchor); |
michael@0 | 36 | NS_IF_ADDREF(*aAnchor = static_cast<nsIAccessible*>(mRange.StartContainer())); |
michael@0 | 37 | return NS_OK; |
michael@0 | 38 | } |
michael@0 | 39 | |
michael@0 | 40 | NS_IMETHODIMP |
michael@0 | 41 | xpcAccessibleTextRange::GetStartOffset(int32_t* aOffset) |
michael@0 | 42 | { |
michael@0 | 43 | NS_ENSURE_ARG_POINTER(aOffset); |
michael@0 | 44 | *aOffset = mRange.StartOffset(); |
michael@0 | 45 | return NS_OK; |
michael@0 | 46 | } |
michael@0 | 47 | |
michael@0 | 48 | NS_IMETHODIMP |
michael@0 | 49 | xpcAccessibleTextRange::GetEndContainer(nsIAccessible** aAnchor) |
michael@0 | 50 | { |
michael@0 | 51 | NS_ENSURE_ARG_POINTER(aAnchor); |
michael@0 | 52 | NS_IF_ADDREF(*aAnchor = static_cast<nsIAccessible*>(mRange.EndContainer())); |
michael@0 | 53 | return NS_OK; |
michael@0 | 54 | } |
michael@0 | 55 | |
michael@0 | 56 | NS_IMETHODIMP |
michael@0 | 57 | xpcAccessibleTextRange::GetEndOffset(int32_t* aOffset) |
michael@0 | 58 | { |
michael@0 | 59 | NS_ENSURE_ARG_POINTER(aOffset); |
michael@0 | 60 | *aOffset = mRange.EndOffset(); |
michael@0 | 61 | return NS_OK; |
michael@0 | 62 | } |
michael@0 | 63 | |
michael@0 | 64 | NS_IMETHODIMP |
michael@0 | 65 | xpcAccessibleTextRange::GetText(nsAString& aText) |
michael@0 | 66 | { |
michael@0 | 67 | nsAutoString text; |
michael@0 | 68 | mRange.Text(text); |
michael@0 | 69 | aText.Assign(text); |
michael@0 | 70 | |
michael@0 | 71 | return NS_OK; |
michael@0 | 72 | } |