michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* vim: set ts=2 et sw=2 tw=80: */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef mozilla_a11y_TextRange_h__ michael@0: #define mozilla_a11y_TextRange_h__ michael@0: michael@0: #include "mozilla/Move.h" michael@0: #include "nsAutoPtr.h" michael@0: michael@0: namespace mozilla { michael@0: namespace a11y { michael@0: michael@0: class Accessible; michael@0: class HyperTextAccessible; michael@0: michael@0: /** michael@0: * Represents a text range within the text control or document. michael@0: */ michael@0: class TextRange MOZ_FINAL michael@0: { michael@0: public: michael@0: TextRange(HyperTextAccessible* aRoot, michael@0: Accessible* aStartContainer, int32_t aStartOffset, michael@0: Accessible* aEndContainer, int32_t aEndOffset); michael@0: TextRange() {} michael@0: TextRange(TextRange&& aRange) : michael@0: mRoot(Move(aRange.mRoot)), mStartContainer(Move(aRange.mStartContainer)), michael@0: mEndContainer(Move(aRange.mEndContainer)), michael@0: mStartOffset(aRange.mStartOffset), mEndOffset(aRange.mEndOffset) {} michael@0: michael@0: TextRange& operator= (TextRange&& aRange) michael@0: { michael@0: mRoot = Move(aRange.mRoot); michael@0: mStartContainer = Move(aRange.mStartContainer); michael@0: mEndContainer = Move(aRange.mEndContainer); michael@0: mStartOffset = aRange.mStartOffset; michael@0: mEndOffset = aRange.mEndOffset; michael@0: return *this; michael@0: } michael@0: michael@0: Accessible* StartContainer() const { return mStartContainer; } michael@0: int32_t StartOffset() const { return mStartOffset; } michael@0: Accessible* EndContainer() const { return mEndContainer; } michael@0: int32_t EndOffset() const { return mEndOffset; } michael@0: michael@0: /** michael@0: * Return text enclosed by the range. michael@0: */ michael@0: void Text(nsAString& aText) const; michael@0: michael@0: /** michael@0: * Return true if this TextRange object represents an actual range of text. michael@0: */ michael@0: bool IsValid() const { return mRoot; } michael@0: michael@0: private: michael@0: TextRange(const TextRange& aRange) MOZ_DELETE; michael@0: TextRange& operator=(const TextRange& aRange) MOZ_DELETE; michael@0: michael@0: friend class HyperTextAccessible; michael@0: friend class xpcAccessibleTextRange; michael@0: michael@0: void Set(HyperTextAccessible* aRoot, michael@0: Accessible* aStartContainer, int32_t aStartOffset, michael@0: Accessible* aEndContainer, int32_t aEndOffset); michael@0: michael@0: nsRefPtr mRoot; michael@0: nsRefPtr mStartContainer; michael@0: nsRefPtr mEndContainer; michael@0: int32_t mStartOffset; michael@0: int32_t mEndOffset; michael@0: }; michael@0: michael@0: michael@0: } // namespace a11y michael@0: } // namespace mozilla michael@0: michael@0: #endif