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